Frontend: Fix tests & code clean-up
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
2b6b1b9f79
commit
55918a40fe
8 changed files with 21 additions and 18 deletions
|
@ -18,5 +18,6 @@ module.exports = {
|
|||
semi: ['error', 'always'],
|
||||
'no-unused-vars': ['warn'],
|
||||
'no-console': 0,
|
||||
'no-prototype-builtins': 0,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -2,12 +2,15 @@ import "@babel/polyfill/noConflict";
|
|||
import Axios from "axios";
|
||||
import Notify from "common/notify";
|
||||
|
||||
const testConfig = {"jsHash": "test", "version": "test"};
|
||||
const config = window.clientConfig ? window.clientConfig : testConfig;
|
||||
|
||||
const Api = Axios.create({
|
||||
baseURL: "/api/v1",
|
||||
headers: {common: {
|
||||
"X-Session-Token": window.localStorage.getItem("session_token"),
|
||||
"X-Client-Hash": window.clientConfig.jsHash,
|
||||
"X-Client-Version": window.clientConfig.version,
|
||||
"X-Client-Hash": config.jsHash,
|
||||
"X-Client-Version": config.version,
|
||||
}},
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import Event from "pubsub-js";
|
||||
import themes from "../resources/themes.json";
|
||||
import translations from "../resources/translations.json";
|
||||
import Vue from "vue";
|
||||
|
||||
class Config {
|
||||
/**
|
||||
|
@ -15,7 +14,7 @@ class Config {
|
|||
this.translations = translations;
|
||||
this.values = values;
|
||||
|
||||
this.subscriptionId = Event.subscribe('config.updated', (ev, data) => this.setValues(data));
|
||||
this.subscriptionId = Event.subscribe("config.updated", (ev, data) => this.setValues(data));
|
||||
|
||||
if(this.hasValue("settings")) {
|
||||
this.setTheme(this.getValue("settings").theme);
|
||||
|
|
|
@ -5,7 +5,7 @@ class Log {
|
|||
this.logs = [];
|
||||
this.logId = 0;
|
||||
|
||||
Event.subscribe('log', this.onLog.bind(this));
|
||||
Event.subscribe("log", this.onLog.bind(this));
|
||||
}
|
||||
|
||||
onLog(ev, data) {
|
||||
|
|
|
@ -24,19 +24,19 @@ const Notify = {
|
|||
Event.publish("ajax.end");
|
||||
},
|
||||
blockUI: function() {
|
||||
const el = document.getElementById('p-busy-overlay');
|
||||
const el = document.getElementById("p-busy-overlay");
|
||||
|
||||
if(el) {
|
||||
el.style.display = 'block';
|
||||
el.style.display = "block";
|
||||
}
|
||||
},
|
||||
unblockUI: function() {
|
||||
const el = document.getElementById('p-busy-overlay');
|
||||
const el = document.getElementById("p-busy-overlay");
|
||||
|
||||
if(el) {
|
||||
el.style.display = 'none';
|
||||
el.style.display = "none";
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default Notify;
|
||||
|
|
|
@ -24,7 +24,7 @@ export default class Session {
|
|||
this.auth = true;
|
||||
}
|
||||
|
||||
Event.subscribe('session.logout', this.onLogout.bind(this));
|
||||
Event.subscribe("session.logout", this.onLogout.bind(this));
|
||||
}
|
||||
|
||||
useSessionStorage() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import randomString from "crypto-random-string";
|
|||
|
||||
export const token = randomString({length: 16});
|
||||
const host = window.location.host;
|
||||
const prot = ('https:' === document.location.protocol ? 'wss://' : 'ws://');
|
||||
const prot = ("https:" === document.location.protocol ? "wss://" : "ws://");
|
||||
const url = prot + host + "/api/v1/ws";
|
||||
const clientInfo = {
|
||||
"token": token,
|
||||
|
@ -15,17 +15,17 @@ const clientInfo = {
|
|||
const Socket = new Sockette(url, {
|
||||
timeout: 5e3,
|
||||
onopen: e => {
|
||||
console.log('websocket: connected', e);
|
||||
console.log("websocket: connected", e);
|
||||
Socket.send(JSON.stringify(clientInfo));
|
||||
},
|
||||
onmessage: e => {
|
||||
const m = JSON.parse(e.data);
|
||||
Event.publish(m.event, m.data);
|
||||
},
|
||||
onreconnect: e => console.log('websocket: reconnecting', e),
|
||||
onmaximum: e => console.warn('websocket: hit max reconnect limit', e),
|
||||
onclose: e => console.log('websocket: closed', e),
|
||||
onerror: e => console.log('websocket: error', e)
|
||||
onreconnect: e => console.log("websocket: reconnecting", e),
|
||||
onmaximum: e => console.warn("websocket: hit max reconnect limit", e),
|
||||
onclose: e => console.log("websocket: closed", e),
|
||||
onerror: e => console.log("websocket: error", e),
|
||||
});
|
||||
|
||||
export default Socket;
|
||||
|
|
|
@ -5,7 +5,7 @@ class Settings {
|
|||
this.__originalValues = {};
|
||||
|
||||
if (!values) {
|
||||
throw "can't create settings with empty values"
|
||||
throw "can't create settings with empty values";
|
||||
}
|
||||
|
||||
this.setValues(values);
|
||||
|
|
Loading…
Reference in a new issue