diff --git a/interface/src/framework/system/UploadFileForm.tsx b/interface/src/framework/system/UploadFileForm.tsx
index c33019df3..3b72c12dd 100644
--- a/interface/src/framework/system/UploadFileForm.tsx
+++ b/interface/src/framework/system/UploadFileForm.tsx
@@ -28,7 +28,7 @@ const UploadFileForm: FC = () => {
const { send: getSchedule, onSuccess: onSuccessGetSchedule } = useRequest(EMSESP.getSchedule(), {
immediate: false
});
- const { send: getAPI, onSuccess: onGetAPI } = useRequest((data) => EMSESP.API(data), {
+ const { send: getSystemAPI, onSuccess: onSystemAPI } = useRequest((data) => EMSESP.APIcall('system', data), {
immediate: false
});
@@ -89,8 +89,8 @@ const UploadFileForm: FC = () => {
onSuccessGetSchedule((event) => {
saveFile(event.data, 'schedule.json');
});
- onGetAPI((event) => {
- saveFile(event.data, event.sendArgs[0].device + '_' + event.sendArgs[0].entity + '.txt');
+ onSystemAPI((event) => {
+ saveFile(event.data, event.sendArgs[0].entity + '.txt');
});
const downloadSettings = async () => {
@@ -121,8 +121,8 @@ const UploadFileForm: FC = () => {
});
};
- const callAPI = async (device: string, entity: string) => {
- await getAPI({ device, entity, id: 0 }).catch((error) => {
+ const callSystemAPI = async (entity: string) => {
+ await getSystemAPI({ entity, id: 0 }).catch((error) => {
toast.error(error.message);
});
};
@@ -134,7 +134,8 @@ const UploadFileForm: FC = () => {
- {LL.UPLOAD_TEXT()}
+ {LL.UPLOAD_TEXT()}.
+
{LL.RESTART_TEXT(1)}.
@@ -155,12 +156,7 @@ const UploadFileForm: FC = () => {
{LL.HELP_INFORMATION_4()}
- }
- variant="outlined"
- color="primary"
- onClick={() => callAPI('system', 'info')}
- >
+ } variant="outlined" color="primary" onClick={() => callSystemAPI('info')}>
{LL.SUPPORT_INFORMATION(0)}
diff --git a/interface/src/project/Help.tsx b/interface/src/project/Help.tsx
index 52cf0e14c..ffea7e633 100644
--- a/interface/src/project/Help.tsx
+++ b/interface/src/project/Help.tsx
@@ -15,7 +15,7 @@ const Help: FC = () => {
const { LL } = useI18nContext();
useLayoutTitle(LL.HELP_OF(''));
- const { send: getAPI, onSuccess: onGetAPI } = useRequest((data) => EMSESP.API(data), {
+ const { send: getSystemAPI, onSuccess: onGetAPI } = useRequest((data) => EMSESP.APIcall('system', data), {
immediate: false
});
@@ -26,14 +26,14 @@ const Help: FC = () => {
type: 'text/plain'
})
);
- anchor.download = 'emsesp_' + event.sendArgs[0].device + '_' + event.sendArgs[0].entity + '.txt';
+ anchor.download = 'emsesp_' + event.sendArgs[0].entity + '.txt';
anchor.click();
URL.revokeObjectURL(anchor.href);
toast.info(LL.DOWNLOAD_SUCCESSFUL());
});
- const callAPI = async (device: string, entity: string) => {
- await getAPI({ device, entity, id: 0 }).catch((error) => {
+ const callSystemAPI = async (entity: string) => {
+ await getSystemAPI({ entity, id: 0 }).catch((error) => {
toast.error(error.message);
});
};
@@ -89,7 +89,7 @@ const Help: FC = () => {
{LL.HELP_INFORMATION_4()}
- } variant="outlined" color="primary" onClick={() => callAPI('system', 'info')}>
+ } variant="outlined" color="primary" onClick={() => callSystemAPI('info')}>
{LL.SUPPORT_INFORMATION(0)}
diff --git a/interface/src/project/api.ts b/interface/src/project/api.ts
index f763ec4e1..ff70805ba 100644
--- a/interface/src/project/api.ts
+++ b/interface/src/project/api.ts
@@ -1,5 +1,5 @@
import type {
- APIcall,
+ APIdata,
Settings,
Status,
CoreData,
@@ -44,7 +44,7 @@ export const readStatus = () => alovaInstance.Get('/rest/status');
export const scanDevices = () => alovaInstance.Post('/rest/scanDevices');
// HelpInformation
-export const API = (apiCall: APIcall) => alovaInstance.Post('/api', apiCall);
+export const APIcall = (device: string, apiData: APIdata) => alovaInstance.Post(`/api/${device}`, apiData);
// UploadFileForm
export const getSettings = () => alovaInstance.Get('/rest/getSettings');
diff --git a/interface/src/project/types.ts b/interface/src/project/types.ts
index 9fe1bde37..fb044ac9f 100644
--- a/interface/src/project/types.ts
+++ b/interface/src/project/types.ts
@@ -266,8 +266,7 @@ export interface BoardProfile {
eth_clock_mode: number;
}
-export interface APIcall {
- device: string;
+export interface APIdata {
entity: string;
id: any;
}
diff --git a/mock-api/Handler.ts b/mock-api/Handler.ts
index fc519a0eb..6b67901d9 100644
--- a/mock-api/Handler.ts
+++ b/mock-api/Handler.ts
@@ -5,7 +5,7 @@ import busboy from 'busboy';
const encoder = new Encoder();
const router = Router();
-// const upload = multer({ dest: '../mock-api/uploads' }); // TODO remove
+// const upload = multer({ dest: '../mock-api/uploads' }); // TODO remove multer
const REST_ENDPOINT_ROOT = '/rest/';
const API_ENDPOINT_ROOT = '/api/';
@@ -2351,11 +2351,11 @@ router
.get(VERIFY_AUTHORIZATION_ENDPOINT, () => new Response(JSON.stringify(verify_authentication), { headers }))
.post(RESTART_ENDPOINT, () => new Response('OK', { status: 200 }))
.post(FACTORY_RESET_ENDPOINT, () => new Response('OK', { status: 200 }))
- .post(UPLOAD_FILE_ENDPOINT, () => new Response('OK', { status: 404 })) // TODO remove
+ .post(UPLOAD_FILE_ENDPOINT, () => new Response('OK', { status: 404 })) // TODO remove upload filepoint
.post(SIGN_IN_ENDPOINT, () => new Response(JSON.stringify(signin), { headers }))
.get(GENERATE_TOKEN_ENDPOINT, () => new Response(JSON.stringify(generate_token), { headers }));
-// uploads // TODO fix later
+// uploads // TODO fix uploads later
// const progress_middleware = async (req: any) => {
// console.log('progress_middleware');
@@ -2775,6 +2775,7 @@ router
});
// API and calls
+const SYSTEM_API_ENDPOINT = API_ENDPOINT_ROOT + 'system';
const SYSTEM_INFO_ENDPOINT = API_ENDPOINT_ROOT + 'system/info';
const GET_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'getSettings';
const GET_CUSTOMIZATIONS_ENDPOINT = REST_ENDPOINT_ROOT + 'getCustomizations';
@@ -2792,32 +2793,18 @@ router
.get(GET_SCHEDULE_ENDPOINT, () => new Response(JSON.stringify(emsesp_schedule), { headers }))
.get(SCHEDULE_ENDPOINT, () => new Response(JSON.stringify(emsesp_schedule), { headers }))
.get(ENTITIES_ENDPOINT, () => new Response(JSON.stringify(emsesp_customentities), { headers }))
- .post(API_ENDPOINT_ROOT, async (request: any) => {
+ .post(SYSTEM_API_ENDPOINT, async (request: any) => {
const data = await request.json();
- if (data.device === 'system') {
- if (data.entity === 'info') {
- return new Response(JSON.stringify(emsesp_info), { headers });
- }
- if (data.entity === 'allvalues') {
- return new Response(JSON.stringify(emsesp_allvalues), { headers });
- }
+ if (data.entity === 'info') {
+ return new Response(JSON.stringify(emsesp_info), { headers });
}
+ if (data.entity === 'allvalues') {
+ return new Response(JSON.stringify(emsesp_allvalues), { headers });
+ }
+
return new Response('Not Found', { status: 404 });
});
-// Event Source // TODO fix later
-
-// const data = {
-// t: '000+00:00:00.000',
-// l: 3, // error
-// i: 1,
-// n: 'system',
-// m: 'incoming message #1'
-// };
-// const sseFormattedResponse = `data: ${JSON.stringify(data)}\n\n`;
-// router.get('/es/log', () => new Response(sseFormattedResponse, { headers: ESheaders }));
-
-var count = 8;
var log_index = 0;
const ES_LOG_ENDPOINT = ES_ENDPOINT_ROOT + 'log';
diff --git a/scripts/api_test.http b/scripts/api_test.http
index b79a172be..bad14ea1b 100755
--- a/scripts/api_test.http
+++ b/scripts/api_test.http
@@ -58,11 +58,12 @@ GET {{host}}/api/temperaturesensor/info
# Test on dev
#
-
GET {{host_dev}}/api/system/info
###
GET {{host_dev}}/api?device=system&cmd=test&data=general
###
+GET {{host_dev}}/api?device=system&cmd=info
+###
GET {{host_dev}}/api/boiler/info
###
GET {{host_dev}}/api/boiler/values
@@ -74,16 +75,14 @@ Authorization: Bearer {{token}}
###
GET {{host_dev}}/api/system/commands
###
-POST {{host_dev}}/api
+POST {{host_dev}}/api/system
Content-Type: application/json
Authorization: Bearer {{token}}
{
- "device" : "system",
"entity" : "info",
"id" : 0
}
-
###
GET {{host_dev}}/rest/features
###