forked from schenkd/nginx-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added restart button and method to interact with container. Resolves s…
- Loading branch information
mohamedtaee
committed
May 26, 2024
1 parent
70173ff
commit 83a2ac5
Showing
6 changed files
with
207 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
setNginxStatusCircle(); | ||
}); | ||
|
||
function setNginxStatusCircle() { | ||
const nginxStatusCircle = document.getElementById('nginx-status-circle'); | ||
|
||
fetch('/api/status-nginx') | ||
.then(response => response.json()) | ||
.then(data => { | ||
console.log(data); | ||
|
||
const containerStatus = data.status; | ||
console.log("Container status: " + containerStatus); | ||
nginxStatusCircle.className = 'status-circle status-' + containerStatus; | ||
return containerStatus; | ||
}); | ||
} | ||
|
||
let restartProcessComplete = true; | ||
|
||
function restartStatusInterval() { | ||
const nginxStatusCircle = document.getElementById('nginx-status-circle'); | ||
nginxStatusCircle.className = 'status-circle status-loading'; | ||
|
||
const intervalId = setInterval(() => { | ||
if (restartProcessComplete) { | ||
clearInterval(intervalId); | ||
setNginxStatusCircle(); | ||
} else { | ||
if (nginxStatusCircle.className === 'status-circle status-loading') { | ||
nginxStatusCircle.className = 'status-circle status-black'; | ||
} else { | ||
nginxStatusCircle.className = 'status-circle status-loading'; | ||
} | ||
} | ||
}, 300); | ||
} | ||
|
||
|
||
function restartNginx() { | ||
restartProcessComplete = false; | ||
restartStatusInterval(); | ||
|
||
const restartBtn = document.getElementById('nginx-restart-btn'); | ||
restartBtn.disabled = true; | ||
|
||
const restartSpinner = document.getElementById('nginx-restart-btn-spinner'); | ||
restartSpinner.className = 'custom-spinner custom-spinner-sm'; | ||
|
||
|
||
fetch('/api/restart-nginx', {method: "POST"}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
console.log(data); | ||
}) | ||
.finally(() => { | ||
setNginxStatusCircle(); | ||
restartProcessComplete = true; | ||
restartSpinner.className = ''; | ||
restartBtn.disabled = false; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Flask~=3.0.3 | ||
gunicorn~=22.0.0 | ||
Flask-Moment~=1.0.5 | ||
Flask-Moment~=1.0.5 | ||
docker~=7.1.0 |