Skip to content

Commit

Permalink
Add usage details (#736)
Browse files Browse the repository at this point in the history
* Update Immich.php

The current implementation of Immich.php issues an `invalid credentials` error on Heimdall when the `config` is enabled with the admin API key.

The below changes fixes these issues and renders the `Photos` and `Videos` as per the api endpoint.

* Linter fixes
  • Loading branch information
tanmaychimurkar authored May 24, 2024
1 parent 4382ef6 commit e6e58cc
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Immich/Immich.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct()

public function test()
{
$test = parent::appTest($this->url("api/server-info/statistics"));
$test = parent::appTest($this->url("server-info/statistics"));
echo $test->status;
}

Expand All @@ -29,22 +29,26 @@ public function livestats()
"x-api-key" => $this->config->api_key,
],
];
$res = parent::execute($this->url("api/server-info/statistics"), $attrs);
$data = json_decode($res->getBody());
$res = parent::execute($this->url("server-info/statistics"), $attrs);
$details = json_decode($res->getBody());

$details = [];
$data = [];

if ($data) {
if ($details) {
$status = "active";
$details["photos"] = number_format($data->photos);
$details["videos"] = number_format($data->videos);
$data["photos"] = number_format($details->photos);
$data["videos"] = number_format($details->videos);
$usageInGiB = number_format($details->usage / 1073741824, 2);
$data["usage"] = $usageInGiB . 'GiB';
}

return parent::getLiveStats($status, $details);
return parent::getLiveStats($status, $data);
}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
$api_url = parent::normaliseurl($this->config->url) .
"api/" .
$endpoint;
return $api_url;
}
}

0 comments on commit e6e58cc

Please sign in to comment.