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