Skip to content

Commit

Permalink
eslint all js
Browse files Browse the repository at this point in the history
  • Loading branch information
baelter committed Jun 13, 2018
1 parent cf30cae commit a2d69ad
Show file tree
Hide file tree
Showing 19 changed files with 630 additions and 419 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
"extends": "standard",
"plugins": [
"html"
],
"settings": {
"html/indent": "+2"
},
"globals": {
"avalanchemq": true
},
"rules": {
"indent": ["error", 2]
}
};
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/**
18 changes: 9 additions & 9 deletions static/channels.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ <h2>
<script src="/js/overview.js"></script>
<script src="/js/table.js"></script>
<script>
avalanchemq.table.renderTable("table", "/api/channels", ["name"], 5000, function (tr, item) {
var mode = "";
mode += item.confirm ? " C" : "";
avalanchemq.table.renderCell(tr, 0, item.name);
avalanchemq.table.renderCell(tr, 1, item.vhost);
avalanchemq.table.renderCell(tr, 2, item.username);
avalanchemq.table.renderCell(tr, 3, mode);
avalanchemq.table.renderTable('table', '/api/channels', ['name'], 5000, function (tr, item) {
let mode = ''
mode += item.confirm ? ' C' : ''
avalanchemq.table.renderCell(tr, 0, item.name)
avalanchemq.table.renderCell(tr, 1, item.vhost)
avalanchemq.table.renderCell(tr, 2, item.username)
avalanchemq.table.renderCell(tr, 3, mode)
avalanchemq.table.renderCell(tr, 4, item.consumer_count)
avalanchemq.table.renderCell(tr, 5, item.prefetch_count)
avalanchemq.table.renderCell(tr, 6, item.messages_unacked);
});
avalanchemq.table.renderCell(tr, 6, item.messages_unacked)
})
</script>
</body>
</html>
Expand Down
171 changes: 171 additions & 0 deletions static/connection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Connection | AvalancheMQ</title>
<link href="/main.css" rel="stylesheet">
<meta name="google" content="notranslate">
</head>
<body>
<div class="container">
<header>
<h1>
AvalancheMQ
<small id="version"></small>
</h1>
<div id="user-info">
<span>👤:&nbsp;</span>
<span id="username"></span>
<span id="vhost"></span>
</div>
</header>
<ul id="menu">
<li><a href="/">Overview</a></li>
<li><a href="/connections">Connections</a></li>
<li><a href="/channels">Channels</a></li>
<li><a href="/queues">Queues</a></li>
<li><a href="/exchanges">Exchanges</a></li>
<li><a href="/users">Users</a></li>
<li><a href="/vhosts">Virtual Hosts</a></li>
</ul>
<h2>
Connection:
<small id="connection"></small>
</h2>
<table>
<tr>
<th>Username</th>
<td id="conn-username"></td>
<th>State</th>
<td id="state"></td>
</tr>
<tr>
<th>Connected at</th>
<td id="connected_at"></td>
<th>Heartbeat</th>
<td id="heartbeat"></td>
</tr>
<tr>
<th>Authentication</th>
<td id="authentication"></td>
<th>Channel max</th>
<td id="channel_max"></td>
</tr>
</table>
<div id="table-error"></div>
<h3>
Channels
<small id="table-count"></small>
</h3>
<table id="table" class="table">
<thead>
<tr>
<th data-sort-key="name">Name</th>
<th data-sort-key="vhost">Virtual Host</th>
<th data-sort-key="username">Username</th>
<th>Mode</th>
<th data-sort-key="consumer_count">Consumers</th>
<th data-sort-key="prefetch_count">Prefetch limit</th>
<th data-sort-key="messages_unacked">Unacked messages</th>
</tr>
</thead>
<tbody></tbody>
</table>
<h3>Client properties</h3>
<table>
<tr>
<th>Capabilities</th>
<td><pre id="cp-capabilities"></pre></td>
</tr>
<tr>
<th>Product</th>
<td id="cp-product"></td>
</tr>
<tr>
<th>Platform</th>
<td id="cp-platform"></td>
</tr>
<tr>
<th>Version</th>
<td id="cp-version"></td>
</tr>
<tr>
<th>Information</th>
<td id="cp-information"></td>
</tr>
</table>
<form method="delete" id="closeConnection">
<fieldset>
<legend>Close connection</legend>
<input type="text" name="reason" value="Closed via Web management">
<button type="submit">Close</button>
</fieldset>
</form>
</div>
<script src="/js/auth.js"></script>
<script src="/js/http.js"></script>
<script src="/js/overview.js"></script>
<script src="/js/table.js"></script>
<script>
const urlEncodedConnection = new URLSearchParams(window.location.search).get('name')
const connection = decodeURIComponent(urlEncodedConnection)
document.title = connection + ' | AvalancheMQ'
document.querySelector('#connection').textContent = connection

const connectionUrl = '/api/connections/' + urlEncodedConnection
function updateConnection (all) {
avalanchemq.http.request('GET', connectionUrl).then(item => {
const stateEl = document.getElementById('state')
if (item.state !== stateEl.textContent) {
stateEl.textContent = item.state
}
if (all) {
document.getElementById('conn-username').textContent = item.user
document.getElementById('connected_at').textContent = new Date(item.connected_at)
document.getElementById('heartbeat').textContent = item.timeout + 's'
document.getElementById('authentication').textContent = item.auth_mechanism
document.getElementById('channel_max').textContent = item.channel_max
const cp = item.client_properties
document.getElementById('cp-capabilities').textContent = JSON.stringify(cp.capabilities, undefined, 2).replace(/["{},]/g, '')
document.getElementById('cp-product').textContent = cp.product
document.getElementById('cp-platform').textContent = cp.platform
document.getElementById('cp-version').textContent = cp.version
const infoEl = document.getElementById('cp-information')
if (cp.information.startsWith('http')) {
const infoLink = document.createElement('a')
infoLink.textContent = cp.information
infoLink.href = cp.information
while (infoEl.lastChild) {
infoEl.removeChild(infoEl.lastChild)
}
infoEl.appendChild(infoLink)
} else {
infoEl.textContent = cp.information
}
}
}).catch(e => console.error.apply(console, e))
}
updateConnection(true)
setInterval(updateConnection, 5000)
const channelsUrl = connectionUrl + '/channels'
avalanchemq.table.renderTable('table', channelsUrl, ['name'], 5000, function (tr, item) {
let mode = ''
mode += item.confirm ? ' C' : ''
avalanchemq.table.renderCell(tr, 0, item.name)
avalanchemq.table.renderCell(tr, 1, item.vhost)
avalanchemq.table.renderCell(tr, 2, item.username)
avalanchemq.table.renderCell(tr, 3, mode)
avalanchemq.table.renderCell(tr, 4, item.consumer_count)
avalanchemq.table.renderCell(tr, 5, item.prefetch_count)
avalanchemq.table.renderCell(tr, 6, item.messages_unacked)
})

document.querySelector('#closeConnection').addEventListener('submit', function (evt) {
evt.preventDefault()
const url = '/api/connections/' + urlEncodedConnection
avalanchemq.http.request('DELETE', url)
.then(() => { window.location = '/connections' })
.catch(e => console.error.apply(console, e))
})
</script>
</body>
</html>
34 changes: 24 additions & 10 deletions static/connections.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ <h2>
<table id="table" class="table">
<thead>
<tr>
<th data-sort-key="vhost">VHost</th>
<th data-sort-key="vhost">Virtual host</th>
<th data-sort-key="name">Name</th>
<th data-sort-key="username">Username</th>
<th data-sort-key="tls">TLS</th>
<th data-sort-key="user">Username</th>
<th data-sort-key="state">State</th>
<th data-sort-key="ssl">TLS</th>
<th data-sort-key="channels">Channels</th>
<th data-sort-key="channel_max">Channel max</th>
<th data-sort-key="auth_mechanism">Auth mechanism</th>
<th>Client</th>
<th data-sort-key="connected_at">Connected at</th>
</tr>
</thead>
<tbody></tbody>
Expand All @@ -50,13 +55,22 @@ <h2>
<script src="/js/overview.js"></script>
<script src="/js/table.js"></script>
<script>
avalanchemq.table.renderTable("table", "/api/connections", ["name"], 5000, function (tr, item) {
avalanchemq.table.renderCell(tr, 0, item.vhost);
avalanchemq.table.renderCell(tr, 1, item.name);
avalanchemq.table.renderCell(tr, 2, item.user);
avalanchemq.table.renderCell(tr, 3, item.ssl ? "🔒" : "");
avalanchemq.table.renderCell(tr, 4, item.channels);
});
avalanchemq.table.renderTable('table', '/api/connections', ['name'], 5000, function (tr, item) {
const client = item.client_properties.product + ' / ' + item.client_properties.platform
const connectionLink = document.createElement('a')
connectionLink.href = '/connection?name=' + encodeURIComponent(item.name)
connectionLink.textContent = item.name
avalanchemq.table.renderCell(tr, 0, item.vhost)
avalanchemq.table.renderCell(tr, 1, connectionLink)
avalanchemq.table.renderCell(tr, 2, item.user)
avalanchemq.table.renderCell(tr, 3, item.state)
avalanchemq.table.renderCell(tr, 4, item.ssl ? '🔒' : '')
avalanchemq.table.renderCell(tr, 5, item.channels)
avalanchemq.table.renderCell(tr, 6, item.channel_max)
avalanchemq.table.renderCell(tr, 7, item.auth_mechanism)
avalanchemq.table.renderHtmlCell(tr, 8, client + '<br><small>' + item.client_properties.version + '</small>')
avalanchemq.table.renderCell(tr, 9, new Date(item.connected_at))
})
</script>
</body>
</html>
20 changes: 10 additions & 10 deletions static/exchanges.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ <h2>
<script src="/js/overview.js"></script>
<script src="/js/table.js"></script>
<script>
avalanchemq.table.renderTable("table", "/api/exchanges", ["vhost", "name"], 5000, function (tr, item) {
var features = "";
features += item.durable ? " D" : "";
features += item.auto_delete ? " AD" : "";
features += item.internal ? " I" : "";
avalanchemq.table.renderCell(tr, 0, item.name);
avalanchemq.table.renderCell(tr, 1, item.vhost);
avalanchemq.table.renderCell(tr, 2, features);
avalanchemq.table.renderCell(tr, 3, item.type);
});
avalanchemq.table.renderTable('table', '/api/exchanges', ['vhost', 'name'], 5000, function (tr, item) {
let features = ''
features += item.durable ? ' D' : ''
features += item.auto_delete ? ' AD' : ''
features += item.internal ? ' I' : ''
avalanchemq.table.renderCell(tr, 0, item.name)
avalanchemq.table.renderCell(tr, 1, item.vhost)
avalanchemq.table.renderCell(tr, 2, features)
avalanchemq.table.renderCell(tr, 3, item.type)
})
</script>
</body>
</html>
16 changes: 8 additions & 8 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ <h2>Overview</h2>
<script src="/js/overview.js"></script>
<script src="/js/table.js"></script>
<script>
avalanchemq.overview.start();
document.querySelector("#definitions").addEventListener("submit", function (evt) {
evt.preventDefault();
avalanchemq.http.request("POST", "/api/definitions/upload", new FormData(this)).then(function () {
window.location.assign('/');
avalanchemq.overview.start()
document.querySelector('#definitions').addEventListener('submit', function (evt) {
evt.preventDefault()
avalanchemq.http.request('POST', '/api/definitions/upload', new FormData(this)).then(function () {
window.location.assign('/')
}).catch(function () {
alert("Upload failed");
});
});
alert('Upload failed')
})
})
</script>

Loading

0 comments on commit a2d69ad

Please sign in to comment.