1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-07-31 19:53:28 +02:00

Set modules.

This commit is contained in:
Bogdan Bodnar
2019-08-27 11:54:57 +02:00
parent 7b38c1658c
commit 19df5c2630
53 changed files with 275 additions and 224 deletions

View File

@@ -5,9 +5,7 @@
* See /LICENSE for more information.
*/
/* eslint no-console: "off" */
import { ForisURLs } from "./constants";
import { ForisUrls } from "forisUrls";
const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss";
@@ -17,13 +15,13 @@ const URL = process.env.LIGHTTPD
const WAITING_FOR_CONNECTION_TIMEOUT = 500;
export default class WebSockets {
export class WebSockets {
constructor() {
this.ws = new WebSocket(URL);
this.ws.onerror = (e) => {
if (window.location.pathname !== ForisURLs.login) {
if (window.location.pathname !== ForisUrls.login) {
console.error("WS: Error observed, you aren't logged probably.");
window.location.replace(ForisURLs.login);
window.location.replace(ForisUrls.login);
}
console.log(`WS: Error: ${e}`);
};

View File

@@ -7,7 +7,7 @@
import { useEffect, useState } from "react";
export default function useWSForisModule(ws, module, action = "update_settings") {
export function useWSForisModule(ws, module, action = "update_settings") {
const [data, setData] = useState(null);
useEffect(() => {