3
3
*/
4
4
5
5
6
-
7
6
/* Java script code to start/stop litespeed */
8
7
app . controller ( 'litespeedStatus' , function ( $scope , $http ) {
9
8
@@ -49,8 +48,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
49
48
$scope . actionResultBad = true ;
50
49
$scope . serverStatusCouldNotConnect = true ;
51
50
52
- }
53
- else {
51
+ } else {
54
52
55
53
$scope . restartorStopLoading = true ;
56
54
$scope . actionResult = true ;
@@ -109,8 +107,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
109
107
$scope . actionResultBad = true ;
110
108
$scope . serverStatusCouldNotConnect = true ;
111
109
112
- }
113
- else {
110
+ } else {
114
111
115
112
$scope . restartorStopLoading = true ;
116
113
$scope . actionResult = true ;
@@ -174,8 +171,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
174
171
} ) ;
175
172
$scope . lsSerial = response . data . lsSerial ;
176
173
$scope . lsexpiration = response . data . lsexpiration ;
177
- }
178
- else {
174
+ } else {
179
175
$scope . cpLoading = true ;
180
176
new PNotify ( {
181
177
title : 'Operation Failed!' ,
@@ -229,8 +225,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
229
225
text : 'License successfully Updated' ,
230
226
type : 'success'
231
227
} ) ;
232
- }
233
- else {
228
+ } else {
234
229
$scope . cpLoading = true ;
235
230
new PNotify ( {
236
231
title : 'Operation Failed!' ,
@@ -292,8 +287,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
292
287
$scope . logsData = response . data . logsdata ;
293
288
294
289
295
- }
296
- else {
290
+ } else {
297
291
298
292
$scope . logFileLoading = true ;
299
293
$scope . logsFeteched = true ;
@@ -347,8 +341,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
347
341
$scope . logsData = response . data . logsdata ;
348
342
349
343
350
- }
351
- else {
344
+ } else {
352
345
353
346
$scope . logFileLoading = true ;
354
347
$scope . logsFeteched = true ;
@@ -409,8 +402,7 @@ app.controller('servicesManager', function ($scope, $http) {
409
402
$scope . olsStart = false ;
410
403
$scope . olsStop = true ;
411
404
$scope . olsMem = Math . round ( parseInt ( response . data . memUsage . litespeed ) / 1048576 ) + " MB" ;
412
- }
413
- else {
405
+ } else {
414
406
$scope . olsStatus = "Stopped" ;
415
407
$scope . olsStats = false ;
416
408
$scope . olsStart = true ;
@@ -421,8 +413,7 @@ app.controller('servicesManager', function ($scope, $http) {
421
413
$scope . dockerStatus = "Running" ;
422
414
$scope . dockerStart = false ;
423
415
$scope . dockerStop = true ;
424
- }
425
- else {
416
+ } else {
426
417
$scope . dockerStatus = "Stopped" ;
427
418
$scope . dockerStart = true ;
428
419
$scope . dockerStop = false ;
@@ -435,8 +426,7 @@ app.controller('servicesManager', function ($scope, $http) {
435
426
$scope . sqlStart = false ;
436
427
$scope . sqlStop = true ;
437
428
$scope . sqlMem = Math . round ( parseInt ( response . data . memUsage . mysql ) / 1048576 ) + " MB" ;
438
- }
439
- else {
429
+ } else {
440
430
$scope . sqlStatus = "Stopped" ;
441
431
$scope . sqlStats = false ;
442
432
$scope . sqlStart = true ;
@@ -451,8 +441,7 @@ app.controller('servicesManager', function ($scope, $http) {
451
441
$scope . dnsStart = false ;
452
442
$scope . dnsStop = true ;
453
443
$scope . dnsMem = Math . round ( parseInt ( response . data . memUsage . powerdns ) / 1048576 ) + " MB" ;
454
- }
455
- else {
444
+ } else {
456
445
$scope . dnsStatus = "Stopped" ;
457
446
$scope . dnsStats = false ;
458
447
$scope . dnsStart = true ;
@@ -467,8 +456,7 @@ app.controller('servicesManager', function ($scope, $http) {
467
456
$scope . ftpStart = false ;
468
457
$scope . ftpStop = true ;
469
458
$scope . ftpMem = Math . round ( parseInt ( response . data . memUsage . pureftp ) / 1048576 ) + " MB" ;
470
- }
471
- else {
459
+ } else {
472
460
$scope . ftpStatus = "Stopped" ;
473
461
$scope . ftpStats = false ;
474
462
$scope . ftpStart = true ;
@@ -487,6 +475,7 @@ app.controller('servicesManager', function ($scope, $http) {
487
475
}
488
476
489
477
}
478
+
490
479
getServiceStatus ( ) ;
491
480
492
481
$scope . serviceAction = function ( serviceName , action ) {
@@ -524,8 +513,7 @@ app.controller('servicesManager', function ($scope, $http) {
524
513
$scope . actionLoader = false ;
525
514
$scope . btnDisable = false ;
526
515
} , 3000 ) ;
527
- }
528
- else {
516
+ } else {
529
517
setTimeout ( function ( ) {
530
518
getServiceStatus ( ) ;
531
519
$scope . ActionSuccessfull = false ;
@@ -583,8 +571,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
583
571
if ( response . data . status === 1 ) {
584
572
$scope . installBoxGen = false ;
585
573
getRequestStatus ( ) ;
586
- }
587
- else {
574
+ } else {
588
575
new PNotify ( {
589
576
title : 'Operation Failed!' ,
590
577
text : response . data . error_message ,
@@ -626,8 +613,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
626
613
if ( response . data . abort === 0 ) {
627
614
$scope . requestData = response . data . requestStatus ;
628
615
$timeout ( getRequestStatus , 1000 ) ;
629
- }
630
- else {
616
+ } else {
631
617
// Notifications
632
618
$scope . cyberPanelLoading = true ;
633
619
$timeout . cancel ( ) ;
@@ -720,8 +706,7 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
720
706
$scope . zombieProcesses = response . data . zombieProcesses ;
721
707
722
708
$timeout ( $scope . topProcessesStatus , 3000 ) ;
723
- }
724
- else {
709
+ } else {
725
710
new PNotify ( {
726
711
title : 'Operation Failed!' ,
727
712
text : response . data . error_message ,
@@ -771,8 +756,111 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
771
756
text : 'Process successfully killed.' ,
772
757
type : 'success'
773
758
} ) ;
759
+ } else {
760
+ new PNotify ( {
761
+ title : 'Operation Failed!' ,
762
+ text : response . data . error_message ,
763
+ type : 'error'
764
+ } ) ;
765
+ }
766
+
767
+ }
768
+
769
+ function cantLoadInitialDatas ( response ) {
770
+ $scope . cyberPanelLoading = true ;
771
+ new PNotify ( {
772
+ title : 'Operation Failed!' ,
773
+ text : 'Could not connect to server, please refresh this page' ,
774
+ type : 'error'
775
+ } ) ;
776
+ }
777
+
778
+ } ;
779
+
780
+ } ) ;
781
+
782
+ ///
783
+
784
+
785
+ app . controller ( 'listOSPackages' , function ( $scope , $http , $timeout ) {
786
+
787
+ $scope . cyberpanelLoading = true ;
788
+
789
+ $scope . currentPage = 1 ;
790
+ $scope . recordsToShow = 10 ;
791
+
792
+ $scope . fetchPackages = function ( ) {
793
+ $scope . cyberpanelLoading = false ;
794
+
795
+ var config = {
796
+ headers : {
797
+ 'X-CSRFToken' : getCookie ( 'csrftoken' )
798
+ }
799
+ } ;
800
+
801
+ var data = {
802
+ page : $scope . currentPage ,
803
+ recordsToShow : $scope . recordsToShow
804
+ } ;
805
+
806
+ dataurl = "/serverstatus/fetchPackages" ;
807
+
808
+ $http . post ( dataurl , data , config ) . then ( ListInitialData , cantLoadInitialData ) ;
809
+
810
+ function ListInitialData ( response ) {
811
+ $scope . cyberpanelLoading = true ;
812
+ if ( response . data . status === 1 ) {
813
+ $scope . allPackages = JSON . parse ( response . data . packages ) ;
814
+ $scope . pagination = response . data . pagination ;
815
+ } else {
816
+ new PNotify ( {
817
+ title : 'Error!' ,
818
+ text : response . data . error_message ,
819
+ type : 'error'
820
+ } ) ;
821
+ }
822
+ }
823
+ function cantLoadInitialData ( response ) {
824
+ $scope . cyberpanelLoading = true ;
825
+ new PNotify ( {
826
+ title : 'Operation Failed!' ,
827
+ text : 'Could not connect to server, please refresh this page' ,
828
+ type : 'error'
829
+ } ) ;
830
+ }
831
+
832
+
833
+ } ;
834
+
835
+ $scope . killProcess = function ( pid ) {
836
+
837
+ $scope . cyberPanelLoading = false ;
838
+
839
+ url = "/serverstatus/killProcess" ;
840
+
841
+ var data = {
842
+ pid : pid
843
+ } ;
844
+
845
+ var config = {
846
+ headers : {
847
+ 'X-CSRFToken' : getCookie ( 'csrftoken' )
774
848
}
775
- else {
849
+ } ;
850
+
851
+
852
+ $http . post ( url , data , config ) . then ( ListInitialDatas , cantLoadInitialDatas ) ;
853
+
854
+
855
+ function ListInitialDatas ( response ) {
856
+ $scope . cyberPanelLoading = true ;
857
+ if ( response . data . status === 1 ) {
858
+ new PNotify ( {
859
+ title : 'Success' ,
860
+ text : 'Process successfully killed.' ,
861
+ type : 'success'
862
+ } ) ;
863
+ } else {
776
864
new PNotify ( {
777
865
title : 'Operation Failed!' ,
778
866
text : response . data . error_message ,
0 commit comments