Skip to content
Snippets Groups Projects
Commit c693fd82 authored by Sandro Weber's avatar Sandro Weber
Browse files

[NRRPLT-8620] trigger proxy storage scan button

parent 3e9c6ab3
No related branches found
No related tags found
No related merge requests found
......@@ -11634,9 +11634,9 @@
}
},
"nrp-jsproto": {
"version": "1.1.1-alpha.10",
"resolved": "https://registry.npmjs.org/nrp-jsproto/-/nrp-jsproto-1.1.1-alpha.10.tgz",
"integrity": "sha512-KFe2AQuhtx4wD76PIzxlhKFXtWYeUtyqSkONA8nYvIV9HfG67q09Qcnzhl745jZHZHZMC03xj9QVEr0x5so8Cg=="
"version": "1.1.1-alpha.20",
"resolved": "https://registry.npmjs.org/nrp-jsproto/-/nrp-jsproto-1.1.1-alpha.20.tgz",
"integrity": "sha512-n39H3PBdhA+ojWIRe43ZcSJEZeogGZ91o5beHKrLdbbjNGcduOAzUS75AYE2hQ0YbOWtGwNVDQL9LGHK0LZugQ=="
},
"nth-check": {
"version": "1.0.2",
......
......@@ -20,7 +20,7 @@
"jquery": "3.6.0",
"jszip": "3.2.0",
"mqtt": "4.3.5",
"nrp-jsproto": "1.1.1-alpha.10",
"nrp-jsproto": "1.1.1-alpha.20",
"protobufjs": "6.11.2",
"react": "^17.0.1",
"react-bootstrap": "1.4.0",
......
import { DomainDisabledOutlined } from '@material-ui/icons';
import React from 'react';
import MqttClientService from '../../services/mqtt-client-service';
import ExperimentStorageService from '../../services/experiments/files/experiment-storage-service';
export default class NrpCoreDashboard extends React.Component {
constructor(props) {
......@@ -22,10 +24,18 @@ export default class NrpCoreDashboard extends React.Component {
});
}
async triggerProxyScanStorage() {
let result = await ExperimentStorageService.instance.scanStorage();
console.info('triggerProxyScanStorage:');
console.info(result);
}
render() {
return (
<div>
{this.mqttBrokerUrl}
<br />
<button onClick={this.triggerProxyScanStorage}>Proxy Scan Storage</button>
</div>
);
}
......
......@@ -5,8 +5,11 @@ import endpoints from '../../proxy/data/endpoints.json';
import config from '../../../config.json';
import DialogService from '../../dialog-service.js';
const storageURL = `${config.api.proxy.url}${endpoints.proxy.storage.url}`;
const storageExperimentsURL = `${config.api.proxy.url}${endpoints.proxy.storage.experiments.url}`;
const PROXY_URL = config.api.proxy.url;
const SCAN_STORAGE_URL = `${PROXY_URL}${endpoints.proxy.storage.scanStorage.url}`;
const storageURL = `${PROXY_URL}${endpoints.proxy.storage.url}`;
const storageExperimentsURL = `${PROXY_URL}${endpoints.proxy.storage.experiments.url}`;
let _instance = null;
const SINGLETON_ENFORCER = Symbol();
......@@ -71,6 +74,7 @@ class ExperimentStorageService extends HttpService {
if (!this.experiments || forceUpdate) {
try {
let experimentList = await (await this.httpRequestGET(storageExperimentsURL)).json();
console.info(['ExperimentStorageService.getExperiments()', experimentList]);
// filter out experiments with incomplete configuration (probably storage corruption)
experimentList = experimentList.filter(experiment => experiment.configuration.experimentFile);
this.sortExperiments(experimentList);
......@@ -275,6 +279,14 @@ class ExperimentStorageService extends HttpService {
'please make sure that the contentType and the body type match.');
}
}
/**
* Trigger proxy to scan storage.
* @returns {promise} Result
*/
async scanStorage() {
return await (await this.httpRequestPOST(SCAN_STORAGE_URL)).json();
}
}
ExperimentStorageService.EVENTS = Object.freeze({
......
import mqtt from 'mqtt';
import { EventEmitter } from 'events';
import * as proto from 'nrp-jsproto/nrp-engine_msgs-protobufjs';
//import * as proto from 'nrp-jsproto/engine_grpc_pb';
let _instance = null;
const SINGLETON_ENFORCER = Symbol();
......@@ -16,7 +16,7 @@ export default class MqttClientService extends EventEmitter {
throw new Error('Use ' + this.constructor.name + '.instance');
}
console.info(proto);
//console.info(proto);
}
static get instance() {
......@@ -47,20 +47,9 @@ export default class MqttClientService extends EventEmitter {
console.info('MQTT message: [topic, payload, packet]');
console.info([topic, payload, packet]);
try {
if (topic.endsWith('/type')) {
let msg = String(payload);
console.info('"' + topic + '" message format = ' + msg);
}
else {
let msg = proto.Engine.DataPackMessage.decode(payload);
console.info('DataPackMessage');
console.info(msg);
}
}
catch (error) {
console.error(error);
}
// step 0: deserialize the payload => messageData
// step 1: pick subs based on topic => subs
// step 2: foreach(sub) {sub.callback(messageData, topic);}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment