Skip to content

Commit

Permalink
Merge pull request #328 from fdm-monster/feat/326-add-batch-enable-to…
Browse files Browse the repository at this point in the history
…ggle-button-on-the-emergency-settings-page

Feat/326 add batch enable toggle button on the emergency settings page
  • Loading branch information
davidzwa authored Jul 4, 2023
2 parents c84277c + 83fd9c3 commit 2bf4cc2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/backend/batch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ export class BatchService extends BaseService {
static async batchConnectSocket(printerIds: string[]) {
return await this.postApi(`api/batch/connect/socket`, { printerIds });
}

static async batchToggleEnabled(printerIds: string[], enabled: boolean) {
return await this.postApi(`api/batch/toggle-enabled`, { printerIds, enabled });
}
}
4 changes: 3 additions & 1 deletion src/components/Settings/DiagnosticsSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</v-list-item-content>
</v-list-item>
<v-divider />
<v-list-item>
<v-list-item v-if="hasLogDumpFeature">
<v-list-item-content>
<v-list-item-title>Logs Dump</v-list-item-title>
<v-list-item-subtitle>
Expand Down Expand Up @@ -58,11 +58,13 @@ import { ServerPrivateService } from "../../backend/server-private.service";
const settingsStore = useSettingsStore();
const hasAnonymousDiagnosticsToggleFeature = ref(false);
const hasLogDumpFeature = ref(false);
const sentryDiagnosticsEnabled = ref(false);
onMounted(async () => {
const features = await AppService.getFeatures();
hasAnonymousDiagnosticsToggleFeature.value =
features.anonymousDiagnosticsToggle?.available || false;
hasLogDumpFeature.value = features.logDumpZip?.available || false;
await settingsStore.loadSettings();
sentryDiagnosticsEnabled.value = settingsStore.serverSettings?.sentryDiagnosticsEnabled || false;
Expand Down
31 changes: 31 additions & 0 deletions src/components/Settings/EmergencyCommands.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@
</v-list-item-content>
</v-list-item>

<v-list-item>
<v-list-item-content>
<v-list-item-title>Batch disabling</v-list-item-title>
<v-list-item-subtitle>
Disable all printers in batch (will not affect print)
<br />
<v-btn color="primary" @click="batchToggleEnabled(false)">Batch disable</v-btn>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-list-item>
<v-list-item-content>
<v-list-item-title>Batch enabling</v-list-item-title>
<v-list-item-subtitle>
Enabling all printers in batch (will not affect print and it will skip printers in
maintenance mode)
<br />
<v-btn color="primary" @click="batchToggleEnabled(true)">Batch enable</v-btn>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-list-item>
<v-list-item-content>
<v-list-item-title>Batch USB connect</v-list-item-title>
Expand Down Expand Up @@ -90,6 +113,14 @@ export default defineComponent({
async restartServer() {
await ServerPrivateService.restartServer();
},
async batchToggleEnabled(enabled: boolean) {
if (!confirm("Are you sure you want to toggle all printers?")) {
return;
}
const printerIds = this.printerStore.printers.map((p) => p.id);
await BatchService.batchToggleEnabled(printerIds, enabled);
},
async connectUSBs() {
if (!confirm("Are you sure you want to connect all USBs?")) {
return;
Expand Down
4 changes: 3 additions & 1 deletion src/models/server/features.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export interface IFeatureFlag {

export class FeaturesModel {
batchReprintCalls?: IFeatureFlag;
batchConnectUsbCalls?: IFeatureFlag;
batchConnectSocketCalls?: IFeatureFlag;
batchConnectUsbCalls?: IFeatureFlag;
newSockets?: IFeatureFlag;
anonymousDiagnosticsToggle?: IFeatureFlag;
pauseResumePrinterCommand?: IFeatureFlag;
logDumpZip?: IFeatureFlag;
batchTogglePrinterEnabled?: IFeatureFlag;
}

export type TFeatureFlags = keyof FeaturesModel;
Expand Down

0 comments on commit 2bf4cc2

Please sign in to comment.