Andrea Campanella | 420e4b4 | 2017-09-01 16:51:03 +0200 | [diff] [blame^] | 1 | |
| 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 | |
| 19 | let self; |
| 20 | |
| 21 | class 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 | |
| 60 | export const elineSide: angular.IComponentOptions = { |
| 61 | template: require('./eline-side.component.html'), |
| 62 | controllerAs: 'vm', |
| 63 | controller: ElineSide, |
| 64 | bindings: { |
| 65 | eng: '=' |
| 66 | } |
| 67 | }; |