summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/rest/repository.php
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2017-10-13 08:24:59 +0000
committerramon <ramongomez@us.es>2017-10-13 08:24:59 +0000
commit72bbcf8591f01f284e8901b3683d4222b08312a1 (patch)
treee2b04413dee905f9a62a7767d29e9a948ca4edf1 /admin/WebConsole/rest/repository.php
parent8f34f3a8d39a0e8944d7295ec115b66b722eb755 (diff)
#810: Internacionalización de propiedades de repositorio; corrección al calcular porcentaje de uso y actualizar documentación de la API REST.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5458 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/rest/repository.php')
-rw-r--r--admin/WebConsole/rest/repository.php30
1 files changed, 15 insertions, 15 deletions
diff --git a/admin/WebConsole/rest/repository.php b/admin/WebConsole/rest/repository.php
index 8bb0c66c..bbd365ce 100644
--- a/admin/WebConsole/rest/repository.php
+++ b/admin/WebConsole/rest/repository.php
@@ -77,11 +77,11 @@ function humanSize($bytes)
/**
* @brief List all images in the repository
- * @note Route: /images, Method: GET
+ * @note Route: /repository/images, Method: GET
* @param no
- * @return JSON array with imagename, file size
+ * @return JSON object with directory, images array, ous array and disk data.
*/
-$app->get('/repository/images', 'validateRepositoryApiKey',
+$app->get('/repository/images(/)', 'validateRepositoryApiKey',
function() use ($app) {
$response = array();
// Read repository information file.
@@ -92,29 +92,29 @@ $app->get('/repository/images', 'validateRepositoryApiKey',
if (is_dir($imgPath)) {
// Complete global image information.
for ($i=0; $i<sizeof(@$response['images']); $i++) {
- $img=$response['images'][$i];
- $file=$imgPath."/".($img['type']==="dir" ? $img["name"] : $img["name"].".".$img["type"]);
+ $img = $response['images'][$i];
+ $file = $imgPath."/".($img['type']==="dir" ? $img["name"] : $img["name"].".".$img["type"]);
$response['images'][$i]['size'] = @stat($file)['size'];
- $response['images'][$i]['modified'] = date("Y-m-d H:i:s T", @stat($file)['mtime']);
+ $response['images'][$i]['modified'] = date("Y-m-d H:i:s", @stat($file)['mtime']);
$response['images'][$i]['mode'] = substr(decoct(@stat($file)['mode']), -4);
}
// Complete image in OUs information.
for ($j=0; $j<sizeof(@$response['ous']); $j++) {
for ($i=0; $i<sizeof(@$response['ous'][$j]['images']); $i++) {
- $img=$response['ous'][$j]['images'][$i];
- $file=$imgPath."/".$response['ous'][$j]['subdir']."/".($img['type']==="dir" ? $img["name"] : $img["name"].".".$img["type"]);
+ $img = $response['ous'][$j]['images'][$i];
+ $file = $imgPath."/".$response['ous'][$j]['subdir']."/".($img['type']==="dir" ? $img["name"] : $img["name"].".".$img["type"]);
$response['ous'][$j]['images'][$i]['size'] = @stat($file)['size'];
- $response['ous'][$j]['images'][$i]['modified'] = date("Y-m-d H:i:s T", @stat($file)['mtime']);
+ $response['ous'][$j]['images'][$i]['modified'] = date("Y-m-d H:i:s", @stat($file)['mtime']);
$response['ous'][$j]['images'][$i]['mode'] = substr(decoct(@stat($file)['mode']), -4);
}
}
// Retrieve disk information.
- $total=disk_total_space($imgPath);
- $free=disk_free_space($imgPath);
- $response['disk']['total']=humanSize($total);
- $response['disk']['used']=humanSize($total - $free);
- $response['disk']['free']=humanSize($free);
- $response['disk']['percent']=floor(100 * $free / $total) . " %";
+ $total = disk_total_space($imgPath);
+ $free = disk_free_space($imgPath);
+ $response['disk']['total'] = humanSize($total);
+ $response['disk']['used'] = humanSize($total - $free);
+ $response['disk']['free'] = humanSize($free);
+ $response['disk']['percent'] = 100 - floor(100 * (100 - $free) / $total) . " %";
// JSON response.
jsonResponse(200, $response);
} else {