Skip to content

Commit

Permalink
Merge pull request #40 from fdm-monster/bugfix/36-printers-placed-on-…
Browse files Browse the repository at this point in the history
…grid-are-not-showing-up

fix: printers are now placed and hot updated using floor.printers
  • Loading branch information
davidzwa authored Apr 15, 2023
2 parents 44fffe1 + 613875a commit 15cef69
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 15 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.0.0-rc6",
"version": "1.0.0-rc7",
"private": false,
"author": "David Zwart",
"license": "AGPL-3.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Generic/Dialogs/CreatePrinterDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { generateInitials } from "@/constants/noun-adjectives.data";
import { infoMessageEvent } from "@/event-bus/alert.events";
import { usePrintersStore } from "@/store/printers.store";
import { Printer } from "@/models/printers/printer.model";
import { sseTestPrinterUpdate } from "@/event-bus/sse.events";
import { sseTestPrinterUpdate } from "../../../event-bus/socketio.events";
import {
SocketIoTestPrinterMessage,
TestProgressDetails,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Generic/Dialogs/UpdatePrinterDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import { defineComponent } from "vue";
import { ValidationObserver } from "vee-validate";
import { Printer } from "@/models/printers/printer.model";
import { sseTestPrinterUpdate } from "@/event-bus/sse.events";
import { sseTestPrinterUpdate } from "../../../event-bus/socketio.events";
import {
SocketIoTestPrinterMessage,
TestProgressDetails,
Expand Down
8 changes: 4 additions & 4 deletions src/components/PrinterGrid/PrinterGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<script lang="ts">
import { defineComponent } from "vue";
import { sseGroups, sseMessageGlobal } from "@/event-bus/sse.events";
import { socketIoFloors } from "../../event-bus/socketio.events";
import PrinterGridTile from "@/components/PrinterGrid/PrinterGridTile.vue";
import {
largeGridcolumnCount,
Expand Down Expand Up @@ -129,15 +129,15 @@ export default defineComponent({
updateGridMatrix() {
this.printerMatrix = this.printersStore.gridSortedPrinters;
},
onSseMessage() {
onSocketIoFloorMessage() {
this.updateGridMatrix();
},
},
async mounted() {
this.$bus.on(sseGroups, this.onSseMessage);
this.$bus.on(socketIoFloors, this.onSocketIoFloorMessage);
},
beforeDestroy() {
this.$bus.off(sseMessageGlobal, this.onSseMessage);
this.$bus.off(socketIoFloors, this.onSocketIoFloorMessage);
},
});
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const sseMessageGlobal = "sse-message-global";
export const sseGroups = "sse-groups";
export const socketIoFloors = "sse-floors";
export const sseTestPrinterUpdate = (correlationToken: string) =>
`sse-message-test-printer-${correlationToken}`;
9 changes: 6 additions & 3 deletions src/services/socketio.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { io, Socket } from "socket.io-client";
import Vue from "vue";
import { VueBus } from "vue-bus";
import {
SocketIoTestPrinterMessage,
SocketIoUpdateMessage,
} from "@/models/sse-messages/printer-sse-message.model";
import { sseGroups, sseMessageGlobal, sseTestPrinterUpdate } from "@/event-bus/sse.events";
import {
socketIoFloors,
sseMessageGlobal,
sseTestPrinterUpdate,
} from "../event-bus/socketio.events";
import { InfoEventType, uploadMessageEvent } from "@/event-bus/alert.events";
import { updatedPrinterEvent } from "@/event-bus/printer.events";
import { useOutletCurrentStore } from "@/store/outlet-current.store";
Expand Down Expand Up @@ -60,6 +63,7 @@ export class SocketIoService {

if (message.floors) {
this.printersStore.saveFloors(message.floors);
this.$bus.emit(socketIoFloors, message.floors);
}

if (message.printers) {
Expand All @@ -73,7 +77,6 @@ export class SocketIoService {
this.$bus.emit(updatedPrinterEvent(p.id), p);
});
}

const outletStore = useOutletCurrentStore();
if (message.outletCurrentValues) {
outletStore.setOutletCurrentValues(message.outletCurrentValues);
Expand Down
6 changes: 5 additions & 1 deletion src/store/printers.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const usePrintersStore = defineStore("Printers", {
row.push(undefined);
} else {
const printer = this.printers.find((p) => p.id === position.printerId);
row.push(printer || undefined);
row.push(printer);
}
}
}
Expand Down Expand Up @@ -164,6 +164,10 @@ export const usePrintersStore = defineStore("Printers", {
this.floors = floors.sort((f, f2) => f.floor - f2.floor);
if (!this.selectedFloor) {
this.selectedFloor = this.floors[0];
} else {
const floorId = this.selectedFloor?._id;
const foundFloor = this.floors.find((f) => f._id === floorId);
this.selectedFloor = foundFloor ? this.floors[0] : foundFloor;
}
},
async changeSelectedFloorByIndex(selectedPrinterFloorIndex: number) {
Expand Down
6 changes: 3 additions & 3 deletions src/views/PrintersView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
{{ item.printerName || item.printerURL }}
</v-chip>
</template>
<template v-slot:item.group="{ item }">
<template v-slot:item.floor="{ item }">
<v-chip v-if="item.id" color="primary" dark>
{{ groupOfPrinter(item.id)?.name }}
{{ floorOfPrinter(item.id)?.name }}
</v-chip>
</template>
<template v-slot:item.actions="{ item }">
Expand Down Expand Up @@ -199,7 +199,7 @@ export default defineComponent({
sortable: true,
value: "printerName",
},
{ text: "Assigned Group", value: "group", sortable: false },
{ text: "Floor", value: "floor", sortable: false },
{ text: "Actions", value: "actions", sortable: false },
{ text: "", value: "data-table-expand" },
],
Expand Down

0 comments on commit 15cef69

Please sign in to comment.