blob: 2affd22785c4bcace15338a12e312fb8920eb668 [file] [log] [blame]
Matteo Scandoloe23060c2016-06-14 14:50:23 -07001/**
2 * © OpenCORD
3 *
4 * Visit http://guide.xosproject.org/devguide/addview/ for more information
5 *
6 * Created by teone on 6/13/16.
7 */
8
9(function () {
10 'use strict';
11 angular.module('mCord')
Matteo Scandolof25db3b2016-06-29 17:41:27 -070012 .directive('profileDetails', function ($uibModal, $q, Helpers) {
Matteo Scandoloe23060c2016-06-14 14:50:23 -070013 return {
14 restrict: 'E',
15 scope: {},
16 controllerAs: 'vm',
17 templateUrl: 'app/view/profiles-details/profiles-details.tpl.html',
18 controller: function ($uibModal, $stateParams, Profile, _) {
Matteo Scandolo3b82a592016-06-21 12:10:35 +020019 this.isNew = true;
20 if($stateParams.id){
21 Profile.get({id: $stateParams.id}).$promise
22 .then((profile) => {
23 this.profile = profile;
24 this.isNew = false;
25 this.formConfig.actions[0].label = 'Update';
26 return $q.all([
27 profile.getImsis(),
28 profile.getEnodes()
29 ]);
30 })
31 .then(res => {
32 const [imsis, enodes] = res;
33 this.imsis = imsis;
34 this.enodes = enodes;
35 })
36 .catch(e => console.log(e));
37 }
38 else {
39 this.profile = new Profile();
40 this.imsis = [];
41 this.enodes = [];
42 }
43
44 const UD_Types = [
45 {id: 'RR', label: 'RR'},
46 {id: 'PF', label: 'PF'},
47 {id: 'MAXCI', label: 'MAXCI'}
48 ];
Matteo Scandoloe23060c2016-06-14 14:50:23 -070049
50 this.formConfig = {
Matteo Scandolof25db3b2016-06-29 17:41:27 -070051 exclude: ['IMSIRuleArray', 'Start', 'End'],
Matteo Scandoloe23060c2016-06-14 14:50:23 -070052 formName: 'updateProfiles',
Matteo Scandolo3b82a592016-06-21 12:10:35 +020053 fields: {
54 Name: {
55 type: 'string',
56 validator: {
57 required: true
58 }
59 },
60 DlSchedType: {
61 type: 'select',
62 validator: {
63 required: true
64 },
65 options: UD_Types
66 },
67 DlAllocRBRate: {
68 type: 'number',
69 validator: {
70 required: true
71 }
72 },
73 UlSchedType: {
74 type: 'select',
75 validator: {
76 required: true
77 },
78 options: UD_Types
79 },
80 UlAllocRBRate: {
81 type: 'number',
82 validator: {
83 required: true
84 }
85 },
Matteo Scandolof25db3b2016-06-29 17:41:27 -070086 jsStart: {
87 type: 'datetime-local',
88 label: 'Start',
Matteo Scandolo3b82a592016-06-21 12:10:35 +020089 validator: {
90 required: true
91 }
92 },
Matteo Scandolof25db3b2016-06-29 17:41:27 -070093 jsEnd: {
94 type: 'datetime-local',
95 label: 'End',
Matteo Scandolo3b82a592016-06-21 12:10:35 +020096 validator: {
97 required: true
98 }
99 },
100 AdmControl: {
101 type: 'select',
102 validator: {
103 required: true
104 },
105 options: [
106 {id: 0, label: 'All'},
107 {id: 1, label: 'Voice Only'},
108 {id: 2, label: 'Data Only'}
109 ]
110 },
111 CellIndividualOffset: {
112 type: 'number',
113 validator: {
114 required: true
115 }
116 },
117 Handover: {
118 type: 'object',
119 properties: {
120 A3offset: {
121 type: 'number',
122 validator: {
123 required: true
124 }
125 },
Matteo Scandolo3b3eee82016-06-23 16:38:04 -0700126 A3Hysteresis: {
Matteo Scandolo3b82a592016-06-21 12:10:35 +0200127 type: 'number',
128 validator: {
129 required: true
130 }
131 },
Matteo Scandolo3b3eee82016-06-23 16:38:04 -0700132 A3TriggerQuantity: {
133 type: 'number',
134 validator: {
135 required: true
136 }
137 },
138 A5TriggerQuantity: {
Matteo Scandolo3b82a592016-06-21 12:10:35 +0200139 type: 'number',
140 validator: {
141 required: true
142 }
143 },
144 A5Thresh1Rsrp: {
145 type: 'number',
146 validator: {
147 required: true
148 }
149 },
150 A5Thresh1Rsrq: {
151 type: 'number',
152 validator: {
153 required: true
154 }
155 },
156 A5Thresh2Rsrp: {
157 type: 'number',
158 validator: {
159 required: true
160 }
161 },
162 A5Thresh2Rsrq: {
163 type: 'number',
164 validator: {
165 required: true
166 }
167 },
Matteo Scandolo3b3eee82016-06-23 16:38:04 -0700168 A5Hysteresis: {
Matteo Scandolo3b82a592016-06-21 12:10:35 +0200169 type: 'number',
170 validator: {
171 required: true
172 }
173 },
174 }
175 }
176 },
Matteo Scandoloe23060c2016-06-14 14:50:23 -0700177 actions: [
178 {
Matteo Scandolo3b82a592016-06-21 12:10:35 +0200179 label: 'Save',
Matteo Scandoloe23060c2016-06-14 14:50:23 -0700180 icon: 'ok',
Matteo Scandolo3b82a592016-06-21 12:10:35 +0200181 cb: (profile) => {
Matteo Scandolof25db3b2016-06-29 17:41:27 -0700182 profile.Start = moment(profile.jsStart).format('DD.MM.YYYY HH:mm');
183 profile.End = moment(profile.jsEnd).format('DD.MM.YYYY HH:mm');
184
185 delete profile.jsStart;
186 delete profile.jsEnd;
187
188 let p;
Matteo Scandolo3b82a592016-06-21 12:10:35 +0200189 if(this.isNew){
Matteo Scandolof25db3b2016-06-29 17:41:27 -0700190 p = Profile.save(profile).$promise
Matteo Scandolo3b82a592016-06-21 12:10:35 +0200191 }
192 else{
Matteo Scandolof25db3b2016-06-29 17:41:27 -0700193 p = profile.$save().$promise;
Matteo Scandolo3b82a592016-06-21 12:10:35 +0200194 }
Matteo Scandolof25db3b2016-06-29 17:41:27 -0700195 p.then(() => {
196 profile.jsStart = Helpers.stringToTime(profile.Start);
197 profile.jsEnd = Helpers.stringToTime(profile.End);
198
199 console.log(profile);
200
201 this.formConfig.feedback = {
202 show: true,
203 message: `Profile ${profile.Name} saved!`,
204 type: 'success'
205 };
206 });
Matteo Scandoloe23060c2016-06-14 14:50:23 -0700207 },
208 class: 'primary-border'
209 }
210 ]
211 };
212
213 this.imsiTableCfg = {
214 order: true,
215 filter: 'field',
216 columns: [
217 {
218 label: '#',
219 prop: 'IMSI',
220 link: item => `#/imsi/${item.IMSI}`
221 },
222 {
223 label: 'Enodeb',
224 prop: 'Enodeb'
225 },
226 {
227 label: 'DlMeasBitRate',
228 prop: 'DlMeasBitRate'
229 },
230 {
231 label: 'UlMeasBitRate',
232 prop: 'UlMeasBitRate'
233 },
234 {
235 label: 'Status',
236 prop: 'UeStatus',
237 type: 'boolean'
238 }
239 ],
240 actions: [
241 {
242 label: 'Delete',
243 icon: 'remove',
244 color: 'red',
245 cb: (imsi) => {
246 this.profile.deleteImsi(imsi.IMSI)
247 .then(() => {
248 _.remove(this.imsis, i =>i.IMSI === imsi.IMSI);
249 });
250 }
251 }
252 ]
253 };
254
255 this.enodeTableCfg = {
256 order: true,
257 filter: 'field',
258 columns: [
259 {
260 label: '#',
261 prop: 'eNBId',
262 link: item => `#/enode/${item.eNBId}`
263 },
264 {
265 label: 'Ip Address',
266 prop: 'IpAddr'
267 },
268 {
269 label: 'Description',
270 prop: 'Description'
271 },
272 {
273 label: 'Status',
274 prop: 'Status',
275 type: 'boolean'
276 }
277 ],
278 actions: [
279 {
280 label: 'Delete',
281 icon: 'remove',
282 color: 'red',
283 cb: (enode) => {
Matteo Scandolo3b3eee82016-06-23 16:38:04 -0700284 this.profile.deleteEnode(enode.eNBId)
Matteo Scandoloe23060c2016-06-14 14:50:23 -0700285 .then(() => {
286 _.remove(this.enodes, i =>i.eNBId === enode.eNBId);
287 });
288 }
289 }
290 ]
291 };
292
293 this.deleteAllImsi = () => {
294 this.profile.deleteImsis()
295 .then(() => {
296 this.imsis = [];
297 });
298 };
299
300 this.addImsi = () => {
301 const _this = this;
302 this.modalInstance = $uibModal.open({
303 animation: true,
304 templateUrl: 'addImsiToProfile',
305 controllerAs: 'vm',
306 controller: function ($uibModalInstance) {
307 this.modal = $uibModalInstance;
308 this.callback = (imsi) => {
Matteo Scandolo3b3eee82016-06-23 16:38:04 -0700309 this.profile.addImsi(imsi)
310 .then(i => {
311 _this.imsis.push(imsi);
312 })
Matteo Scandoloe23060c2016-06-14 14:50:23 -0700313 };
314 this.profile = _this.profile;
315 }
316 });
317 };
318
319 this.addEnode = () => {
320 const _this = this;
321 this.modalInstance = $uibModal.open({
322 animation: true,
323 templateUrl: 'addEnodeToProfile',
324 controllerAs: 'vm',
325 controller: function ($uibModalInstance) {
326 this.modal = $uibModalInstance;
327 this.callback = (enode) => {
Matteo Scandolo3b82a592016-06-21 12:10:35 +0200328 // TODO call BE (if !this.isNew)
Matteo Scandoloe23060c2016-06-14 14:50:23 -0700329 _this.enodes.push(enode);
330 };
331 this.profile = _this.profile;
332 }
333 });
334 };
335
336 this.deleteAllEnodes = () => {
337 this.profile.deleteEnodes()
338 .then(() => {
339 this.enodes = [];
340 });
341 };
342 }
343 }
344 });
345})();
346