1
1
/*
2
- * Copyright 2015-2018 Jeeva Kandasamy ([email protected] )
2
+ * Copyright 2015-2019 Jeeva Kandasamy ([email protected] )
3
3
* and other contributors as indicated by the @author tags.
4
4
*
5
5
* Licensed under the Apache License, Version 2.0 (the "License");
21
21
'use strict' ;
22
22
23
23
angular . module ( 'adf.widget.myc-os-commands' , [ ] )
24
- . config ( function ( dashboardProvider ) {
24
+ . config ( function ( dashboardProvider ) {
25
25
dashboardProvider
26
26
. widget ( 'mycOsCommands' , {
27
27
title : 'OS Commands' ,
@@ -30,9 +30,9 @@ angular.module('adf.widget.myc-os-commands', [])
30
30
controller : 'mycOsCommandController' ,
31
31
controllerAs : 'mycOsBtns' ,
32
32
config : {
33
- minBtnHeight :30 ,
34
- minBtnWidth :90 ,
35
- buttonsJson :"[\n]" ,
33
+ minBtnHeight : 30 ,
34
+ minBtnWidth : 90 ,
35
+ buttonsJson : "[\n]" ,
36
36
} ,
37
37
edit : {
38
38
templateUrl : 'controllers/adf-widgets/adf-myc-os/edit.html?mcv=${mc.gui.version}' ,
@@ -41,7 +41,7 @@ angular.module('adf.widget.myc-os-commands', [])
41
41
}
42
42
} ) ;
43
43
} )
44
- . controller ( 'mycOsCommandController' , function ( $scope , $interval , config , mchelper , $uibModal , $filter , OSCommandFactory , CommonServices ) {
44
+ . controller ( 'mycOsCommandController' , function ( $scope , $interval , config , mchelper , $uibModal , $filter , OSCommandFactory , CommonServices ) {
45
45
var mycOsBtns = this ;
46
46
47
47
mycOsBtns . showLoading = false ;
@@ -50,49 +50,55 @@ angular.module('adf.widget.myc-os-commands', [])
50
50
mycOsBtns . buttons = angular . fromJson ( config . buttonsJson ) ;
51
51
52
52
// execute OS command directly
53
- $scope . executeOsCommandDirect = function ( button ) {
53
+ $scope . executeOsCommandDirect = function ( button ) {
54
54
var request = { } ;
55
55
request . os = button . os ;
56
56
request . command = button . command ;
57
- OSCommandFactory . execute ( request , function ( response ) {
58
- if ( response . error === undefined ) {
57
+ OSCommandFactory . execute ( request , function ( response ) {
58
+ if ( response . error === undefined ) {
59
59
alertService . success ( response . result ) ;
60
- } else {
60
+ } else {
61
61
alertService . danger ( angular . toJson ( response ) ) ;
62
62
}
63
- } , function ( error ) {
63
+ } , function ( error ) {
64
64
displayRestError . display ( error ) ;
65
65
} ) ;
66
66
} ;
67
67
68
68
// execute OS command with confirmation check
69
69
$scope . executeOsCommand = function ( button ) {
70
- if ( button . confirmation === true ) {
71
- var addModalInstance = $uibModal . open ( {
72
- templateUrl : 'controllers/adf-widgets/adf-myc-os/confirmation-modal.html?mcv=${mc.gui.version}' ,
73
- controller : 'CommandConfirmationController' ,
74
- resolve : { button : button }
70
+ if ( button . confirmation === true ) {
71
+ var addModalInstance = $uibModal . open ( {
72
+ templateUrl : 'controllers/adf-widgets/adf-myc-os/confirmation-modal.html?mcv=${mc.gui.version}' ,
73
+ controller : 'CommandConfirmationController' ,
74
+ resolve : {
75
+ button : button
76
+ }
75
77
} ) ;
76
78
77
79
addModalInstance . result . then ( function ( ) {
78
- $scope . executeOsCommandDirect ( button ) ;
79
- } ) ,
80
- function ( ) {
81
- //console.log('Modal dismissed at: ' + new Date());
82
- }
80
+ $scope . executeOsCommandDirect ( button ) ;
81
+ } ) ,
82
+ function ( ) {
83
+ //console.log('Modal dismissed at: ' + new Date());
84
+ }
83
85
} else {
84
86
$scope . executeOsCommandDirect ( button ) ;
85
87
}
86
88
} ;
87
89
88
90
89
- } ) . controller ( 'mycOsCommandEditController' , function ( $scope , $interval , config , mchelper , $filter , CommonServices ) {
91
+ } ) . controller ( 'mycOsCommandEditController' , function ( $scope , $interval , config , mchelper , $filter , CommonServices ) {
90
92
var mycOsBtnsEdit = this ;
91
93
mycOsBtnsEdit . cs = CommonServices ;
92
94
93
95
} ) . controller ( 'CommandConfirmationController' , function ( $scope , $uibModalInstance , $filter , button ) {
94
- $scope . header = $filter ( 'translate' ) ( 'OS_COMMAND_EXECTION_CONFIRMATION_TITLE' ) ;
95
- $scope . button = button ;
96
- $scope . reboot = function ( ) { $uibModalInstance . close ( ) ; } ;
97
- $scope . cancel = function ( ) { $uibModalInstance . dismiss ( 'cancel' ) ; }
98
- } ) ;
96
+ $scope . header = $filter ( 'translate' ) ( 'OS_COMMAND_EXECTION_CONFIRMATION_TITLE' ) ;
97
+ $scope . button = button ;
98
+ $scope . reboot = function ( ) {
99
+ $uibModalInstance . close ( ) ;
100
+ } ;
101
+ $scope . cancel = function ( ) {
102
+ $uibModalInstance . dismiss ( 'cancel' ) ;
103
+ }
104
+ } ) ;
0 commit comments