- Added SSL configuration to the backend, including self-signed certificate generation and management. - Updated `setup_myp.sh` to create SSL certificates during installation. - Enhanced `app.py` to support SSL context for secure communication. - Introduced a new SSL management menu in the setup script for easier certificate handling. - Updated frontend API calls to use HTTPS for secure data transmission. - Implemented kiosk mode features, including automatic browser launch with SSL support. - Improved documentation in `SUMMARY.md` to reflect new features and network topology changes.
75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
import { ExternalAPI } from './external-api';
|
|
|
|
// Typdefinitionen für API-Responses
|
|
export interface Printer {
|
|
id: string;
|
|
name: string;
|
|
ip: string;
|
|
status: string;
|
|
is_enabled: boolean;
|
|
}
|
|
|
|
export interface Job {
|
|
id: string;
|
|
printer_id: string;
|
|
user_id: string;
|
|
start_time: string;
|
|
end_time: string;
|
|
status: string;
|
|
}
|
|
|
|
// Instanz der ExternalAPI erstellen
|
|
const externalAPI = new ExternalAPI();
|
|
|
|
// Fetcher für SWR mit Fehlerbehandlung und HTTPS-Unterstützung
|
|
const fetchWithErrorHandling = async (endpoint: string) => {
|
|
try {
|
|
return await externalAPI.fetch(endpoint);
|
|
} catch (error) {
|
|
console.error('API-Fehler:', error);
|
|
throw new Error('Ein Fehler ist bei der API-Anfrage aufgetreten');
|
|
}
|
|
};
|
|
|
|
// API-Funktionen, die mit der bisherigen API-Struktur kompatibel sind
|
|
export const api = {
|
|
// Drucker-Endpunkte
|
|
printers: {
|
|
getAll: () => fetchWithErrorHandling('/api/printers'),
|
|
getById: (id: string) => fetchWithErrorHandling(`/api/printers/${id}`),
|
|
create: (data: Partial<Printer>) =>
|
|
externalAPI.fetch('/api/printers', {
|
|
method: 'POST',
|
|
body: JSON.stringify(data),
|
|
}),
|
|
update: (id: string, data: Partial<Printer>) =>
|
|
externalAPI.fetch(`/api/printers/${id}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data),
|
|
}),
|
|
delete: (id: string) =>
|
|
externalAPI.fetch(`/api/printers/${id}`, {
|
|
method: 'DELETE',
|
|
}),
|
|
},
|
|
|
|
// Jobs-Endpunkte
|
|
jobs: {
|
|
getAll: () => fetchWithErrorHandling('/api/jobs'),
|
|
getById: (id: string) => fetchWithErrorHandling(`/api/jobs/${id}`),
|
|
create: (data: Partial<Job>) =>
|
|
externalAPI.fetch('/api/jobs', {
|
|
method: 'POST',
|
|
body: JSON.stringify(data),
|
|
}),
|
|
update: (id: string, data: Partial<Job>) =>
|
|
externalAPI.fetch(`/api/jobs/${id}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data),
|
|
}),
|
|
delete: (id: string) =>
|
|
externalAPI.fetch(`/api/jobs/${id}`, {
|
|
method: 'DELETE',
|
|
}),
|
|
},
|
|
};
|