Skip to content

Commit

Permalink
add better folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
sohamkamani committed Sep 22, 2018
1 parent e5997e2 commit f5d2c80
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 47 deletions.
15 changes: 15 additions & 0 deletions detective-dashboard/a_main-packr.go

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<title>Detective Dashboard 🔎</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<header>
<h1>Detective Dashboard</h1>
<h1>Detective Dashboard 🔎</h1>
</header>
<div class="input-container">
<h3>Enter detective endpoint URL</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<title>Detective Dashboard 🔎</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<header>
<h1>Detective Dashboard</h1>
<h1>Detective Dashboard 🔎</h1>
</header>
<div class="container">
<svg id="diagram" class="diagram"></svg>
<div class="status-bar">
<h2>Faulty nodes</h2>
<ul id="faulty-node-list"></ul>
<ul id="faulty-node-list" class="faulty-node-list"></ul>
</div>
</div>
</body>
Expand Down
57 changes: 31 additions & 26 deletions ui/static/script.js → detective-dashboard/static/script.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
var svgElem = document.getElementById('diagram')
var svg = d3.select('svg')
console.log(svgElem.height.baseVal.value)
var width = svgElem.width.baseVal.value
var height = svgElem.height.baseVal.value
var g = svg.append('g').attr('transform', 'translate(100,0)')

var tree = d3.tree().size([ height, width - 160 ])

var stratify = d3.stratify()

var monitorURL = decodeURIComponent(window.location.search.split('=')[1])

fetch('/getStatus', {
Expand All @@ -27,6 +16,16 @@ fetch('/getStatus', {
})
.then((response) => response.json())
.then((data) => {
var svgElem = document.getElementById('diagram')
var svg = d3.select('svg')
var width = svgElem.width.baseVal.value
var height = svgElem.height.baseVal.value
var g = svg.append('g').attr('transform', 'translate(100,0)')

var tree = d3.tree().size([ height, width - 160 ])

var stratify = d3.stratify()

var normalizedData = []

function addToNormalizedData (d, parentId) {
Expand All @@ -44,7 +43,7 @@ fetch('/getStatus', {
}
}
addToNormalizedData(data)
refreshFaultyNodeList(normalizedData)
refreshFaultyNodeList(data)

var root = stratify(normalizedData).sort(function (a, b) {
return a.height - b.height || a.id.localeCompare(b.id)
Expand Down Expand Up @@ -115,23 +114,29 @@ fetch('/getStatus', {

const faultyNodeList = document.getElementById('faulty-node-list')

const refreshFaultyNodeList = (normalizedData) => {
// remove all elements
while (faultyNodeList.firstChild) {
faultyNodeList.removeChild(faultyNodeList.firstChild)
}
const faultyNodes = normalizedData.filter((d) => !d.active)
if (faultyNodes.length === 0) {
faultyNodeList.appendChild(newLi('<none>'))
}
faultyNodes.forEach((d) => {
faultyNodeList.appendChild(newLi(d.name))
})
}

const newLi = (txt) => {
const li = document.createElement('li')
const txtNode = document.createTextNode(txt)
li.appendChild(txtNode)
return li
}

const refreshFaultyNodeList = (data, listNode) => {
listNode = listNode || faultyNodeList
while (listNode.firstChild) {
listNode.removeChild(listNode.firstChild)
}
const faultyNodes = data.dependencies.filter((d) => !d.active)
if (faultyNodes.length === 0) {
listNode.appendChild(newLi('<none>'))
return
}
faultyNodes.forEach((d) => {
listNode.appendChild(newLi(d.name + ': ' + d.status))
if (d.dependencies instanceof Array) {
const newList = document.createElement('ul')
listNode.appendChild(newList)
refreshFaultyNodeList(d, newList)
}
})
}
4 changes: 4 additions & 0 deletions ui/static/style.css → detective-dashboard/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ header {
padding-left: 10px;
}

.faulty-node-list {
margin-top: 15px;
}

body {
margin: 0;
padding: 0;
Expand Down
1 change: 0 additions & 1 deletion state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package detective

import (
"errors"
"fmt"
"time"
)

Expand Down
15 changes: 0 additions & 15 deletions ui/a_main-packr.go

This file was deleted.

0 comments on commit f5d2c80

Please sign in to comment.