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

move database credential inputs to the center on initial load #46455

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
93 changes: 83 additions & 10 deletions programs/server/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,52 @@

.chart div { position: absolute; }

.inputs { font-size: 14pt; }
.inputs {
height: auto;
width: 100%;

font-size: 14pt;

display: flex;
flex-flow: column nowrap;
justify-content: center;
}

.inputs.unconnected {
height: 100vh;
}
.unconnected #params {
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
}
.unconnected #connection-params {
width: 50%;

display: flex;
flex-flow: row wrap;
}
.unconnected #url {
width: 100%;
}
.unconnected #user {
width: 50%;
}
.unconnected #password {
width: 49.5%;
}
.unconnected input {
margin-bottom: 5px;
}

.inputs #chart-params {
display: block;
}

.inputs.unconnected #chart-params {
display: none;
}

#connection-params {
margin-bottom: 0.5rem;
Expand Down Expand Up @@ -223,6 +268,10 @@
color: var(--chart-button-hover-color);
}

.disabled {
opacity: 0.5;
}

.query-editor {
display: none;
grid-template-columns: auto fit-content(10%);
Expand Down Expand Up @@ -286,16 +335,16 @@
</style>
</head>
<body>
<div class="inputs">
<div class="inputs unconnected">
<form id="params">
<div id="connection-params">
<input spellcheck="false" id="url" type="text" value="" placeholder="URL" />
<input spellcheck="false" id="user" type="text" value="" placeholder="user" />
<input spellcheck="false" id="password" type="password" placeholder="password" />
</div>
<div>
<input id="reload" type="button" value="Reload" style="display: none;">
<input id="add" type="button" value="Add chart">
<input id="reload" type="button" value="Reload">
<input id="add" type="button" value="Add chart" style="display: none;">
<span class="nowrap themes"><span id="toggle-dark">🌚</span><span id="toggle-light">🌞</span></span>
<div id="chart-params"></div>
</div>
Expand Down Expand Up @@ -845,7 +894,7 @@
error_div.firstChild.data = error;
title_div.style.display = 'none';
error_div.style.display = 'block';
return;
return false;
} else {
error_div.firstChild.data = '';
error_div.style.display = 'none';
Expand Down Expand Up @@ -886,6 +935,7 @@
/// Set title
const title = queries[idx] && queries[idx].title ? queries[idx].title.replaceAll(/\{(\w+)\}/g, (_, name) => params[name] ) : '';
chart.querySelector('.title').firstChild.data = title;
return true
}

function showAuthError(message) {
Expand All @@ -902,8 +952,6 @@
function hideAuthError() {
const charts = document.querySelector('#charts');
charts.style.display = 'flex';
const add = document.querySelector('#add');
add.style.display = 'block';

const authError = document.querySelector('#auth-error');
authError.textContent = '';
Expand All @@ -924,9 +972,20 @@
if (!firstLoad) {
showAuthError(e.message);
}
return false;
});
})).then(() => {
firstLoad = false;
})).then((results) => {
if (firstLoad) {
firstLoad = false;
} else {
enableReloadButton();
}
if (!results.includes(false)) {
const element = document.querySelector('.inputs');
element.classList.remove('unconnected');
const add = document.querySelector('#add');
add.style.display = 'block';
}
})
}

Expand All @@ -941,11 +1000,25 @@

new ResizeObserver(resize).observe(document.body);

function disableReloadButton() {
const reloadButton = document.getElementById('reload')
reloadButton.value = 'Reloading...'
reloadButton.disabled = true
reloadButton.classList.add('disabled')
}

function enableReloadButton() {
const reloadButton = document.getElementById('reload')
reloadButton.value = 'Reload'
reloadButton.disabled = false
reloadButton.classList.remove('disabled')
}

function reloadAll() {
updateParams();
drawAll();
saveState();
document.getElementById('reload').style.display = 'none';
disableReloadButton()
}

document.getElementById('params').onsubmit = function(event) {
Expand Down