diff --git a/ui/src/api/index.js b/ui/src/api/index.js index 1f532c36336..0c8e8e9696c 100644 --- a/ui/src/api/index.js +++ b/ui/src/api/index.js @@ -23,6 +23,19 @@ import { ACCESS_TOKEN } from '@/store/mutation-types' +const getAPICommandsRegex = /^(get|list|query|find)\w+$/i +const additionalGetAPICommandsList = [ + 'isaccountallowedtocreateofferingswithtags', + 'readyforshutdown', + 'cloudianisenabled', + 'quotabalance', + 'quotasummary', + 'quotatarifflist', + 'quotaisenabled', + 'quotastatement', + 'verifyoauthcodeandgetuser' +] + export function getAPI (command, args = {}) { args.command = command args.response = 'json' @@ -64,6 +77,12 @@ export function postAPI (command, data = {}) { }) } +export function callAPI (command, args = {}) { + const isGetAPICommand = getAPICommandsRegex.test(command) || additionalGetAPICommandsList.includes(command.toLowerCase()) + const call = isGetAPICommand ? getAPI : postAPI + return call(command, args) +} + export function login (arg) { if (!sourceToken.checkExistSource()) { sourceToken.init() diff --git a/ui/src/components/view/ListView.vue b/ui/src/components/view/ListView.vue index 205e340652d..f1f9469a400 100644 --- a/ui/src/components/view/ListView.vue +++ b/ui/src/components/view/ListView.vue @@ -1230,45 +1230,45 @@ export default { this.editableValue = record.value }, getUpdateApi () { - let apiString = '' + let apiCommand = '' switch (this.$route.name) { case 'template': - apiString = 'updateTemplate' + apiCommand = 'updateTemplate' break case 'iso': - apiString = 'updateIso' + apiCommand = 'updateIso' break case 'zone': - apiString = 'updateZone' + apiCommand = 'updateZone' break case 'computeoffering': case 'systemoffering': - apiString = 'updateServiceOffering' + apiCommand = 'updateServiceOffering' break case 'diskoffering': - apiString = 'updateDiskOffering' + apiCommand = 'updateDiskOffering' break case 'networkoffering': - apiString = 'updateNetworkOffering' + apiCommand = 'updateNetworkOffering' break case 'vpcoffering': - apiString = 'updateVPCOffering' + apiCommand = 'updateVPCOffering' break case 'guestoscategory': - apiString = 'updateOsCategory' + apiCommand = 'updateOsCategory' break } - return apiString + return apiCommand }, isOrderUpdatable () { return this.getUpdateApi() in this.$store.getters.apis }, handleUpdateOrder (id, index) { this.parentToggleLoading() - const apiString = this.getUpdateApi() + const apiCommand = this.getUpdateApi() return new Promise((resolve, reject) => { - postAPI(apiString, { + postAPI(apiCommand, { id, sortKey: index }).then((response) => { diff --git a/ui/src/components/view/TreeView.vue b/ui/src/components/view/TreeView.vue index 0307b097475..f767b7adef2 100644 --- a/ui/src/components/view/TreeView.vue +++ b/ui/src/components/view/TreeView.vue @@ -92,7 +92,7 @@