added right actionbar icons and asset solution list
This commit is contained in:
23
server/api/getSelectedSolutionsByType/[id].ts
Normal file
23
server/api/getSelectedSolutionsByType/[id].ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { selectedSolutionsByType, errorMsg } from "../../middleware/solutions";
|
||||
import { OutgoingMessage } from 'http';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
|
||||
const headers: Record<string, Parameters<OutgoingMessage['setHeader']>[1]> = {
|
||||
'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de',
|
||||
'Access-Control-Allow-Headers': 'authorization, content-type',
|
||||
'Access-Control-Allow-Methods': 'OPTIONS,GET,HEAD,PUT,PATCH,POST,DELETE',
|
||||
'Access-Control-Allow-Credentials': 'true',
|
||||
};
|
||||
setResponseHeaders(event, headers)
|
||||
|
||||
if (!(errorMsg === '')) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: errorMsg,
|
||||
})
|
||||
}
|
||||
|
||||
setResponseStatus(event, 200)
|
||||
return selectedSolutionsByType
|
||||
})
|
||||
@ -8,6 +8,7 @@ let selectedSolutionsByCustomer = [];
|
||||
let selectedSolutionsBySolution = [];
|
||||
let selectedSolutionsByAsset = [];
|
||||
let solTodosBySolutionId = [];
|
||||
let selectedSolutionsByType = [];
|
||||
let insertId = -1;
|
||||
let errorMsg = '';
|
||||
|
||||
@ -117,6 +118,38 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.path.startsWith("/api/getSelectedSolutionsByType")) {
|
||||
// get selected solutions object by type from backend
|
||||
let filteredType = null;
|
||||
const path = event._path;
|
||||
const pathSegments = path.split('/');
|
||||
filteredType = pathSegments[pathSegments.length - 1];
|
||||
|
||||
try {
|
||||
let res = await axiosInstance.get(`https://${serversideConfig.url}:${serversideConfig.port}/selectedSolutionsByType/${filteredType}`);
|
||||
selectedSolutionsByType = res.data;
|
||||
} catch (err) {
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
|
||||
if (axiosError.response) {
|
||||
// Axios error
|
||||
console.error(axiosError.response.data.message);
|
||||
errorMsg = axiosError.response.data.message;
|
||||
} else if (axiosError.request) {
|
||||
// If error was caused by the request
|
||||
console.error(axiosError.request);
|
||||
} else {
|
||||
// Other errors
|
||||
console.error('Error', axiosError.message);
|
||||
}
|
||||
} else {
|
||||
// No AxiosError
|
||||
console.error('Error', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.path.startsWith("/api/getSelectedSolutionsBySolution")) {
|
||||
// get selected solutions object by asset from backend
|
||||
let filteredSolution = null;
|
||||
@ -424,4 +457,4 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
})
|
||||
|
||||
export { solutions, solution, selectedSolutionsByAsset, selectedSolutionsByCustomer, selectedSolutionsBySolution, solTodosBySolutionId, insertId, errorMsg };
|
||||
export { solutions, solution, selectedSolutionsByType, selectedSolutionsByAsset, selectedSolutionsByCustomer, selectedSolutionsBySolution, solTodosBySolutionId, insertId, errorMsg };
|
||||
Reference in New Issue
Block a user