blob: fb8a2f1056c836d73fe161dc9a2b432df3588aa9 [file] [log] [blame]
Andrea Campanella95c02bd2017-09-01 16:51:03 +02001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * 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
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * 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
23 static $inject = ['XosSidePanel', 'XosModelStore', '$http', '$log', 'toastr'];
24
25 constructor(
26 private XosSidePanel: any,
27 private XosModelStore: any,
28 private $http: any,
29 private $log: any,
30 private toastr: any,
31 ) {
32 self = this;
33 }
34
35 public saveEline(item: any) {
36 let path = item.path;
37 delete item.path;
38 item.$save().then((res) => {
39 item.path = path;
40 this.toastr.success(`${item.name} successfully saved!`);
41 })
42 .catch((error) => {
43 this.toastr.error(`Error while saving ${item.name}: ${error.specific_error}`);
44 });
45 }
46
47 public deleteEline(item: any) {
48 let name = item.name;
49 item.$delete().then((res) => {
50 this.toastr.success(`${name} successfully deleted!`);
51 })
52 .catch((error) => {
53 this.toastr.error(`Error while deleting ${name}: ${error.specific_error}`);
54 });
55 }
56
57
58}
59
60export const elineSide: angular.IComponentOptions = {
61 template: require('./eline-side.component.html'),
62 controllerAs: 'vm',
63 controller: ElineSide,
64 bindings: {
65 eng: '='
66 }
67};