blob: 17f050491fc2c5169be8a2d7b3a7d27ad0109677 [file] [log] [blame]
Matteo Scandolo05bff8c2016-06-13 16:55:20 -07001/*
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
17angular.module('mCord')
18 .directive('addProfileToItem', function () {
19 return {
20 restrict: 'E',
21 templateUrl: 'app/components/add-profile-to-item/add-profile-to-item.html',
22 scope: {
23 modal: '=',
24 cb: '=',
25 item: '='
26 },
27 bindToController: true,
28 controllerAs: 'vm',
29 controller: function(Profile){
30
31 Profile.query().$promise
32 .then((profiles) => {
33 // TODO diff all profile from item.getProfiles
34 this.profiles = profiles;
35 return this.item.getProfiles();
36 })
37 .then((itemProfiles) => {
38 this.profiles = _.differenceBy(this.profiles, itemProfiles, 'Name');
39 });
40
41 this.config = {
42 columns: [
43 {
44 label: 'Name',
45 prop: 'Name'
46 },
47 {
48 label: 'DlAllocRBRate',
49 prop: 'DlAllocRBRate'
50 },
51 {
52 label: 'UlAllocRBRate',
53 prop: 'UlAllocRBRate'
54 },
55 {
56 label: 'Start',
57 prop: 'Start'
58 },
59 {
60 label: 'End',
61 prop: 'End'
62 }
63 ],
64 actions: [
65 {
66 label: 'Add',
67 icon: 'plus',
68 cb: (profile) => {
69 _.remove(this.profiles, p => p.Name === profile.Name);
70 this.cb(profile);
71 },
72 }
73 ],
74 filter: 'field',
75 order: true
76 }
77 }
78 };
79 });