Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config dev server prototype #1615

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions dashboard/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
<title>Privacy config dashboard</title>
<style>
#config-table {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 70%;
}

#config-table td, #config-table th {
border: 1px solid #ddd;
padding: 8px;
}

#config-table th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #f2f2f2;
color: black;
}
</style>
</head>
<body>
<table id='config-table'>
<tr>
<th>Platform</th>
<th>URL</th>
<th>Loaded?</th>
</tr>
</table>
<template id="config-row">
<tr>
<td>Platform name</td>
<td><a href=""></a></td>
<td>Not yet fetched</td>
</tr>
</template>
<script src="./index.js"></script>
</body>
</html>
47 changes: 47 additions & 0 deletions dashboard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const GREEN = '#71bf69'
const YELLOW = 'yellow'
const RED = '#f97268'
const table = document.getElementById('config-table')
const baseUrl = document.location.origin

const platforms = [
['Android', 'v4/android-config.json'],
['Extension', 'v4/extension-config.json'],
['iOS', 'v4/ios-config.json'],
['macOS', 'v4/macos-config.json'],
['Windows', 'v4/windows-config.json']
]

platforms.forEach(([name, path]) => {
const template = document.querySelector('#config-row')
const clone = template.content.cloneNode(true)
const td = clone.querySelectorAll('td')
td[0].innerText = name
const link = clone.querySelector('a')
link.href = `${baseUrl}/generated/${path}`
link.innerText = path
td[2].id = `platform_${name}_status`
table.appendChild(clone)
})

async function updateStatus () {
const req = await fetch('/status')
const { lastBuild, lastHit } = await req.json()
platforms.forEach(([name, path]) => {
const cell = document.getElementById(`platform_${name}_status`)
const fullPath = `/generated/${path}`
if (lastHit[fullPath] && lastHit[fullPath] > lastBuild) {
cell.innerText = 'Loaded'
cell.style.backgroundColor = GREEN
} else if (lastHit[fullPath]) {
cell.innerText = 'Out of date'
cell.style.backgroundColor = YELLOW
} else {
cell.innerText = 'Not yet loaded'
cell.style.backgroundColor = RED
}
})
}

updateStatus()
setInterval(updateStatus, 500)
Loading
Loading