diff options
author | 2017-09-05 17:37:54 +0800 | |
---|---|---|
committer | 2017-09-05 17:37:54 +0800 | |
commit | 8aaddf4913dd792402331f6e9424067a78246c18 (patch) | |
tree | 0414cc82ab6fab5075a94ee8e784b0b20e305550 /portal/src/main/webapp/extsys/vim/js/vimChartController.js | |
parent | 71ef7dd040b057abb85521caeff0cf9154647086 (diff) |
Try to fix the daily builed failed bug.
change the esr catagory name to portal, Fix the pom definition.
Change-Id: I21861aba0fe9b7d0528c5ffcb220d6e6096efcc4
Issue-ID: AAI-224
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'portal/src/main/webapp/extsys/vim/js/vimChartController.js')
-rw-r--r-- | portal/src/main/webapp/extsys/vim/js/vimChartController.js | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/portal/src/main/webapp/extsys/vim/js/vimChartController.js b/portal/src/main/webapp/extsys/vim/js/vimChartController.js new file mode 100644 index 0000000..cdfaa40 --- /dev/null +++ b/portal/src/main/webapp/extsys/vim/js/vimChartController.js @@ -0,0 +1,160 @@ +/* + * Copyright 2016-2017 ZTE Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var vm = avalon + .define({ + $id: "vimChartController", + $vimChartUrl: '../../api/vim/v1/{vim_id}/resource', + $tenantChartUrl: '../../api/vim/v1/{vim_id}/resource/{tenant_name}', + $tenantListUrl: '../../api/vim/v1/{vim_id}/tenants', + $tenantRoleUrl: '../../api/vim/v1/{vim_id}/roles', + vimInfo: { + name: name, + id: id, + tenant: tenant, + isAdmin: true + }, + tenantSelectList: { + condName: $.i18n.prop("com_zte_ums_eco_roc_vim_type"), + component_type: 'select', + selectItems: [] + }, + initChart: function () { + + //has admin role + var tenantRoleUrl = vm.$tenantRoleUrl.replace("{vim_id}", vm.vimInfo.id); + $.ajax({ + "type": 'get', + "url": tenantRoleUrl, + "dataType": "json", + success: function (resp) { + vm.vimInfo.isAdmin = (resp == null) ? false : resp.isAdminRole; + + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + vimChart.growl("get [tenant Role] is error :" + textStatus + ":" + errorThrown, "danger"); + }, + complete: function () { + if (vm.vimInfo.isAdmin == true) { + + //get all resource + vm.vimChartLoad(); + + //get tenant list + vm.vimListLoad(); + } + + } + }); + //get resource of tenant + vm.tenantChartLoad(); + }, + gotoVimPage: function () { + window.parent.ZteFrameWork.goToURLByIDAndNewAction('eco_roc_vimmgr'); + }, + vimListLoad: function () { + var tenantListUrl = vm.$tenantListUrl.replace("{vim_id}", vm.vimInfo.id); + $.ajax({ + "type": 'get', + "url": tenantListUrl, + "dataType": "json", + success: function (resp) { + vm.tenantSelectList.selectItems = (resp == null) ? [] : resp; + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + vimChart.growl("get [tenant List] is error :" + textStatus + ":" + errorThrown, "danger"); + } + }); + }, + vimChartLoad: function () { + var viminitData = { + "resource": { + "cpu": 0, + "memoryMb": 503, + "diskGb": 9.8 + }, + "usage": { + "cpu": 0, + "memoryMb": 0, + "diskGb": 0 + } + } + + vimChart.vimPieChartInit(); + + var vimChartUrl = vm.$vimChartUrl.replace("{vim_id}", vm.vimInfo.id); + + + $.ajax({ + "type": 'get', + "url": vimChartUrl, + "dataType": "json", + success: function (resp) { + var vimData = (resp == null) ? viminitData : resp; + vimChart.vimPieChart(vimData); + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + vimChart.growl("get [virtual machine manager resource using status] is error :" + textStatus + ":" + errorThrown, "danger"); + } + }); + + }, + tenantChartLoad: function () { + var tenantChartUrl = vm.$tenantChartUrl.replace("{vim_id}", vm.vimInfo.id).replace("{tenant_name}", vm.vimInfo.tenant); + + var tenantinitData = { + "tenant_name": "", + "errormsg": "", + "quota": { + "cpu": 0, + "memoryMb": 0, + "instances": 0, + "floatingIps": 0, + "securityGroups": 0, + "volumeStorage": 0, + "volumes": 0 + }, + "usage": { + "cpu": 0, + "memoryMb": 0, + "instances": 0, + "floatingIps": 0, + "securityGroups": 0, + "volumeStorage": 0, + "volumes": 0 + } + }; + vimChart.tenantPieChartInit(); + $.ajax({ + "type": 'get', + "url": tenantChartUrl, + "dataType": "json", + success: function (resp) { + var tenantData = (resp == null) ? tenantinitData : resp; + if (tenantData.errormsg != null) { + vimChart.growl(tenantData.errormsg, "danger"); + } + vimChart.tenantPieChart(tenantData); + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + vimChart.growl("get [tenant quota using status] occur error :" + textStatus + ":" + errorThrown, "danger"); + } + }); + + } + + }); +avalon.scan(); +vm.initChart();
\ No newline at end of file |