2 <div class="wrapper wrapper-content">
\r
4 <div class="col-lg-offset-2 col-lg-8">
\r
6 <div class="ibox-content">
\r
7 <h1>CONTEXT <i class="fa fa-question-circle"></i></h1>
\r
9 <div class="col-md-offset-1 col-md-10">
\r
10 <textarea v-model="context" id="context-content" style="white-space:nowrap; overflow:scroll; font-size: 16px; padding: 4px; width: 100%; min-height: 300px; max-height: 300px;">
\r
12 <button type="button" class="btn btn-primary pull-right" v-on:click="saveContext()">Save</button>
\r
20 <div class="col-lg-offset-2 col-lg-8">
\r
22 <div class="ibox-content">
\r
24 <div class="service-table">
\r
25 <table id="serviceList" class="table table-bordered table-hover text-center">
\r
28 <th class="text-center">No</th>
\r
29 <th class="text-center">Service</th>
\r
30 <th class="text-center">Time</th>
\r
31 <th class="text-center">Operation</th>
\r
35 <tr v-for="service in serviceList" v-on:click="editService(service.name)" style="cursor: pointer;">
\r
36 <td style="vertical-align: middle;">{{ service.id }}</td>
\r
37 <td style="vertical-align: middle;">{{ service.name }}</td>
\r
38 <td style="vertical-align: middle;">{{ service.time }}</td>
\r
39 <td style="vertical-align: middle;"><button type="button" class="btn btn-white" v-on:click.stop="deleteService(service.name)"><i class="fa fa-trash"></i></button>
\r
45 <button class="btn btn-lg btn-success" style="float:right;" v-on:click="addNewService()"> Add </button>
\r
48 <!-- modal of one service -->
\r
50 <service-modal v-bind:type="type" v-on:service-creation="plusAService" v-on:service-edition="editAServiceName" v-on:creation-fail="creationFailHandler"></service-modal>
\r
59 import Vue from 'vue'
\r
60 import service_modal from "./env_component/service_modal.vue"
\r
61 import showMessage from './message/showMessage.js'
\r
63 name: 'environment',
\r
76 'service-modal': service_modal
\r
78 created: function() {
\r
80 var msgTitle = "GET -- SERVICE LIST";
\r
81 var errorInfo = 'Unable to get the service list';
\r
83 url: this.global.SERVER_ADDR + "env/getAllServices",
\r
85 success: function(data) {
\r
86 if(data['code'] == 200) {
\r
87 self.serviceList = data['result'];
\r
89 showMessage(data['code'], msgTitle, errorInfo, data['error']);
\r
92 error: function(obj, status, msg) {
\r
93 showMessage("error", msgTitle, errorInfo, msg);
\r
97 url: this.global.SERVER_ADDR + "env/getContext",
\r
99 success: function(data) {
\r
100 if(data['code'] == 200) {
\r
101 self.context = data['result']['context'];
\r
103 showMessage(data['code'], msgTitle, errorInfo, data['error']);
\r
106 error: function(obj, status, msg) {
\r
107 showMessage("error", msgTitle, errorInfo, msg);
\r
112 addNewService: function(){
\r
113 this.type.edit = false;
\r
114 this.type.tag = "abc";
\r
115 this.type.service = null;
\r
116 this.type.originName = null;
\r
117 if(this.type.content){
\r
118 this.type.content = null;
\r
120 $("#myModal").modal("show");
\r
122 plusAService: function(serviceName){
\r
123 var item = {'id': '', 'name': '', 'time': ''};
\r
124 item['id'] = this.serviceList[this.serviceList.length - 1]['id'] + 1;
\r
125 item['name'] = serviceName;
\r
126 item['time'] = this.getFormatDate(new Date());
\r
127 this.serviceList.push(item);
\r
129 editAServiceName: function(edition) {
\r
130 for(var i = 0;i < this.serviceList.length; i++) {
\r
131 if(edition['oldName'] == this.serviceList[i]['name']) {
\r
132 this.serviceList[i]['name'] = edition['newName'];
\r
136 editService: function(serviceName){
\r
137 this.type.edit = true;
\r
138 this.type.tag = "abc";
\r
139 this.type.service = serviceName;
\r
140 this.type.originName = serviceName;
\r
141 if(this.type.content){
\r
142 this.type.content = null;
\r
144 console.log(this.type);
\r
146 var msgTitle = "GET -- SERVICE";
\r
147 var errorInfo = "Unable to get the service: <strong>" + self.type.service + "</strong>";
\r
149 url: this.global.SERVER_ADDR + "env/getService",
\r
152 "serviceName": serviceName
\r
154 success: function(data) {
\r
155 if(data['code'] == 200) {
\r
156 self.type.tag = "hhh";
\r
157 self.type.content = data['result'];
\r
158 self.type.originName = self.type.service;
\r
160 showMessage(data['code'], msgTitle, errorInfo, data['error']);
\r
163 error: function(obj, status, msg) {
\r
164 showMessage("error", msgTitle, errorInfo, msg);
\r
167 $("#myModal").modal("show");
\r
169 deleteService: function(serviceName){
\r
170 var msgTitle = "DELETE -- SERVICE";
\r
172 url: this.global.SERVER_ADDR + "env/deleteService",
\r
175 "serviceName": serviceName
\r
177 success: function(data) {
\r
178 if(data['code'] == 200) {
\r
179 showMessage(data['code'], msgTitle, "Delete <strong>" + serviceName + "</strong> successfully.");
\r
181 showMessage(data['code'], msgTitle, "Failed to delete <strong>" + serviceName + "</strong>", data['error']);
\r
184 error: function(obj, status, msg) {
\r
185 showMessage("error", msgTitle, "Failed to delete <strong>" + serviceName + "</strong>", msg);
\r
188 for(var i = 0;i < this.serviceList.length; i++) {
\r
189 if(serviceName == this.serviceList[i]['name']) {
\r
190 this.serviceList.splice(i, 1);
\r
194 creationFailHandler: function(serviceName) {
\r
195 for(var i = 0; i < this.serviceList.length; i++) {
\r
196 if(serviceName == this.serviceList[i].name) {
\r
197 this.serviceList.splice(i, 1);
\r
201 getFormatDate: function(date) {
\r
202 var year = date.getFullYear();
\r
203 var month = date.getMonth() + 1;
\r
204 var strDate = date.getDate();
\r
205 var seperator = "-";
\r
206 if(month >= 1 && month <= 9) {
\r
207 month = "0" + month;
\r
209 if(strDate >= 1 && strDate <= 9) {
\r
210 strDate = "0" + strDate;
\r
212 var formatDate = year + seperator + month + seperator + strDate;
\r
215 saveContext: function() {
\r
217 var msgTitle = "SAVE -- CONTEXT";
\r
218 var errorInfo = "Failed to save context!";
\r
220 url: this.global.SERVER_ADDR + "env/editContext",
\r
223 context: self.context
\r
225 success: function(data) {
\r
226 if(data['code'] == 200) {
\r
227 showMessage(data['code'], msgTitle, "Save context successfully!");
\r
229 showMessage(data['code'], msgTitle, errorInfo, data['error']);
\r
232 error: function(obj, status, msg) {
\r
233 showMessage("error", msgTitle, errorInfo, msg);
\r