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

Restore previous functionality #152

Merged
merged 3 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 1.1.2

- [FP-2297: Redirect to login after losing token](https://movai.atlassian.net/browse/FP-2297)
- [FP-2049: Use Roles v2 endpoint](https://movai.atlassian.net/browse/FP-2049)
- [FP-2202: Robot power off but online in the fleetboard alerts window](https://movai.atlassian.net/browse/FP-2202)
- [FP-2233: De-activating alerts is not removing alerts in real-time](https://movai.atlassian.net/browse/FP-2233)
- [FP-2233: De-activating alerts is not removing alerts in real-time](https://movai.atlassian.net/browse/FP-2233)
- [FP-2537: Offline robot status is not working in fleet manager - or just slow?](https://movai.atlassian.net/browse/FP-2537)
10,823 changes: 2,007 additions & 8,816 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mov-ai/mov-fe-lib-core",
"version": "1.1.2-8",
"version": "1.1.2-25",
"description": "The Mov.AI's core frontend library.",
"publishConfig": {
"registry": "https://npm.pkg.github.com/mov-ai"
Expand Down Expand Up @@ -55,7 +55,7 @@
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.3",
"@types/roslib": "^1.1.8",
"deep-equal": "^2.2.0",
"fast-equals": "^5.0.1",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"monet": "^0.9.2",
Expand Down
10 changes: 8 additions & 2 deletions src/api/Database/WSSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class WSSub {
this.RESEND_TIMEOUT = 1000;
this.RETRIES = 3;
this.NORMAL_CLOSE_EVT = 1000;

// supported commands
this.commands = {
SUBSCRIBE: "subscribe",
Expand Down Expand Up @@ -321,6 +321,10 @@ class WSSub {
return connectionPromise;
};

handleFalseConnection = (statusText) => {
if(statusText === "Token must be a string!") return Authentication.logout();
}

/**
* Check connection state by doing requests
* @returns Heartbeat fetch promise
Expand All @@ -330,12 +334,14 @@ class WSSub {
method: "POST",
body: JSON.stringify({ token: getToken() })
})
.then(_res => {
.then(res => {
if (!res.ok && res.status !== 200) return this.handleFalseConnection(res.statusText);
if (this.connectionState === CONNECTION.online) return;
this.connectionState = CONNECTION.online;
this.onOnline();
})
.catch(_err => {
console.warn(_err);
if (this.connectionState === CONNECTION.offline) return;
this.connectionState = CONNECTION.offline;
this.onOffline();
Expand Down
17 changes: 8 additions & 9 deletions src/api/RobotManager/Robot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from "../Utils/constants";
import DocumentV2 from "../Document/DocumentV2";
import MasterDB from "../Database/MasterDB";
import { Utils } from "../index";
import * as Utils from "./../Utils/Utils";
import Rest from "../Rest/Rest";
import Document from "../Document/Document";

Expand Down Expand Up @@ -79,7 +79,6 @@ class Robot {

/**
* Subscribe to a robot property from redis
* @param {SubscriberModel} params
*/
private subscribe(params: SubscriberModel) {
const {
Expand All @@ -101,8 +100,6 @@ class Robot {

/**
* Unsubscribe to a robot property from redis
*
* @param {UnsubscriberModel} params: Property name and value to unsubscribe
*/
unsubscribe(params: UnsubscriberModel) {
const { property, propValue = "*" } = params;
Expand Down Expand Up @@ -134,6 +131,8 @@ class Robot {
);
}
return robotData;
}).catch((e: Error) => {
console.error("Robot.getData", e);
});
}

Expand All @@ -143,7 +142,7 @@ class Robot {
* @param value : Robot data key value
*/
setData(key: keyof RobotModel, value: any) {
this.data[key] = value;
(this.data as { [key: string]: any })[key] = value;
}

/**
Expand Down Expand Up @@ -191,7 +190,7 @@ class Robot {
*/
stopLogger() {
this.logger.status = LOGGER_STATUS.paused;
clearTimeout(this.logger.timeout);
clearTimeout(this.logger.timeout as NodeJS.Timeout);
}

/**
Expand Down Expand Up @@ -289,7 +288,7 @@ class Robot {
* Refresh logs
*/
refreshLogs() {
clearTimeout(this.logger.timeout);
clearTimeout(this.logger.timeout as NodeJS.Timeout);
this._getLogs();
}

Expand Down Expand Up @@ -355,14 +354,14 @@ class Robot {
* Enqueue next request to get logs
*/
private _enqueueNextRequest() {
clearTimeout(this.logger.timeout);
clearTimeout(this.logger.timeout as NodeJS.Timeout);
this.logger.timeout = setTimeout(() => this._getLogs(), this.logger.time);
}

/**
* Function to be called when robot IP subscribed loads
*
* @param {Object} data: Data returned on IP subscribe event
* @param {Robot} data: Data returned on IP subscribe event
*/
private _loadIP(robot: Robot) {
return (data: LoadRobotParam) => {
Expand Down
2 changes: 1 addition & 1 deletion src/api/Utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _isEmpty from "lodash/isEmpty";
import _isArray from "lodash/isArray";
import _isObject from "lodash/isObject";
import _transform from "lodash/transform";
import equal from "deep-equal";
import { deepEqual as equal } from "fast-equals";
import Role from "../Role/Role";


Expand Down
4 changes: 2 additions & 2 deletions src/api/Utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ export const WS_EVENT_TYPES = {
export const DEL_WS_EVENTS = [WS_EVENT_TYPES.DEL, WS_EVENT_TYPES.HDEL];
export const SET_WS_EVENTS = [WS_EVENT_TYPES.SET, WS_EVENT_TYPES.HSET];

export const TIME_TO_OFFLINE = 10000;
export const HEARTBEAT_TIMEOUT = 3000;
export const TIME_TO_OFFLINE = 5000;
export const HEARTBEAT_TIMEOUT = 2000;