rebuild GUI structure(only changed modules' name)
[vnfsdk/refrepo.git] / catalog / src / main / webapp / catalog / js / template / tmController.js
1 /*
2  * Copyright 2016-2017 ZTE Corporation.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 avalon.config({
17         interpolate: ["<!--", "-->"]
18 });
19
20 var vm = avalon.define({
21         $id: "tmController",
22     $tableId : "ict_template_table",
23         $templateTableFields : {// table columns
24                 table: [
25             {"mData": "serviceTemplateId", name: "ID", "bVisible": false},
26             {"mData": "templateName",name: $.i18n.prop("nfv-template-iui-field-templatename"),"fnRender": tmUtil.nameRender},
27             //{"mData": "templateName", name: $.i18n.prop("nfv-template-iui-field-templatename-topo"), "fnRender" : tmUtil.topoRender},
28             //{"mData": "templateName", name: $.i18n.prop("nfv-template-iui-field-templatename-nodes"), "fnRender" : tmUtil.nodesRender},
29             {"mData": "vendor", name: $.i18n.prop("nfv-template-iui-field-vendor")},
30             {"mData": "version", name: $.i18n.prop("nfv-template-iui-field-version")},
31             {"mData":"csarId", name: "packageID","bVisible": false},
32             {"mData": "type", name: $.i18n.prop("nfv-template-iui-field-type")},
33                 ]
34         },
35     $language: {
36             "sProcessing": "<img src='../common/thirdparty/data-tables/images/loading-spinner-grey.gif'/><span>&nbsp;&nbsp;"
37                         +$.i18n.prop("nfv-nso-iui-table-sProcess")+"</span>",
38             "sLengthMenu": $.i18n.prop("nfv-nso-iui-table-sLengthMenu"),
39             "sZeroRecords": $.i18n.prop("nfv-nso-iui-table-sZeroRecords"),
40             "sInfo": "<span class='seperator'>  </span>" + $.i18n.prop("nfv-nso-iui-table-sInfo"),
41             "sInfoEmpty": $.i18n.prop("nfv-nso-iui-table-sInfoEmpty"),
42             "sGroupActions": $.i18n.prop("nfv-nso-iui-table-sGroupActions"),
43             "sAjaxRequestGeneralError":$.i18n.prop("nfv-nso-iui-table-sAjaxRequestGeneralError"),
44             "sEmptyTable": $.i18n.prop("nfv-nso-iui-table-sEmptyTable"),
45             "oPaginate": {
46                 "sPrevious": $.i18n.prop("nfv-nso-iui-table-sPrevious"),
47                 "sNext": $.i18n.prop("nfv-nso-iui-table-sNext"),
48                 "sPage": $.i18n.prop("nfv-nso-iui-table-sPage"),
49                 "sPageOf": $.i18n.prop("nfv-nso-iui-table-sPageOf")
50             }
51     },
52     $restUrl : {
53         queryTemplateInfoUrl : "/openoapi/catalog/v1/servicetemplates"
54     },
55     $getTemplateCond: function() {
56         var cond = {};
57                 return cond;
58     },
59         $initTable: function() {
60                 var setting = {};
61                 setting.language = vm.$language;
62         setting.paginate = true;
63         setting.info = true;
64                 setting.columns = vm.$templateTableFields.table;
65                 setting.restUrl = vm.$restUrl.queryTemplateInfoUrl;
66                 setting.tableId = vm.$tableId;
67                 serverPageTable.initDataTable(setting, vm.$getTemplateCond(),
68                                 vm.$tableId + '_div');
69         },
70     $openDetail : function(templateId, rowId) {
71         var oSelect = $("tbody tr select").eq(rowId);
72         var flavor = "";
73         if(oSelect.length) {
74             oSelect.find("option:selected").val();
75         }
76         window.open("./templateDetail.html?templateId="+templateId+"&flavor="+flavor,"_self");
77     },
78     $openTopoDetail : function(templateId, rowId) {
79         var oSelect = $("tbody tr select").eq(rowId);
80         var flavor = "";
81         if(oSelect.length) {
82             oSelect.find("option:selected").val();
83         }
84         window.open("./topologyDetail.html?templateId="+templateId+"&flavor="+flavor,"_self");
85     },
86     $openNodesDetail : function(templateId, rowId) {
87         var oSelect = $("tbody tr select").eq(rowId);
88         var flavor = "";
89         if(oSelect.length) {
90             oSelect.find("option:selected").val();
91         }
92         window.open("./nodesDetail.html?templateId="+templateId+"&flavor="+flavor,"_self");
93     }
94 });
95 avalon.scan();
96 vm.$initTable();
97
98 var refreshByCond = function() {
99     vm.$initTable();
100 };