stand2026_10_06
This commit is contained in:
1 parent
41f80ce947
commit
266f8c3b4f
199 files changed
+17061
-87
No files matched your search
@@ -0,0 +1,53 @@
|
||||
'use server'
|
||||
|
||||
import { Sites } from "@/_config/sites";
|
||||
import { Anlage } from "@/types/rk";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function api_anlagen_getAll(): Promise<Anlage[]> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/anlage`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function api_anlage_getSelected(): Promise<Anlage> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/anlage/selected`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function api_anlage_setSelected(id: string): Promise<Anlage> {
|
||||
console.log(`http://localhost:3000/anlage/selected/${id}`);
|
||||
|
||||
const result = await fetch(`http://localhost:3000/anlage/selected/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
|
||||
console.log(result.status, result.statusText);
|
||||
|
||||
if (!result.ok) {
|
||||
const error = await result.text();
|
||||
throw new Error(`API Fehler ${result.status}: ${error}`);
|
||||
}
|
||||
|
||||
revalidatePath(Sites.anlagen.url);
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { DrawShapeData, DrawShapeOptionen } from "@/types/draw/draw.types";
|
||||
import { Anlage } from "@/types/rk";
|
||||
|
||||
export async function drawGetSvg(name: string, optionen?: DrawShapeOptionen): Promise<DrawShapeData> {
|
||||
|
||||
let optionenStr = '';
|
||||
if (optionen) {
|
||||
optionenStr = '?'
|
||||
|
||||
let separator = ''
|
||||
for (const [key, value] of Object.entries(optionen)) {
|
||||
|
||||
optionenStr += separator + key + "=" + value;
|
||||
separator = '&'
|
||||
}
|
||||
console.log(optionenStr)
|
||||
|
||||
}
|
||||
|
||||
const result = await fetch(`http://localhost:3000/draw/gurtfoerderer${optionenStr}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json() as DrawShapeData;
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
"use server"
|
||||
|
||||
import { Sites } from "@/_config/sites";
|
||||
import { Element, ElementCreate, ElementFilterOptionen, ElementUpdate } from "@/types/rk";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function api_ElementsGet(filter?: ElementFilterOptionen): Promise<Element[]> {
|
||||
|
||||
let filterStr = '';
|
||||
|
||||
if (filter) {
|
||||
filterStr = '?'
|
||||
|
||||
let separator = ''
|
||||
for (const [key, value] of Object.entries(filter)) {
|
||||
|
||||
filterStr += separator + key + "=" + value;
|
||||
separator = '&'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const result = await fetch(`http://localhost:3000/element${filterStr}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function elementCreate(data: ElementCreate): Promise<ActionResult<Element>> {
|
||||
|
||||
const result = await fetch('http://localhost:3000/element', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.elements.url+"/")
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
export async function elementUpdate(id: string, data: ElementUpdate): Promise<ActionResult<Element>> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/element/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.elements.url);
|
||||
return { success: true };
|
||||
|
||||
}
|
||||
|
||||
|
||||
export async function api_elementDelete(id: string): Promise<ActionResult<Element>> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/element/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.elements.url);
|
||||
return { success: true };
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
'use server';
|
||||
|
||||
export async function uploadFile(formData: FormData) {
|
||||
const file = formData.get('file') as File;
|
||||
|
||||
if (!file) {
|
||||
throw new Error('Keine Datei');
|
||||
}
|
||||
|
||||
// Neues FormData für NestJS
|
||||
const backendForm = new FormData();
|
||||
backendForm.append('file', file);
|
||||
|
||||
const res = await fetch('http://localhost:3000/draw/upload', {
|
||||
method: 'POST',
|
||||
body: backendForm,
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error('Upload fehlgeschlagen');
|
||||
}
|
||||
|
||||
return await res.json();
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
"use server"
|
||||
|
||||
import { Sites } from "@/_config/sites";
|
||||
import { Group, GroupCreate, GroupFilterOptionen, GroupUpdate } from "@/types/rk";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function api_GroupAll(filter?: GroupFilterOptionen): Promise<Group[]> {
|
||||
|
||||
let filterStr = '';
|
||||
|
||||
if (filter) {
|
||||
filterStr = '?'
|
||||
|
||||
let separator = ''
|
||||
for (const [key, value] of Object.entries(filter)) {
|
||||
|
||||
filterStr += separator + key + "=" + value;
|
||||
separator = '&'
|
||||
}
|
||||
console.log(filterStr)
|
||||
console.log(`http://localhost:3000/group${filter}`);
|
||||
}
|
||||
|
||||
|
||||
const result = await fetch(`http://localhost:3000/group${filterStr}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function groupCreate(data: GroupCreate): Promise<ActionResult<Group>> {
|
||||
|
||||
const result = await fetch('http://localhost:3000/group', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.groups.url)
|
||||
return { success: true,data:resultData };
|
||||
}
|
||||
|
||||
export async function groupUpdate(id: string, data: GroupUpdate): Promise<ActionResult<Group>> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/group/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.groups.url);
|
||||
return { success: true,data:resultData };
|
||||
|
||||
}
|
||||
|
||||
export async function api_groupDelete(id: string): Promise<ActionResult<Group>> {
|
||||
console.log('delete Group')
|
||||
const result = await fetch(`http://localhost:3000/group/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.groups.url);
|
||||
return { success: true,data:resultData };
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
"use server"
|
||||
|
||||
import { Sites } from "@/_config/sites";
|
||||
import { LogNote, LogNoteCreate, LogNoteFilterOptionen, LogNoteUpdate } from "@/types/rk";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
const path ="log-note"
|
||||
export async function api_LogNoteGet(filter?: LogNoteFilterOptionen): Promise<LogNote[]> {
|
||||
|
||||
let filterStr = '';
|
||||
|
||||
if (filter) {
|
||||
filterStr = '?'
|
||||
|
||||
let separator = ''
|
||||
for (const [key, value] of Object.entries(filter)) {
|
||||
|
||||
filterStr += separator + key + "=" + value;
|
||||
separator = '&'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const result = await fetch(`http://localhost:3000/${path}${filterStr}`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function api_logNoteCreate(data: LogNoteCreate): Promise<ActionResult<LogNote>> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/${path}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
// revalidatePath(Sites.elements.url)
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
export async function api_logNoteUpdate(id: string, data: LogNoteUpdate): Promise<ActionResult<LogNote>> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/${path}/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.logNote.url);
|
||||
return { success: true };
|
||||
|
||||
}
|
||||
|
||||
|
||||
export async function api_logNoteDelete(id: string): Promise<ActionResult<LogNote>> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/${path}/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.logNote.url);
|
||||
return { success: true };
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
"use server";
|
||||
|
||||
import { Sites } from "@/_config/sites";
|
||||
import { Group, Peripherie, PeripherieFilterOptionen, PeripherieUpdate } from "@/types/rk";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
|
||||
|
||||
export async function PeripherieFindApi(filter?: PeripherieFilterOptionen): Promise<Peripherie[]> {
|
||||
let filterStr = '';
|
||||
if (filter && (filter.adrByte || filter.elementId || filter.groupId)) {
|
||||
filterStr = '?'
|
||||
if (filter.adrByte) filterStr += 'adrByte=' + filter.adrByte;
|
||||
if (filter.groupId) filterStr += 'groupId=' + filter.groupId;
|
||||
if (filter.elementId) filterStr += 'elementId=' + filter.elementId;
|
||||
}
|
||||
console.log(`http://localhost:3000/peripherie` + filterStr)
|
||||
const result = await fetch(`http://localhost:3000/peripherie` + filterStr, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function GetEA_Differences(): Promise<Peripherie[]> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/peripherie/differences`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function api_peripherieUpdate(id: string, data: PeripherieUpdate): Promise<ActionResult<Peripherie>> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/peripherie/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.peripheries.url);
|
||||
return { success: true };
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
'use server'
|
||||
|
||||
import { Sites } from "@/_config/sites";
|
||||
import { VisuElement, VisuElementCreate, VisuElementUpdate } from "@/types/visu/visuElements.types";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function api_VisuElementsAll(): Promise<VisuElement[]> {
|
||||
|
||||
|
||||
|
||||
const result = await fetch(`http://localhost:3000/visu-elements`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json() as VisuElement[];
|
||||
|
||||
return data;
|
||||
}
|
||||
export async function api_VisuElementCreate(data: VisuElementCreate): Promise<ActionResult<VisuElement>> {
|
||||
|
||||
|
||||
const result = await fetch(`http://localhost:3000/visu-elements/`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.visu.url);
|
||||
return { success: true };
|
||||
|
||||
}
|
||||
|
||||
export async function api_VisuElementUpdate(id: string, data: VisuElementUpdate): Promise<ActionResult<VisuElement>> {
|
||||
|
||||
|
||||
const result = await fetch(`http://localhost:3000/visu-elements/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.visu.url);
|
||||
return { success: true };
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user