Matteo Scandolo | e23060c | 2016-06-14 14:50:23 -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('addImsiToItem', function () { |
| 19 | return { |
| 20 | restrict: 'E', |
| 21 | templateUrl: 'app/components/add-imsi-to-item/add-imsi-to-item.html', |
| 22 | scope: { |
| 23 | modal: '=', |
| 24 | cb: '=', |
| 25 | item: '=' |
| 26 | }, |
| 27 | bindToController: true, |
| 28 | controllerAs: 'vm', |
| 29 | controller: function(Imsi){ |
| 30 | |
| 31 | Imsi.query().$promise |
| 32 | .then((imsis) => { |
| 33 | this.imsis = imsis; |
| 34 | return this.item.getImsis(); |
| 35 | }) |
| 36 | .then((itemImsi) => { |
| 37 | console.log(itemImsi, this.imsis); |
| 38 | this.imsis = _.differenceBy(this.imsis, itemImsi, 'IMSI'); |
| 39 | }); |
| 40 | |
| 41 | this.config = { |
| 42 | columns: [ |
| 43 | { |
| 44 | label: '#', |
| 45 | prop: 'IMSI', |
| 46 | link: item => `#/imsi/${item.IMSI}` |
| 47 | }, |
| 48 | { |
| 49 | label: 'Enodeb', |
| 50 | prop: 'Enodeb' |
| 51 | }, |
| 52 | { |
| 53 | label: 'DlMeasBitRate', |
| 54 | prop: 'DlMeasBitRate' |
| 55 | }, |
| 56 | { |
| 57 | label: 'UlMeasBitRate', |
| 58 | prop: 'UlMeasBitRate' |
| 59 | }, |
| 60 | { |
| 61 | label: 'Status', |
| 62 | prop: 'UeStatus', |
| 63 | type: 'boolean' |
| 64 | } |
| 65 | ], |
| 66 | actions: [ |
| 67 | { |
| 68 | label: 'Add', |
| 69 | icon: 'plus', |
| 70 | cb: (imsi) => { |
| 71 | _.remove(this.imsis, p => p.IMSI === imsi.IMSI); |
| 72 | this.cb(imsi); |
| 73 | }, |
| 74 | } |
| 75 | ], |
| 76 | filter: 'field', |
| 77 | order: true |
| 78 | } |
| 79 | } |
| 80 | }; |
| 81 | }); |