From ed89eabc9e42cf21913de85a47b29a9db4acb0d0 Mon Sep 17 00:00:00 2001 From: Christoph Schlaepfer <1939311+Anuril@users.noreply.github.com> Date: Fri, 13 Oct 2023 22:51:17 +0200 Subject: [PATCH] Fixed small issue with storage view / edit (#30) * Fixed remaining storageclass issue and rewrote storage settings for use with tags * Fixed missed variable --- src/Api/Admin.php | 46 ++++++---------------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/src/Api/Admin.php b/src/Api/Admin.php index e3eec93..317df81 100644 --- a/src/Api/Admin.php +++ b/src/Api/Admin.php @@ -180,16 +180,6 @@ public function storage_get_list() return $storages_grouped; } - /** - * Get list of storageclasses - * - * @return array - */ - public function storageclass_get_list() - { - $storageclasses = $this->di['db']->find('service_proxmox_storageclass'); - return $storageclasses; - } /** * Get list of storage controllers @@ -224,29 +214,6 @@ public function service_proxmox_get_list() return $services; } - /** - * Create a new storageclass - * - * @return array - */ - public function storageclass_create($data) - { - $storageclass = $this->di['db']->dispense('service_proxmox_storageclass'); - $storageclass->storageclass = $data['storageClassName']; - $this->di['db']->store($storageclass); - return $storageclass; - } - - /** - * Retrieve a single storageclass - * - * @return array - */ - public function storageclass_get($data) - { - $storageclass = $this->di['db']->getExistingModelById('service_proxmox_storageclass', $data['id'], 'Storageclass not found'); - return $storageclass; - } /** * Get list of server groups @@ -820,8 +787,6 @@ public function storage_get($data) 'used' => $storage->used, 'free' => $storage->free, 'percent_used' => ($storage->size == 0 || $storage->used == 0 || $storage->free == 0) ? 0 : round($storage->used / $storage->size * 100, 2), - // add list of storage classes - 'storageclasses' => $this->storageclass_get_list(), 'server_name' => $server->name, ); @@ -842,6 +807,7 @@ public function storage_update($data) $required = array( 'storageid' => 'Storage id is missing', 'storageTypeTags' => 'Storage tags are missing', + 'storagetype' => 'Storage type is missing', ); $this->di['validator']->checkRequiredParamsForArray($required, $data); @@ -852,14 +818,14 @@ public function storage_update($data) $tagArray = []; foreach ($data['storageTypeTags'] as $tag) { $splitTags = explode(',', $tag); - $tagArray = array_merge($tagArray, $splitTags); + $tagArray = array_merge($tagArray, $splitTags); } $jsonArray = []; - foreach ($tagArray as $tagId) { + foreach ($tagArray as $tagName) { // Fetch the tag details from DB - $tag_from_db = $this->di['db']->findOne('service_proxmox_tag', 'id=:id AND type=:type', [ - ':id' => $tagId, + $tag_from_db = $this->di['db']->findOne('service_proxmox_tag', 'name=:name AND type=:type', [ + ':name' => $tagName, ':type' => $storageType ]); @@ -869,7 +835,7 @@ public function storage_update($data) 'name' => $tag_from_db->name ]; } else { - error_log("No DB entry found for tagId: $tagId and type: $storageType"); + error_log("No DB entry found for tagId: $tagName and type: $storageType"); } }