mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-26 00:21:36 +01:00
Merge branch 'dev' into 'master'
Dev See merge request turris/reforis/foris-js!177
This commit is contained in:
commit
60f850a095
38
package-lock.json
generated
38
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "5.1.16",
|
"version": "5.2.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "5.1.16",
|
"version": "5.2.0",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
|
@ -11889,9 +11889,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/json-schema": {
|
"node_modules/json-schema": {
|
||||||
"version": "0.2.3",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
|
||||||
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=",
|
"integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/json-schema-traverse": {
|
"node_modules/json-schema-traverse": {
|
||||||
|
@ -11943,18 +11943,18 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/jsprim": {
|
"node_modules/jsprim": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
|
||||||
"integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
|
"integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": [
|
|
||||||
"node >=0.6.0"
|
|
||||||
],
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"assert-plus": "1.0.0",
|
"assert-plus": "1.0.0",
|
||||||
"extsprintf": "1.3.0",
|
"extsprintf": "1.3.0",
|
||||||
"json-schema": "0.2.3",
|
"json-schema": "0.4.0",
|
||||||
"verror": "1.10.0"
|
"verror": "1.10.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/jss": {
|
"node_modules/jss": {
|
||||||
|
@ -32733,9 +32733,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"json-schema": {
|
"json-schema": {
|
||||||
"version": "0.2.3",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
|
||||||
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=",
|
"integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"json-schema-traverse": {
|
"json-schema-traverse": {
|
||||||
|
@ -32778,14 +32778,14 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"jsprim": {
|
"jsprim": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
|
||||||
"integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
|
"integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"assert-plus": "1.0.0",
|
"assert-plus": "1.0.0",
|
||||||
"extsprintf": "1.3.0",
|
"extsprintf": "1.3.0",
|
||||||
"json-schema": "0.2.3",
|
"json-schema": "0.4.0",
|
||||||
"verror": "1.10.0"
|
"verror": "1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "foris",
|
"name": "foris",
|
||||||
"version": "5.1.16",
|
"version": "5.2.0",
|
||||||
"description": "Set of components and utils for Foris and its plugins.",
|
"description": "Set of components and utils for Foris and its plugins.",
|
||||||
"author": "CZ.NIC, z.s.p.o.",
|
"author": "CZ.NIC, z.s.p.o.",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
* Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||||
*
|
*
|
||||||
* This is free software, licensed under the GNU General Public License v3.
|
* This is free software, licensed under the GNU General Public License v3.
|
||||||
* See /LICENSE for more information.
|
* See /LICENSE for more information.
|
||||||
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
import { useCallback, useEffect, useReducer, useState } from "react";
|
import { useCallback, useEffect, useReducer, useState } from "react";
|
||||||
|
|
||||||
import { ForisURLs } from "../utils/forisUrls";
|
|
||||||
import {
|
import {
|
||||||
API_ACTIONS,
|
API_ACTIONS,
|
||||||
API_METHODS,
|
API_METHODS,
|
||||||
|
@ -84,8 +83,8 @@ function APIReducer(state, action) {
|
||||||
data: action.payload,
|
data: action.payload,
|
||||||
};
|
};
|
||||||
case API_ACTIONS.FAILURE:
|
case API_ACTIONS.FAILURE:
|
||||||
if (action.status === 403) {
|
if (action.status === 401) {
|
||||||
window.location.assign(ForisURLs.login);
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not an API error - should be rethrown.
|
// Not an API error - should be rethrown.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
* Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||||
*
|
*
|
||||||
* This is free software, licensed under the GNU General Public License v3.
|
* This is free software, licensed under the GNU General Public License v3.
|
||||||
* See /LICENSE for more information.
|
* See /LICENSE for more information.
|
||||||
|
@ -11,6 +11,7 @@ export const HEADERS = {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-CSRFToken": getCookie("_csrf_token"),
|
"X-CSRFToken": getCookie("_csrf_token"),
|
||||||
|
"X-Requested-With": "json",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TIMEOUT = 30500;
|
export const TIMEOUT = 30500;
|
||||||
|
@ -56,7 +57,7 @@ function getCookie(name) {
|
||||||
|
|
||||||
export function getErrorPayload(error) {
|
export function getErrorPayload(error) {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
if (error.response.status === 403) {
|
if (error.response.status === 401) {
|
||||||
return _("The session is expired. Please log in again.");
|
return _("The session is expired. Please log in again.");
|
||||||
}
|
}
|
||||||
return getJSONErrorMessage(error);
|
return getJSONErrorMessage(error);
|
||||||
|
|
|
@ -9,8 +9,8 @@ export const REFORIS_URL_PREFIX = "/reforis";
|
||||||
export const REFORIS_API_URL_PREFIX = `${REFORIS_URL_PREFIX}/api`;
|
export const REFORIS_API_URL_PREFIX = `${REFORIS_URL_PREFIX}/api`;
|
||||||
|
|
||||||
export const ForisURLs = {
|
export const ForisURLs = {
|
||||||
login: `${REFORIS_URL_PREFIX}/login`,
|
login: `/login?${REFORIS_URL_PREFIX}/`,
|
||||||
logout: `${REFORIS_URL_PREFIX}/logout`,
|
logout: `/logout`,
|
||||||
|
|
||||||
static: `${REFORIS_URL_PREFIX}/static/reforis`,
|
static: `${REFORIS_URL_PREFIX}/static/reforis`,
|
||||||
wifi: `${REFORIS_URL_PREFIX}/network-settings/wifi`,
|
wifi: `${REFORIS_URL_PREFIX}/network-settings/wifi`,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
* Copyright (C) 2020-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||||
*
|
*
|
||||||
* This is free software, licensed under the GNU General Public License v3.
|
* This is free software, licensed under the GNU General Public License v3.
|
||||||
* See /LICENSE for more information.
|
* See /LICENSE for more information.
|
||||||
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
/* eslint no-console: "off" */
|
/* eslint no-console: "off" */
|
||||||
|
|
||||||
import { ForisURLs } from "../utils/forisUrls";
|
|
||||||
|
|
||||||
const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss";
|
const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss";
|
||||||
|
|
||||||
const URL = process.env.LIGHTTPD
|
const URL = process.env.LIGHTTPD
|
||||||
|
@ -21,12 +19,6 @@ export class WebSockets {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.ws = new WebSocket(URL);
|
this.ws = new WebSocket(URL);
|
||||||
this.ws.onerror = (e) => {
|
this.ws.onerror = (e) => {
|
||||||
if (!window.initialData.logged) {
|
|
||||||
console.error(
|
|
||||||
"WS: Error observed, you aren't logged probably."
|
|
||||||
);
|
|
||||||
window.location.replace(ForisURLs.login);
|
|
||||||
}
|
|
||||||
console.error("WS: Error:", e);
|
console.error("WS: Error:", e);
|
||||||
};
|
};
|
||||||
this.ws.onmessage = (e) => {
|
this.ws.onmessage = (e) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user