@@ -37,12 +37,17 @@ function refresh() {
3737 tBody . removeChild ( row ) ;
3838 }
3939 }
40+ if ( tBody . children . length == 0 ) {
41+ document . getElementById ( "delete-selected-button-action" ) . style . display = "none" ;
42+ document . getElementById ( "edit-button" ) . style . display = "none" ;
43+ document . getElementById ( "am__div--select" ) . style . display = "none" ;
44+ }
4045 } ) ;
4146}
4247
4348
4449window . addEventListener ( "DOMContentLoaded" , ( event ) => {
45- window . setInterval ( refresh , 20000 ) ; ;
50+ window . setInterval ( refresh , 20000 ) ;
4651} ) ;
4752
4853var selectMaintenanceWindows = function ( toggle , className ) {
@@ -59,7 +64,7 @@ Behaviour.specify(".am__action-delete", 'agent-maintenance', 0, function(e) {
5964 let message = this . getAttribute ( "data-message" ) ;
6065 let messageSuccess = this . getAttribute ( "data-message-success" ) ;
6166 let id = row . id ;
62- if ( confirm ( message ) ) {
67+ dialog . confirm ( message ) . then ( ( ) => {
6368 maintenanceJavaScriptBind . deleteMaintenance ( id , function ( response ) {
6469 let result = response . responseObject ( ) ;
6570 if ( result ) {
@@ -69,12 +74,13 @@ Behaviour.specify(".am__action-delete", 'agent-maintenance', 0, function(e) {
6974 if ( tbody . children . length == 0 ) {
7075 document . getElementById ( "edit-button" ) . style . display = "none" ;
7176 document . getElementById ( "delete-selected-button-action" ) . style . display = "none" ;
77+ document . getElementById ( "am__div--select" ) . style . display = "none" ;
7278 }
7379 } else {
7480 notificationBar . show ( "Something went wrong. Please check the logs." , notificationBar . ERROR ) ;
7581 }
7682 } ) ;
77- }
83+ } ) ;
7884 }
7985} ) ;
8086
@@ -84,7 +90,7 @@ Behaviour.specify(".am__action-delete-recurring", 'agent-maintenance', 0, functi
8490 let message = this . getAttribute ( "data-message" ) ;
8591 let messageSuccess = this . getAttribute ( "data-message-success" ) ;
8692 let id = row . id ;
87- if ( confirm ( message ) ) {
93+ dialog . confirm ( message ) . then ( ( ) => {
8894 maintenanceJavaScriptBind . deleteRecurringMaintenance ( id , function ( response ) {
8995 let result = response . responseObject ( ) ;
9096 if ( result ) {
@@ -94,12 +100,13 @@ Behaviour.specify(".am__action-delete-recurring", 'agent-maintenance', 0, functi
94100 if ( tbody . children . length == 0 ) {
95101 document . getElementById ( "edit-recurring" ) . style . display = "none" ;
96102 document . getElementById ( "delete-selected-recurring-action" ) . style . display = "none" ;
103+ document . getElementById ( "am__div--select" ) . style . display = "none" ;
97104 }
98105 } else {
99106 notificationBar . show ( "Something went wrong. Please check the logs." , notificationBar . ERROR ) ;
100107 }
101108 } ) ;
102- }
109+ } ) ;
103110 }
104111} ) ;
105112
@@ -110,7 +117,7 @@ Behaviour.specify(".am__link-delete", 'agent-maintenance', 0, function(e) {
110117 let row = findAncestor ( this , "TR" ) ;
111118 let id = row . id ;
112119 let computerName = row . getAttribute ( "data-computer-name" ) ;
113- if ( confirm ( message ) ) {
120+ dialog . confirm ( message ) . then ( ( ) => {
114121 maintenanceJavaScriptBind . deleteMaintenance ( id , computerName , function ( response ) {
115122 let result = response . responseObject ( ) ;
116123 if ( result ) {
@@ -119,47 +126,50 @@ Behaviour.specify(".am__link-delete", 'agent-maintenance', 0, function(e) {
119126 notificationBar . show ( messageSuccess , notificationBar . SUCCESS )
120127 if ( tbody . children . length == 0 ) {
121128 document . getElementById ( "delete-selected-button-link" ) . style . display = "none" ;
129+ document . getElementById ( "am__div--select" ) . style . display = "none" ;
122130 }
123131 } else {
124132 notificationBar . show ( "Something went wrong. Please check the logs." , notificationBar . ERROR ) ;
125133 }
126134 } ) ;
127- }
135+ } ) ;
128136 }
129137} ) ;
130138
131139Behaviour . specify ( ".am__disable" , 'agent-maintenance' , 0 , function ( e ) {
132140 e . onclick = function ( ) {
133141 let message = this . getAttribute ( "data-message" ) ;
134- if ( confirm ( message ) ) {
142+ dialog . confirm ( message ) . then ( ( ) => {
135143 fetch ( "disable" , {
136144 method : "POST" ,
137145 headers : crumb . wrap ( { } ) ,
138146 }
139147 ) ;
140148 location . reload ( ) ;
141- } ;
149+ } ) ;
142150 }
143151} ) ;
144152
145153Behaviour . specify ( ".am__enable" , 'agent-maintenance' , 0 , function ( e ) {
146154 e . onclick = function ( ) {
147155 let message = this . getAttribute ( "data-message" ) ;
148- if ( confirm ( message ) ) {
156+ dialog . confirm ( message ) . then ( ( ) => {
149157 fetch ( "enable" , {
150158 method : "POST" ,
151159 headers : crumb . wrap ( { } ) ,
152160 }
153161 ) ;
154162 location . reload ( ) ;
155- } ;
163+ } ) ;
156164 }
157165} ) ;
158166
159167Behaviour . specify ( "#add-button" , 'agent-maintenance' , 0 , function ( e ) {
160- e . onclick = function ( ) {
168+ e . onclick = function ( ) {
161169 openForm ( "maintenance-add-form" )
162- } ;
170+ } ;
171+ e . style . display = 'inline-flex' ;
172+ e . classList . remove ( "jenkins-hidden" ) ;
163173} ) ;
164174
165175Behaviour . specify ( "#add-recurring" , 'agent-maintenance' , 0 , function ( e ) {
@@ -174,8 +184,9 @@ Behaviour.specify("#edit-button", 'agent-maintenance', 0, function(e) {
174184 }
175185 let table = document . getElementById ( "maintenance-table" ) ;
176186 let tbody = table . tBodies [ 0 ] ;
177- if ( tbody . children . length == 0 ) {
178- e . style . display = 'none' ;
187+ if ( tbody . children . length != 0 ) {
188+ e . style . display = 'inline-flex' ;
189+ e . classList . remove ( "jenkins-hidden" ) ;
179190 }
180191} ) ;
181192
@@ -237,8 +248,12 @@ Behaviour.specify("#delete-selected-button-action", 'agent-maintenance', 0, func
237248 } ) ;
238249 }
239250 }
240- if ( tbody . children . length == 0 ) {
241- e . style . display = 'none' ;
251+ if ( tbody . children . length != 0 ) {
252+ e . style . display = 'inline-flex' ;
253+ e . classList . remove ( "jenkins-hidden" ) ;
254+ let select = document . getElementById ( "am__div--select" ) ;
255+ select . classList . remove ( "jenkins-hidden" ) ;
256+ select . style . display = "block" ;
242257 }
243258} ) ;
244259
@@ -319,8 +334,12 @@ Behaviour.specify("#delete-selected-button-link", 'agent-maintenance', 0, functi
319334 } ) ;
320335 }
321336 }
322- if ( tbody . children . length == 0 ) {
323- e . style . display = 'none' ;
337+ if ( tbody . children . length != 0 ) {
338+ e . style . display = "inline-flex" ;
339+ e . classList . remove ( "jenkins-hidden" )
340+ let select = document . getElementById ( "am__div--select" ) ;
341+ select . classList . remove ( "jenkins-hidden" ) ;
342+ select . style . display = "block" ;
324343 }
325344} ) ;
326345
0 commit comments