blob: e8613e792b326be12f7d7ef9593ee896111a76b1 [file] [log] [blame]
Andrea Campanella95c02bd2017-09-01 16:51:03 +02001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
Max Chudd0b2e12017-09-06 08:49:21 -07005 * Licensed under the Apache License, Version 2.0 (the 'License');
Andrea Campanella95c02bd2017-09-01 16:51:03 +02006 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
Max Chudd0b2e12017-09-06 08:49:21 -070012 * distributed under the License is distributed on an 'AS IS' BASIS,
Andrea Campanella95c02bd2017-09-01 16:51:03 +020013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
19let self;
20
21class ElineSide {
22
Max Chudd0b2e12017-09-06 08:49:21 -070023 static $inject = ['XosSidePanel', 'XosModelStore', '$http', '$log', 'toastr', 'XosConfirm'];
Andrea Campanella95c02bd2017-09-01 16:51:03 +020024
25 constructor(
26 private XosSidePanel: any,
27 private XosModelStore: any,
28 private $http: any,
29 private $log: any,
30 private toastr: any,
Max Chudd0b2e12017-09-06 08:49:21 -070031 private XosConfirm: any,
Andrea Campanella95c02bd2017-09-01 16:51:03 +020032 ) {
33 self = this;
34 }
35
36 public saveEline(item: any) {
37 let path = item.path;
38 delete item.path;
39 item.$save().then((res) => {
40 item.path = path;
41 this.toastr.success(`${item.name} successfully saved!`);
42 })
43 .catch((error) => {
44 this.toastr.error(`Error while saving ${item.name}: ${error.specific_error}`);
45 });
46 }
47
48 public deleteEline(item: any) {
49 let name = item.name;
Max Chudd0b2e12017-09-06 08:49:21 -070050 this.XosConfirm.open({
51 header: 'Confirm deletion',
52 text: 'Are you sure you want to delete this? This action cannot be undone.',
53 actions: [{
54 label: 'Delete',
55 class: 'btn-danger',
56 cb: () => {
57 item.$delete().then((res) => {
58 this.toastr.success(`${name} successfully deleted!`);
59 })
60 .catch((error) => {
61 this.toastr.error(`Error while deleting ${name}: ${error.specific_error}`);
62 });
63 }
64 }]
65 });
66
Andrea Campanella95c02bd2017-09-01 16:51:03 +020067 }
68
69
70}
71
72export const elineSide: angular.IComponentOptions = {
73 template: require('./eline-side.component.html'),
74 controllerAs: 'vm',
75 controller: ElineSide,
76 bindings: {
Max Chudd0b2e12017-09-06 08:49:21 -070077 vng: '='
Andrea Campanella95c02bd2017-09-01 16:51:03 +020078 }
79};