66/* Java script code to create database */
77app . controller ( 'createDatabase' , function ( $scope , $http ) {
88
9- $scope . createDatabaseLoading = true ;
10- $scope . dbDetails = true ;
11- $scope . databaseCreationFailed = true ;
12- $scope . databaseCreated = true ;
13- $scope . couldNotConnect = true ;
14- $scope . generatedPasswordView = true ;
9+ $ ( document ) . ready ( function ( ) {
10+ $ ( ".dbDetails" ) . hide ( ) ;
11+ $ ( ".generatedPasswordDetails" ) . hide ( ) ;
12+ $ ( '#create-database-select' ) . select2 ( ) ;
13+ } ) ;
14+
15+ $ ( '#create-database-select' ) . on ( 'select2:select' , function ( e ) {
16+ var data = e . params . data ;
17+ $scope . databaseWebsite = data . text ;
18+ $ ( ".dbDetails" ) . show ( ) ;
19+ $ ( "#domainDatabase" ) . text ( getWebsiteName ( data . text ) ) ;
20+ $ ( "#domainUsername" ) . text ( getWebsiteName ( data . text ) ) ;
21+ } ) ;
1522
1623
1724 $scope . showDetailsBoxes = function ( ) {
1825 $scope . dbDetails = false ;
19- } ;
26+ }
27+
28+ $scope . createDatabaseLoading = true ;
2029
2130 $scope . createDatabase = function ( ) {
2231
2332 $scope . createDatabaseLoading = false ;
2433 $scope . dbDetails = false ;
25- $scope . databaseCreationFailed = true ;
26- $scope . databaseCreated = true ;
27- $scope . couldNotConnect = true ;
2834
2935
3036 var databaseWebsite = $scope . databaseWebsite ;
@@ -65,26 +71,24 @@ app.controller('createDatabase', function ($scope, $http) {
6571 function ListInitialDatas ( response ) {
6672
6773
68- if ( response . data . createDBStatus == 1 ) {
74+ if ( response . data . createDBStatus === 1 ) {
6975
7076 $scope . createDatabaseLoading = true ;
7177 $scope . dbDetails = false ;
72- $scope . databaseCreationFailed = true ;
73- $scope . databaseCreated = false ;
74- $scope . couldNotConnect = true ;
75-
76-
77- }
78-
79- else {
80-
78+ new PNotify ( {
79+ title : 'Success!' ,
80+ text : 'Database successfully created.' ,
81+ type : 'success'
82+ } ) ;
83+ } else {
8184
8285 $scope . createDatabaseLoading = true ;
8386 $scope . dbDetails = false ;
84- $scope . databaseCreationFailed = false ;
85- $scope . databaseCreated = true ;
86- $scope . couldNotConnect = true ;
87- $scope . errorMessage = response . data . error_message ;
87+ new PNotify ( {
88+ title : 'Operation Failed!' ,
89+ text : response . data . error_message ,
90+ type : 'error'
91+ } ) ;
8892
8993
9094 }
@@ -96,21 +100,23 @@ app.controller('createDatabase', function ($scope, $http) {
96100
97101 $scope . createDatabaseLoading = true ;
98102 $scope . dbDetails = true ;
99- $scope . databaseCreationFailed = true ;
100- $scope . databaseCreated = true ;
101- $scope . couldNotConnect = false ;
103+ new PNotify ( {
104+ title : 'Operation Failed!' ,
105+ text : 'Could not connect to server, please refresh this page' ,
106+ type : 'error'
107+ } ) ;
102108 }
103109
104110
105111 } ;
106112
107113 $scope . generatePassword = function ( ) {
108- $scope . generatedPasswordView = false ;
114+ $ ( ".generatedPasswordDetails" ) . show ( ) ;
109115 $scope . dbPassword = randomPassword ( 16 ) ;
110116 } ;
111117
112118 $scope . usePassword = function ( ) {
113- $scope . generatedPasswordView = true ;
119+ $ ( ".generatedPasswordDetails" ) . hide ( ) ;
114120 } ;
115121
116122} ) ;
@@ -170,9 +176,7 @@ app.controller('deleteDatabase', function ($scope, $http) {
170176 $scope . couldNotConnect = true ;
171177
172178
173- }
174-
175- else {
179+ } else {
176180 $scope . deleteDatabaseLoading = true ;
177181 $scope . fetchedDatabases = true ;
178182 $scope . databaseDeletionFailed = false ;
@@ -240,9 +244,7 @@ app.controller('deleteDatabase', function ($scope, $http) {
240244 $scope . couldNotConnect = true ;
241245
242246
243- }
244-
245- else {
247+ } else {
246248 $scope . deleteDatabaseLoading = true ;
247249 $scope . fetchedDatabases = true ;
248250 $scope . databaseDeletionFailed = false ;
@@ -344,8 +346,7 @@ app.controller('listDBs', function ($scope, $http) {
344346 $scope . dbLoading = true ;
345347 $scope . domainFeteched = $scope . selectedDomain ;
346348
347- }
348- else {
349+ } else {
349350 $scope . notificationsBox = false ;
350351 $scope . canNotChangePassword = false ;
351352 $scope . dbLoading = true ;
@@ -411,8 +412,7 @@ app.controller('listDBs', function ($scope, $http) {
411412
412413 $scope . domainFeteched = $scope . selectedDomain ;
413414
414- }
415- else {
415+ } else {
416416 $scope . recordsFetched = true ;
417417 $scope . passwordChanged = true ;
418418 $scope . canNotChangePassword = true ;
@@ -481,8 +481,7 @@ app.controller('listDBs', function ($scope, $http) {
481481
482482 $scope . dbHost = response . data . dbHost ;
483483
484- }
485- else {
484+ } else {
486485 new PNotify ( {
487486 title : 'Operation Failed!' ,
488487 text : response . data . error_message ,
@@ -537,8 +536,7 @@ app.controller('listDBs', function ($scope, $http) {
537536 type : 'success'
538537 } ) ;
539538
540- }
541- else {
539+ } else {
542540 new PNotify ( {
543541 title : 'Operation Failed!' ,
544542 text : response . data . error_message ,
@@ -570,7 +568,7 @@ app.controller('listDBs', function ($scope, $http) {
570568app . controller ( 'phpMyAdmin' , function ( $scope , $http , $window ) {
571569 $scope . cyberPanelLoading = true ;
572570
573- $scope . generateAccess = function ( ) {
571+ $scope . generateAccess = function ( ) {
574572
575573 $scope . cyberPanelLoading = false ;
576574
@@ -593,12 +591,14 @@ app.controller('phpMyAdmin', function ($scope, $http, $window) {
593591 if ( response . data . status === 1 ) {
594592 var rUrl = '/phpmyadmin/phpmyadminsignin.php?username=' + response . data . username + '&token=' + response . data . token ;
595593 $window . location . href = rUrl ;
594+ } else {
596595 }
597- else { }
598596
599597 }
600598
601- function cantLoadInitialDatas ( response ) { $scope . cyberPanelLoading = true ; }
599+ function cantLoadInitialDatas ( response ) {
600+ $scope . cyberPanelLoading = true ;
601+ }
602602
603603 }
604604
0 commit comments