2 * Copyright 2016-2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 $id: "vimChartController",
19 $vimChartUrl: '../../api/vim/v1/{vim_id}/resource',
20 $tenantChartUrl: '../../api/vim/v1/{vim_id}/resource/{tenant_name}',
21 $tenantListUrl: '../../api/vim/v1/{vim_id}/tenants',
22 $tenantRoleUrl: '../../api/vim/v1/{vim_id}/roles',
30 condName: $.i18n.prop("com_zte_ums_eco_roc_vim_type"),
31 component_type: 'select',
34 initChart: function () {
37 var tenantRoleUrl = vm.$tenantRoleUrl.replace("{vim_id}", vm.vimInfo.id);
42 success: function (resp) {
43 vm.vimInfo.isAdmin = (resp == null) ? false : resp.isAdminRole;
46 error: function (XMLHttpRequest, textStatus, errorThrown) {
47 vimChart.growl("get [tenant Role] is error :" + textStatus + ":" + errorThrown, "danger");
49 complete: function () {
50 if (vm.vimInfo.isAdmin == true) {
61 //get resource of tenant
64 gotoVimPage: function () {
65 window.parent.ZteFrameWork.goToURLByIDAndNewAction('eco_roc_vimmgr');
67 vimListLoad: function () {
68 var tenantListUrl = vm.$tenantListUrl.replace("{vim_id}", vm.vimInfo.id);
73 success: function (resp) {
74 vm.tenantSelectList.selectItems = (resp == null) ? [] : resp;
76 error: function (XMLHttpRequest, textStatus, errorThrown) {
77 vimChart.growl("get [tenant List] is error :" + textStatus + ":" + errorThrown, "danger");
81 vimChartLoad: function () {
95 vimChart.vimPieChartInit();
97 var vimChartUrl = vm.$vimChartUrl.replace("{vim_id}", vm.vimInfo.id);
104 success: function (resp) {
105 var vimData = (resp == null) ? viminitData : resp;
106 vimChart.vimPieChart(vimData);
108 error: function (XMLHttpRequest, textStatus, errorThrown) {
109 vimChart.growl("get [virtual machine manager resource using status] is error :" + textStatus + ":" + errorThrown, "danger");
114 tenantChartLoad: function () {
115 var tenantChartUrl = vm.$tenantChartUrl.replace("{vim_id}", vm.vimInfo.id).replace("{tenant_name}", vm.vimInfo.tenant);
117 var tenantinitData = {
139 vimChart.tenantPieChartInit();
142 "url": tenantChartUrl,
144 success: function (resp) {
145 var tenantData = (resp == null) ? tenantinitData : resp;
146 if (tenantData.errormsg != null) {
147 vimChart.growl(tenantData.errormsg, "danger");
149 vimChart.tenantPieChart(tenantData);
151 error: function (XMLHttpRequest, textStatus, errorThrown) {
152 vimChart.growl("get [tenant quota using status] occur error :" + textStatus + ":" + errorThrown, "danger");