blob: 3294ae55b159c5691193c576165ea5f6f5c54368 [file] [log] [blame]
Matteo Scandoloed9e3ec2016-06-13 15:20:11 -07001/*
Brian O'Connor8fb63ec2017-08-03 22:46:35 -07002 * Copyright 2015 Open Networking Foundation
Matteo Scandoloed9e3ec2016-06-13 15:20:11 -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('addImsi', function () {
19 return {
20 restrict: 'E',
21 templateUrl: 'app/components/add-imsi/add-imsi.html',
22 scope: {
23 modal: '='
24 },
25 bindToController: true,
26 controllerAs: 'vm',
27 controller: function(Imsi, Enodeb, _){
28 this.model = {
29 };
30 this.config = {
31 formName: 'createImsi',
32 fields: {
Matteo Scandolo3b3eee82016-06-23 16:38:04 -070033 IMSI: {
Matteo Scandoloed9e3ec2016-06-13 15:20:11 -070034 type: 'number',
35 validators: {
36 required: true
37 }
38 }
39 },
40 actions: [
41 {
42 label: 'Save',
43 icon: 'ok',
44 cb: (imsi) => {
45 // TODO validate form (wait for arpit to commit)
46 Imsi.save(imsi).$promise
47 .then(() => {
Matteo Scandolo3b3eee82016-06-23 16:38:04 -070048 // TODO add to list
Matteo Scandoloed9e3ec2016-06-13 15:20:11 -070049 this.modal.close();
50 })
51 .catch(e => {
52 console.log(this.modal);
53 })
54 },
55 class: 'success'
56 },
57 {
58 label: 'Cancel',
59 icon: 'remove',
60 cb: () => {
61 this.modal.close();
62 },
63 class: 'warning'
64 }
65 ]
66 };
Matteo Scandoloed9e3ec2016-06-13 15:20:11 -070067 }
68 };
69 });