diff --git a/.env.development b/.env.development
index 7579c6cc3..2d1b3e8a4 100644
--- a/.env.development
+++ b/.env.development
@@ -1,2 +1,2 @@
-REACT_APP_TEST = "http://localhost:3000/memorec/"
+REACT_APP_MEMOREC = "http://localhost:8080"
diff --git a/.env.production b/.env.production
index c31262e65..ae18078f0 100644
--- a/.env.production
+++ b/.env.production
@@ -1 +1 @@
-REACT_APP_TEST = "http://localhost:3000/memorec/"
+REACT_APP_MEMOREC = "http://localhost:8080"
diff --git a/src/components/toolbar/ContextMenu.tsx b/src/components/toolbar/ContextMenu.tsx
index ddd7ee1bd..18bc9be17 100644
--- a/src/components/toolbar/ContextMenu.tsx
+++ b/src/components/toolbar/ContextMenu.tsx
@@ -121,7 +121,7 @@ function ContextMenuComponent(props: AllProps) {
{(memorec && memorec.data?.map((obj, index) => {
return (
setSuggestedName(obj.recommendedItem)}>
- {obj.recommendedItem} : {obj.score}
+ {obj.recommendedItem} : {Math.round(obj.score * 100) / 100}
)
})) }
diff --git a/src/memorec/api.ts b/src/memorec/api.ts
index 10c193e61..f41cc3cdd 100644
--- a/src/memorec/api.ts
+++ b/src/memorec/api.ts
@@ -1,18 +1,13 @@
-import axios, {AxiosRequestConfig, AxiosResponse} from 'axios';
-import {GObject, LModelElement, LNamedElement, U} from "../joiner";
+import axios, {AxiosResponse} from 'axios';
+import {GObject, LModelElement, LNamedElement} from "../joiner";
import {MemoRecModel, MemoRecNamed, MemoRecObject} from "./types";
-/*
-
-per cors policy il client deve mandare richieste allo stesso server.
-quindi le deve mandare a node.js e node.js server deve rimandarle a spring con un proxy server
-
-*/
export default class MemoRec {
static async post(path: string, obj: MemoRecObject): Promise {
console.clear();
- return await axios.post('/' + path, obj);
+ console.log(obj);
+ return await axios.post('/memorec/' + path, obj);
}
static async structuralFeature(me: LModelElement): Promise<{data:GObject[], type:'class'|'package'}> {
@@ -21,7 +16,6 @@ export default class MemoRec {
const model = me.model;
const classes = model.classes;
-
const memorecClasses: MemoRecNamed[] = [];
for(let myClass of classes) {
@@ -38,10 +32,9 @@ export default class MemoRec {
const response = await MemoRec.post('structuralFeatures', memorecObject);
console.log(response);
- const data:GObject[] = response.data.slice(0, 10);
+ const data: GObject[] = response.data.slice(0, 10);
data.sort((a,b) => b.score - a.score);
- // SetRootFieldAction.new('memorec', {data: response.data, type: 'class'});
return {data: data, type: 'class'};
}
@@ -68,7 +61,6 @@ export default class MemoRec {
const data:GObject[] = response.data.slice(0, 10);
data.sort((a,b) => b.score - a.score);
- //SetRootFieldAction.new('memorec', {data: response.data, type: 'package'}); //setta l'oggetto memorec
return {data: data, type: 'package'};
}
}
diff --git a/src/setupProxy.js b/src/setupProxy.js
index ed6e44259..569bbdff2 100644
--- a/src/setupProxy.js
+++ b/src/setupProxy.js
@@ -1,18 +1,11 @@
-const { createProxyMiddleware } = require('http-proxy-middleware');
+const {createProxyMiddleware} = require('http-proxy-middleware');
module.exports = function (app) {
app.use(
- '/classes',
+ '/memorec/*',
createProxyMiddleware({
- target: 'http://localhost:8080',
- changeOrigin: true,
- })
- );
- app.use(
- '/structuralFeatures',
- createProxyMiddleware({
- target: 'http://localhost:8080',
- changeOrigin: true,
+ target: process.env['REACT_APP_MEMOREC'],
+ changeOrigin: true
})
);
};