Matteo Scandolo | ed9e3ec | 2016-06-13 15:20:11 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 | |
| 17 | angular.module('mCord') |
| 18 | .directive('addImsi', function () { |
| 19 | return { |
| 20 | restrict: 'E', |
| 21 | templateUrl: 'app/components/add-imsi/add-imsi.html', |
| 22 | scope: { |
| 23 | modal: '=' |
| 24 | }, |
| 25 | bindToController: true, |
| 26 | controllerAs: 'vm', |
| 27 | controller: function(Imsi, Enodeb, _){ |
| 28 | this.model = { |
| 29 | }; |
| 30 | this.config = { |
| 31 | formName: 'createImsi', |
| 32 | fields: { |
| 33 | Enodeb: { |
| 34 | type: 'select', |
| 35 | validators: { |
| 36 | required: true |
| 37 | }, |
| 38 | options: [ |
| 39 | { |
| 40 | id: 591, |
| 41 | label: '591' |
| 42 | }, |
| 43 | { |
| 44 | id: 592, |
| 45 | label: '592' |
| 46 | }, |
| 47 | { |
| 48 | id: 593, |
| 49 | label: '593' |
| 50 | } |
| 51 | ] |
| 52 | }, |
| 53 | DlMeasBitRate: { |
| 54 | type: 'number', |
| 55 | validators: { |
| 56 | required: true |
| 57 | } |
| 58 | }, |
| 59 | UlMeasBitRate: { |
| 60 | type: 'number', |
| 61 | validators: { |
| 62 | required: true |
| 63 | } |
| 64 | } |
| 65 | }, |
| 66 | actions: [ |
| 67 | { |
| 68 | label: 'Save', |
| 69 | icon: 'ok', |
| 70 | cb: (imsi) => { |
| 71 | // TODO validate form (wait for arpit to commit) |
| 72 | Imsi.save(imsi).$promise |
| 73 | .then(() => { |
| 74 | this.modal.close(); |
| 75 | }) |
| 76 | .catch(e => { |
| 77 | console.log(this.modal); |
| 78 | }) |
| 79 | }, |
| 80 | class: 'success' |
| 81 | }, |
| 82 | { |
| 83 | label: 'Cancel', |
| 84 | icon: 'remove', |
| 85 | cb: () => { |
| 86 | this.modal.close(); |
| 87 | }, |
| 88 | class: 'warning' |
| 89 | } |
| 90 | ] |
| 91 | }; |
| 92 | |
| 93 | // TODO use this once merged Arpit PR |
| 94 | Enodeb.query().$promise |
| 95 | .then(enodes => { |
| 96 | this.config.fields.Enodeb.options = _.reduce(enodes, (list, enode) => { |
| 97 | return list.concat([{ |
| 98 | id: enode.eNBId, |
| 99 | label: enode.eNBId.toString() |
| 100 | }]); |
| 101 | }, []); |
| 102 | }) |
| 103 | } |
| 104 | }; |
| 105 | }); |