blob: 0b92cc082d0359dc737bc584dd28c55d9acffdbf [file] [log] [blame]
Matteo Scandolobe342fa2016-06-08 15:54:55 -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('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 },
40 GpsCoordinate: {
41 type: 'object',
42 properties: {
43 Latitude: {
44 type: 'string',
45 validators: {
46 required: true
47 }
48 },
49 Longitude: {
50 type: 'string',
51 validators: {
52 required: true
53 }
54 }
55 }
56 },
57 },
58 actions: [
59 {
60 label: 'Save',
61 icon: 'ok',
62 cb: (enode) => {
63 // TODO validate form (wait for arpit to commit)
64 Enodeb.save(enode).$promise
65 .then(() => {
66 this.modal.close();
67 })
68 .catch(e => {
69 console.log(this.modal);
70 })
71 },
72 class: 'success'
73 },
74 {
75 label: 'Cancel',
76 icon: 'remove', // refers to bootstraps glyphicon
77 cb: () => { // receive the model
78 this.modal.close();
79 },
80 class: 'warning'
81 }
82 ]
83 };
84 }
85 };
86 });