Skip to content

Commit

Permalink
Merge pull request #955 from fdm-monster/feat/batch-reprint-dialog
Browse files Browse the repository at this point in the history
Feature: batch reprint dialog for intermediate batch print selection
  • Loading branch information
davidzwa authored Feb 3, 2024
2 parents e2f5997 + 07c2942 commit f3cba2e
Show file tree
Hide file tree
Showing 29 changed files with 544 additions and 313 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.5.0-rc6",
"version": "1.5.0-rc7",
"author": "David Zwart",
"license": "AGPL-3.0-or-later",
"repository": {
Expand Down
Binary file added public/img/thumbail_unknown.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<BatchJsonCreateDialog />
<YamlImportExportDialog />
<FileExplorerSideNav />
<BatchReprintDialog />
</v-app>
</template>

Expand All @@ -42,6 +43,7 @@ import { useSettingsStore } from "./store/settings.store";
import { useDialogsStore } from "@/store/dialog.store";
import BatchJsonCreateDialog from "@/components/Generic/Dialogs/BatchJsonCreateDialog.vue";
import YamlImportExportDialog from "@/components/Generic/Dialogs/YamlImportExportDialog.vue";
import BatchReprintDialog from "@/components/Generic/Dialogs/BatchReprintDialog.vue";
import { useFeatureStore } from "./store/features.store";
import { useSnackbar } from "./shared/snackbar.composable";
import AppProgressSnackbar from "./components/Generic/Snackbars/AppProgressSnackbar.vue";
Expand Down Expand Up @@ -71,6 +73,7 @@ export default defineComponent({
PrinterMaintenanceDialog,
FileExplorerSideNav,
BatchJsonCreateDialog,
BatchReprintDialog,
},
setup: () => {
return {
Expand Down
12 changes: 12 additions & 0 deletions src/backend/batch.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { BaseService } from "./base.service";
import { IdType } from "@/utils/id.type";
import { ServerApi } from "@/backend/server.api";
import { ReprintFileDto } from "@/models/batch/reprint.dto";

export class BatchService extends BaseService {
static async batchConnectUsb(printerIds: IdType[]) {
Expand All @@ -13,4 +15,14 @@ export class BatchService extends BaseService {
static async batchToggleEnabled(printerIds: IdType[], enabled: boolean) {
return await this.postApi(`api/batch/toggle-enabled`, { printerIds, enabled });
}

static async batchGetLastPrintedFiles(printerIds: IdType[]) {
const path = ServerApi.batchGetLastPrintedFilesRoute;
return await this.postApi<ReprintFileDto[]>(path, { printerIds });
}

static async batchReprintFiles(prints: { printerId: IdType; path: string }[]) {
const path = ServerApi.batchReprintFilesRoute;
return await this.postApi(path, { prints });
}
}
5 changes: 0 additions & 5 deletions src/backend/printer-file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export class PrinterFileService extends BaseService {
return (await this.getApi(path)) as PrinterFileDto[];
}

static async batchReprintFiles(printerIds: IdType[]) {
const path = ServerApi.printerFilesBatchReprintRoute;
return await this.postApi(path, { printerIds });
}

static async selectAndPrintFile(printerId: IdType, filePath: string, print = true) {
const path = ServerApi.printerFilesSelectAndPrintRoute(printerId);
return await this.postApi(path, { filePath, print });
Expand Down
6 changes: 5 additions & 1 deletion src/backend/server.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ export class ServerApi {

static floorRoute = `${ServerApi.base}/floor`;

static batchRoute = `${ServerApi.base}/batch`;
static batchGetLastPrintedFilesRoute = `${ServerApi.batchRoute}/reprint/list`;
static batchReprintFilesRoute = `${ServerApi.batchRoute}/reprint/execute`;

static printCompletionRoute = `${ServerApi.base}/print-completion`;

static printerFilesRoute = `${ServerApi.base}/printer-files`;
static printerFilesBatchReprintRoute = `${ServerApi.printerFilesRoute}/batch/reprint-files`;

static printerFilesPurgeRoute = `${ServerApi.printerFilesRoute}/purge`;

static customGCodeRoute = `${ServerApi.base}/custom-gcode`;
Expand Down
36 changes: 12 additions & 24 deletions src/components/AboutHelp/AboutView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,18 @@
</v-card>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";
import { AppService } from "../../backend/app.service";
import { version } from "../../../package.json";
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import { AppService } from "@/backend/app.service";
import { version as clientVersion } from "../../../package.json";
export default defineComponent({
name: "AboutView",
components: {},
setup: () => {
return {
serverVersion: ref(""),
monsterPiVersion: ref<string | null>(""),
version,
};
},
async created() {},
async mounted() {
const versionSpec = await AppService.getVersion();
this.serverVersion = versionSpec.version;
this.monsterPiVersion = versionSpec.monsterPi;
},
props: {},
computed: {},
methods: {},
watch: {},
const serverVersion = ref("");
const monsterPiVersion = ref<string | null>("");
const version = ref(clientVersion);
onMounted(async () => {
const versionSpec = await AppService.getVersion();
serverVersion.value = versionSpec.version;
monsterPiVersion.value = versionSpec.monsterPi;
});
</script>
2 changes: 1 addition & 1 deletion src/components/Generic/Actions/PrinterCreateAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineComponent({
computed: {},
methods: {
openCreatePrinterDialog() {
this.dialogsStore.openDialog(DialogName.AddOrUpdatePrinterDialog);
this.dialogsStore.openDialogWithContext(DialogName.AddOrUpdatePrinterDialog);
},
},
});
Expand Down
105 changes: 52 additions & 53 deletions src/components/Generic/Dialogs/BaseDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,64 @@
<slot></slot>
</v-dialog>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import { usePrinterStore } from "../../../store/printer.store";

<script lang="ts" setup>
import { computed, onBeforeUnmount, onMounted } from "vue";
import { useDialogsStore } from "@/store/dialog.store";
import { DialogName } from "@/components/Generic/Dialogs/dialog.constants";
import { onKeyStroke } from "@vueuse/core";
import { useDialog } from "@/shared/dialog.composable";
export default defineComponent({
name: "BaseDialog",
components: {},
setup: () => {
return {
printersStore: usePrinterStore(),
dialogsStore: useDialogsStore(),
};
},
async created() {
onKeyStroke("Escape", (e) => {
if (this.showingDialog) {
e.preventDefault();
this.emitEscape();
}
});
},
async mounted() {
this.dialogsStore.registerDialogReference(this.id);
},
beforeDestroy() {
this.dialogsStore.unregisterDialogReference(this.id);
const props = defineProps({
id: {
type: String as () => DialogName,
required: true,
},
props: {
id: {
type: String as () => DialogName,
required: true,
},
maxWidth: {
type: String,
default: "400px",
},
maxWidth: {
type: String,
default: "400px",
},
computed: {
dialog() {
return this.id ? this.dialogsStore.dialogsById[this.id] : undefined;
},
showingDialog() {
if (!this.id) return;
});
const dialogsStore = useDialogsStore();
const emit = defineEmits(["escape", "opened", "beforeOpened"]);
const dialog = useDialog(props.id);
const isOpened = this.dialogsStore.isDialogOpened(this.id);
if (isOpened) {
console.debug(`[BaseDialog ${this.id}] Showing dialog: ${this.dialog?.opened}`);
}
return isOpened;
},
},
methods: {
emitEscape() {
this.$emit("escape");
},
},
watch: {},
function openedCallback(input: any) {
return emit("opened", input);
}
function beforeOpenedCallback(input: any) {
return emit("beforeOpened", input);
}
onMounted(async () => {
onKeyStroke("Escape", (e) => {
if (showingDialog.value) {
e.preventDefault();
emitEscape();
}
});
dialogsStore.registerDialogReference(props.id, {
beforeOpenedCallback,
openedCallback,
});
});
onBeforeUnmount(() => {
dialogsStore.unregisterDialogReference(props.id);
});
const showingDialog = computed(() => {
if (!props.id) return;
const isOpened = dialogsStore.isDialogOpened(props.id);
if (isOpened) {
console.debug(`[BaseDialog ${props.id}] Showing dialog: ${dialog?.isDialogOpened()}`);
}
return isOpened;
});
function emitEscape() {
emit("escape");
}
</script>
5 changes: 5 additions & 0 deletions src/components/Generic/Dialogs/BatchReprintDialog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { IdType } from "@/utils/id.type";

interface ReprintPrinterIds {
printerIds: IdType[];
}
Loading

0 comments on commit f3cba2e

Please sign in to comment.