blob: adef31045eb18a0de41dffcbe9eb2a7cd1d284e7 [file] [log] [blame]
Matteo Scandoloe23060c2016-06-14 14:50:23 -07001/*
Brian O'Connor8fb63ec2017-08-03 22:46:35 -07002 * Copyright 2015 Open Networking Foundation
Matteo Scandoloe23060c2016-06-14 14:50:23 -07003 *
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
17angular.module('mCord')
18 .directive('addEnodeToItem', function () {
19 return {
20 restrict: 'E',
21 templateUrl: 'app/components/add-enode-to-item/add-enode-to-item.html',
22 scope: {
23 modal: '=',
24 cb: '=',
25 item: '='
26 },
27 bindToController: true,
28 controllerAs: 'vm',
29 controller: function(Enodeb){
30
31 Enodeb.query().$promise
32 .then((enodes) => {
33 this.enodes = enodes;
34 return this.item.getEnodes();
35 })
36 .then((itemEnodes) => {
37 console.log(itemEnodes, this.enodes);
38 this.enodes = _.differenceBy(this.enodes, itemEnodes, 'eNBId');
39 });
40
41 this.config = {
42 columns: [
43 {
44 label: '#',
45 prop: 'eNBId',
46 link: item => `#/enode/${item.eNBId}`
47 },
48 {
49 label: 'Ip Address',
50 prop: 'IpAddr'
51 },
52 {
53 label: 'Description',
54 prop: 'Description'
55 },
56 {
57 label: 'Status',
58 prop: 'Status',
59 type: 'boolean'
60 }
61 ],
62 actions: [
63 {
64 label: 'Add',
65 icon: 'plus',
66 cb: (enode) => {
67 _.remove(this.enodes, p => p.eNBId === enode.eNBId);
68 this.cb(enode);
69 },
70 }
71 ],
72 filter: 'field',
73 order: true
74 }
75 }
76 };
77 });