Skip to content

Commit

Permalink
Make circle red if service is down
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbloch committed Jun 2, 2022
1 parent 327d19a commit e3c39dc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ window.liveSocket = liveSocket;
// [email protected] version is used
// Docs: http://progressbarjs.readthedocs.org/en/1.0.0/

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

// Set default step function for all animate calls
step: function (state, circle) {
Expand Down
2 changes: 1 addition & 1 deletion lib/zout_web/templates/project/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</tr>
<script>
window.addEventListener("load",function(event) {
loadStatusProgressBar("loading-container-<%= project.id %>");
loadStatusProgressBar("loading-container-<%= project.id %>", <%= is_down(downtime) %>);
});
</script>
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions lib/zout_web/views/project_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ defmodule ZoutWeb.ProjectView do

def render_status(%Downtime{status: status, start: start}),
do: "#{status} since #{DateTime.to_iso8601(start)}"

def is_down(nil), do: false
def is_down(%Downtime{status: :working}), do: false
def is_down(_), do: true
end

0 comments on commit e3c39dc

Please sign in to comment.