Matteo Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 1 | /** |
| 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 Scandolo | f25db3b | 2016-06-29 17:41:27 -0700 | [diff] [blame^] | 12 | .directive('profileDetails', function ($uibModal, $q, Helpers) { |
Matteo Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 13 | 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 Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 19 | 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 Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 49 | |
| 50 | this.formConfig = { |
Matteo Scandolo | f25db3b | 2016-06-29 17:41:27 -0700 | [diff] [blame^] | 51 | exclude: ['IMSIRuleArray', 'Start', 'End'], |
Matteo Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 52 | formName: 'updateProfiles', |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 53 | 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 Scandolo | f25db3b | 2016-06-29 17:41:27 -0700 | [diff] [blame^] | 86 | jsStart: { |
| 87 | type: 'datetime-local', |
| 88 | label: 'Start', |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 89 | validator: { |
| 90 | required: true |
| 91 | } |
| 92 | }, |
Matteo Scandolo | f25db3b | 2016-06-29 17:41:27 -0700 | [diff] [blame^] | 93 | jsEnd: { |
| 94 | type: 'datetime-local', |
| 95 | label: 'End', |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 96 | 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 Scandolo | 3b3eee8 | 2016-06-23 16:38:04 -0700 | [diff] [blame] | 126 | A3Hysteresis: { |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 127 | type: 'number', |
| 128 | validator: { |
| 129 | required: true |
| 130 | } |
| 131 | }, |
Matteo Scandolo | 3b3eee8 | 2016-06-23 16:38:04 -0700 | [diff] [blame] | 132 | A3TriggerQuantity: { |
| 133 | type: 'number', |
| 134 | validator: { |
| 135 | required: true |
| 136 | } |
| 137 | }, |
| 138 | A5TriggerQuantity: { |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 139 | 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 Scandolo | 3b3eee8 | 2016-06-23 16:38:04 -0700 | [diff] [blame] | 168 | A5Hysteresis: { |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 169 | type: 'number', |
| 170 | validator: { |
| 171 | required: true |
| 172 | } |
| 173 | }, |
| 174 | } |
| 175 | } |
| 176 | }, |
Matteo Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 177 | actions: [ |
| 178 | { |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 179 | label: 'Save', |
Matteo Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 180 | icon: 'ok', |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 181 | cb: (profile) => { |
Matteo Scandolo | f25db3b | 2016-06-29 17:41:27 -0700 | [diff] [blame^] | 182 | 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 Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 189 | if(this.isNew){ |
Matteo Scandolo | f25db3b | 2016-06-29 17:41:27 -0700 | [diff] [blame^] | 190 | p = Profile.save(profile).$promise |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 191 | } |
| 192 | else{ |
Matteo Scandolo | f25db3b | 2016-06-29 17:41:27 -0700 | [diff] [blame^] | 193 | p = profile.$save().$promise; |
Matteo Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 194 | } |
Matteo Scandolo | f25db3b | 2016-06-29 17:41:27 -0700 | [diff] [blame^] | 195 | 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 Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 207 | }, |
| 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 Scandolo | 3b3eee8 | 2016-06-23 16:38:04 -0700 | [diff] [blame] | 284 | this.profile.deleteEnode(enode.eNBId) |
Matteo Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 285 | .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 Scandolo | 3b3eee8 | 2016-06-23 16:38:04 -0700 | [diff] [blame] | 309 | this.profile.addImsi(imsi) |
| 310 | .then(i => { |
| 311 | _this.imsis.push(imsi); |
| 312 | }) |
Matteo Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 313 | }; |
| 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 Scandolo | 3b82a59 | 2016-06-21 12:10:35 +0200 | [diff] [blame] | 328 | // TODO call BE (if !this.isNew) |
Matteo Scandolo | e23060c | 2016-06-14 14:50:23 -0700 | [diff] [blame] | 329 | _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 | |