blob: 1b4f9cca1af0a2afe835da58a4d7725aa3d1eb40 [file] [log] [blame]
Matteo Scandolobe342fa2016-06-08 15:54:55 -07001/*
Brian O'Connor8fb63ec2017-08-03 22:46:35 -07002 * Copyright 2015 Open Networking Foundation
Matteo Scandolobe342fa2016-06-08 15:54:55 -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('addEnodeB', function () {
19 return {
20 restrict: 'E',
21 templateUrl: 'app/components/add-enodeb/add-enodeb.html',
22 scope: {
23 modal: '='
24 },
25 bindToController: true,
26 controllerAs: 'vm',
27 controller: function(Enodeb){
28 this.model = {
29 };
30 this.config = {
31 formName: 'createEnode',
32 fields: {
33 Description: {
34 type: 'string',
35 validators: {
36 required: true,
37 minlength: 10
38 }
39 },
Matteo Scandolo3b3eee82016-06-23 16:38:04 -070040 eNBId: {
41 type: 'number',
42 validators: {
43 required: true
Matteo Scandolobe342fa2016-06-08 15:54:55 -070044 }
45 },
Matteo Scandolo3b3eee82016-06-23 16:38:04 -070046 IpAddr: {
47 type: 'string',
48 validators: {
49 required: true
50 }
51 }
Matteo Scandolobe342fa2016-06-08 15:54:55 -070052 },
53 actions: [
54 {
55 label: 'Save',
56 icon: 'ok',
57 cb: (enode) => {
58 // TODO validate form (wait for arpit to commit)
59 Enodeb.save(enode).$promise
60 .then(() => {
Matteo Scandolo3b3eee82016-06-23 16:38:04 -070061 // TODO add to list
Matteo Scandolobe342fa2016-06-08 15:54:55 -070062 this.modal.close();
63 })
64 .catch(e => {
65 console.log(this.modal);
66 })
67 },
68 class: 'success'
69 },
70 {
71 label: 'Cancel',
72 icon: 'remove', // refers to bootstraps glyphicon
73 cb: () => { // receive the model
74 this.modal.close();
75 },
76 class: 'warning'
77 }
78 ]
79 };
80 }
81 };
82 });