Skip to content

Commit e3c39dc

Browse files
committed
Make circle red if service is down
1 parent 327d19a commit e3c39dc

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

assets/js/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ window.liveSocket = liveSocket;
5151
// progressbar.js@1.0.0 version is used
5252
// Docs: http://progressbarjs.readthedocs.org/en/1.0.0/
5353

54-
window.loadStatusProgressBar = function(divId) {
54+
window.loadStatusProgressBar = function(divId, isDown) {
5555
console.log(`Loading bar for id ${divId}`);
5656
let bar = new ProgressBar.Circle(`#${divId}`, {
5757
color: "#aaa",
@@ -65,7 +65,7 @@ window.loadStatusProgressBar = function(divId) {
6565
autoStyleContainer: false,
6666
},
6767
from: { color: "#aaa", width: 1 },
68-
to: { color: "#5cb571", width: 4 }, // #333
68+
to: { color: isDown ? "#d65c3a" : "#5cb571", width: 4 }, // #333
6969

7070
// Set default step function for all animate calls
7171
step: function (state, circle) {

lib/zout_web/templates/project/index.html.heex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</tr>
2020
<script>
2121
window.addEventListener("load",function(event) {
22-
loadStatusProgressBar("loading-container-<%= project.id %>");
22+
loadStatusProgressBar("loading-container-<%= project.id %>", <%= is_down(downtime) %>);
2323
});
2424
</script>
2525
<% end %>

lib/zout_web/views/project_view.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ defmodule ZoutWeb.ProjectView do
88

99
def render_status(%Downtime{status: status, start: start}),
1010
do: "#{status} since #{DateTime.to_iso8601(start)}"
11+
12+
def is_down(nil), do: false
13+
def is_down(%Downtime{status: :working}), do: false
14+
def is_down(_), do: true
1115
end

0 commit comments

Comments
 (0)