Matteo Scandolo | be342fa | 2016-06-08 15:54:55 -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('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 Scandolo | 3b3eee8 | 2016-06-23 16:38:04 -0700 | [diff] [blame] | 40 | eNBId: { |
| 41 | type: 'number', |
| 42 | validators: { |
| 43 | required: true |
Matteo Scandolo | be342fa | 2016-06-08 15:54:55 -0700 | [diff] [blame] | 44 | } |
| 45 | }, |
Matteo Scandolo | 3b3eee8 | 2016-06-23 16:38:04 -0700 | [diff] [blame] | 46 | IpAddr: { |
| 47 | type: 'string', |
| 48 | validators: { |
| 49 | required: true |
| 50 | } |
| 51 | } |
Matteo Scandolo | be342fa | 2016-06-08 15:54:55 -0700 | [diff] [blame] | 52 | }, |
| 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 Scandolo | 3b3eee8 | 2016-06-23 16:38:04 -0700 | [diff] [blame] | 61 | // TODO add to list |
Matteo Scandolo | be342fa | 2016-06-08 15:54:55 -0700 | [diff] [blame] | 62 | 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 | }); |