Skip to content

Commit

Permalink
Deep cleanup 🧹 (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehevi authored Jul 27, 2023
1 parent d90f9fb commit fabdb13
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 264 deletions.
1 change: 0 additions & 1 deletion app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class RunConditionTableApplication {
httpServer.post(EP.logout, (req, res) => databaseService.logoutSession(req, res));
httpServer.get(EP.rctData, (req, res) => databaseService.pgExecFetchData(req, res));
httpServer.post(EP.insertData, (req, res) => databaseService.pgExecDataInsert(req, res));
httpServer.get(EP.date, (req, res) => databaseService.getDate(req, res));
httpServer.get(EP.sync, async (_req, _res) => this.syncManager.syncAll());
}

Expand Down
1 change: 0 additions & 1 deletion app/config/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module.exports = { // Properties that will be provided to frontend in the public
rctData: '/RCT-Data/',
insertData: '/Rct-Data/insert-data/',
authControl: '/auth-control/',
date: '/date/',
sync: '/sync/',
},
methods: {
Expand Down
27 changes: 0 additions & 27 deletions app/public/components/common/inputForm.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/public/model/navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export default class Navigation extends Observable {
}
break;
}
case '/admin/':
throw 'TODO';
default:
break;
}
Expand Down
7 changes: 7 additions & 0 deletions app/public/styles/custom.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
* or submit itself to any jurisdiction.
*/

.panel {
justify-content: center;
display: flex;
flex-direction: column;
align-items: center;
}

.font-size-small {
font-size: small !important;
}
Expand Down
67 changes: 0 additions & 67 deletions app/public/styles/ehevi/custom/components/tooltip.css

This file was deleted.

19 changes: 0 additions & 19 deletions app/public/styles/ehevi/custom/input/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,3 @@
padding-top: 0px;
height: 50px;
}

.ehevi .loginButton {
color: var(--color-white) !important;
font-weight: bolder;
background-color: #1e90ff !important;
}

.ehevi .loginFormInput {
background-color: var(--color-gray-light);
width: 100%;
height: 32px;
border: none;
border-radius: 5px;
text-indent: 34px;
}

.ehevi .loginFormInput:focus {
background-color: var(--active-color);
}
9 changes: 0 additions & 9 deletions app/public/styles/ehevi/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
@import (less) "./custom/components/run-quality.css";
@import (less) "./custom/components/sidebar.css";
@import (less) "./custom/components/snackbar.css";
@import (less) "./custom/components/tooltip.css";
@import (less) "./custom/filter/filter.css";
@import (less) "./custom/input/form.css";
@import (less) "./custom/input/select.css";
Expand Down Expand Up @@ -73,11 +72,3 @@
.justify-center;
}

.loginForm {
.flex-column;
.p4;
.abs-center;
background-color: var(--off-white);
box-shadow:0 0 15px 4px rgba(0,0,0,0.06);
border-radius: 20px;
}
21 changes: 5 additions & 16 deletions app/public/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,11 @@ import serviceUnavailablePanel from './views/serviceUnavailableView.js';
import sessionErrorPanel from './views/sessionErrorView.js';
import waitingPanel from './views/waitingView.js';
import { switchCase } from '/js/src/index.js';
import loginForm from './views/loginForm.js';
import modal from './components/common/modal.js';
import { h } from '/js/src/index.js';

export const adminLoginModalId = 'adminLoginModal';

export default function view(model) {
return h('',
modal(loginForm(model), adminLoginModalId),
switchCase(model.mode, {
serviceUnavailable: () => serviceUnavailablePanel(model),
sessionError: () => sessionErrorPanel(model),
dataAccess: () => userPanel(model),
admin: () => {
document.getElementById(adminLoginModalId).style.display = 'block';
return '';
},
}, () => waitingPanel())());
return switchCase(model.mode, {
serviceUnavailable: () => serviceUnavailablePanel(model),
sessionError: () => sessionErrorPanel(model),
dataAccess: () => userPanel(model),
}, () => waitingPanel())();
}
44 changes: 0 additions & 44 deletions app/public/views/loginForm.js

