@fdm-monster/server
Version:
FDM Monster is a bulk OctoPrint manager to set up, configure and monitor 3D printers. Our aim is to provide extremely optimized websocket performance and reliability.
142 lines (141 loc) • 6.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "BatchCallController", {
enumerable: true,
get: function() {
return BatchCallController;
}
});
const _awilixexpress = require("awilix-express");
const _validators = require("../handlers/validators");
const _batchcontrollervalidation = require("./validation/batch-controller.validation");
const _serverconstants = require("../server.constants");
const _authenticate = require("../middleware/authenticate");
const _authorizationconstants = require("../constants/authorization.constants");
const _batchcallservice = require("../services/core/batch-call.service");
const _express = require("express");
function _ts_decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function _ts_metadata(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
class BatchCallController {
batchCallService;
isTypeormMode;
constructor(batchCallService, isTypeormMode){
this.batchCallService = batchCallService;
this.isTypeormMode = isTypeormMode;
}
async batchSettingsGet(req, res) {
const { printerIds } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrinterSchema)(this.isTypeormMode));
const results = await this.batchCallService.batchSettingsGet(printerIds);
res.send(results);
}
async batchConnectUsb(req, res) {
const { printerIds } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrinterSchema)(this.isTypeormMode));
const results = await this.batchCallService.batchConnectUsb(printerIds);
res.send(results);
}
async batchConnectSocket(req, res) {
const { printerIds } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrinterSchema)(this.isTypeormMode));
this.batchCallService.batchConnectSocket(printerIds);
res.send({});
}
async getLastPrintedFiles(req, res) {
const { printerIds } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrinterSchema)(this.isTypeormMode));
const files = await this.batchCallService.getBatchPrinterReprintFile(printerIds);
res.send(files);
}
async batchReprintFiles(req, res) {
const { prints } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.executeBatchRePrinterSchema)(this.isTypeormMode));
const files = await this.batchCallService.batchReprintCalls(prints);
res.send(files);
}
async batchTogglePrintersEnabled(req, res) {
const { printerIds, enabled } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrintersEnabledSchema)(this.isTypeormMode));
const results = await this.batchCallService.batchTogglePrintersEnabled(printerIds, enabled);
res.send(results);
}
}
_ts_decorate([
(0, _awilixexpress.POST)(),
(0, _awilixexpress.route)("/settings/get"),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof _express.Request === "undefined" ? Object : _express.Request,
typeof _express.Response === "undefined" ? Object : _express.Response
]),
_ts_metadata("design:returntype", Promise)
], BatchCallController.prototype, "batchSettingsGet", null);
_ts_decorate([
(0, _awilixexpress.POST)(),
(0, _awilixexpress.route)("/connect/usb"),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof _express.Request === "undefined" ? Object : _express.Request,
typeof _express.Response === "undefined" ? Object : _express.Response
]),
_ts_metadata("design:returntype", Promise)
], BatchCallController.prototype, "batchConnectUsb", null);
_ts_decorate([
(0, _awilixexpress.POST)(),
(0, _awilixexpress.route)("/connect/socket"),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof _express.Request === "undefined" ? Object : _express.Request,
typeof _express.Response === "undefined" ? Object : _express.Response
]),
_ts_metadata("design:returntype", Promise)
], BatchCallController.prototype, "batchConnectSocket", null);
_ts_decorate([
(0, _awilixexpress.POST)(),
(0, _awilixexpress.route)("/reprint/list"),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof _express.Request === "undefined" ? Object : _express.Request,
typeof _express.Response === "undefined" ? Object : _express.Response
]),
_ts_metadata("design:returntype", Promise)
], BatchCallController.prototype, "getLastPrintedFiles", null);
_ts_decorate([
(0, _awilixexpress.POST)(),
(0, _awilixexpress.route)("/reprint/execute"),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof _express.Request === "undefined" ? Object : _express.Request,
typeof _express.Response === "undefined" ? Object : _express.Response
]),
_ts_metadata("design:returntype", Promise)
], BatchCallController.prototype, "batchReprintFiles", null);
_ts_decorate([
(0, _awilixexpress.POST)(),
(0, _awilixexpress.route)("/toggle-enabled"),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof _express.Request === "undefined" ? Object : _express.Request,
typeof _express.Response === "undefined" ? Object : _express.Response
]),
_ts_metadata("design:returntype", Promise)
], BatchCallController.prototype, "batchTogglePrintersEnabled", null);
BatchCallController = _ts_decorate([
(0, _awilixexpress.route)(_serverconstants.AppConstants.apiRoute + "/batch"),
(0, _awilixexpress.before)([
(0, _authenticate.authenticate)(),
(0, _authenticate.authorizeRoles)([
_authorizationconstants.ROLES.ADMIN,
_authorizationconstants.ROLES.OPERATOR
])
]),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof _batchcallservice.BatchCallService === "undefined" ? Object : _batchcallservice.BatchCallService,
Boolean
])
], BatchCallController);
//# sourceMappingURL=batch-call.controller.js.map