Skip to content

Commit

Permalink
Merge pull request #69 from fdm-monster/chore/remove-printer-sort-ind…
Browse files Browse the repository at this point in the history
…ex-usage

fix: use printer name for sorting
  • Loading branch information
davidzwa authored Apr 27, 2023
2 parents 0bfd3e1 + 708fff7 commit d825347
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 21 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.1",
"version": "1.0.2",
"private": false,
"author": "David Zwart",
"license": "AGPL-3.0-or-later",
Expand Down
1 change: 0 additions & 1 deletion src/components/PrinterList/PrinterDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
WebSocket: {{ printer.webSocketState?.colour }} <br />
Printer: {{ printer.printerState?.state }} <br />
Files: {{ getPrinterFileCount() }} <br />
Sort Index: {{ printer.sortIndex }} <br />
Id: {{ printer.id }}
</v-col>
<v-col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ import SyncPrinterNameAction from "@/components/Generic/Actions/SyncPrinterNameA
import { usePrintersStore } from "@/store/printers.store";
import { useDialogsStore } from "@/store/dialog.store";
import { DialogName } from "@/components/Generic/Dialogs/dialog.constants";
import { firmwareUpdateSection } from "../constants/experimental.constants";
import PrinterCreateAction from "../components/Generic/Actions/PrinterCreateAction.vue";
import PrinterDeleteAction from "../components/Generic/Actions/PrinterDeleteAction.vue";
import { firmwareUpdateSection } from "@/constants/experimental.constants";
import PrinterCreateAction from "@/components/Generic/Actions/PrinterCreateAction.vue";
import PrinterDeleteAction from "@/components/Generic/Actions/PrinterDeleteAction.vue";
interface Data {
showJsonImportDialog: boolean;
Expand Down Expand Up @@ -186,12 +186,6 @@ export default defineComponent({
search: "",
expanded: [],
tableHeaders: [
{
text: "Order",
align: "start",
sortable: true,
value: "sortIndex",
},
{ text: "Enabled", value: "enabled" },
{
text: "Printer Name",
Expand Down
3 changes: 0 additions & 3 deletions src/models/printers/crud/create-printer.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const getDefaultCreatePrinter = (): PreCreatePrinter => ({
printerHostPort: 80,
websocketPrefix: "ws",
printerHostName: "",
sortIndex: 0,
apiKey: "",
enabled: true,
stepSize: 1,
Expand All @@ -23,7 +22,6 @@ export interface PreCreatePrinter {
id?: string; // Only in case of update

enabled: boolean;
sortIndex: number;
printerName: string;

websocketPrefix: WebSocketProtocol;
Expand All @@ -44,7 +42,6 @@ export interface CreatePrinter {
id?: string; // Only in case of update

enabled: boolean;
sortIndex: number;
printerName: string;

webSocketURL: string;
Expand Down
2 changes: 1 addition & 1 deletion src/models/printers/printer.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export interface Printer {
currentJob: PrinterCurrentJob | PrinterJob;

enabled: boolean;
dateAdded: number;
disabledReason: string;
sortIndex: number;
printerName: string;
webSocketURL: string;
apiKey: string;
Expand Down
6 changes: 3 additions & 3 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vue from "vue";
import VueRouter, { RouteConfig } from "vue-router";
import HomePrinterGrid from "@/views/PrinterGridView.vue";
import Printers from "@/views/PrintersView.vue";
import PrintersView from "@/components/PrinterList/PrintersView.vue";
import Settings from "@/views/SettingsView.vue";
import About from "@/views/AboutView.vue";
import PrintTimeline from "@/views/PrintTimelineView.vue";
Expand All @@ -20,8 +20,8 @@ const routes: Array<RouteConfig> = [
},
{
path: "/printers",
name: "Printers",
component: Printers,
name: "PrintersView",
component: PrintersView,
},
{
path: "/settings",
Expand Down
9 changes: 6 additions & 3 deletions src/store/printers.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ export const usePrintersStore = defineStore("Printers", {
async createPrinter(newPrinter: CreatePrinter) {
const data = await PrintersService.createPrinter(newPrinter);
this.printers.push(data);
this.printers.sort((a: Printer, b: Printer) => (a.sortIndex > b.sortIndex ? 1 : -1));
this.printers.sort((a: Printer, b: Printer) =>
a.printerName?.toLowerCase()?.localeCompare(b?.printerName?.toLowerCase()) ? 1 : -1
);
return data;
},
async createTestPrinter(newPrinter: CreatePrinter) {
const data = await PrintersService.testConnection(newPrinter);
this.testPrinters = data;
return data;
},
// TODO renamed
toggleSelectedPrinter(printer: Printer) {
const selectedPrinterIndex = this.selectedPrinters.findIndex((sp) => sp.id == printer.id);
if (selectedPrinterIndex === -1) {
Expand Down Expand Up @@ -208,7 +209,9 @@ export const usePrintersStore = defineStore("Printers", {
if (viewedPrinterId) {
this.sideNavPrinter = printers.find((p) => p.id === viewedPrinterId);
}
this.printers = printers;
this.printers = printers.sort((a: Printer, b: Printer) =>
a.printerName?.toLowerCase()?.localeCompare(b?.printerName?.toLowerCase()) ? 1 : -1
);
},
_popPrinter(printerId: string) {
const printerIndex = this.printers.findIndex((p: Printer) => p.id === printerId);
Expand Down

0 comments on commit d825347

Please sign in to comment.