feat: streamline dashboard actions by removing inline add-entry form and manual refresh
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -21,3 +21,5 @@
|
|||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
|
.commitmessage
|
||||||
|
|||||||
163
src/App.js
163
src/App.js
@@ -2,14 +2,6 @@ import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
|||||||
import { BrowserRouter as Router, Routes, Route, Navigate, Link, useLocation } from 'react-router-dom';
|
import { BrowserRouter as Router, Routes, Route, Navigate, Link, useLocation } from 'react-router-dom';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
|
|
||||||
const emptyEntry = {
|
|
||||||
id: '',
|
|
||||||
label: '',
|
|
||||||
active: false,
|
|
||||||
checkProfileId: true,
|
|
||||||
onlyNotify: false
|
|
||||||
};
|
|
||||||
|
|
||||||
const TOKEN_STORAGE_KEY = 'pickupConfigToken';
|
const TOKEN_STORAGE_KEY = 'pickupConfigToken';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
@@ -20,8 +12,6 @@ function App() {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [status, setStatus] = useState('');
|
const [status, setStatus] = useState('');
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
const [newEntry, setNewEntry] = useState(emptyEntry);
|
|
||||||
const [showNewEntryForm, setShowNewEntryForm] = useState(false);
|
|
||||||
const [availableCollapsed, setAvailableCollapsed] = useState(true);
|
const [availableCollapsed, setAvailableCollapsed] = useState(true);
|
||||||
const [adminSettings, setAdminSettings] = useState(null);
|
const [adminSettings, setAdminSettings] = useState(null);
|
||||||
const [adminSettingsLoading, setAdminSettingsLoading] = useState(false);
|
const [adminSettingsLoading, setAdminSettingsLoading] = useState(false);
|
||||||
@@ -115,8 +105,6 @@ function App() {
|
|||||||
setStores([]);
|
setStores([]);
|
||||||
setStatus('');
|
setStatus('');
|
||||||
setError('');
|
setError('');
|
||||||
setShowNewEntryForm(false);
|
|
||||||
setNewEntry(emptyEntry);
|
|
||||||
setAdminSettings(null);
|
setAdminSettings(null);
|
||||||
setAdminSettingsLoading(false);
|
setAdminSettingsLoading(false);
|
||||||
setAvailableCollapsed(true);
|
setAvailableCollapsed(true);
|
||||||
@@ -588,26 +576,6 @@ function App() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addEntry = () => {
|
|
||||||
if (!newEntry.id || !newEntry.label) {
|
|
||||||
setError('ID und Bezeichnung müssen ausgefüllt werden!');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized = {
|
|
||||||
...newEntry,
|
|
||||||
id: String(newEntry.id),
|
|
||||||
hidden: false
|
|
||||||
};
|
|
||||||
|
|
||||||
const updatedConfig = [...config.filter((item) => item.id !== normalized.id), normalized];
|
|
||||||
setConfig(updatedConfig);
|
|
||||||
setNewEntry(emptyEntry);
|
|
||||||
setShowNewEntryForm(false);
|
|
||||||
setStatus('Neuer Eintrag hinzugefügt!');
|
|
||||||
setTimeout(() => setStatus(''), 3000);
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteEntry = (entryId) => {
|
const deleteEntry = (entryId) => {
|
||||||
if (window.confirm('Soll dieser Eintrag dauerhaft gelöscht werden?')) {
|
if (window.confirm('Soll dieser Eintrag dauerhaft gelöscht werden?')) {
|
||||||
const updatedConfig = config.filter((item) => item.id !== entryId);
|
const updatedConfig = config.filter((item) => item.id !== entryId);
|
||||||
@@ -681,14 +649,6 @@ function App() {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNewEntryChange = (event) => {
|
|
||||||
const { name, value, type, checked } = event.target;
|
|
||||||
setNewEntry({
|
|
||||||
...newEntry,
|
|
||||||
[name]: type === 'checkbox' ? checked : value
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const configMap = useMemo(() => {
|
const configMap = useMemo(() => {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
config.forEach((item) => {
|
config.forEach((item) => {
|
||||||
@@ -1165,128 +1125,7 @@ function App() {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{showNewEntryForm ? (
|
<div className="flex justify-end mb-6">
|
||||||
<div className="bg-gray-50 p-4 rounded-lg border border-gray-200 mb-6">
|
|
||||||
<h2 className="text-lg font-semibold mb-4">Neuen Eintrag hinzufügen</h2>
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">ID *</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="id"
|
|
||||||
value={newEntry.id}
|
|
||||||
onChange={handleNewEntryChange}
|
|
||||||
className="border rounded p-2 w-full focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Bezeichnung *</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="label"
|
|
||||||
value={newEntry.label}
|
|
||||||
onChange={handleNewEntryChange}
|
|
||||||
className="border rounded p-2 w-full focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex flex-wrap gap-6 mb-4">
|
|
||||||
<label className="flex items-center">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
name="active"
|
|
||||||
checked={newEntry.active}
|
|
||||||
onChange={handleNewEntryChange}
|
|
||||||
className="h-5 w-5 text-blue-600 rounded focus:ring-2 focus:ring-blue-500 mr-2"
|
|
||||||
/>
|
|
||||||
<span className="text-sm font-medium text-gray-700">Aktiv</span>
|
|
||||||
</label>
|
|
||||||
<label className="flex items-center">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
name="checkProfileId"
|
|
||||||
checked={newEntry.checkProfileId}
|
|
||||||
onChange={handleNewEntryChange}
|
|
||||||
className="h-5 w-5 text-blue-600 rounded focus:ring-2 focus:ring-blue-500 mr-2"
|
|
||||||
/>
|
|
||||||
<span className="text-sm font-medium text-gray-700">Profil prüfen</span>
|
|
||||||
</label>
|
|
||||||
<label className="flex items-center">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
name="onlyNotify"
|
|
||||||
checked={newEntry.onlyNotify}
|
|
||||||
onChange={handleNewEntryChange}
|
|
||||||
className="h-5 w-5 text-blue-600 rounded focus:ring-2 focus:ring-blue-500 mr-2"
|
|
||||||
/>
|
|
||||||
<span className="text-sm font-medium text-gray-700">Nur benachrichtigen</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Wochentag</label>
|
|
||||||
<select
|
|
||||||
name="desiredWeekday"
|
|
||||||
value={newEntry.desiredWeekday || ''}
|
|
||||||
onChange={handleNewEntryChange}
|
|
||||||
className="border rounded p-2 w-full bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
||||||
>
|
|
||||||
<option value="">Kein Wochentag</option>
|
|
||||||
{weekdays.map((day) => (
|
|
||||||
<option key={day} value={day}>
|
|
||||||
{day}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Spezifisches Datum</label>
|
|
||||||
<input
|
|
||||||
type="date"
|
|
||||||
name="desiredDate"
|
|
||||||
value={newEntry.desiredDate || ''}
|
|
||||||
onChange={handleNewEntryChange}
|
|
||||||
className="border rounded p-2 w-full focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
||||||
disabled={newEntry.desiredWeekday}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-end space-x-2">
|
|
||||||
<button
|
|
||||||
onClick={() => setShowNewEntryForm(false)}
|
|
||||||
className="bg-gray-300 hover:bg-gray-400 text-gray-800 px-4 py-2 rounded focus:outline-none focus:ring-2 focus:ring-gray-500"
|
|
||||||
>
|
|
||||||
Abbrechen
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={addEntry}
|
|
||||||
className="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
||||||
>
|
|
||||||
Hinzufügen
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<button
|
|
||||||
onClick={() => setShowNewEntryForm(true)}
|
|
||||||
className="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded mb-6 focus:outline-none focus:ring-2 focus:ring-green-500"
|
|
||||||
>
|
|
||||||
Neuen Eintrag hinzufügen
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="flex justify-between mb-6">
|
|
||||||
<button
|
|
||||||
onClick={fetchConfig}
|
|
||||||
className="bg-gray-500 hover:bg-gray-600 text-white py-2 px-4 rounded focus:outline-none focus:ring-2 focus:ring-gray-500 transition-colors"
|
|
||||||
>
|
|
||||||
Aktualisieren
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
onClick={saveConfig}
|
onClick={saveConfig}
|
||||||
className="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors"
|
className="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors"
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Alle übergebenen Argumente als Commit-Message (oder Fallback)
|
# --- Commit Message bestimmen ---
|
||||||
if [[ $# -gt 0 ]]; then
|
if [[ $# -gt 0 ]]; then
|
||||||
MSG="$*"
|
MSG="$*"
|
||||||
|
elif [[ -f .commitmessage ]]; then
|
||||||
|
MSG="$(<.commitmessage)"
|
||||||
else
|
else
|
||||||
MSG="Aktueller Stand"
|
MSG="Aktueller Stand"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Nur committen, wenn es Änderungen gibt
|
# --- Git Commit & Push (nur bei Änderungen) ---
|
||||||
if [[ -n $(git status --porcelain) ]]; then
|
if [[ -n $(git status --porcelain) ]]; then
|
||||||
echo "📦 Committe mit Nachricht: '$MSG'"
|
echo "📦 Committe mit Nachricht: '$MSG'"
|
||||||
git add .
|
git add .
|
||||||
@@ -18,7 +20,7 @@ else
|
|||||||
echo "✅ Keine Änderungen – überspringe Git-Commit."
|
echo "✅ Keine Änderungen – überspringe Git-Commit."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Container neu bauen und starten
|
# --- Docker Compose Build & Up ---
|
||||||
echo "🐳 Starte Docker Compose Build & Up..."
|
echo "🐳 Starte Docker Compose Build & Up..."
|
||||||
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose up --build -d pickup-config-app
|
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose up --build -d pickup-config-app
|
||||||
echo "🚀 Fertig!"
|
echo "🚀 Fertig!"
|
||||||
|
|||||||
Reference in New Issue
Block a user