Admin stazioni: campo Worker visione (URL), traduzioni e test (#45)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NABedeMX43pyXZbDNUgA5B
This commit is contained in:
@@ -204,6 +204,17 @@
|
|||||||
maxlength="255">
|
maxlength="255">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{# Worker visione (#45): vuoto = worker centrale #}
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-[var(--text-primary)] mb-1">{{ _('Worker visione (URL)') }}</label>
|
||||||
|
<input type="text" x-model="form.vision_worker_url"
|
||||||
|
class="w-full px-3 py-2 rounded-lg border border-[var(--border-color)] bg-[var(--bg-card)]
|
||||||
|
text-sm font-mono text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary transition-colors"
|
||||||
|
placeholder="http://10.0.0.7:8100"
|
||||||
|
maxlength="500">
|
||||||
|
<p class="mt-1 text-xs text-[var(--text-secondary)]">{{ _('Vuoto = worker centrale') }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-[var(--text-primary)] mb-1">{{ _('Note') }}</label>
|
<label class="block text-sm font-medium text-[var(--text-primary)] mb-1">{{ _('Note') }}</label>
|
||||||
<textarea x-model="form.notes" rows="3"
|
<textarea x-model="form.notes" rows="3"
|
||||||
@@ -452,6 +463,7 @@ function stationManagement(initialStations, initialRecipes) {
|
|||||||
name: '',
|
name: '',
|
||||||
location: '',
|
location: '',
|
||||||
notes: '',
|
notes: '',
|
||||||
|
vision_worker_url: '', // #45
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -505,7 +517,7 @@ function stationManagement(initialStations, initialRecipes) {
|
|||||||
this.isEditing = false;
|
this.isEditing = false;
|
||||||
this.editingId = null;
|
this.editingId = null;
|
||||||
this.errorMsg = '';
|
this.errorMsg = '';
|
||||||
this.form = { code: '', name: '', location: '', notes: '', active: true };
|
this.form = { code: '', name: '', location: '', notes: '', vision_worker_url: '', active: true };
|
||||||
this.showModal = true;
|
this.showModal = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -518,6 +530,7 @@ function stationManagement(initialStations, initialRecipes) {
|
|||||||
name: station.name,
|
name: station.name,
|
||||||
location: station.location || '',
|
location: station.location || '',
|
||||||
notes: station.notes || '',
|
notes: station.notes || '',
|
||||||
|
vision_worker_url: station.vision_worker_url || '', // #45
|
||||||
active: station.active,
|
active: station.active,
|
||||||
};
|
};
|
||||||
this.showModal = true;
|
this.showModal = true;
|
||||||
@@ -537,6 +550,7 @@ function stationManagement(initialStations, initialRecipes) {
|
|||||||
name: this.form.name,
|
name: this.form.name,
|
||||||
location: this.form.location || null,
|
location: this.form.location || null,
|
||||||
notes: this.form.notes || null,
|
notes: this.form.notes || null,
|
||||||
|
vision_worker_url: (this.form.vision_worker_url || '').trim() || null, // #45
|
||||||
active: this.form.active,
|
active: this.form.active,
|
||||||
};
|
};
|
||||||
const resp = await fetch(`/admin/api/stations/${this.editingId}`, {
|
const resp = await fetch(`/admin/api/stations/${this.editingId}`, {
|
||||||
@@ -563,6 +577,7 @@ function stationManagement(initialStations, initialRecipes) {
|
|||||||
name: this.form.name,
|
name: this.form.name,
|
||||||
location: this.form.location || null,
|
location: this.form.location || null,
|
||||||
notes: this.form.notes || null,
|
notes: this.form.notes || null,
|
||||||
|
vision_worker_url: (this.form.vision_worker_url || '').trim() || null, // #45
|
||||||
active: this.form.active,
|
active: this.form.active,
|
||||||
};
|
};
|
||||||
const resp = await fetch('/admin/api/stations', {
|
const resp = await fetch('/admin/api/stations', {
|
||||||
|
|||||||
@@ -176,3 +176,41 @@ def test_station_list_page_renders_assigned_recipes(logged_in_client, mock_admin
|
|||||||
resp = logged_in_client.get("/admin/stations")
|
resp = logged_in_client.get("/admin/stations")
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert b"REC-ABC" in resp.data
|
assert b"REC-ABC" in resp.data
|
||||||
|
|
||||||
|
|
||||||
|
# --- Worker visione per stazione (#45) ---
|
||||||
|
|
||||||
|
def test_station_form_has_the_vision_worker_field(logged_in_client, mock_admin_api):
|
||||||
|
mock_admin_api.get.return_value = []
|
||||||
|
resp = logged_in_client.get("/admin/stations")
|
||||||
|
assert resp.status_code == 200
|
||||||
|
assert b"form.vision_worker_url" in resp.data
|
||||||
|
assert "Worker visione (URL)".encode() in resp.data
|
||||||
|
|
||||||
|
|
||||||
|
def test_station_list_exposes_the_vision_worker_url(logged_in_client, mock_admin_api):
|
||||||
|
mock_admin_api.get.side_effect = [
|
||||||
|
[{"id": 1, "code": "ST-001", "name": "Linea A", "location": None,
|
||||||
|
"notes": None, "active": True, "vision_worker_url": "http://10.0.0.7:8100",
|
||||||
|
"created_by": 1, "created_at": "2026-04-25T10:00:00"}],
|
||||||
|
[],
|
||||||
|
]
|
||||||
|
resp = logged_in_client.get("/admin/stations")
|
||||||
|
assert b"http://10.0.0.7:8100" in resp.data # nel JSON iniziale della pagina
|
||||||
|
|
||||||
|
|
||||||
|
def test_station_proxies_pass_the_vision_worker_url_untouched(logged_in_client, mock_admin_api):
|
||||||
|
mock_admin_api.post.return_value = {"id": 7, "code": "ST-7", "name": "n"}
|
||||||
|
mock_admin_api.put.return_value = {"id": 7, "code": "ST-7", "name": "n"}
|
||||||
|
logged_in_client.post(
|
||||||
|
"/admin/api/stations",
|
||||||
|
json={"code": "ST-7", "name": "n", "vision_worker_url": "http://w:8100"},
|
||||||
|
)
|
||||||
|
mock_admin_api.post.assert_called_once_with(
|
||||||
|
"/api/stations",
|
||||||
|
data={"code": "ST-7", "name": "n", "vision_worker_url": "http://w:8100"},
|
||||||
|
)
|
||||||
|
logged_in_client.put("/admin/api/stations/7", json={"vision_worker_url": None})
|
||||||
|
mock_admin_api.put.assert_called_once_with(
|
||||||
|
"/api/stations/7", data={"vision_worker_url": None},
|
||||||
|
)
|
||||||
|
|||||||
@@ -754,6 +754,14 @@ msgstr "Code cannot be modified"
|
|||||||
msgid "Identificativo univoco usato dal client tramite STATION_CODE"
|
msgid "Identificativo univoco usato dal client tramite STATION_CODE"
|
||||||
msgstr "Unique identifier used by client via STATION_CODE"
|
msgstr "Unique identifier used by client via STATION_CODE"
|
||||||
|
|
||||||
|
#: templates/admin/stations.html
|
||||||
|
msgid "Worker visione (URL)"
|
||||||
|
msgstr "Vision worker (URL)"
|
||||||
|
|
||||||
|
#: templates/admin/stations.html
|
||||||
|
msgid "Vuoto = worker centrale"
|
||||||
|
msgstr "Empty = central worker"
|
||||||
|
|
||||||
#: templates/admin/stations.html:194
|
#: templates/admin/stations.html:194
|
||||||
msgid "Nome descrittivo della stazione"
|
msgid "Nome descrittivo della stazione"
|
||||||
msgstr "Descriptive name of the station"
|
msgstr "Descriptive name of the station"
|
||||||
|
|||||||
@@ -756,6 +756,14 @@ msgstr "Il codice non può essere modificato"
|
|||||||
msgid "Identificativo univoco usato dal client tramite STATION_CODE"
|
msgid "Identificativo univoco usato dal client tramite STATION_CODE"
|
||||||
msgstr "Identificativo univoco usato dal client tramite STATION_CODE"
|
msgstr "Identificativo univoco usato dal client tramite STATION_CODE"
|
||||||
|
|
||||||
|
#: templates/admin/stations.html
|
||||||
|
msgid "Worker visione (URL)"
|
||||||
|
msgstr "Worker visione (URL)"
|
||||||
|
|
||||||
|
#: templates/admin/stations.html
|
||||||
|
msgid "Vuoto = worker centrale"
|
||||||
|
msgstr "Vuoto = worker centrale"
|
||||||
|
|
||||||
#: templates/admin/stations.html:194
|
#: templates/admin/stations.html:194
|
||||||
msgid "Nome descrittivo della stazione"
|
msgid "Nome descrittivo della stazione"
|
||||||
msgstr "Nome descrittivo della stazione"
|
msgstr "Nome descrittivo della stazione"
|
||||||
|
|||||||
Reference in New Issue
Block a user