Skip to content

Commit

Permalink
Merge pull request #125 from fdm-monster/feat/socket-update-date
Browse files Browse the repository at this point in the history
Feat/socket update date
  • Loading branch information
davidzwa authored May 14, 2023
2 parents c2d5b79 + 2292184 commit 42d3e02
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fdm-monster/client",
"version": "1.1.4",
"version": "1.1.5",
"private": false,
"author": "David Zwart",
"license": "AGPL-3.0-or-later",
Expand Down
15 changes: 12 additions & 3 deletions src/components/PrinterList/PrintersView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@
</v-chip>
</template>
<template v-slot:item.floor="{ item }">
<v-chip v-if="item.id" color="primary" dark>
{{ floorOfPrinter(item.id)?.name }}
</v-chip>
<v-chip v-if="item.id" color="primary" dark> {{ floorOfPrinter(item.id)?.name }} </v-chip>
</template>
<template v-slot:item.actions="{ item }">
<PrinterUrlAction :printer="item" />
Expand All @@ -82,6 +80,10 @@
<SyncPrinterNameAction :printer="item" />
<PrinterDeleteAction :printer="item" />
<PrinterSettingsAction :printer="item" v-on:update:show="openEditDialog(item)" />
<span v-if="item.lastMessageReceivedDate">
Updated {{ diffSeconds(item.lastMessageReceivedDate) }} seconds ago
</span>
<span v-else> No update received (silence)</span>
</template>
<template v-slot:expanded-item="{ headers, item }">
<td :colspan="headers.length">
Expand Down Expand Up @@ -236,6 +238,13 @@ export default defineComponent({
},
},
methods: {
diffSeconds(dateString: string) {
if (!dateString?.length) return;
const date = new Date(dateString);
const now = new Date();
const diff = (now.getTime() - date.getTime()) / 1000;
return diff; // new Intl.DateTimeFormat("default", { dateStyle: "long" }).format(date)
},
firmwareUpdateSection() {
return firmwareUpdateSection;
},
Expand Down
1 change: 1 addition & 0 deletions src/models/printers/printer.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface Printer {
hostState: HostState;
apiAccessibility: ApiAccessibility;
webSocketState: WebsocketState;
lastMessageReceivedDate: string;
currentJob: PrinterCurrentJob | PrinterJob;

enabled: boolean;
Expand Down

0 comments on commit 42d3e02

Please sign in to comment.