Compare commits
2 Commits
7bc3c1f938
...
bde8fafd77
| Author | SHA1 | Date | |
|---|---|---|---|
| bde8fafd77 | |||
| 6fbff2fe76 |
@@ -15,6 +15,7 @@ from src.backend.models.api.production import (
|
||||
ProductionRunCreate,
|
||||
ProductionRunResponse,
|
||||
ProductionRunWithEventsResponse,
|
||||
RemeasurePayload,
|
||||
SupervisorAction,
|
||||
)
|
||||
from src.backend.models.orm.production import ProductionRun
|
||||
@@ -23,13 +24,19 @@ from src.backend.services import production_service
|
||||
|
||||
router = APIRouter(prefix="/api/production-runs", tags=["production"])
|
||||
|
||||
_DERIVED = {
|
||||
"seconds_to_next_measurement", "overdue", "server_time", "measurement_task_ids",
|
||||
}
|
||||
|
||||
def _as_response(run: ProductionRun) -> ProductionRunResponse:
|
||||
|
||||
async def _as_response(db: AsyncSession, run: ProductionRun) -> ProductionRunResponse:
|
||||
"""The stored run plus everything the client cannot work out on its own."""
|
||||
return ProductionRunResponse(
|
||||
**ProductionRunResponse.model_validate(run).model_dump(
|
||||
exclude={"seconds_to_next_measurement", "overdue", "server_time"}
|
||||
),
|
||||
**ProductionRunResponse.model_validate(run).model_dump(exclude=_DERIVED),
|
||||
**production_service.describe(run),
|
||||
measurement_task_ids=await production_service.measurement_task_ids(
|
||||
db, run.version_id,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -41,7 +48,7 @@ async def open_production_run(
|
||||
):
|
||||
"""Start a production at a station."""
|
||||
run = await production_service.open_run(db, data, user)
|
||||
return _as_response(run)
|
||||
return await _as_response(db, run)
|
||||
|
||||
|
||||
@router.get("/current", response_model=ProductionRunResponse | None)
|
||||
@@ -56,7 +63,7 @@ async def get_current_production_run(
|
||||
"""
|
||||
station = await production_service.get_station_by_code(db, station_code)
|
||||
run = await production_service.get_open_run_for_station(db, station.id)
|
||||
return _as_response(run) if run is not None else None
|
||||
return await _as_response(db, run) if run is not None else None
|
||||
|
||||
|
||||
@router.get("/{run_id}", response_model=ProductionRunWithEventsResponse)
|
||||
@@ -69,7 +76,7 @@ async def get_production_run(
|
||||
run = await production_service.get_run(db, run_id)
|
||||
events = await production_service.list_run_events(db, run_id)
|
||||
return ProductionRunWithEventsResponse(
|
||||
**_as_response(run).model_dump(),
|
||||
**(await _as_response(db, run)).model_dump(),
|
||||
events=[ProductionEventResponse.model_validate(e) for e in events],
|
||||
)
|
||||
|
||||
@@ -81,12 +88,31 @@ async def complete_measurement_cycle(
|
||||
user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Record a finished measurement cycle and restart the interval."""
|
||||
"""Record a finished measurement task; the last one restarts the interval."""
|
||||
run = await production_service.get_run(db, run_id)
|
||||
run = await production_service.complete_cycle(
|
||||
db, run, user, note=payload.note if payload else None,
|
||||
db, run, user,
|
||||
task_id=payload.task_id if payload else None,
|
||||
note=payload.note if payload else None,
|
||||
)
|
||||
return _as_response(run)
|
||||
return await _as_response(db, run)
|
||||
|
||||
|
||||
@router.post("/{run_id}/remeasure", response_model=ProductionRunResponse)
|
||||
async def remeasure_in_cycle(
|
||||
run_id: int,
|
||||
payload: RemeasurePayload | None = None,
|
||||
user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Turn the piece over and measure again, without closing the cycle."""
|
||||
run = await production_service.get_run(db, run_id)
|
||||
run = await production_service.remeasure(
|
||||
db, run, user,
|
||||
task_id=payload.task_id if payload else None,
|
||||
note=payload.note if payload else None,
|
||||
)
|
||||
return await _as_response(db, run)
|
||||
|
||||
|
||||
@router.post("/{run_id}/pause", response_model=ProductionRunResponse)
|
||||
@@ -102,7 +128,7 @@ async def pause_production_run(
|
||||
db, action.supervisor_username, action.supervisor_password,
|
||||
)
|
||||
run = await production_service.pause_run(db, run, user, supervisor, note=action.note)
|
||||
return _as_response(run)
|
||||
return await _as_response(db, run)
|
||||
|
||||
|
||||
@router.post("/{run_id}/resume", response_model=ProductionRunResponse)
|
||||
@@ -118,7 +144,7 @@ async def resume_production_run(
|
||||
db, action.supervisor_username, action.supervisor_password,
|
||||
)
|
||||
run = await production_service.resume_run(db, run, user, supervisor, note=action.note)
|
||||
return _as_response(run)
|
||||
return await _as_response(db, run)
|
||||
|
||||
|
||||
@router.post("/{run_id}/close", response_model=ProductionRunResponse)
|
||||
@@ -134,4 +160,4 @@ async def close_production_run(
|
||||
db, action.supervisor_username, action.supervisor_password,
|
||||
)
|
||||
run = await production_service.close_run(db, run, user, supervisor, note=action.note)
|
||||
return _as_response(run)
|
||||
return await _as_response(db, run)
|
||||
|
||||
@@ -172,6 +172,7 @@ async def create_task(
|
||||
new_task = RecipeTask(
|
||||
version_id=new_version.id,
|
||||
order_index=max_order + 1,
|
||||
task_type=data.task_type,
|
||||
title=data.title,
|
||||
directive=data.directive,
|
||||
description=data.description,
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
"""add an explicit type to recipe tasks
|
||||
|
||||
Until now the kind of a task was deduced: quotes present meant a measurement,
|
||||
otherwise a note. A measurement task whose quotes had not been entered yet was
|
||||
therefore treated as a note - the system behaved differently depending on how
|
||||
complete the recipe happened to be.
|
||||
|
||||
Existing rows are classified by the rule that was in force, so nothing changes
|
||||
behaviour on upgrade: tasks with quotes become 'measure'. Tasks with no quotes but
|
||||
a drawing attached become 'drawing' rather than 'note' - that is what they already
|
||||
displayed as, and calling them notes would be the one place this migration did
|
||||
change behaviour.
|
||||
|
||||
Revision ID: 007_task_type
|
||||
Revises: 006_measurement_run
|
||||
Create Date: 2026-07-28
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision: str = '007_task_type'
|
||||
down_revision: Union[str, None] = '006_measurement_run'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
TASK_TYPES = ('note', 'measure', 'drawing', 'xf_compare', 'camera_measure')
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
'recipe_tasks',
|
||||
sa.Column(
|
||||
'task_type',
|
||||
sa.Enum(*TASK_TYPES, name='task_type_enum'),
|
||||
nullable=False,
|
||||
server_default='note',
|
||||
),
|
||||
)
|
||||
op.create_index('ix_recipe_tasks_task_type', 'recipe_tasks', ['task_type'])
|
||||
|
||||
# Backfill by the rule the frontend used, so no recipe changes behaviour.
|
||||
op.execute(
|
||||
"""
|
||||
UPDATE recipe_tasks
|
||||
SET task_type = 'measure'
|
||||
WHERE id IN (SELECT DISTINCT task_id FROM recipe_subtasks)
|
||||
"""
|
||||
)
|
||||
op.execute(
|
||||
"""
|
||||
UPDATE recipe_tasks
|
||||
SET task_type = 'drawing'
|
||||
WHERE task_type = 'note'
|
||||
AND file_path IS NOT NULL
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index('ix_recipe_tasks_task_type', table_name='recipe_tasks')
|
||||
op.drop_column('recipe_tasks', 'task_type')
|
||||
@@ -0,0 +1,74 @@
|
||||
"""widen the production event trace for the measurement loop
|
||||
|
||||
The loop needs to distinguish two things the trace could not say before: a
|
||||
measurement task finished while the cycle is still running (task_measured), and the
|
||||
piece turned over and measured again without closing the cycle (remeasure). Only
|
||||
the last measurement task of a recipe still produces cycle_completed, because only
|
||||
that one restarts the interval.
|
||||
|
||||
Both values are added in one go. Widening a MySQL enum rewrites the table, so the
|
||||
values that are already planned go in now rather than one migration at a time -
|
||||
the same reasoning as the task types in 007.
|
||||
|
||||
The events that happen inside a cycle also need to say which task they are about,
|
||||
so the column comes with them: a task_measured that does not name its task records
|
||||
nothing usable.
|
||||
|
||||
Revision ID: 008_loop_events
|
||||
Revises: 007_task_type
|
||||
Create Date: 2026-07-28
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision: str = '008_loop_events'
|
||||
down_revision: Union[str, None] = '007_task_type'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
OLD_TYPES = ('start', 'cycle_completed', 'line_stop', 'resume', 'close')
|
||||
NEW_TYPES = (
|
||||
'start', 'cycle_completed', 'task_measured', 'remeasure',
|
||||
'line_stop', 'resume', 'close',
|
||||
)
|
||||
|
||||
|
||||
def _alter(values: Sequence[str]) -> None:
|
||||
"""Restate the column with a new set of allowed values.
|
||||
|
||||
On MySQL this is the ALTER that rewrites the enum. On SQLite, where an enum is
|
||||
stored as a plain VARCHAR, batch mode rebuilds the table instead of emitting an
|
||||
ALTER the engine does not support - the tests run there.
|
||||
"""
|
||||
with op.batch_alter_table('production_events') as batch:
|
||||
batch.alter_column(
|
||||
'event_type',
|
||||
existing_type=sa.Enum(*OLD_TYPES, name='production_event_type_enum'),
|
||||
type_=sa.Enum(*values, name='production_event_type_enum'),
|
||||
existing_nullable=False,
|
||||
)
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
_alter(NEW_TYPES)
|
||||
with op.batch_alter_table('production_events') as batch:
|
||||
batch.add_column(sa.Column('task_id', sa.Integer(), nullable=True))
|
||||
batch.create_foreign_key(
|
||||
'fk_production_events_task_id', 'recipe_tasks', ['task_id'], ['id'],
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
with op.batch_alter_table('production_events') as batch:
|
||||
batch.drop_constraint('fk_production_events_task_id', type_='foreignkey')
|
||||
batch.drop_column('task_id')
|
||||
# The new kinds of event have no equivalent in the old vocabulary, and a row
|
||||
# left with a value the column no longer accepts would fail the rebuild.
|
||||
op.execute(
|
||||
"DELETE FROM production_events "
|
||||
"WHERE event_type IN ('task_measured', 'remeasure')"
|
||||
)
|
||||
_alter(OLD_TYPES)
|
||||
@@ -19,6 +19,7 @@ class ProductionEventResponse(BaseModel):
|
||||
event_type: str
|
||||
user_id: int
|
||||
supervisor_id: Optional[int]
|
||||
task_id: Optional[int] = None
|
||||
note: Optional[str]
|
||||
created_at: datetime
|
||||
|
||||
@@ -50,6 +51,11 @@ class ProductionRunResponse(BaseModel):
|
||||
overdue: bool = False
|
||||
server_time: Optional[datetime] = None
|
||||
|
||||
# The measurement tasks of this run's version, in execution order. The client
|
||||
# needs them to bring the operator back to the measurement when the interval
|
||||
# expires, whichever screen they are on, and to know which task closes a cycle.
|
||||
measurement_task_ids: list[int] = Field(default_factory=list)
|
||||
|
||||
|
||||
class ProductionRunWithEventsResponse(ProductionRunResponse):
|
||||
events: list[ProductionEventResponse] = Field(default_factory=list)
|
||||
@@ -64,9 +70,20 @@ class SupervisorAction(BaseModel):
|
||||
|
||||
|
||||
class CycleCompletePayload(BaseModel):
|
||||
# Which measurement task was just finished. The interval restarts only on the
|
||||
# last one of the recipe; omitting it closes the cycle outright.
|
||||
task_id: Optional[int] = Field(default=None, gt=0)
|
||||
note: Optional[str] = None
|
||||
|
||||
|
||||
class RemeasurePayload(BaseModel):
|
||||
"""The piece was turned over: measure it again inside the same cycle."""
|
||||
|
||||
task_id: Optional[int] = Field(default=None, gt=0)
|
||||
note: Optional[str] = None
|
||||
|
||||
|
||||
ProductionEventType = Literal[
|
||||
"start", "cycle_completed", "line_stop", "resume", "close",
|
||||
"start", "cycle_completed", "task_measured", "remeasure",
|
||||
"line_stop", "resume", "close",
|
||||
]
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
"""Pydantic schemas for RecipeTask and RecipeSubtask operations."""
|
||||
from typing import Any, Optional
|
||||
from typing import Any, Literal, Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from src.backend.models.orm.task import TASK_TYPES
|
||||
|
||||
# Kept in step with the ORM enum so the two cannot drift apart.
|
||||
TaskType = Literal[TASK_TYPES]
|
||||
|
||||
|
||||
class SubtaskCreate(BaseModel):
|
||||
"""Schema for creating a subtask."""
|
||||
@@ -53,6 +58,7 @@ class SubtaskResponse(BaseModel):
|
||||
class TaskCreate(BaseModel):
|
||||
"""Schema for creating a task."""
|
||||
title: str = Field(..., min_length=1, max_length=255)
|
||||
task_type: TaskType = "note"
|
||||
directive: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
file_path: Optional[str] = Field(None, max_length=500)
|
||||
@@ -64,6 +70,7 @@ class TaskCreate(BaseModel):
|
||||
class TaskUpdate(BaseModel):
|
||||
"""Schema for updating a task."""
|
||||
title: Optional[str] = Field(None, min_length=1, max_length=255)
|
||||
task_type: Optional[TaskType] = None
|
||||
directive: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
file_path: Optional[str] = Field(None, max_length=500)
|
||||
@@ -79,6 +86,7 @@ class TaskResponse(BaseModel):
|
||||
version_id: int
|
||||
recipe_id: Optional[int] = None
|
||||
order_index: int
|
||||
task_type: str
|
||||
title: str
|
||||
directive: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
|
||||
@@ -31,7 +31,13 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
RUN_STATUSES = ("running", "paused", "closed")
|
||||
EVENT_TYPES = ("start", "cycle_completed", "line_stop", "resume", "close")
|
||||
# task_measured marks a measurement task finished inside a cycle that is not over
|
||||
# yet; only the last one produces cycle_completed and restarts the interval.
|
||||
# remeasure is the piece being turned and measured again without closing the cycle.
|
||||
EVENT_TYPES = (
|
||||
"start", "cycle_completed", "task_measured", "remeasure",
|
||||
"line_stop", "resume", "close",
|
||||
)
|
||||
|
||||
|
||||
class ProductionRun(Base):
|
||||
@@ -139,6 +145,12 @@ class ProductionEvent(Base):
|
||||
supervisor_id: Mapped[Optional[int]] = mapped_column(
|
||||
Integer, ForeignKey("users.id"), nullable=True
|
||||
)
|
||||
# Which task the event is about, for the ones that happen inside a cycle. A
|
||||
# task_measured or a remeasure that does not say which task is not a record of
|
||||
# anything; null for the events that concern the run as a whole.
|
||||
task_id: Mapped[Optional[int]] = mapped_column(
|
||||
Integer, ForeignKey("recipe_tasks.id"), nullable=True
|
||||
)
|
||||
note: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, server_default=func.now(), index=True
|
||||
|
||||
@@ -12,6 +12,15 @@ if TYPE_CHECKING:
|
||||
from src.backend.models.orm.recipe import RecipeVersion
|
||||
|
||||
|
||||
# What a task is, declared by whoever writes the recipe instead of guessed from its
|
||||
# contents. The last two are not built yet; they are in the enum from the start
|
||||
# because widening a MySQL enum later is an ALTER on a live table.
|
||||
TASK_TYPES = ("note", "measure", "drawing", "xf_compare", "camera_measure")
|
||||
|
||||
# Types the operator screen treats as "there are quotes to take here".
|
||||
MEASURING_TASK_TYPES = ("measure", "camera_measure")
|
||||
|
||||
|
||||
class RecipeTask(Base):
|
||||
__tablename__ = "recipe_tasks"
|
||||
|
||||
@@ -20,6 +29,16 @@ class RecipeTask(Base):
|
||||
Integer, ForeignKey("recipe_versions.id"), nullable=False
|
||||
)
|
||||
order_index: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
# Declared, not deduced. The old rule - "has subtasks, therefore a measurement" -
|
||||
# meant a measurement task whose quotes had not been entered yet behaved as a
|
||||
# note, so the system acted differently depending on how finished the recipe was.
|
||||
task_type: Mapped[str] = mapped_column(
|
||||
Enum(*TASK_TYPES, name="task_type_enum"),
|
||||
nullable=False,
|
||||
default="note",
|
||||
server_default="note",
|
||||
index=True,
|
||||
)
|
||||
title: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
directive: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
@@ -24,6 +24,7 @@ from src.backend.models.api.production import ProductionRunCreate
|
||||
from src.backend.models.orm.production import ProductionEvent, ProductionRun
|
||||
from src.backend.models.orm.recipe import Recipe, RecipeVersion
|
||||
from src.backend.models.orm.station import Station
|
||||
from src.backend.models.orm.task import MEASURING_TASK_TYPES, RecipeTask
|
||||
from src.backend.models.orm.user import User
|
||||
from src.backend.services import auth_service, production_export_service
|
||||
|
||||
@@ -103,6 +104,28 @@ async def get_station_by_code(db: AsyncSession, code: str) -> Station:
|
||||
return station
|
||||
|
||||
|
||||
async def measurement_task_ids(db: AsyncSession, version_id: int) -> list[int]:
|
||||
"""Ids of the measurement tasks of a version, in the order they are executed.
|
||||
|
||||
This is the loop the operator lives in once production starts: the client uses
|
||||
the first of these to bring the measurement back on screen when the interval
|
||||
expires, and the last to know which task closes a cycle.
|
||||
|
||||
The type is read from the declared task_type (point 2), not from whether quotes
|
||||
happen to be present: a measurement task with no quotes yet is still where the
|
||||
operator has to be taken.
|
||||
"""
|
||||
result = await db.execute(
|
||||
select(RecipeTask.id)
|
||||
.where(
|
||||
RecipeTask.version_id == version_id,
|
||||
RecipeTask.task_type.in_(MEASURING_TASK_TYPES),
|
||||
)
|
||||
.order_by(RecipeTask.order_index, RecipeTask.id)
|
||||
)
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
async def list_run_events(db: AsyncSession, run_id: int) -> list[ProductionEvent]:
|
||||
result = await db.execute(
|
||||
select(ProductionEvent)
|
||||
@@ -149,6 +172,7 @@ def _add_event(
|
||||
user: User,
|
||||
supervisor: Optional[User] = None,
|
||||
note: Optional[str] = None,
|
||||
task_id: Optional[int] = None,
|
||||
) -> ProductionEvent:
|
||||
"""Append to the run's trace.
|
||||
|
||||
@@ -161,6 +185,7 @@ def _add_event(
|
||||
user_id=user.id,
|
||||
supervisor_id=supervisor.id if supervisor else None,
|
||||
note=note,
|
||||
task_id=task_id,
|
||||
created_at=_now(),
|
||||
)
|
||||
db.add(event)
|
||||
@@ -254,10 +279,7 @@ def _require_open(run: ProductionRun) -> None:
|
||||
)
|
||||
|
||||
|
||||
async def complete_cycle(
|
||||
db: AsyncSession, run: ProductionRun, user: User, note: Optional[str] = None,
|
||||
) -> ProductionRun:
|
||||
"""Record a finished measurement cycle and restart the interval."""
|
||||
def _require_measurable(run: ProductionRun) -> None:
|
||||
_require_open(run)
|
||||
if run.status == "paused":
|
||||
raise HTTPException(
|
||||
@@ -265,6 +287,36 @@ async def complete_cycle(
|
||||
detail="Production run is paused: resume it before measuring",
|
||||
)
|
||||
|
||||
|
||||
async def complete_cycle(
|
||||
db: AsyncSession,
|
||||
run: ProductionRun,
|
||||
user: User,
|
||||
task_id: Optional[int] = None,
|
||||
note: Optional[str] = None,
|
||||
) -> ProductionRun:
|
||||
"""Record a finished measurement task, and restart the interval if it was the last.
|
||||
|
||||
A cycle spans every measurement task of the recipe, so only the last one closes
|
||||
it. Restarting the interval at the first would make a recipe with three
|
||||
measurement tasks measure three times as often as it was set up to.
|
||||
|
||||
An unrecognised task_id - or none at all - closes the cycle: a caller that does
|
||||
not know about the sequence gets the behaviour that existed before it.
|
||||
"""
|
||||
_require_measurable(run)
|
||||
|
||||
measure_ids = await measurement_task_ids(db, run.version_id)
|
||||
closes_cycle = (
|
||||
task_id is None or task_id not in measure_ids or task_id == measure_ids[-1]
|
||||
)
|
||||
|
||||
if not closes_cycle:
|
||||
_add_event(db, run, "task_measured", user, note=note, task_id=task_id)
|
||||
await db.flush()
|
||||
await db.refresh(run)
|
||||
return run
|
||||
|
||||
now = _now()
|
||||
run.cycle_count += 1
|
||||
if run.measurement_interval_minutes and run.measurement_interval_minutes > 0:
|
||||
@@ -273,7 +325,29 @@ async def complete_cycle(
|
||||
run.next_measurement_at = now + timedelta(
|
||||
minutes=run.measurement_interval_minutes
|
||||
)
|
||||
_add_event(db, run, "cycle_completed", user, note=note)
|
||||
_add_event(db, run, "cycle_completed", user, note=note, task_id=task_id)
|
||||
await db.flush()
|
||||
await db.refresh(run)
|
||||
return run
|
||||
|
||||
|
||||
async def remeasure(
|
||||
db: AsyncSession,
|
||||
run: ProductionRun,
|
||||
user: User,
|
||||
task_id: Optional[int] = None,
|
||||
note: Optional[str] = None,
|
||||
) -> ProductionRun:
|
||||
"""Measure the same task again without closing the cycle.
|
||||
|
||||
This is the piece being turned over. The deadline and the cycle count are left
|
||||
exactly as they are - a second reading of the same part is not a new cycle, and
|
||||
it must not buy the operator another interval's worth of time. The values
|
||||
themselves are ordinary measurements: both readings stay in the statistics,
|
||||
which is the point of taking them.
|
||||
"""
|
||||
_require_measurable(run)
|
||||
_add_event(db, run, "remeasure", user, note=note, task_id=task_id)
|
||||
await db.flush()
|
||||
await db.refresh(run)
|
||||
return run
|
||||
|
||||
@@ -55,6 +55,9 @@ async def _copy_tasks_to_version(
|
||||
new_task = RecipeTask(
|
||||
version_id=target_version.id,
|
||||
order_index=task.order_index,
|
||||
# Carried over explicitly: a copy-on-write version that dropped the type
|
||||
# would silently reclassify every task the moment a recipe is edited.
|
||||
task_type=task.task_type,
|
||||
title=task.title,
|
||||
directive=task.directive,
|
||||
description=task.description,
|
||||
@@ -254,6 +257,7 @@ async def create_new_version(
|
||||
default_task = RecipeTask(
|
||||
version_id=new_version.id,
|
||||
order_index=0,
|
||||
task_type="drawing",
|
||||
title="Technical Drawing",
|
||||
file_path=data.file_path,
|
||||
file_type=data.file_type or (
|
||||
|
||||
@@ -243,6 +243,10 @@ async def create_test_recipe(
|
||||
version_id=version.id,
|
||||
order_index=0,
|
||||
title="Test Task",
|
||||
# Declared, like any task since the type stopped being deduced: this one has
|
||||
# a quote under it, so a fixture that called it a note would be modelling
|
||||
# exactly the inconsistency point 2 removed.
|
||||
task_type="measure",
|
||||
directive="Measure the part",
|
||||
description="First measurement task",
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ from sqlalchemy import select
|
||||
from src.backend.models.orm.production import ProductionRun
|
||||
from src.backend.models.orm.recipe import Recipe
|
||||
from src.backend.models.orm.station import Station
|
||||
from src.backend.models.orm.task import RecipeTask
|
||||
from src.backend.services import auth_service, production_service
|
||||
from src.backend.tests.conftest import auth_headers, create_test_recipe
|
||||
|
||||
@@ -63,6 +64,29 @@ async def _advance_clock(db_session, run_id: int, delta: timedelta) -> None:
|
||||
await db_session.commit()
|
||||
|
||||
|
||||
async def _only_task(db_session, version_id: int):
|
||||
"""The single task the fixture recipe comes with - a measurement one."""
|
||||
row = await db_session.execute(
|
||||
select(RecipeTask)
|
||||
.where(RecipeTask.version_id == version_id)
|
||||
.order_by(RecipeTask.order_index)
|
||||
)
|
||||
return row.scalars().first()
|
||||
|
||||
|
||||
async def _add_task(
|
||||
db_session, version_id: int, order_index: int, title: str, task_type: str = "measure",
|
||||
) -> RecipeTask:
|
||||
"""A further task in the sequence, of a declared type."""
|
||||
task = RecipeTask(
|
||||
version_id=version_id, order_index=order_index, title=title, task_type=task_type,
|
||||
)
|
||||
db_session.add(task)
|
||||
await db_session.commit()
|
||||
await db_session.refresh(task)
|
||||
return task
|
||||
|
||||
|
||||
async def _open(client, user, station, recipe, **extra):
|
||||
return await client.post(
|
||||
"/api/production-runs",
|
||||
@@ -209,6 +233,138 @@ async def test_cycle_restarts_the_interval_and_counts(
|
||||
assert 9 * 60 <= body["seconds_to_next_measurement"] <= 10 * 60
|
||||
|
||||
|
||||
async def test_measurement_tasks_travel_with_the_run(
|
||||
client: AsyncClient, measurement_tec_user, admin_user, db_session,
|
||||
):
|
||||
"""Where the measurement is cannot be guessed by the client: the run says so.
|
||||
|
||||
This is what lets a screen bring the operator back to the measurement when the
|
||||
interval expires, whatever page they wandered off to.
|
||||
"""
|
||||
station = await _station(db_session, admin_user.id, code="ST-SEQ")
|
||||
recipe = await _recipe_with_interval(db_session, admin_user.id, 10, code="REC-SEQ")
|
||||
opened = (await _open(client, measurement_tec_user, station, recipe)).json()
|
||||
first = await _only_task(db_session, opened["version_id"])
|
||||
# A drawing between the two measurements, to prove it is left out.
|
||||
await _add_task(db_session, opened["version_id"], 1, "Disegno", "drawing")
|
||||
second = await _add_task(db_session, opened["version_id"], 2, "Seconda misura")
|
||||
|
||||
body = (await client.get(
|
||||
"/api/production-runs/current",
|
||||
params={"station_code": station.code},
|
||||
headers=auth_headers(measurement_tec_user),
|
||||
)).json()
|
||||
assert body["measurement_task_ids"] == [first.id, second.id]
|
||||
|
||||
|
||||
async def test_cycle_closes_only_on_the_last_measurement_task(
|
||||
client: AsyncClient, measurement_tec_user, admin_user, db_session,
|
||||
):
|
||||
"""Restarting at the first would measure three times as often as configured."""
|
||||
station = await _station(db_session, admin_user.id, code="ST-MULTI")
|
||||
recipe = await _recipe_with_interval(db_session, admin_user.id, 10, code="REC-MULTI")
|
||||
opened = (await _open(client, measurement_tec_user, station, recipe)).json()
|
||||
run_id = opened["id"]
|
||||
first = await _only_task(db_session, opened["version_id"])
|
||||
second = await _add_task(db_session, opened["version_id"], 1, "Seconda misura")
|
||||
headers = auth_headers(measurement_tec_user)
|
||||
|
||||
# Four minutes of the interval have gone by when the first task is finished.
|
||||
await _advance_clock(db_session, run_id, timedelta(minutes=4))
|
||||
|
||||
mid = (await client.post(
|
||||
f"/api/production-runs/{run_id}/cycle", headers=headers, json={"task_id": first.id},
|
||||
)).json()
|
||||
assert mid["cycle_count"] == 0, "il ciclo non e' ancora finito"
|
||||
assert 5 * 60 <= mid["seconds_to_next_measurement"] <= 6 * 60, (
|
||||
"l'intervallo non deve ripartire a meta' ciclo"
|
||||
)
|
||||
|
||||
end = (await client.post(
|
||||
f"/api/production-runs/{run_id}/cycle", headers=headers, json={"task_id": second.id},
|
||||
)).json()
|
||||
assert end["cycle_count"] == 1
|
||||
assert 9 * 60 <= end["seconds_to_next_measurement"] <= 10 * 60
|
||||
|
||||
events = (await client.get(
|
||||
f"/api/production-runs/{run_id}", headers=headers,
|
||||
)).json()["events"]
|
||||
by_type = {e["event_type"]: e for e in events}
|
||||
assert by_type["task_measured"]["task_id"] == first.id
|
||||
assert by_type["cycle_completed"]["task_id"] == second.id
|
||||
|
||||
|
||||
async def test_cycle_without_a_task_closes_as_before(
|
||||
client: AsyncClient, measurement_tec_user, admin_user, db_session,
|
||||
):
|
||||
"""A caller that knows nothing of the sequence keeps the old behaviour."""
|
||||
station = await _station(db_session, admin_user.id, code="ST-PLAIN")
|
||||
recipe = await _recipe_with_interval(db_session, admin_user.id, 10, code="REC-PLAIN")
|
||||
opened = (await _open(client, measurement_tec_user, station, recipe)).json()
|
||||
await _add_task(db_session, opened["version_id"], 1, "Seconda misura")
|
||||
|
||||
body = (await client.post(
|
||||
f"/api/production-runs/{opened['id']}/cycle",
|
||||
headers=auth_headers(measurement_tec_user),
|
||||
)).json()
|
||||
assert body["cycle_count"] == 1
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Rimisura - turning the piece over
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
async def test_remeasure_does_not_buy_another_interval(
|
||||
client: AsyncClient, measurement_tec_user, admin_user, db_session,
|
||||
):
|
||||
"""A second reading of the same part is not a new cycle."""
|
||||
station = await _station(db_session, admin_user.id, code="ST-AGAIN")
|
||||
recipe = await _recipe_with_interval(db_session, admin_user.id, 10, code="REC-AGAIN")
|
||||
opened = (await _open(client, measurement_tec_user, station, recipe)).json()
|
||||
run_id = opened["id"]
|
||||
task = await _only_task(db_session, opened["version_id"])
|
||||
headers = auth_headers(measurement_tec_user)
|
||||
|
||||
await _advance_clock(db_session, run_id, timedelta(minutes=7))
|
||||
|
||||
body = (await client.post(
|
||||
f"/api/production-runs/{run_id}/remeasure", headers=headers,
|
||||
json={"task_id": task.id},
|
||||
)).json()
|
||||
assert body["cycle_count"] == 0
|
||||
assert 2 * 60 <= body["seconds_to_next_measurement"] <= 3 * 60, (
|
||||
"rigirare il pezzo non deve spostare la scadenza"
|
||||
)
|
||||
|
||||
events = (await client.get(
|
||||
f"/api/production-runs/{run_id}", headers=headers,
|
||||
)).json()["events"]
|
||||
remeasured = [e for e in events if e["event_type"] == "remeasure"]
|
||||
assert len(remeasured) == 1
|
||||
assert remeasured[0]["task_id"] == task.id
|
||||
|
||||
|
||||
async def test_remeasure_refused_while_the_line_is_stopped(
|
||||
client: AsyncClient, measurement_tec_user, admin_user, db_session,
|
||||
):
|
||||
station = await _station(db_session, admin_user.id, code="ST-AGPAUSE")
|
||||
recipe = await _recipe_with_interval(db_session, admin_user.id, 10, code="REC-AGPAUSE")
|
||||
run_id = (await _open(client, measurement_tec_user, station, recipe)).json()["id"]
|
||||
supervisor, password = await _supervisor(db_session, username="capo-again")
|
||||
|
||||
await client.post(
|
||||
f"/api/production-runs/{run_id}/pause",
|
||||
headers=auth_headers(measurement_tec_user),
|
||||
json={"supervisor_username": supervisor.username, "supervisor_password": password},
|
||||
)
|
||||
resp = await client.post(
|
||||
f"/api/production-runs/{run_id}/remeasure",
|
||||
headers=auth_headers(measurement_tec_user),
|
||||
)
|
||||
assert resp.status_code == 409
|
||||
|
||||
|
||||
async def test_overdue_run_reports_negative_seconds(
|
||||
client: AsyncClient, measurement_tec_user, admin_user, db_session,
|
||||
):
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
"""Tests for the explicit task type (point 2).
|
||||
|
||||
The type used to be deduced - quotes present meant a measurement - so a measurement
|
||||
task whose quotes had not been entered yet was treated as a note, and the system
|
||||
behaved differently depending on how complete the recipe was. These tests pin the
|
||||
type down as something declared and carried.
|
||||
"""
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
from sqlalchemy import select
|
||||
|
||||
from src.backend.models.orm.recipe import RecipeVersion
|
||||
from src.backend.models.orm.task import RecipeTask
|
||||
from src.backend.tests.conftest import auth_headers, create_test_recipe
|
||||
|
||||
|
||||
async def _current_version(db_session, recipe_id: int) -> RecipeVersion:
|
||||
row = await db_session.execute(
|
||||
select(RecipeVersion).where(
|
||||
RecipeVersion.recipe_id == recipe_id,
|
||||
RecipeVersion.is_current == True, # noqa: E712
|
||||
)
|
||||
)
|
||||
return row.scalar_one()
|
||||
|
||||
|
||||
async def test_task_defaults_to_note(client: AsyncClient, maker_user, db_session):
|
||||
recipe = await create_test_recipe(db_session, user_id=maker_user.id, code="REC-T1")
|
||||
await db_session.commit()
|
||||
|
||||
resp = await client.post(
|
||||
f"/api/recipes/{recipe.id}/tasks",
|
||||
headers=auth_headers(maker_user),
|
||||
json={"title": "Solo una nota"},
|
||||
)
|
||||
assert resp.status_code == 201, resp.text
|
||||
assert resp.json()["task_type"] == "note"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("declared", ["note", "measure", "drawing"])
|
||||
async def test_task_keeps_the_declared_type(
|
||||
client: AsyncClient, maker_user, db_session, declared,
|
||||
):
|
||||
recipe = await create_test_recipe(
|
||||
db_session, user_id=maker_user.id, code=f"REC-{declared}",
|
||||
)
|
||||
await db_session.commit()
|
||||
|
||||
resp = await client.post(
|
||||
f"/api/recipes/{recipe.id}/tasks",
|
||||
headers=auth_headers(maker_user),
|
||||
json={"title": f"Task {declared}", "task_type": declared},
|
||||
)
|
||||
assert resp.status_code == 201, resp.text
|
||||
assert resp.json()["task_type"] == declared
|
||||
|
||||
|
||||
async def test_measure_task_without_quotes_is_still_a_measure_task(
|
||||
client: AsyncClient, maker_user, db_session,
|
||||
):
|
||||
"""The criterion from the document: an unfinished recipe must not change kind."""
|
||||
recipe = await create_test_recipe(db_session, user_id=maker_user.id, code="REC-NOQ")
|
||||
await db_session.commit()
|
||||
|
||||
created = await client.post(
|
||||
f"/api/recipes/{recipe.id}/tasks",
|
||||
headers=auth_headers(maker_user),
|
||||
json={"title": "Misura da compilare", "task_type": "measure"},
|
||||
)
|
||||
task_id = created.json()["id"]
|
||||
|
||||
fetched = await client.get(f"/api/tasks/{task_id}", headers=auth_headers(maker_user))
|
||||
body = fetched.json()
|
||||
assert body["subtasks"] == [], "il task non ha ancora quote"
|
||||
assert body["task_type"] == "measure", "e resta comunque un task di misura"
|
||||
|
||||
|
||||
async def test_unknown_type_is_rejected(client: AsyncClient, maker_user, db_session):
|
||||
recipe = await create_test_recipe(db_session, user_id=maker_user.id, code="REC-BAD")
|
||||
await db_session.commit()
|
||||
|
||||
resp = await client.post(
|
||||
f"/api/recipes/{recipe.id}/tasks",
|
||||
headers=auth_headers(maker_user),
|
||||
json={"title": "x", "task_type": "qualcosa"},
|
||||
)
|
||||
assert resp.status_code == 422
|
||||
|
||||
|
||||
async def test_type_can_be_changed(client: AsyncClient, maker_user, db_session):
|
||||
recipe = await create_test_recipe(db_session, user_id=maker_user.id, code="REC-CHG")
|
||||
await db_session.commit()
|
||||
created = await client.post(
|
||||
f"/api/recipes/{recipe.id}/tasks",
|
||||
headers=auth_headers(maker_user),
|
||||
json={"title": "Nasce nota", "task_type": "note"},
|
||||
)
|
||||
task_id = created.json()["id"]
|
||||
|
||||
resp = await client.put(
|
||||
f"/api/tasks/{task_id}",
|
||||
headers=auth_headers(maker_user),
|
||||
json={"task_type": "measure"},
|
||||
)
|
||||
assert resp.status_code == 200, resp.text
|
||||
assert resp.json()["task_type"] == "measure"
|
||||
|
||||
|
||||
async def test_type_survives_copy_on_write_versioning(
|
||||
client: AsyncClient, maker_user, measurement_tec_user, db_session,
|
||||
):
|
||||
"""A new version must not silently reclassify every task of the recipe."""
|
||||
recipe = await create_test_recipe(db_session, user_id=maker_user.id, code="REC-COW")
|
||||
await db_session.commit()
|
||||
|
||||
version = await _current_version(db_session, recipe.id)
|
||||
row = await db_session.execute(
|
||||
select(RecipeTask).where(RecipeTask.version_id == version.id)
|
||||
)
|
||||
first_task = row.scalars().first()
|
||||
|
||||
# Declare it a drawing. The point is that this survives, not how it got set.
|
||||
await client.put(
|
||||
f"/api/tasks/{first_task.id}",
|
||||
headers=auth_headers(maker_user),
|
||||
json={"task_type": "drawing"},
|
||||
)
|
||||
|
||||
# Measure on the current version, which forces the next edit to copy-on-write.
|
||||
await client.post(
|
||||
"/api/measurements/",
|
||||
headers=auth_headers(measurement_tec_user),
|
||||
json={
|
||||
"subtask_id": first_task.subtasks[0].id,
|
||||
"version_id": version.id,
|
||||
"value": 10.0,
|
||||
},
|
||||
)
|
||||
|
||||
# Editing now must create a new version.
|
||||
await client.put(
|
||||
f"/api/recipes/{recipe.id}",
|
||||
headers=auth_headers(maker_user),
|
||||
json={"name": "Rinominata"},
|
||||
)
|
||||
|
||||
new_version = await _current_version(db_session, recipe.id)
|
||||
assert new_version.id != version.id, "l'edit doveva creare una nuova versione"
|
||||
|
||||
copied = await db_session.execute(
|
||||
select(RecipeTask).where(RecipeTask.version_id == new_version.id)
|
||||
)
|
||||
types = sorted(t.task_type for t in copied.scalars().all())
|
||||
assert "drawing" in types, "il tipo dichiarato non e' sopravvissuto alla copia"
|
||||
|
||||
|
||||
async def test_task_list_exposes_the_type(client: AsyncClient, maker_user, db_session):
|
||||
"""The operator's task list reads the type, so it must come over the wire."""
|
||||
recipe = await create_test_recipe(db_session, user_id=maker_user.id, code="REC-LST")
|
||||
await db_session.commit()
|
||||
await client.post(
|
||||
f"/api/recipes/{recipe.id}/tasks",
|
||||
headers=auth_headers(maker_user),
|
||||
json={"title": "Misura", "task_type": "measure"},
|
||||
)
|
||||
|
||||
resp = await client.get(
|
||||
f"/api/recipes/{recipe.id}/tasks", headers=auth_headers(maker_user),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert all("task_type" in t for t in resp.json())
|
||||
@@ -470,10 +470,30 @@ def api_start_production():
|
||||
@login_required
|
||||
@role_required("MeasurementTec")
|
||||
def api_complete_cycle(run_id: int):
|
||||
"""Proxy: record a finished measurement cycle and restart the interval."""
|
||||
"""Proxy: record a finished measurement task.
|
||||
|
||||
The task travels with the call: only the last measurement task of the recipe
|
||||
closes the cycle and restarts the interval, and the server is what decides.
|
||||
"""
|
||||
data = request.get_json(silent=True) or {}
|
||||
resp = api_client.post(
|
||||
f"/api/production-runs/{run_id}/cycle", data={"note": data.get("note")},
|
||||
f"/api/production-runs/{run_id}/cycle",
|
||||
data={"task_id": data.get("task_id"), "note": data.get("note")},
|
||||
)
|
||||
if isinstance(resp, dict) and resp.get("error"):
|
||||
return jsonify(resp), resp.get("status_code", 500)
|
||||
return jsonify(resp), 200
|
||||
|
||||
|
||||
@measure_bp.route("/api/production/<int:run_id>/remeasure", methods=["POST"])
|
||||
@login_required
|
||||
@role_required("MeasurementTec")
|
||||
def api_remeasure(run_id: int):
|
||||
"""Proxy: the piece was turned over - measure again inside the same cycle."""
|
||||
data = request.get_json(silent=True) or {}
|
||||
resp = api_client.post(
|
||||
f"/api/production-runs/{run_id}/remeasure",
|
||||
data={"task_id": data.get("task_id"), "note": data.get("note")},
|
||||
)
|
||||
if isinstance(resp, dict) and resp.get("error"):
|
||||
return jsonify(resp), resp.get("status_code", 500)
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
* The measurement clock, shared by every screen an operator can be on.
|
||||
*
|
||||
* Two things the shop floor asked for live here. First, the countdown does not stop
|
||||
* at zero: it keeps going the other way, so how late a measurement is can be read
|
||||
* off the screen instead of worked out. Second, when the interval expires the
|
||||
* measurement comes back on its own, wherever the operator happens to be - the task
|
||||
* list, the summary, the recipe picker.
|
||||
*
|
||||
* The number always comes from the server (seconds_to_next_measurement, already
|
||||
* signed). Ticking locally only keeps the display smooth between round trips, and
|
||||
* every resync overwrites it: a tab that was asleep, or a machine whose clock is
|
||||
* off, still shows the same figure as the station next to it.
|
||||
*
|
||||
* ProductionClock holds the pure parts, used here and by the measurement screen,
|
||||
* which has its own component but must not grow a second copy of these rules.
|
||||
*/
|
||||
(function (global) {
|
||||
'use strict';
|
||||
|
||||
var ProductionClock = {
|
||||
/* mm:ss of the distance from the deadline, in whichever direction. The sign is
|
||||
carried by the wording around it ("tra" / "in ritardo di"), not by a minus. */
|
||||
format: function (seconds) {
|
||||
var total = Math.abs(Math.round(seconds || 0));
|
||||
var m = Math.floor(total / 60);
|
||||
var s = total % 60;
|
||||
return (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s;
|
||||
},
|
||||
|
||||
hasClock: function (seconds) {
|
||||
return seconds !== null && seconds !== undefined;
|
||||
},
|
||||
|
||||
isOverdue: function (seconds) {
|
||||
return ProductionClock.hasClock(seconds) && seconds <= 0;
|
||||
},
|
||||
|
||||
/* Three short beeps. Wrapped because a browser refuses to make noise before the
|
||||
page has been touched, and a silent buzzer must not take the screen with it.
|
||||
Whether a light column replaces this is question D-5. */
|
||||
playBuzzer: function () {
|
||||
try {
|
||||
var ctx = new (global.AudioContext || global.webkitAudioContext)();
|
||||
[0, 0.25, 0.5].forEach(function (delay) {
|
||||
var osc = ctx.createOscillator();
|
||||
var gain = ctx.createGain();
|
||||
osc.connect(gain);
|
||||
gain.connect(ctx.destination);
|
||||
osc.frequency.value = 880;
|
||||
osc.type = 'square';
|
||||
gain.gain.value = 0.3;
|
||||
osc.start(ctx.currentTime + delay);
|
||||
osc.stop(ctx.currentTime + delay + 0.15);
|
||||
});
|
||||
} catch (_) {}
|
||||
},
|
||||
|
||||
/* The task the operator has to be taken back to: the first measurement task of
|
||||
the recipe. Null when the recipe has none, which is the whole reason this is
|
||||
a lookup and not an assumption. */
|
||||
measurementUrl: function (run, executeUrlTemplate) {
|
||||
var ids = (run && run.measurement_task_ids) || [];
|
||||
if (!ids.length) return null;
|
||||
return executeUrlTemplate.replace('/0', '/' + ids[0]);
|
||||
},
|
||||
};
|
||||
|
||||
global.ProductionClock = ProductionClock;
|
||||
|
||||
/* How long the operator gets to see why the screen is about to change. Long
|
||||
enough to read it, short enough that it is not a way of putting the
|
||||
measurement off. */
|
||||
var ANNOUNCE_SECONDS = 5;
|
||||
/* The server is asked again on this cadence: the run may have been stopped or
|
||||
closed from another screen, and a sleeping tab drifts. */
|
||||
var RESYNC_MS = 60000;
|
||||
|
||||
/**
|
||||
* Banner component for the screens that only watch the clock.
|
||||
*
|
||||
* options.currentUrl - endpoint returning the run open at this station, or null
|
||||
* options.executeUrl - url of a task execution page with 0 as the task id
|
||||
*/
|
||||
global.productionClock = function (options) {
|
||||
var opts = options || {};
|
||||
|
||||
return {
|
||||
run: null,
|
||||
seconds: null,
|
||||
announced: false,
|
||||
redirectIn: 0,
|
||||
_tick: null,
|
||||
_resync: null,
|
||||
|
||||
init: function () {
|
||||
var self = this;
|
||||
this.load();
|
||||
this._tick = setInterval(function () { self.onSecond(); }, 1000);
|
||||
this._resync = setInterval(function () { self.load(); }, RESYNC_MS);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
if (this._tick) clearInterval(this._tick);
|
||||
if (this._resync) clearInterval(this._resync);
|
||||
},
|
||||
|
||||
load: async function () {
|
||||
try {
|
||||
var resp = await fetch(opts.currentUrl);
|
||||
if (!resp.ok) return;
|
||||
var run = await resp.json();
|
||||
this.adopt(run && run.id ? run : null);
|
||||
} catch (e) {
|
||||
// Offline or server down: the page stays usable, just without the clock.
|
||||
}
|
||||
},
|
||||
|
||||
adopt: function (run) {
|
||||
this.run = run;
|
||||
this.seconds = run ? run.seconds_to_next_measurement : null;
|
||||
if (!run || run.status !== 'running') {
|
||||
// Closed or stopped: nothing is due, and an announcement left on screen
|
||||
// would be telling the operator to go and measure a stopped line.
|
||||
this.announced = false;
|
||||
this.redirectIn = 0;
|
||||
return;
|
||||
}
|
||||
// Arriving on a page that is already late is the same event as going late
|
||||
// while sitting on it.
|
||||
if (this.isDue) this.announce();
|
||||
},
|
||||
|
||||
get running() { return !!this.run && this.run.status === 'running'; },
|
||||
get paused() { return !!this.run && this.run.status === 'paused'; },
|
||||
get visible() {
|
||||
return !!this.run && ProductionClock.hasClock(this.seconds);
|
||||
},
|
||||
get isDue() { return this.running && ProductionClock.isOverdue(this.seconds); },
|
||||
get display() { return ProductionClock.format(this.seconds); },
|
||||
get measurementUrl() {
|
||||
return ProductionClock.measurementUrl(this.run, opts.executeUrl || '');
|
||||
},
|
||||
|
||||
onSecond: function () {
|
||||
var wasAnnounced = this.announced;
|
||||
|
||||
if (this.running && ProductionClock.hasClock(this.seconds)) {
|
||||
// Past zero it keeps counting, into the negative: that is the figure the
|
||||
// operator reads as "how long I am late by".
|
||||
this.seconds--;
|
||||
if (this.seconds <= 0) this.announce();
|
||||
}
|
||||
|
||||
if (wasAnnounced && this.redirectIn > 0) {
|
||||
this.redirectIn--;
|
||||
if (this.redirectIn === 0) this.goToMeasurement();
|
||||
}
|
||||
},
|
||||
|
||||
announce: function () {
|
||||
if (this.announced) return;
|
||||
this.announced = true;
|
||||
ProductionClock.playBuzzer();
|
||||
// Without a measurement task to go to there is nothing to announce beyond
|
||||
// the banner going red, and a redirect to nowhere would be a broken link.
|
||||
this.redirectIn = this.measurementUrl ? ANNOUNCE_SECONDS : 0;
|
||||
},
|
||||
|
||||
goToMeasurement: function () {
|
||||
var url = this.measurementUrl;
|
||||
if (url) global.location.href = url;
|
||||
},
|
||||
};
|
||||
};
|
||||
})(window);
|
||||
@@ -0,0 +1,108 @@
|
||||
{#
|
||||
The measurement clock, for every screen that is not the measurement itself.
|
||||
|
||||
Two requirements of 28/07 are in here. The countdown is always on screen while a
|
||||
production is open, and past zero it turns round and shows how long the line has
|
||||
been over the interval - in red, because a late measurement that looks like an
|
||||
early one is how it stays late. And when the interval expires the measurement
|
||||
comes back on its own: the operator is told, and taken there.
|
||||
|
||||
The measurement screen has its own component and does not include this: being
|
||||
already on the measurement is the one place there is nothing to announce.
|
||||
#}
|
||||
<script src="{{ url_for('static', filename='js/production-clock.js') }}"></script>
|
||||
|
||||
<div x-data="productionClock({
|
||||
currentUrl: '{{ url_for('measure.api_current_production') }}',
|
||||
executeUrl: '{{ url_for('measure.task_execute', task_id=0) }}'
|
||||
})"
|
||||
x-init="init()"
|
||||
x-cloak>
|
||||
|
||||
{# ---- Countdown bar: sticky, so scrolling never hides it ---- #}
|
||||
<div x-show="visible"
|
||||
x-transition
|
||||
class="sticky top-0 z-30 -mx-4 sm:-mx-6 lg:-mx-8 mb-4 px-4 py-2 border-b shadow-sm"
|
||||
:class="isDue
|
||||
? 'bg-red-50 dark:bg-red-900/30 border-red-400 dark:border-red-700'
|
||||
: paused
|
||||
? 'bg-amber-100 dark:bg-amber-900/40 border-amber-500'
|
||||
: 'bg-amber-50 dark:bg-amber-900/20 border-amber-300 dark:border-amber-700'">
|
||||
<div class="flex flex-wrap items-center justify-center gap-x-3 gap-y-1">
|
||||
|
||||
<svg class="w-5 h-5 shrink-0"
|
||||
:class="isDue ? 'text-red-600 animate-pulse' : 'text-amber-600'"
|
||||
fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||
</svg>
|
||||
|
||||
{# In time #}
|
||||
<template x-if="!isDue && !paused">
|
||||
<span class="text-sm font-medium text-amber-800 dark:text-amber-200">
|
||||
{{ _('Prossima misurazione tra') }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
{# Over the interval: the delay is the headline, not a footnote #}
|
||||
<template x-if="isDue">
|
||||
<span class="text-sm font-bold text-red-800 dark:text-red-200">
|
||||
{{ _('Misurazione in ritardo di') }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
{# Line stopped: the figure is frozen, and says so. Frozen past the interval
|
||||
it is a delay held in place, not a wait - the wording has to say which. #}
|
||||
<template x-if="paused && seconds > 0">
|
||||
<span class="text-sm font-semibold text-amber-900 dark:text-amber-100">
|
||||
{{ _('Linea ferma — conto alla rovescia congelato a') }}
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="paused && seconds <= 0">
|
||||
<span class="text-sm font-semibold text-amber-900 dark:text-amber-100">
|
||||
{{ _('Linea ferma') }} — {{ _('Misurazione in ritardo di') }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<span class="text-lg font-bold font-mono px-2 py-0.5 rounded"
|
||||
:class="isDue
|
||||
? 'text-red-900 dark:text-red-100 bg-red-100 dark:bg-red-900/40'
|
||||
: 'text-amber-900 dark:text-amber-100 bg-amber-100 dark:bg-amber-900/40'"
|
||||
x-text="display"></span>
|
||||
|
||||
<span class="text-xs"
|
||||
:class="isDue ? 'text-red-600 dark:text-red-300' : 'text-amber-600 dark:text-amber-400'">
|
||||
({{ _('Ciclo') }} #<span x-text="run ? run.cycle_count : 0"></span>)
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ---- Time to measure: announced, then taken there ---- #}
|
||||
<div x-show="announced && redirectIn > 0"
|
||||
x-transition
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
|
||||
<div class="bg-[var(--bg-card)] rounded-2xl shadow-2xl p-8 max-w-sm mx-4 text-center border-2 border-red-500">
|
||||
|
||||
<div class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-red-100 dark:bg-red-900/30 mb-4">
|
||||
<svg class="w-8 h-8 text-red-600 animate-pulse" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<h3 class="text-lg font-bold text-[var(--text-primary)] mb-1">
|
||||
{{ _('È ora di misurare') }}
|
||||
</h3>
|
||||
<p class="text-sm text-[var(--text-secondary)] mb-5">
|
||||
{{ _('Ritorno alla misurazione tra') }}
|
||||
<span class="font-bold font-mono" x-text="redirectIn"></span> s
|
||||
</p>
|
||||
|
||||
<button @click="goToMeasurement()"
|
||||
class="btn w-full justify-center gap-2 bg-red-600 hover:bg-red-700 text-white font-bold py-2.5">
|
||||
{{ _('Vai alla misura') }}
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -270,6 +270,18 @@
|
||||
class="tmf-input"
|
||||
placeholder="{{ _('Es. Controllo dimensionale flangia') }}">
|
||||
</div>
|
||||
<!-- Tipo: dichiarato qui, non dedotto dal contenuto -->
|
||||
<div>
|
||||
<label class="tmf-label">{{ _('Tipo') }} <span class="text-red-500">*</span></label>
|
||||
<select x-model="newTask.task_type" class="tmf-input">
|
||||
<option value="note">{{ _('Nota') }}</option>
|
||||
<option value="measure">{{ _('Misura') }}</option>
|
||||
<option value="drawing">{{ _('Disegno') }}</option>
|
||||
</select>
|
||||
<p class="mt-1 text-xs text-[var(--text-secondary)]">
|
||||
{{ _('Un task di misura resta tale anche prima di inserire le quote') }}
|
||||
</p>
|
||||
</div>
|
||||
<!-- Direttiva -->
|
||||
<div>
|
||||
<label class="tmf-label">{{ _('Direttiva') }}</label>
|
||||
@@ -516,6 +528,14 @@
|
||||
<!-- Edit Task Extra Fields (when in edit mode) -->
|
||||
<template x-if="editingTask === task.id">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 p-3 rounded-lg bg-blue-50 dark:bg-blue-900/10 border border-blue-200 dark:border-blue-800">
|
||||
<div>
|
||||
<label class="tmf-label">{{ _('Tipo') }}</label>
|
||||
<select x-model="editTaskData.task_type" class="tmf-input text-sm">
|
||||
<option value="note">{{ _('Nota') }}</option>
|
||||
<option value="measure">{{ _('Misura') }}</option>
|
||||
<option value="drawing">{{ _('Disegno') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="tmf-label">{{ _('Direttiva') }}</label>
|
||||
<input type="text"
|
||||
@@ -1084,8 +1104,8 @@ function taskEditor() {
|
||||
|
||||
// ---- Task CRUD state ----
|
||||
editingTask: null,
|
||||
editTaskData: { title: '', directive: '', description: '' },
|
||||
newTask: { title: '', directive: '', description: '' },
|
||||
editTaskData: { title: '', directive: '', description: '', task_type: 'note' },
|
||||
newTask: { title: '', directive: '', description: '', task_type: 'note' },
|
||||
|
||||
// ---- Subtask CRUD state ----
|
||||
editingSubtaskId: null,
|
||||
@@ -1207,7 +1227,7 @@ function taskEditor() {
|
||||
// ============================================================
|
||||
|
||||
resetNewTask() {
|
||||
this.newTask = { title: '', directive: '', description: '' };
|
||||
this.newTask = { title: '', directive: '', description: '', task_type: 'note' };
|
||||
},
|
||||
|
||||
// ============================================================
|
||||
@@ -1298,6 +1318,7 @@ function taskEditor() {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title: this.newTask.title.trim(),
|
||||
task_type: this.newTask.task_type || 'note',
|
||||
directive: this.newTask.directive.trim() || null,
|
||||
description: this.newTask.description.trim() || null
|
||||
})
|
||||
@@ -1328,6 +1349,7 @@ function taskEditor() {
|
||||
this.editingTask = task.id;
|
||||
this.editTaskData = {
|
||||
title: task.title,
|
||||
task_type: task.task_type || 'note',
|
||||
directive: task.directive || '',
|
||||
description: task.description || ''
|
||||
};
|
||||
@@ -1337,7 +1359,7 @@ function taskEditor() {
|
||||
|
||||
cancelEditTask() {
|
||||
this.editingTask = null;
|
||||
this.editTaskData = { title: '', directive: '', description: '' };
|
||||
this.editTaskData = { title: '', directive: '', description: '', task_type: 'note' };
|
||||
},
|
||||
|
||||
async updateTask(taskId) {
|
||||
@@ -1354,6 +1376,7 @@ function taskEditor() {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title: this.editTaskData.title.trim(),
|
||||
task_type: this.editTaskData.task_type || 'note',
|
||||
directive: this.editTaskData.directive.trim() || null,
|
||||
description: this.editTaskData.description.trim() || null
|
||||
})
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
}
|
||||
}">
|
||||
|
||||
{# A production open at this station keeps its clock on screen even here: the
|
||||
interval runs whether or not the operator is looking at the measurement. #}
|
||||
{% include "components/production_clock.html" %}
|
||||
|
||||
<!-- Page Header -->
|
||||
<div class="mb-8">
|
||||
<div class="flex items-center justify-between flex-wrap gap-4">
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
|
||||
{# The summary is where an operator lingers: the clock has to be here as well. #}
|
||||
{% include "components/production_clock.html" %}
|
||||
|
||||
<!-- Breadcrumb -->
|
||||
<nav class="mb-6" aria-label="Breadcrumb">
|
||||
<ol class="flex items-center gap-2 text-sm text-[var(--text-secondary)]">
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
</div>
|
||||
|
||||
{# Fermo linea + Fine produzione (measurement tasks only) #}
|
||||
<template x-if="subtasks.length > 0">
|
||||
<template x-if="isMeasureTask">
|
||||
<div class="shrink-0 flex items-center gap-1.5">
|
||||
{# While the line is stopped this becomes the way to restart it, so the
|
||||
capoturno never has to hunt for a second control. #}
|
||||
@@ -182,7 +182,7 @@
|
||||
{# ──────────────────────────────────────────────
|
||||
LEFT SIDEBAR — Marker list (vertical, hidden when no subtasks)
|
||||
────────────────────────────────────────────── #}
|
||||
<div x-show="subtasks.length > 0"
|
||||
<div x-show="isMeasureTask && subtasks.length > 0"
|
||||
class="shrink-0 w-14 md:w-16 bg-[var(--bg-card)] border-r border-[var(--border-color)] flex flex-col sidebar-markers overflow-y-auto">
|
||||
<template x-for="(st, idx) in subtasks" :key="st.id">
|
||||
<button @click="goToSubtask(idx)"
|
||||
@@ -272,7 +272,7 @@
|
||||
{# ──────────────────────────────────────────────
|
||||
RIGHT PANEL — Info + tolerances + numpad (hidden when no subtasks)
|
||||
────────────────────────────────────────────── #}
|
||||
<div x-show="subtasks.length > 0"
|
||||
<div x-show="isMeasureTask && subtasks.length > 0"
|
||||
class="shrink-0 w-72 lg:w-80 bg-[var(--bg-card)] border-l border-[var(--border-color)] flex flex-col right-panel overflow-y-auto">
|
||||
|
||||
{# ---- Subtask header ---- #}
|
||||
@@ -420,25 +420,58 @@
|
||||
{# ================================================================
|
||||
MEASUREMENT TIMER BANNER
|
||||
================================================================ #}
|
||||
{# Past zero the counter turns round: it stops saying how long is left and starts
|
||||
saying how late the line is, in red. A delay has to be read, not deduced. #}
|
||||
<div x-show="timerActive"
|
||||
x-transition
|
||||
x-cloak
|
||||
class="shrink-0 bg-amber-50 dark:bg-amber-900/20 border-t border-amber-300 dark:border-amber-700 px-4 py-2">
|
||||
class="shrink-0 border-t px-4 py-2"
|
||||
:class="isOverdue
|
||||
? 'bg-red-50 dark:bg-red-900/30 border-red-400 dark:border-red-700'
|
||||
: 'bg-amber-50 dark:bg-amber-900/20 border-amber-300 dark:border-amber-700'">
|
||||
<div class="flex items-center justify-center gap-3">
|
||||
<svg class="w-5 h-5 text-amber-600 animate-pulse" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<svg class="w-5 h-5 animate-pulse"
|
||||
:class="isOverdue ? 'text-red-600' : 'text-amber-600'"
|
||||
fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||
</svg>
|
||||
<span class="text-sm font-medium text-amber-800 dark:text-amber-200">
|
||||
<span x-show="!isOverdue" class="text-sm font-medium text-amber-800 dark:text-amber-200">
|
||||
{{ _('Prossima misurazione tra') }}
|
||||
</span>
|
||||
<span class="text-lg font-bold font-mono text-amber-900 dark:text-amber-100 bg-amber-100 dark:bg-amber-900/40 px-2 py-0.5 rounded"
|
||||
<span x-show="isOverdue" class="text-sm font-bold text-red-800 dark:text-red-200">
|
||||
{{ _('Misurazione in ritardo di') }}
|
||||
</span>
|
||||
<span class="text-lg font-bold font-mono px-2 py-0.5 rounded"
|
||||
:class="isOverdue
|
||||
? 'text-red-900 dark:text-red-100 bg-red-100 dark:bg-red-900/40'
|
||||
: 'text-amber-900 dark:text-amber-100 bg-amber-100 dark:bg-amber-900/40'"
|
||||
x-text="timerDisplay"></span>
|
||||
<span class="text-xs text-amber-600 dark:text-amber-400">
|
||||
<span class="text-xs"
|
||||
:class="isOverdue ? 'text-red-600 dark:text-red-300' : 'text-amber-600 dark:text-amber-400'">
|
||||
({{ _('Ciclo') }} #<span x-text="cycleCount"></span>)
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ================================================================
|
||||
MISURA SENZA QUOTE — declared a measurement task but none configured yet.
|
||||
Under the old rule this screen quietly looked like a note; now the task keeps
|
||||
its identity and says what is missing instead.
|
||||
================================================================ #}
|
||||
<div x-show="isMeasureTaskWithoutQuotes"
|
||||
x-transition
|
||||
x-cloak
|
||||
class="shrink-0 bg-amber-50 dark:bg-amber-900/20 border-t border-amber-300 dark:border-amber-700 px-4 py-2">
|
||||
<div class="flex items-center justify-center gap-2">
|
||||
<svg class="w-4 h-4 text-amber-600 shrink-0" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"/>
|
||||
</svg>
|
||||
<span class="text-sm text-amber-800 dark:text-amber-200">
|
||||
{{ _('Task di misura senza quote configurate: la ricetta è incompleta') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ================================================================
|
||||
LINEA FERMA — the countdown is frozen, not merely hidden. Stated plainly
|
||||
because a stopped line that looks like a running one is how a measurement
|
||||
@@ -455,8 +488,11 @@
|
||||
<span class="text-sm font-semibold text-amber-900 dark:text-amber-100">
|
||||
{{ _('Linea ferma') }}
|
||||
</span>
|
||||
{# A line stopped past its interval is frozen at a delay, not at a wait. Both
|
||||
read as mm:ss, so the wording is what has to change. #}
|
||||
<span class="text-xs text-amber-800 dark:text-amber-200">
|
||||
{{ _('Il conto alla rovescia è congelato a') }}
|
||||
<span x-show="timerRemaining > 0">{{ _('Il conto alla rovescia è congelato a') }}</span>
|
||||
<span x-show="timerRemaining <= 0">{{ _('Misurazione in ritardo di') }}</span>
|
||||
<span class="font-mono font-bold" x-text="timerDisplay"></span>
|
||||
— {{ _('serve il capoturno per riprendere') }}
|
||||
</span>
|
||||
@@ -486,7 +522,7 @@
|
||||
{# ================================================================
|
||||
AVVIO PRODUZIONE — visible after first cycle, before production started
|
||||
================================================================ #}
|
||||
<div x-show="cycleConfirmed && cycleCount === 1 && !productionStarted && subtasks.length > 0"
|
||||
<div x-show="cycleConfirmed && cycleCount === 1 && !productionStarted && isMeasureTask"
|
||||
x-transition
|
||||
x-cloak
|
||||
class="shrink-0 border-t border-[var(--border-color)] bg-[var(--bg-card)] px-4 py-3">
|
||||
@@ -505,7 +541,7 @@
|
||||
{{ _('Invia segnale al gestionale per avviare il timer della linea') }}
|
||||
</p>
|
||||
</div>
|
||||
<div x-show="productionStarted && subtasks.length > 0"
|
||||
<div x-show="productionStarted && isMeasureTask"
|
||||
x-transition
|
||||
x-cloak
|
||||
class="shrink-0 border-t border-emerald-200 dark:border-emerald-800 bg-emerald-50 dark:bg-emerald-900/20 px-4 py-1.5">
|
||||
@@ -548,7 +584,7 @@
|
||||
</div>
|
||||
|
||||
{# Right: Fine ciclo misura (measurement tasks) / Completato (non-measurement or after cycle) #}
|
||||
<template x-if="subtasks.length > 0">
|
||||
<template x-if="isMeasureTask && subtasks.length > 0">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<button x-show="isComplete && !cycleConfirmed"
|
||||
x-transition
|
||||
@@ -560,6 +596,17 @@
|
||||
</svg>
|
||||
{{ _('Fine ciclo misura') }}
|
||||
</button>
|
||||
{# Girare il pezzo e rimisurare, senza chiudere il ciclo: a second reading
|
||||
of the same part is not a new one, and must not restart the interval. #}
|
||||
<button x-show="isComplete && productionStarted"
|
||||
x-transition
|
||||
@click="remeasure()"
|
||||
class="btn btn-secondary text-xs shrink-0 gap-1 py-1.5 px-3">
|
||||
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992V4.356M3.977 14.652H8.97v4.992m10.058-9.348a8.25 8.25 0 00-14.02-3.34L3.977 9.348m0 5.304a8.25 8.25 0 0014.02 3.34l1.03-1.03"/>
|
||||
</svg>
|
||||
{{ _('Rimisura') }}
|
||||
</button>
|
||||
<button x-show="cycleConfirmed"
|
||||
x-transition
|
||||
@click="goToNextTask()"
|
||||
@@ -575,7 +622,7 @@
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<template x-if="subtasks.length === 0">
|
||||
<template x-if="!isMeasureTask || subtasks.length === 0">
|
||||
<button @click="goToNextTask()"
|
||||
class="btn text-xs shrink-0 gap-1 py-1.5 px-3 shadow-md
|
||||
bg-measure-pass text-white hover:opacity-90">
|
||||
@@ -591,6 +638,37 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ================================================================
|
||||
È ORA DI MISURARE — the interval expired on a task that is not the
|
||||
measurement. The operator is told why the screen is about to change, then
|
||||
taken there; there is no way to dismiss it, because putting the measurement
|
||||
off is exactly what the interval exists to prevent.
|
||||
================================================================ #}
|
||||
<div x-show="announcedRedirect"
|
||||
x-transition
|
||||
x-cloak
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
|
||||
<div class="bg-[var(--bg-card)] rounded-2xl shadow-2xl p-8 max-w-sm mx-4 text-center border-2 border-red-500">
|
||||
<div class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-red-100 dark:bg-red-900/30 mb-4">
|
||||
<svg class="w-8 h-8 text-red-600 animate-pulse" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="text-lg font-bold text-[var(--text-primary)] mb-1">{{ _('È ora di misurare') }}</h3>
|
||||
<p class="text-sm text-[var(--text-secondary)] mb-5">
|
||||
{{ _('Ritorno alla misurazione tra') }}
|
||||
<span class="font-bold font-mono" x-text="redirectIn"></span> s
|
||||
</p>
|
||||
<button @click="goToMeasurementTask()"
|
||||
class="btn w-full justify-center gap-2 bg-red-600 hover:bg-red-700 text-white font-bold py-2.5">
|
||||
{{ _('Vai alla misura') }}
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ================================================================
|
||||
COMPLETION OVERLAY
|
||||
================================================================ #}
|
||||
@@ -640,9 +718,10 @@
|
||||
{{ _('Riepilogo') }}
|
||||
</button>
|
||||
|
||||
{# Production phase: confirm the cycle (starts the interval timer) #}
|
||||
{# Production phase: confirm the cycle. Goes through confirmCycle so the
|
||||
server records it - setting the flag here only looked like it had. #}
|
||||
<button x-show="productionStarted"
|
||||
@click="showCompletionOverlay = false; cycleConfirmed = true"
|
||||
@click="confirmCycle()"
|
||||
class="btn btn-primary flex-1 justify-center gap-2">
|
||||
{{ _('Conferma ciclo') }}
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
@@ -670,6 +749,18 @@
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{# The piece can be turned over here, where the operator actually is when the
|
||||
quotes are done - not only from the bar behind the overlay. #}
|
||||
<button x-show="productionStarted"
|
||||
@click="remeasure()"
|
||||
class="mt-3 w-full text-sm text-[var(--text-secondary)] hover:text-primary
|
||||
inline-flex items-center justify-center gap-1.5 py-1">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992V4.356M3.977 14.652H8.97v4.992m10.058-9.348a8.25 8.25 0 00-14.02-3.34L3.977 9.348m0 5.304a8.25 8.25 0 0014.02 3.34l1.03-1.03"/>
|
||||
</svg>
|
||||
{{ _('Girare il pezzo e rimisurare') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -742,6 +833,9 @@
|
||||
<script src="{{ url_for('static', filename='js/numpad.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/annotation-viewer.js') }}?v=6"></script>
|
||||
<script src="{{ url_for('static', filename='js/caliper.js') }}"></script>
|
||||
{# The clock's rules - how a delay reads, when the buzzer goes, where the
|
||||
measurement lives - are shared with the other screens rather than restated. #}
|
||||
<script src="{{ url_for('static', filename='js/production-clock.js') }}"></script>
|
||||
|
||||
<script>
|
||||
/**
|
||||
@@ -778,6 +872,13 @@ function taskExecute() {
|
||||
// This is read back from the server on every load instead.
|
||||
productionRun: null,
|
||||
productionError: '',
|
||||
// The measurement tasks of this recipe, in order: the loop the operator stays
|
||||
// in once production starts, and what says which task closes a cycle.
|
||||
measurementTaskIds: [],
|
||||
// The interval has elapsed and it has been said out loud - buzzer, and the
|
||||
// operator on their way back to the measurement. Kept so it is said once.
|
||||
dueAnnounced: false,
|
||||
redirectIn: 0,
|
||||
|
||||
// ---- Cycle & workflow state ----
|
||||
cycleConfirmed: false,
|
||||
@@ -898,6 +999,7 @@ function taskExecute() {
|
||||
this.productionRun = run;
|
||||
this.productionStarted = run.status !== 'closed';
|
||||
this.cycleCount = run.cycle_count;
|
||||
this.measurementTaskIds = run.measurement_task_ids || [];
|
||||
|
||||
const seconds = run.seconds_to_next_measurement;
|
||||
if (seconds === null || seconds === undefined) {
|
||||
@@ -1059,17 +1161,26 @@ function taskExecute() {
|
||||
},
|
||||
|
||||
// ---- Confirm measurement cycle (Fine ciclo misura) ----
|
||||
/* A cycle spans every measurement task of the recipe, so this one only closes
|
||||
it if it is the last. The server decides that - it knows the sequence - and
|
||||
the cycle count coming back tells us which of the two happened. */
|
||||
async confirmCycle() {
|
||||
this.cycleConfirmed = true;
|
||||
this.showCompletionOverlay = false;
|
||||
|
||||
// Recorded server-side so the count and the next deadline outlive this page.
|
||||
if (this.productionRun) {
|
||||
const countBefore = this.cycleCount;
|
||||
const run = await this.postProduction(
|
||||
'{{ url_for("measure.api_complete_cycle", run_id=0) }}'.replace('/0/', '/' + this.productionRun.id + '/'),
|
||||
{ task_id: this.task.id },
|
||||
);
|
||||
if (run) {
|
||||
this.adoptProductionRun(run);
|
||||
// Cycle still open: on to the next measurement task, interval untouched.
|
||||
if (run.cycle_count === countBefore && this.nextMeasurementTaskId) {
|
||||
this.goToTask(this.nextMeasurementTaskId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1082,6 +1193,25 @@ function taskExecute() {
|
||||
}
|
||||
},
|
||||
|
||||
/* Rimisura: turn the piece over and measure it again, inside the same cycle.
|
||||
|
||||
Not a new cycle - the deadline and the count stay where they are, so a second
|
||||
reading of the same part does not buy another interval's worth of time. Both
|
||||
readings stay in the statistics: that is what they are for. */
|
||||
async remeasure() {
|
||||
if (this.productionRun) {
|
||||
const run = await this.postProduction(
|
||||
'{{ url_for("measure.api_remeasure", run_id=0) }}'.replace('/0/', '/' + this.productionRun.id + '/'),
|
||||
{ task_id: this.task.id },
|
||||
);
|
||||
// Refused - the line is stopped, or the production is closed. The screen
|
||||
// stays as it is: clearing it would hide the reason.
|
||||
if (!run) return;
|
||||
this.adoptProductionRun(run);
|
||||
}
|
||||
this.resetForNewCycle();
|
||||
},
|
||||
|
||||
/* POST to a production endpoint, returning the updated run or null on failure. */
|
||||
async postProduction(url, body) {
|
||||
this.productionError = '';
|
||||
@@ -1106,18 +1236,34 @@ function taskExecute() {
|
||||
|
||||
// ---- Measurement timer ----
|
||||
/* Ticks locally for a smooth display, but the number it starts from always comes
|
||||
from the server, and every page load resynchronises it. */
|
||||
from the server, and every page load resynchronises it.
|
||||
It does not stop at zero: past the deadline it keeps counting the other way,
|
||||
and the banner reads the delay off it. */
|
||||
startCountdownFrom(seconds) {
|
||||
this.stopMeasurementTimer();
|
||||
this.timerRemaining = seconds;
|
||||
this.timerActive = true;
|
||||
// Landing on a page that is already late is the same event as going late
|
||||
// while sitting on it; being back in time re-arms the announcement.
|
||||
if (seconds <= 0) {
|
||||
this.onMeasurementDue();
|
||||
} else {
|
||||
this.dueAnnounced = false;
|
||||
this.redirectIn = 0;
|
||||
}
|
||||
var self = this;
|
||||
this._timerInterval = setInterval(function () {
|
||||
self.timerRemaining--;
|
||||
if (self.timerRemaining <= 0) {
|
||||
self.onTimerExpired();
|
||||
}
|
||||
}, 1000);
|
||||
this._timerInterval = setInterval(function () { self.onSecond(); }, 1000);
|
||||
},
|
||||
|
||||
onSecond() {
|
||||
const wasAnnounced = this.dueAnnounced;
|
||||
this.timerRemaining--;
|
||||
if (this.timerRemaining <= 0) this.onMeasurementDue();
|
||||
|
||||
if (wasAnnounced && this.redirectIn > 0) {
|
||||
this.redirectIn--;
|
||||
if (this.redirectIn === 0) this.goToMeasurementTask();
|
||||
}
|
||||
},
|
||||
|
||||
stopMeasurementTimer() {
|
||||
@@ -1128,32 +1274,79 @@ function taskExecute() {
|
||||
this.timerActive = false;
|
||||
},
|
||||
|
||||
onTimerExpired() {
|
||||
this.stopMeasurementTimer();
|
||||
this.playBuzzer();
|
||||
// Reset for new measurement cycle
|
||||
/* The interval has run out. Said once, then acted on.
|
||||
|
||||
Someone already measuring is late, not lost: the banner turns red and they
|
||||
are left alone. Taking them elsewhere mid-cycle would wipe quotes they can
|
||||
see on the screen and gain nothing.
|
||||
|
||||
Otherwise a new cycle starts, and it starts at the first measurement task of
|
||||
the recipe - re-arming wherever the operator happens to be standing would
|
||||
skip whatever comes before it and still count as a full cycle. */
|
||||
onMeasurementDue() {
|
||||
if (this.dueAnnounced) return;
|
||||
this.dueAnnounced = true;
|
||||
window.ProductionClock.playBuzzer();
|
||||
|
||||
if (this.isMeasurementTaskOfRun && !this.cycleConfirmed) return;
|
||||
|
||||
if (this.task.id === this.measurementTaskIds[0]) {
|
||||
this.resetForNewCycle();
|
||||
return;
|
||||
}
|
||||
this.redirectIn = this.measurementTaskUrl ? 5 : 0;
|
||||
},
|
||||
|
||||
/* Clear the screen for another pass over the same quotes.
|
||||
Local only: everything already measured is on the server, and the next
|
||||
reading is saved beside it rather than replacing it. */
|
||||
resetForNewCycle() {
|
||||
this.cycleConfirmed = false;
|
||||
this.showCompletionOverlay = false;
|
||||
this.measurements = [];
|
||||
this.currentIndex = 0;
|
||||
this.currentValue = null;
|
||||
this.errorMessage = '';
|
||||
this.inputStartedAt = Date.now();
|
||||
},
|
||||
|
||||
playBuzzer() {
|
||||
try {
|
||||
var ctx = new (window.AudioContext || window.webkitAudioContext)();
|
||||
// 3 short beeps
|
||||
[0, 0.25, 0.5].forEach(function (delay) {
|
||||
var osc = ctx.createOscillator();
|
||||
var gain = ctx.createGain();
|
||||
osc.connect(gain);
|
||||
gain.connect(ctx.destination);
|
||||
osc.frequency.value = 880;
|
||||
osc.type = 'square';
|
||||
gain.gain.value = 0.3;
|
||||
osc.start(ctx.currentTime + delay);
|
||||
osc.stop(ctx.currentTime + delay + 0.15);
|
||||
});
|
||||
} catch (_) {}
|
||||
// ---- Where the measurement lives ----
|
||||
|
||||
get isMeasurementTaskOfRun() {
|
||||
return this.measurementTaskIds.indexOf(this.task.id) !== -1;
|
||||
},
|
||||
|
||||
get measurementTaskUrl() {
|
||||
return window.ProductionClock.measurementUrl(
|
||||
this.productionRun, '{{ url_for("measure.task_execute", task_id=0) }}',
|
||||
);
|
||||
},
|
||||
|
||||
/* The next measurement task of the recipe, or null if this is the last one -
|
||||
which is the one that closes the cycle and restarts the interval. */
|
||||
get nextMeasurementTaskId() {
|
||||
const ids = this.measurementTaskIds;
|
||||
const idx = ids.indexOf(this.task.id);
|
||||
if (idx === -1 || idx >= ids.length - 1) return null;
|
||||
return ids[idx + 1];
|
||||
},
|
||||
|
||||
get isOverdue() {
|
||||
return this.timerActive && this.timerRemaining <= 0;
|
||||
},
|
||||
|
||||
get announcedRedirect() {
|
||||
return this.dueAnnounced && this.redirectIn > 0;
|
||||
},
|
||||
|
||||
goToMeasurementTask() {
|
||||
const url = this.measurementTaskUrl;
|
||||
if (url) window.location.href = url;
|
||||
},
|
||||
|
||||
goToTask(taskId) {
|
||||
window.location.href =
|
||||
'{{ url_for("measure.task_execute", task_id=0) }}'.replace('/0', '/' + taskId);
|
||||
},
|
||||
|
||||
// ---- Avvio Produzione ----
|
||||
@@ -1205,18 +1398,35 @@ function taskExecute() {
|
||||
await this.confirmCycle();
|
||||
},
|
||||
|
||||
/* mm:ss of the distance from the deadline, either side of it. The direction is
|
||||
carried by the wording in the banner, not by a minus sign. */
|
||||
get timerDisplay() {
|
||||
var m = Math.floor(this.timerRemaining / 60);
|
||||
var s = this.timerRemaining % 60;
|
||||
return (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s;
|
||||
return window.ProductionClock.format(this.timerRemaining);
|
||||
},
|
||||
|
||||
// ---- Navigate to next task (Completato) ----
|
||||
/* With a production open the operator stays in the measurement loop until the
|
||||
capoturno closes it: after the last measurement task they go back to the
|
||||
first, not out to the summary. Before production starts, and on the
|
||||
documental tasks that come before the measurement, the plain sequence
|
||||
applies - that is the run-up, not the loop. */
|
||||
goToNextTask() {
|
||||
if (this.productionStarted && this.isMeasurementTaskOfRun) {
|
||||
const next = this.nextMeasurementTaskId || this.measurementTaskIds[0];
|
||||
// A recipe with a single measurement task loops on the spot: reloading the
|
||||
// same page to arrive at the same state would only cost a round trip.
|
||||
if (next === this.task.id) {
|
||||
this.resetForNewCycle();
|
||||
return;
|
||||
}
|
||||
this.goToTask(next);
|
||||
return;
|
||||
}
|
||||
|
||||
const taskIds = window.__allTaskIds || [];
|
||||
const currentIdx = taskIds.indexOf(this.task.id);
|
||||
if (currentIdx >= 0 && currentIdx < taskIds.length - 1) {
|
||||
window.location.href = '{{ url_for("measure.task_execute", task_id=0) }}'.replace('/0', '/' + taskIds[currentIdx + 1]);
|
||||
this.goToTask(taskIds[currentIdx + 1]);
|
||||
} else {
|
||||
this.goToSummary();
|
||||
}
|
||||
@@ -1238,6 +1448,23 @@ function taskExecute() {
|
||||
this.supervisorError = '';
|
||||
},
|
||||
|
||||
/* What kind of task this is, as declared in the recipe.
|
||||
Deducing it from the quotes meant a measurement task whose quotes had not
|
||||
been entered yet behaved as a note - the screen changed shape depending on
|
||||
how finished the recipe was. Falls back to the old rule for tasks saved
|
||||
before the type existed and not yet migrated. */
|
||||
get isMeasureTask() {
|
||||
const declared = this.task.task_type;
|
||||
if (!declared) return this.subtasks.length > 0;
|
||||
return declared === 'measure' || declared === 'camera_measure';
|
||||
},
|
||||
|
||||
/* A measurement task with no quotes yet: the recipe is unfinished. Said out
|
||||
loud rather than silently rendering an empty screen. */
|
||||
get isMeasureTaskWithoutQuotes() {
|
||||
return this.isMeasureTask && this.subtasks.length === 0;
|
||||
},
|
||||
|
||||
// ---- Is the production stopped? ----
|
||||
get isPaused() {
|
||||
return !!this.productionRun && this.productionRun.status === 'paused';
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
{% block content %}
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8 py-8 max-w-5xl">
|
||||
|
||||
{# The clock follows the operator here too, and brings them back when it expires. #}
|
||||
{% include "components/production_clock.html" %}
|
||||
|
||||
<!-- Breadcrumb -->
|
||||
<nav class="mb-6" aria-label="Breadcrumb">
|
||||
<ol class="flex items-center gap-2 text-sm text-[var(--text-secondary)]">
|
||||
@@ -164,8 +167,26 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Indicators (top-right): measurements + attachment -->
|
||||
<!-- Indicators (top-right): type + measurements + attachment -->
|
||||
<div class="shrink-0 self-start flex items-center gap-2.5">
|
||||
{# The declared type, so the operator sees what a task is before opening
|
||||
it - and a measurement task still reads as one before its quotes are in. #}
|
||||
{% set task_type_labels = {
|
||||
'measure': _('Misura'),
|
||||
'drawing': _('Disegno'),
|
||||
'note': _('Nota'),
|
||||
'xf_compare': _('Confronto profilo'),
|
||||
'camera_measure': _('Misura camera'),
|
||||
} %}
|
||||
{% set is_measure = task.task_type in ('measure', 'camera_measure') %}
|
||||
{% if task.task_type %}
|
||||
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-[11px] font-medium
|
||||
{% if is_measure %}bg-primary-50 dark:bg-primary-900/20 text-primary
|
||||
{% else %}bg-steel-100 dark:bg-steel-800 text-steel-600 dark:text-steel-300{% endif %}">
|
||||
{{ task_type_labels.get(task.task_type, task.task_type) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
{% if task.subtask_count is defined or task.subtasks %}
|
||||
<span class="inline-flex items-center gap-1 text-xs text-[var(--text-secondary)]"
|
||||
title="{{ _('misurazioni') }}">
|
||||
|
||||
@@ -53,6 +53,23 @@ class TestTaskList:
|
||||
assert resp.status_code == 200
|
||||
|
||||
|
||||
class TestTaskComplete:
|
||||
"""GET /measure/complete/<recipe_id> tests."""
|
||||
|
||||
def test_task_complete_renders(self, logged_in_client, mock_api_client):
|
||||
"""The summary carries the measurement clock, so it has to render with it."""
|
||||
mock_api_client.get.side_effect = [
|
||||
# The summary serialises the version number, so the recipe carries one.
|
||||
{"id": 1, "code": "REC-001", "name": "Test Recipe", "version": 1},
|
||||
[{"id": 1, "title": "Task 1", "order_index": 0, "subtasks": []}],
|
||||
{"items": []}, # measurements
|
||||
]
|
||||
|
||||
resp = logged_in_client.get("/measure/complete/1?version_id=5")
|
||||
assert resp.status_code == 200
|
||||
assert b"productionClock(" in resp.data
|
||||
|
||||
|
||||
class TestSaveMeasurement:
|
||||
"""POST /measure/save-measurement tests."""
|
||||
|
||||
|
||||
@@ -140,6 +140,40 @@ def test_complete_cycle_hits_the_run(logged_in_client, monkeypatch):
|
||||
assert endpoint[0] == "/api/production-runs/7/cycle"
|
||||
|
||||
|
||||
def test_complete_cycle_forwards_the_task(logged_in_client, monkeypatch):
|
||||
"""Which task was finished is what tells the server whether the cycle closed."""
|
||||
measure_mod = _with_station(monkeypatch)
|
||||
with patch.object(measure_mod, "api_client") as mock_api:
|
||||
mock_api.post.return_value = RUN
|
||||
logged_in_client.post("/measure/api/production/7/cycle", json={"task_id": 11})
|
||||
assert mock_api.post.call_args[1]["data"]["task_id"] == 11
|
||||
|
||||
|
||||
def test_remeasure_hits_its_own_endpoint(logged_in_client, monkeypatch):
|
||||
"""Turning the piece over must not go down the cycle path and restart the timer."""
|
||||
measure_mod = _with_station(monkeypatch)
|
||||
with patch.object(measure_mod, "api_client") as mock_api:
|
||||
mock_api.post.return_value = RUN
|
||||
resp = logged_in_client.post(
|
||||
"/measure/api/production/7/remeasure", json={"task_id": 11},
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
endpoint, kwargs = mock_api.post.call_args
|
||||
assert endpoint[0] == "/api/production-runs/7/remeasure"
|
||||
assert kwargs["data"]["task_id"] == 11
|
||||
|
||||
|
||||
def test_remeasure_propagates_paused_conflict(logged_in_client, monkeypatch):
|
||||
measure_mod = _with_station(monkeypatch)
|
||||
with patch.object(measure_mod, "api_client") as mock_api:
|
||||
mock_api.post.return_value = {
|
||||
"error": True, "status_code": 409,
|
||||
"detail": "Production run is paused: resume it before measuring",
|
||||
}
|
||||
resp = logged_in_client.post("/measure/api/production/7/remeasure", json={})
|
||||
assert resp.status_code == 409
|
||||
|
||||
|
||||
def test_complete_cycle_propagates_paused_conflict(logged_in_client, monkeypatch):
|
||||
measure_mod = _with_station(monkeypatch)
|
||||
with patch.object(measure_mod, "api_client") as mock_api:
|
||||
@@ -157,6 +191,7 @@ def test_production_routes_require_login(client, monkeypatch):
|
||||
("get", "/measure/api/production/current"),
|
||||
("post", "/measure/api/production/start"),
|
||||
("post", "/measure/api/production/7/cycle"),
|
||||
("post", "/measure/api/production/7/remeasure"),
|
||||
):
|
||||
resp = getattr(client, method)(url)
|
||||
assert resp.status_code in (302, 401), f"{method} {url} -> {resp.status_code}"
|
||||
|
||||
@@ -264,3 +264,29 @@ def test_task_execute_inline_js_is_valid(logged_in_client, mock_measure_api):
|
||||
_node_check(body, f"/measure/execute script[{i}]")
|
||||
|
||||
_check_alpine_attributes(html, "/measure/execute")
|
||||
|
||||
|
||||
def test_task_list_inline_js_is_valid(logged_in_client, mock_measure_api):
|
||||
"""The task list carries the shared measurement clock.
|
||||
|
||||
Its bindings are the ones that turn the countdown red and announce the return
|
||||
to the measurement; a broken expression here would take the whole page's Alpine
|
||||
with it, and the operator would simply never be called back.
|
||||
"""
|
||||
_force_italian(logged_in_client)
|
||||
mock_measure_api.get.side_effect = [
|
||||
{"id": 3, "code": "REC-3", "name": "Ricetta", "description": None},
|
||||
[{
|
||||
"id": 11, "order_index": 0, "title": "Quota d'ingresso",
|
||||
"task_type": "measure", "subtasks": [], "file_path": None,
|
||||
}],
|
||||
]
|
||||
|
||||
resp = logged_in_client.get("/measure/tasks/3")
|
||||
assert resp.status_code == 200
|
||||
html = resp.get_data(as_text=True)
|
||||
|
||||
for i, body in enumerate(_INLINE_SCRIPT_RX.findall(html)):
|
||||
_node_check(body, f"/measure/tasks script[{i}]")
|
||||
|
||||
_check_alpine_attributes(html, "/measure/tasks")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user