This file was deleted.

4 changes: 2 additions & 2 deletions app/public/views/userView/data/dataPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import { h } from '/js/src/index.js';
import tablePanel from './table/tablePanel.js';
import spinnerAndReloadView from './fetchingStates/loading.js';
import loading from './fetchingStates/loading.js';
import failureStatusAndReload from './fetchingStates/failure.js';
import unknownError from './fetchingStates/unknown.js';
import { RCT } from '../../../config.js';
Expand All @@ -34,7 +34,7 @@ export default function dataPanel(model, runs, detectors, flags) {

return data ? data.match({
NotAsked: () => h('', 'not asked'),
Loading: () => spinnerAndReloadView(model),
Loading: () => loading(),
Success: () => {
switch (page) {
case pageNames.flags:
Expand Down
81 changes: 6 additions & 75 deletions app/public/views/userView/data/fetchingStates/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,87 +13,18 @@
*/

import { h } from '/js/src/index.js';
import viewButton from '../../../../components/common/viewButton.js';
import spinner from '../../../../components/common/spinner.js';

const pos = { x: 0, y: 0 };

const saveCursorPosition = (x, y) => {
pos.x = (x / window.innerWidth).toFixed(2);
pos.y = (y / window.innerHeight).toFixed(2);
document.documentElement.style.setProperty('--x', pos.x);
document.documentElement.style.setProperty('--y', pos.y);
};

export default function spinnerAndReloadView(model) {
const loadingFinished = () => model.fetchedData[model.getCurrentDataPointer().page][model.getCurrentDataPointer().index]?.kind !== 'Loading';
let totalSeconds = 0;
let counterId = undefined;

const initCounter = () => {
if (counterId !== undefined) {
clearInterval(counterId);
counterId = undefined;
totalSeconds = 0;
}
if (counterId === undefined) {
counterId = setInterval(setTime, 1000);
}
};

const setTime = () => {
let minutesLabel = null;
let secondsLabel = null;
do {
minutesLabel = document.getElementById('minutes');
secondsLabel = document.getElementById('seconds');
if (loadingFinished()) {
clearInterval(counterId);
return;
}
} while (!(secondsLabel && minutesLabel));
++totalSeconds;
secondsLabel.innerHTML = pad(totalSeconds % 60);
minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60, 10));
};

const pad = (val) => {
const valString = `${val}`;
if (valString.length < 2) {
return `0${valString}`;
} else {
return valString;
}
};

const reloadBtn = viewButton(
model,
'Retry',
() => {
document.location.reload(true);
},
'',
undefined,
'.btn-primary.m3',
);
export default function loading() {
const reloadBtn = h('button.btn.btn-primary.m3', {
onclick: () => document.location.reload(),
}, 'Retry');
const loadingMessage = h('h3', 'Loading...');
const counter = h('h5.inline',
h('span.clear-both', { id: 'minutes' }, '00'),
h('span.clear-both', ':'),
h('span.clear-both', { id: 'seconds' }, '00'),
h('.tooltiptext2.tracker.p2.br3',
'If you are seeing this for way too long, then probably something is messed up'));

document.addEventListener('mousemove', (e) => {
saveCursorPosition(e.clientX, e.clientY);
});
setTimeout(() => initCounter(), 0);

return h('.loginDiv.top-100', [
h('.my-tooltip-bg',
h('.panel',
spinner(),
loadingMessage,
counter),
loadingMessage),
reloadBtn,
]);
}
2 changes: 1 addition & 1 deletion app/public/views/waitingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function waitingPanel() {
const loadingMessage = h('h3', 'Loading...');

return h('.loginDiv.top-100', [
h('.my-tooltip-bg',
h('.panel',
spinner(),
loadingMessage),
reloadBtn,
Expand Down

0 comments on commit fabdb13

Please sign in to comment.