Skip to content

Commit 6098f66

Browse files
committed
Merge PR #2335 into staging
2 parents 05c266e + 0962787 commit 6098f66

20 files changed

Lines changed: 154 additions & 30 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class AddStateCommentToFileEntity1783504170192 implements MigrationInterface {
4+
name = 'AddStateCommentToFileEntity1783504170192';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`ALTER TABLE "file_entity" ADD "stateComment" text`,
9+
);
10+
}
11+
12+
public async down(queryRunner: QueryRunner): Promise<void> {
13+
await queryRunner.query(
14+
`ALTER TABLE "file_entity" DROP COLUMN "stateComment"`,
15+
);
16+
}
17+
}

cli/kleinkram/api/deser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class FileObjectKeys(str, Enum):
5959
HASH = "hash"
6060
TYPE = "type"
6161
CATEGORIES = "categories"
62+
STATE_COMMENT = "stateComment"
6263

6364

6465
class MissionObjectKeys(str, Enum):
@@ -226,6 +227,7 @@ def _parse_file(file: FileObject) -> File:
226227
created_at = _parse_datetime(file[FileObjectKeys.CREATED_AT])
227228
updated_at = _parse_datetime(file[FileObjectKeys.UPDATED_AT])
228229
state = _parse_file_state(file[FileObjectKeys.STATE])
230+
state_comment = file.get(FileObjectKeys.STATE_COMMENT)
229231
categories_raw = file.get(FileObjectKeys.CATEGORIES) or []
230232
categories = [c["name"] if isinstance(c, dict) and "name" in c else str(c) for c in categories_raw]
231233

@@ -241,6 +243,7 @@ def _parse_file(file: FileObject) -> File:
241243
date=fdate,
242244
categories=categories,
243245
state=state,
246+
state_comment=state_comment,
244247
created_at=created_at,
245248
updated_at=updated_at,
246249
mission_id=mission_id,

cli/kleinkram/api/file_transfer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,14 @@ def _download_state_message(state: DownloadState, path: Path, file: File) -> Opt
545545
False,
546546
),
547547
DownloadState.SKIPPED_INVALID_REMOTE_STATE: (
548-
f"skipped {path}, remote file has invalid state ({file.state.value})",
548+
f"skipped {path}, remote file has invalid state ({file.state.value})"
549+
+ (f": {file.state_comment}" if file.state_comment else ""),
549550
False,
550551
),
551552
DownloadState.SKIPPED_CORRUPTED: (
552-
f"skipped {path}, remote file is CORRUPTED (use --allow-corrupt to override)",
553+
f"skipped {path}, remote file is CORRUPTED"
554+
+ (f": {file.state_comment}" if file.state_comment else "")
555+
+ " (use --allow-corrupt to override)",
553556
False,
554557
),
555558
DownloadState.SKIPPED_CORRUPTED_LOCAL_OK: (

cli/kleinkram/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class File:
8181
categories: List[str] = field(default_factory=list)
8282
topics: List[str] = field(default_factory=list)
8383
state: FileState = FileState.OK
84+
state_comment: Optional[str] = None
8485

8586

8687
class ExecutionStatus(str, Enum):

cli/kleinkram/printing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ def file_info_table(file: File) -> Table:
250250
table.add_row("updated", str(file.updated_at))
251251
table.add_row("size", format_bytes(file.size))
252252
table.add_row("state", file_state_to_text(file.state))
253+
if file.state_comment:
254+
table.add_row("state comment", Text(file.state_comment, style="dim"))
253255
table.add_row("categories", ", ".join(file.categories))
254256
table.add_row("topics", ", ".join(file.topics))
255257
table.add_row("hash", file.hash)

frontend/src/components/explorer-page/explorer-page-files-table.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
:color="getColorFileState(props.row.state)"
3636
size="20px"
3737
>
38-
<q-tooltip>{{ getTooltip(props.row.state) }}</q-tooltip>
38+
<q-tooltip>{{
39+
getTooltip(props.row.state, props.row.stateComment)
40+
}}</q-tooltip>
3941
</q-icon>
4042
</q-td>
4143
</template>

frontend/src/components/inspect-file/file-error-state.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@
3535
<span class="text-weight-bold">.{{ fileExtension }}</span>
3636
</div>
3737
</div>
38+
39+
<div
40+
v-if="file.stateComment"
41+
class="text-caption q-mt-md text-red"
42+
style="
43+
max-width: 600px;
44+
word-break: break-word;
45+
margin-left: auto;
46+
margin-right: auto;
47+
"
48+
>
49+
{{ file.stateComment }}
50+
</div>
3851
</div>
3952
</template>
4053

frontend/src/components/inspect-file/file-header.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@
143143
"
144144
size="sm"
145145
>
146-
<q-tooltip>{{ getTooltip(file?.state) }}</q-tooltip>
146+
<q-tooltip>{{
147+
getTooltip(file?.state, file?.stateComment)
148+
}}</q-tooltip>
147149
</q-icon>
148150
</div>
149151
<div class="col-12 col-md-1">

frontend/src/pages/data-table-page.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
:color="getColorFileState(props.row.state)"
3535
size="20px"
3636
>
37-
<q-tooltip>{{ getTooltip(props.row.state) }}</q-tooltip>
37+
<q-tooltip>{{
38+
getTooltip(props.row.state, props.row.stateComment)
39+
}}</q-tooltip>
3840
</q-icon>
3941
</q-td>
4042
</template>

frontend/src/services/generic.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,34 +291,53 @@ export function getActionColor(state: ActionState) {
291291
}
292292
}
293293

294-
export function getTooltip(state: FileState | undefined) {
294+
export function getTooltip(
295+
state: FileState | undefined,
296+
stateComment?: string | null,
297+
) {
295298
if (state === undefined) {
296299
return 'Unknown';
297300
}
298301

302+
let baseText = '';
299303
switch (state) {
300304
case FileState.OK: {
301-
return 'File is OK';
305+
baseText = 'File is OK';
306+
break;
302307
}
303308
case FileState.ERROR: {
304-
return 'File has an error';
309+
baseText = 'File has an error';
310+
break;
305311
}
306312
case FileState.UPLOADING: {
307-
return 'File is uploading';
313+
baseText = 'File is uploading';
314+
break;
308315
}
309316
case FileState.CORRUPTED: {
310-
return 'File is corrupted';
317+
baseText = 'File is corrupted';
318+
break;
311319
}
312320
case FileState.LOST: {
313-
return 'File cannot be found in storage';
321+
baseText = 'File cannot be found in storage';
322+
break;
314323
}
315324
case FileState.FOUND: {
316-
return 'File was recovered';
325+
baseText = 'File was recovered';
326+
break;
317327
}
318328
case FileState.CONVERSION_ERROR: {
319-
return 'File conversion failed';
329+
baseText = 'File conversion failed';
330+
break;
331+
}
332+
default: {
333+
baseText = 'Unknown';
320334
}
321335
}
336+
337+
if (stateComment) {
338+
return `${baseText}: ${stateComment}`;
339+
}
340+
return baseText;
322341
}
323342

324343
export function getIcon(state: FileState) {

0 commit comments

Comments
 (0)