Skip to content

Commit 62461c4

Browse files
Some fixes to disabled buttons and bootstrap grid (#116)
* Button disable to tied to backend status check and css is not switched * Change column css and add small timed check to disable collapsed buttons
1 parent 35245c2 commit 62461c4

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

src/main/resources/static/js/subscription.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ jQuery(document).ready(function () {
7474
backendStatus = true;
7575
},
7676
complete: function () {
77+
toggleOnBackendStatus(backendStatus);
7778
setTimeout(loadSubButtons, 800);
7879
}
7980
});
@@ -89,21 +90,25 @@ jQuery(document).ready(function () {
8990
window.setInterval(function () { checkBackendStatus(); }, 15000);
9091

9192
// Check if buttons should be enabled or disabled
92-
// Execute code to show or hide status enable disable buttons
93-
var buttonsDisabled = false;
94-
window.setInterval(function () {
95-
if (!backendStatus && !buttonsDisabled) {
96-
$("#back_end_down_warning").show();
97-
$(".hidden_by_default").show();
98-
buttonsDisabled = true;
99-
toggleButtonsDisabled(buttonsDisabled);
100-
} else if (backendStatus && buttonsDisabled) {
101-
$("#back_end_down_warning").hide();
102-
buttonsDisabled = false;
103-
toggleButtonsDisabled(buttonsDisabled);
93+
// Toggle warning text on and off
94+
// Check backend status to shrink or increase space for warning to show
95+
function toggleOnBackendStatus(backendStatus) {
96+
if(!backendStatus && !$("#back_end_down_warning").is(":visible")) {
97+
$("#subTitle").parent().removeClass("col-md-9");
98+
$("#btnEIContainer").parent().removeClass("col-md-3");
99+
$("#subTitle").parent().addClass("col-md-4");
100+
$("#btnEIContainer").parent().addClass("col-md-2");
101+
}
102+
if(backendStatus && $("#back_end_down_warning").is(":visible")) {
103+
$("#subTitle").parent().removeClass("col-md-4");
104+
$("#btnEIContainer").parent().removeClass("col-md-2");
105+
$("#subTitle").parent().addClass("col-md-9");
106+
$("#btnEIContainer").parent().addClass("col-md-3");
104107
reload_table();
105108
}
106-
}, 1000);
109+
$("#back_end_down_warning").toggle(!backendStatus);
110+
toggleButtonsDisabled(!backendStatus);
111+
}
107112

108113
// Check if EI Backend Server is online when Status Connection button is pressed.
109114
$("#btnEIConnection").click(function () {
@@ -381,7 +386,7 @@ jQuery(document).ready(function () {
381386
"targets": [0],
382387
"orderable": false,
383388
"className": "control",
384-
"data":"subscriptionName",
389+
"data": "subscriptionName",
385390
"render": function (data, type, row, meta) {
386391
return '';
387392
}
@@ -460,6 +465,9 @@ jQuery(document).ready(function () {
460465
$("#check-all").click(function () {
461466
$(".data-check").prop('checked', $(this).prop('checked'));
462467
});
468+
$(".control").click(function () {
469+
setTimeout(function () { toggleOnBackendStatus(backendStatus); }, 50);
470+
});
463471
}
464472
});
465473
};

src/main/resources/templates/subscription.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
<body>
1717
<div class="d-none" id="subscriptionTemplate" th:text="${subscriptionTemplate}"></div>
1818
<div class="d-flex flex-wrap">
19-
<div class="col-md-4 col-6 order-md-0">
20-
<h3>Eiffel Intelligence Subscription Handling</h3>
19+
<div class="col-md-9 col-sm-8 col-6 order-md-0">
20+
<h3 id="subTitle">Eiffel Intelligence Subscription Handling</h3>
2121
</div>
22-
<div class="col-md-6 col-12 order-last order-md-1">
23-
<span id="back_end_down_warning" class="hidden_by_default">
22+
<div id="back_end_down_warning" class="col-md-6 col-12 order-last order-md-1 hidden_by_default">
23+
<span>
2424
Ensure back end is up or switch to another back end before continuing!
2525
</span>
2626
</div>
27-
<div class="col-md-2 col-6 order-md-2 d-flex justify-content-end">
27+
<div class="col-md-3 col-sm-4 col-6 order-md-2 d-flex justify-content-end">
2828
<div id="btnEIContainer">
2929
<button title="EI connection status check is refreshed continuously. Click button to force check status."
3030
type="button" id="btnEIConnection" class="btn btnEIConnectionStatus white-space-normal">

0 commit comments

Comments
 (0)