Update iOS webapp styling and backend target
This commit is contained in:
@@ -1,152 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Station Config</title>
|
||||
|
||||
<style>
|
||||
/* ===== BASE THEME (wie Workbench / HMI) ===== */
|
||||
:root{
|
||||
--bg:#0b1020;
|
||||
--card:rgba(255,255,255,0.08);
|
||||
--border:rgba(255,255,255,0.14);
|
||||
--text:rgba(255,255,255,0.92);
|
||||
--muted:rgba(255,255,255,0.6);
|
||||
--accent:#4f7cff;
|
||||
--shadow:0 16px 60px rgba(0,0,0,.4);
|
||||
--radius:20px;
|
||||
}
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<title>Config</title>
|
||||
<!-- Handsontable CSS -->
|
||||
|
||||
*{box-sizing:border-box}
|
||||
html,body{height:100%}
|
||||
|
||||
body{
|
||||
margin:0;
|
||||
padding:16px;
|
||||
font-family:-apple-system,system-ui,Segoe UI,Roboto;
|
||||
background:
|
||||
radial-gradient(900px 600px at 20% 10%, rgba(79,124,255,.35), transparent 60%),
|
||||
var(--bg);
|
||||
color:var(--text);
|
||||
}
|
||||
|
||||
/* ===== LAYOUT ===== */
|
||||
.app{
|
||||
max-width:1600px;
|
||||
margin:0 auto;
|
||||
height:100%;
|
||||
display:grid;
|
||||
grid-template-rows:auto 1fr;
|
||||
gap:16px;
|
||||
}
|
||||
|
||||
.panel{
|
||||
background:linear-gradient(180deg,var(--card),rgba(255,255,255,.04));
|
||||
border:1px solid var(--border);
|
||||
border-radius:var(--radius);
|
||||
box-shadow:var(--shadow);
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
.header{
|
||||
padding:14px 18px;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:space-between;
|
||||
border-bottom:1px solid var(--border);
|
||||
}
|
||||
|
||||
.header h1{
|
||||
margin:0;
|
||||
font-size:18px;
|
||||
}
|
||||
|
||||
.header span{
|
||||
color:var(--muted);
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
/* ===== CONTENT ===== */
|
||||
.content{
|
||||
padding:16px;
|
||||
height:100%;
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
gap:12px;
|
||||
}
|
||||
|
||||
/* ===== BUTTONS ===== */
|
||||
button{
|
||||
padding:10px 18px;
|
||||
border-radius:14px;
|
||||
border:0;
|
||||
background:var(--accent);
|
||||
color:white;
|
||||
font-size:14px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
button:hover{
|
||||
filter:brightness(1.1);
|
||||
}
|
||||
|
||||
#hot{
|
||||
flex:1;
|
||||
overflow:auto;
|
||||
border-radius:14px;
|
||||
border:1px solid var(--border);
|
||||
}
|
||||
|
||||
.config-table {
|
||||
width: 100%;
|
||||
min-width: 980px;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.config-table th,
|
||||
.config-table td {
|
||||
padding: 9px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.config-table input[type="text"] {
|
||||
width: 100%;
|
||||
min-width: 160px;
|
||||
padding: 7px 9px;
|
||||
}
|
||||
|
||||
.config-table input[type="checkbox"] {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="/backend/ios.css">
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
margin: 20px;
|
||||
}
|
||||
#hot {
|
||||
margin-top: 10px;
|
||||
width: 100%;
|
||||
min-height: 300px; /* damit man etwas sieht */
|
||||
}
|
||||
button {
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<main class="app">
|
||||
<h1>Station <span id="stationNumberDisplay"></span></h1>
|
||||
|
||||
<!-- HEADER -->
|
||||
<section class="panel">
|
||||
<div class="header">
|
||||
<h1>
|
||||
Station Config
|
||||
<span>Station <strong id="stationNumberDisplay"></strong></span>
|
||||
</h1>
|
||||
<button onclick="setConfig()">Speichern</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- CONTENT -->
|
||||
<section class="panel content">
|
||||
<div id="hot"></div>
|
||||
</section>
|
||||
<!-- Zwei Buttons -->
|
||||
|
||||
</main>
|
||||
<button onclick="setConfig()">Speichern (setConfig)</button>
|
||||
|
||||
<div id="hot"></div>
|
||||
<!-- Einbinden der Handsontable-JS-Bibliothek -->
|
||||
<script src="/backend/handsontable/handsontable/dist/handsontable.full.min.js"></script>
|
||||
<link rel="stylesheet" href="/backend/handsontable/handsontable/dist/handsontable.full.min.css">
|
||||
<link rel="stylesheet" href="/backend/ios.css">
|
||||
<script>
|
||||
/*
|
||||
0) Globale Variablen für Ihre URL, stationNumber, persID etc.
|
||||
@@ -429,71 +317,73 @@ function transformData(rawArray) {
|
||||
});
|
||||
}
|
||||
|
||||
let configRows = [];
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value ?? "")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
function renderConfigTable(rows) {
|
||||
configRows = rows;
|
||||
const container = document.getElementById("hot");
|
||||
container.innerHTML = `
|
||||
<table class="config-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>code_nr</th>
|
||||
<th>Description</th>
|
||||
<th>code_wert</th>
|
||||
<th>Change by</th>
|
||||
<th>Changed Date</th>
|
||||
<th>used</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${rows.map((row, index) => `
|
||||
<tr>
|
||||
<td>${escapeHtml(row.code_nr)}</td>
|
||||
<td>${escapeHtml(row.description)}</td>
|
||||
<td>${renderValueCell(row, index)}</td>
|
||||
<td>${escapeHtml(row.changedby)}</td>
|
||||
<td>${escapeHtml(row.timestamp)}</td>
|
||||
<td><input type="checkbox" data-row="${index}" data-field="used" ${row.used ? "checked" : ""}></td>
|
||||
</tr>
|
||||
`).join("")}
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
|
||||
container.querySelectorAll("input[data-row]").forEach(input => {
|
||||
input.addEventListener("change", updateConfigRow);
|
||||
input.addEventListener("input", updateConfigRow);
|
||||
});
|
||||
}
|
||||
|
||||
function renderValueCell(row, index) {
|
||||
if (typeof row.code_wert === "boolean") {
|
||||
return `<input type="checkbox" data-row="${index}" data-field="code_wert" ${row.code_wert ? "checked" : ""}>`;
|
||||
}
|
||||
return `<input type="text" data-row="${index}" data-field="code_wert" value="${escapeHtml(row.code_wert)}">`;
|
||||
}
|
||||
|
||||
function updateConfigRow(event) {
|
||||
const input = event.target;
|
||||
const rowIndex = Number(input.dataset.row);
|
||||
const field = input.dataset.field;
|
||||
configRows[rowIndex][field] = input.type === "checkbox" ? input.checked : input.value;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const transformedData = transformData(myDataRaw);
|
||||
renderConfigTable(transformedData);
|
||||
});
|
||||
/*
|
||||
3) Custom Renderer: boolean => Checkbox, sonst => Text
|
||||
*/
|
||||
function booleanOrTextRenderer(hotInstance, td, row, col, prop, value, cellProperties) {
|
||||
if (typeof value === "boolean") {
|
||||
// Standard-CheckboxRenderer => klickbare Checkbox
|
||||
Handsontable.renderers.CheckboxRenderer.apply(this, arguments);
|
||||
} else {
|
||||
// Andernfalls normaler Text
|
||||
Handsontable.renderers.TextRenderer.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
4) Handsontable initialisieren
|
||||
*/
|
||||
let hot;
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const container = document.getElementById('hot');
|
||||
// Start mit transformierten localData
|
||||
const transformedData = transformData(myDataRaw);
|
||||
|
||||
hot = new Handsontable(container, {
|
||||
data: transformedData,
|
||||
rowHeaders: true,
|
||||
colHeaders: [
|
||||
"code_nr",
|
||||
"Description",
|
||||
"code_wert",
|
||||
"Change by",
|
||||
"Changed Date",
|
||||
"used (checkbox)"
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
data: "code_nr",
|
||||
type: "numeric",
|
||||
readOnly: true
|
||||
},
|
||||
{
|
||||
data: "description",
|
||||
type: "text",
|
||||
readOnly: true
|
||||
},
|
||||
{
|
||||
data: "code_wert",
|
||||
renderer: booleanOrTextRenderer
|
||||
},
|
||||
{
|
||||
data: "changedby",
|
||||
type: "text",
|
||||
readOnly: true
|
||||
},
|
||||
{
|
||||
data: "timestamp",
|
||||
type: "text",
|
||||
readOnly: true
|
||||
},
|
||||
{
|
||||
data: "used",
|
||||
renderer: booleanOrTextRenderer
|
||||
}
|
||||
],
|
||||
licenseKey: "non-commercial-and-evaluation"
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -535,8 +425,9 @@ function getConfig() {
|
||||
}
|
||||
});
|
||||
|
||||
const newData = transformData(myDataRaw);
|
||||
renderConfigTable(newData);
|
||||
// Neu transformieren & in Handsontable laden
|
||||
const newData = transformData(myDataRaw);
|
||||
hot.loadData(newData);
|
||||
|
||||
//alert("Daten gemerged & aktualisiert!");
|
||||
})
|
||||
@@ -567,8 +458,9 @@ function formatTimestampToYMDHMS(timestampNumber) {
|
||||
wandelt true => "USED" etc.
|
||||
=> sendet an '/backend/api/setStationConfig'
|
||||
*/
|
||||
function setConfig() {
|
||||
const allRows = configRows;
|
||||
function setConfig() {
|
||||
// 1) Daten aus Handsontable
|
||||
const allRows = hot.getSourceData();
|
||||
|
||||
// 2) Filtern: Nur used === true
|
||||
const usedRows = allRows.filter(row => row.used === true);
|
||||
|
||||
Reference in New Issue
Block a user