Updated import paths.
This commit is contained in:
parent
e3f28fef12
commit
88a531756f
@ -5,9 +5,9 @@ import axios from 'axios';
|
|||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import NodeCache from 'node-cache';
|
import NodeCache from 'node-cache';
|
||||||
import { userModel } from './schemas/management/user.schema.js';
|
import { userModel } from './database/schemas/management/user.schema.js';
|
||||||
import { getObject } from './database/database.js';
|
import { getObject } from './database/database.js';
|
||||||
import { hostModel } from './schemas/management/host.schema.js';
|
import { hostModel } from './database/schemas/management/host.schema.js';
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const logger = log4js.getLogger('Keycloak');
|
const logger = log4js.getLogger('Keycloak');
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newFilamentStockRouteHandler,
|
newFilamentStockRouteHandler,
|
||||||
deleteFilamentStockRouteHandler,
|
deleteFilamentStockRouteHandler,
|
||||||
listFilamentStocksByPropertiesRouteHandler,
|
listFilamentStocksByPropertiesRouteHandler,
|
||||||
|
getFilamentStockStatsRouteHandler,
|
||||||
|
getFilamentStockHistoryRouteHandler,
|
||||||
} from '../../services/inventory/filamentstocks.js';
|
} from '../../services/inventory/filamentstocks.js';
|
||||||
|
|
||||||
// list of filament stocks
|
// list of filament stocks
|
||||||
@ -35,6 +37,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newFilamentStockRouteHandler(req, res);
|
newFilamentStockRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get filament stock stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getFilamentStockStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get filament stock history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getFilamentStockHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getFilamentStockRouteHandler(req, res);
|
getFilamentStockRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newOrderItemRouteHandler,
|
newOrderItemRouteHandler,
|
||||||
deleteOrderItemRouteHandler,
|
deleteOrderItemRouteHandler,
|
||||||
listOrderItemsByPropertiesRouteHandler,
|
listOrderItemsByPropertiesRouteHandler,
|
||||||
|
getOrderItemStatsRouteHandler,
|
||||||
|
getOrderItemHistoryRouteHandler,
|
||||||
} from '../../services/inventory/orderitems.js';
|
} from '../../services/inventory/orderitems.js';
|
||||||
|
|
||||||
// list of order items
|
// list of order items
|
||||||
@ -35,6 +37,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newOrderItemRouteHandler(req, res);
|
newOrderItemRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get order item stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getOrderItemStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get order item history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getOrderItemHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getOrderItemRouteHandler(req, res);
|
getOrderItemRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newPartStockRouteHandler,
|
newPartStockRouteHandler,
|
||||||
deletePartStockRouteHandler,
|
deletePartStockRouteHandler,
|
||||||
listPartStocksByPropertiesRouteHandler,
|
listPartStocksByPropertiesRouteHandler,
|
||||||
|
getPartStockStatsRouteHandler,
|
||||||
|
getPartStockHistoryRouteHandler,
|
||||||
} from '../../services/inventory/partstocks.js';
|
} from '../../services/inventory/partstocks.js';
|
||||||
|
|
||||||
// list of part stocks
|
// list of part stocks
|
||||||
@ -35,6 +37,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newPartStockRouteHandler(req, res);
|
newPartStockRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get part stock stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getPartStockStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get part stock history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getPartStockHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getPartStockRouteHandler(req, res);
|
getPartStockRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newPurchaseOrderRouteHandler,
|
newPurchaseOrderRouteHandler,
|
||||||
deletePurchaseOrderRouteHandler,
|
deletePurchaseOrderRouteHandler,
|
||||||
listPurchaseOrdersByPropertiesRouteHandler,
|
listPurchaseOrdersByPropertiesRouteHandler,
|
||||||
|
getPurchaseOrderStatsRouteHandler,
|
||||||
|
getPurchaseOrderHistoryRouteHandler,
|
||||||
} from '../../services/inventory/purchaseorders.js';
|
} from '../../services/inventory/purchaseorders.js';
|
||||||
|
|
||||||
// list of purchase orders
|
// list of purchase orders
|
||||||
@ -35,6 +37,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newPurchaseOrderRouteHandler(req, res);
|
newPurchaseOrderRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get purchase order stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getPurchaseOrderStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get purchase order history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getPurchaseOrderHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getPurchaseOrderRouteHandler(req, res);
|
getPurchaseOrderRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newShipmentRouteHandler,
|
newShipmentRouteHandler,
|
||||||
deleteShipmentRouteHandler,
|
deleteShipmentRouteHandler,
|
||||||
listShipmentsByPropertiesRouteHandler,
|
listShipmentsByPropertiesRouteHandler,
|
||||||
|
getShipmentStatsRouteHandler,
|
||||||
|
getShipmentHistoryRouteHandler,
|
||||||
} from '../../services/inventory/shipments.js';
|
} from '../../services/inventory/shipments.js';
|
||||||
|
|
||||||
// list of shipments
|
// list of shipments
|
||||||
@ -49,6 +51,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newShipmentRouteHandler(req, res);
|
newShipmentRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get shipment stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getShipmentStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get shipment history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getShipmentHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getShipmentRouteHandler(req, res);
|
getShipmentRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import {
|
|||||||
newStockAuditRouteHandler,
|
newStockAuditRouteHandler,
|
||||||
updateStockAuditRouteHandler,
|
updateStockAuditRouteHandler,
|
||||||
deleteStockAuditRouteHandler,
|
deleteStockAuditRouteHandler,
|
||||||
|
getStockAuditStatsRouteHandler,
|
||||||
|
getStockAuditHistoryRouteHandler,
|
||||||
} from '../../services/inventory/stockaudits.js';
|
} from '../../services/inventory/stockaudits.js';
|
||||||
|
|
||||||
// List stock audits
|
// List stock audits
|
||||||
@ -36,6 +38,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newStockAuditRouteHandler(req, res);
|
newStockAuditRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get stock audit stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getStockAuditStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get stock audit history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getStockAuditHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
// Get specific stock audit
|
// Get specific stock audit
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getStockAuditRouteHandler(req, res);
|
getStockAuditRouteHandler(req, res);
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
editStockEventRouteHandler,
|
editStockEventRouteHandler,
|
||||||
deleteStockEventRouteHandler,
|
deleteStockEventRouteHandler,
|
||||||
listStockEventsByPropertiesRouteHandler,
|
listStockEventsByPropertiesRouteHandler,
|
||||||
|
getStockEventStatsRouteHandler,
|
||||||
|
getStockEventHistoryRouteHandler,
|
||||||
} from '../../services/inventory/stockevents.js';
|
} from '../../services/inventory/stockevents.js';
|
||||||
|
|
||||||
// list of stock events
|
// list of stock events
|
||||||
@ -35,6 +37,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newStockEventRouteHandler(req, res);
|
newStockEventRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get stock event stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getStockEventStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get stock event history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getStockEventHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getStockEventRouteHandler(req, res);
|
getStockEventRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,6 +3,8 @@ import { isAuthenticated } from '../../keycloak.js';
|
|||||||
import {
|
import {
|
||||||
listAuditLogsRouteHandler,
|
listAuditLogsRouteHandler,
|
||||||
getAuditLogRouteHandler,
|
getAuditLogRouteHandler,
|
||||||
|
getAuditLogStatsRouteHandler,
|
||||||
|
getAuditLogHistoryRouteHandler,
|
||||||
} from '../../services/management/auditlogs.js';
|
} from '../../services/management/auditlogs.js';
|
||||||
import { parseFilter } from '../../utils.js';
|
import { parseFilter } from '../../utils.js';
|
||||||
|
|
||||||
@ -27,6 +29,16 @@ router.get('/', isAuthenticated, async (req, res) => {
|
|||||||
listAuditLogsRouteHandler(req, res, page, limit, filter, sort, order);
|
listAuditLogsRouteHandler(req, res, page, limit, filter, sort, order);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get audit log stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getAuditLogStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get audit log history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getAuditLogHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @route GET /api/auditlogs/:id
|
* @route GET /api/auditlogs/:id
|
||||||
* @desc Get a single audit log by ID
|
* @desc Get a single audit log by ID
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newCourierRouteHandler,
|
newCourierRouteHandler,
|
||||||
deleteCourierRouteHandler,
|
deleteCourierRouteHandler,
|
||||||
listCouriersByPropertiesRouteHandler,
|
listCouriersByPropertiesRouteHandler,
|
||||||
|
getCourierStatsRouteHandler,
|
||||||
|
getCourierHistoryRouteHandler,
|
||||||
} from '../../services/management/courier.js';
|
} from '../../services/management/courier.js';
|
||||||
|
|
||||||
// list of couriers
|
// list of couriers
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newCourierRouteHandler(req, res);
|
newCourierRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get courier stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getCourierStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get courier history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getCourierHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getCourierRouteHandler(req, res);
|
getCourierRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newCourierServiceRouteHandler,
|
newCourierServiceRouteHandler,
|
||||||
deleteCourierServiceRouteHandler,
|
deleteCourierServiceRouteHandler,
|
||||||
listCourierServicesByPropertiesRouteHandler,
|
listCourierServicesByPropertiesRouteHandler,
|
||||||
|
getCourierServiceStatsRouteHandler,
|
||||||
|
getCourierServiceHistoryRouteHandler,
|
||||||
} from '../../services/management/courierservice.js';
|
} from '../../services/management/courierservice.js';
|
||||||
|
|
||||||
// list of courier services
|
// list of courier services
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newCourierServiceRouteHandler(req, res);
|
newCourierServiceRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get courier service stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getCourierServiceStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get courierservice history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getCourierServiceHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getCourierServiceRouteHandler(req, res);
|
getCourierServiceRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newDocumentJobRouteHandler,
|
newDocumentJobRouteHandler,
|
||||||
deleteDocumentJobRouteHandler,
|
deleteDocumentJobRouteHandler,
|
||||||
listDocumentJobsByPropertiesRouteHandler,
|
listDocumentJobsByPropertiesRouteHandler,
|
||||||
|
getDocumentJobStatsRouteHandler,
|
||||||
|
getDocumentJobHistoryRouteHandler,
|
||||||
} from '../../services/management/documentjobs.js';
|
} from '../../services/management/documentjobs.js';
|
||||||
|
|
||||||
// list of document jobs
|
// list of document jobs
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newDocumentJobRouteHandler(req, res);
|
newDocumentJobRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get document job stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getDocumentJobStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get documentjobs history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getDocumentJobHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getDocumentJobRouteHandler(req, res);
|
getDocumentJobRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newDocumentPrinterRouteHandler,
|
newDocumentPrinterRouteHandler,
|
||||||
deleteDocumentPrinterRouteHandler,
|
deleteDocumentPrinterRouteHandler,
|
||||||
listDocumentPrintersByPropertiesRouteHandler,
|
listDocumentPrintersByPropertiesRouteHandler,
|
||||||
|
getDocumentPrinterStatsRouteHandler,
|
||||||
|
getDocumentPrinterHistoryRouteHandler,
|
||||||
} from '../../services/management/documentprinters.js';
|
} from '../../services/management/documentprinters.js';
|
||||||
|
|
||||||
// list of document printers
|
// list of document printers
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newDocumentPrinterRouteHandler(req, res);
|
newDocumentPrinterRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get document printer stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getDocumentPrinterStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get documentprinters history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getDocumentPrinterHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getDocumentPrinterRouteHandler(req, res);
|
getDocumentPrinterRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newDocumentSizeRouteHandler,
|
newDocumentSizeRouteHandler,
|
||||||
deleteDocumentSizeRouteHandler,
|
deleteDocumentSizeRouteHandler,
|
||||||
listDocumentSizesByPropertiesRouteHandler,
|
listDocumentSizesByPropertiesRouteHandler,
|
||||||
|
getDocumentSizeStatsRouteHandler,
|
||||||
|
getDocumentSizeHistoryRouteHandler,
|
||||||
} from '../../services/management/documentsizes.js';
|
} from '../../services/management/documentsizes.js';
|
||||||
|
|
||||||
// list of document sizes
|
// list of document sizes
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newDocumentSizeRouteHandler(req, res);
|
newDocumentSizeRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get document size stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getDocumentSizeStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get documentsizes history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getDocumentSizeHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getDocumentSizeRouteHandler(req, res);
|
getDocumentSizeRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newDocumentTemplateRouteHandler,
|
newDocumentTemplateRouteHandler,
|
||||||
deleteDocumentTemplateRouteHandler,
|
deleteDocumentTemplateRouteHandler,
|
||||||
listDocumentTemplatesByPropertiesRouteHandler,
|
listDocumentTemplatesByPropertiesRouteHandler,
|
||||||
|
getDocumentTemplateStatsRouteHandler,
|
||||||
|
getDocumentTemplateHistoryRouteHandler,
|
||||||
} from '../../services/management/documenttemplates.js';
|
} from '../../services/management/documenttemplates.js';
|
||||||
|
|
||||||
// list of document templates
|
// list of document templates
|
||||||
@ -35,6 +37,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newDocumentTemplateRouteHandler(req, res);
|
newDocumentTemplateRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get document template stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getDocumentTemplateStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get document template history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getDocumentTemplateHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getDocumentTemplateRouteHandler(req, res);
|
getDocumentTemplateRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import {
|
|||||||
getFilamentRouteHandler,
|
getFilamentRouteHandler,
|
||||||
editFilamentRouteHandler,
|
editFilamentRouteHandler,
|
||||||
newFilamentRouteHandler,
|
newFilamentRouteHandler,
|
||||||
|
getFilamentStatsRouteHandler,
|
||||||
|
getFilamentHistoryRouteHandler,
|
||||||
} from '../../services/management/filaments.js';
|
} from '../../services/management/filaments.js';
|
||||||
|
|
||||||
// list of filaments
|
// list of filaments
|
||||||
@ -50,6 +52,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newFilamentRouteHandler(req, res);
|
newFilamentRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get filament stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getFilamentStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get filaments history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getFilamentHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getFilamentRouteHandler(req, res);
|
getFilamentRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import {
|
|||||||
flushFileRouteHandler,
|
flushFileRouteHandler,
|
||||||
deleteFileRouteHandler,
|
deleteFileRouteHandler,
|
||||||
listFilesByPropertiesRouteHandler,
|
listFilesByPropertiesRouteHandler,
|
||||||
|
getFileStatsRouteHandler,
|
||||||
|
getFileHistoryRouteHandler,
|
||||||
} from '../../services/management/files.js';
|
} from '../../services/management/files.js';
|
||||||
|
|
||||||
// list of files
|
// list of files
|
||||||
@ -33,6 +35,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newFileRouteHandler(req, res);
|
newFileRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get file stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getFileStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get file history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getFileHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.delete('/:id/flush', isAuthenticated, (req, res) => {
|
router.delete('/:id/flush', isAuthenticated, (req, res) => {
|
||||||
flushFileRouteHandler(req, res);
|
flushFileRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newHostRouteHandler,
|
newHostRouteHandler,
|
||||||
deleteHostRouteHandler,
|
deleteHostRouteHandler,
|
||||||
listHostsByPropertiesRouteHandler,
|
listHostsByPropertiesRouteHandler,
|
||||||
|
getHostStatsRouteHandler,
|
||||||
|
getHostHistoryRouteHandler,
|
||||||
} from '../../services/management/hosts.js';
|
} from '../../services/management/hosts.js';
|
||||||
|
|
||||||
// list of hosts
|
// list of hosts
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newHostRouteHandler(req, res);
|
newHostRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get host stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getHostStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get hosts history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getHostHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getHostRouteHandler(req, res);
|
getHostRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import {
|
|||||||
getMaterialRouteHandler,
|
getMaterialRouteHandler,
|
||||||
editMaterialRouteHandler,
|
editMaterialRouteHandler,
|
||||||
newMaterialRouteHandler,
|
newMaterialRouteHandler,
|
||||||
|
getMaterialStatsRouteHandler,
|
||||||
|
getMaterialHistoryRouteHandler,
|
||||||
} from '../../services/management/materials.js';
|
} from '../../services/management/materials.js';
|
||||||
|
|
||||||
// list of materials
|
// list of materials
|
||||||
@ -34,6 +36,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newMaterialRouteHandler(req, res);
|
newMaterialRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get material stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getMaterialStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get materials history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getMaterialHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getMaterialRouteHandler(req, res);
|
getMaterialRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newNoteTypeRouteHandler,
|
newNoteTypeRouteHandler,
|
||||||
deleteNoteTypeRouteHandler,
|
deleteNoteTypeRouteHandler,
|
||||||
listNoteTypesByPropertiesRouteHandler,
|
listNoteTypesByPropertiesRouteHandler,
|
||||||
|
getNoteTypeStatsRouteHandler,
|
||||||
|
getNoteTypeHistoryRouteHandler,
|
||||||
} from '../../services/management/notetypes.js';
|
} from '../../services/management/notetypes.js';
|
||||||
|
|
||||||
// list of note types
|
// list of note types
|
||||||
@ -35,6 +37,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newNoteTypeRouteHandler(req, res);
|
newNoteTypeRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get note type stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getNoteTypeStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get notetypes history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getNoteTypeHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getNoteTypeRouteHandler(req, res);
|
getNoteTypeRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newPartRouteHandler,
|
newPartRouteHandler,
|
||||||
deletePartRouteHandler,
|
deletePartRouteHandler,
|
||||||
listPartsByPropertiesRouteHandler,
|
listPartsByPropertiesRouteHandler,
|
||||||
|
getPartStatsRouteHandler,
|
||||||
|
getPartHistoryRouteHandler,
|
||||||
} from '../../services/management/parts.js';
|
} from '../../services/management/parts.js';
|
||||||
|
|
||||||
// list of parts
|
// list of parts
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newPartRouteHandler(req, res);
|
newPartRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get part stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getPartStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get parts history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getPartHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getPartRouteHandler(req, res);
|
getPartRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newProductRouteHandler,
|
newProductRouteHandler,
|
||||||
deleteProductRouteHandler,
|
deleteProductRouteHandler,
|
||||||
listProductsByPropertiesRouteHandler,
|
listProductsByPropertiesRouteHandler,
|
||||||
|
getProductStatsRouteHandler,
|
||||||
|
getProductHistoryRouteHandler,
|
||||||
} from '../../services/management/products.js';
|
} from '../../services/management/products.js';
|
||||||
|
|
||||||
// list of products
|
// list of products
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newProductRouteHandler(req, res);
|
newProductRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get product stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getProductStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get products history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getProductHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getProductRouteHandler(req, res);
|
getProductRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newTaxRateRouteHandler,
|
newTaxRateRouteHandler,
|
||||||
deleteTaxRateRouteHandler,
|
deleteTaxRateRouteHandler,
|
||||||
listTaxRatesByPropertiesRouteHandler,
|
listTaxRatesByPropertiesRouteHandler,
|
||||||
|
getTaxRateStatsRouteHandler,
|
||||||
|
getTaxRateHistoryRouteHandler,
|
||||||
} from '../../services/management/taxrates.js';
|
} from '../../services/management/taxrates.js';
|
||||||
|
|
||||||
// list of tax rates
|
// list of tax rates
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newTaxRateRouteHandler(req, res);
|
newTaxRateRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get tax rate stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getTaxRateStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get tax rate history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getTaxRateHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getTaxRateRouteHandler(req, res);
|
getTaxRateRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newTaxRecordRouteHandler,
|
newTaxRecordRouteHandler,
|
||||||
deleteTaxRecordRouteHandler,
|
deleteTaxRecordRouteHandler,
|
||||||
listTaxRecordsByPropertiesRouteHandler,
|
listTaxRecordsByPropertiesRouteHandler,
|
||||||
|
getTaxRecordStatsRouteHandler,
|
||||||
|
getTaxRecordHistoryRouteHandler,
|
||||||
} from '../../services/management/taxrecords.js';
|
} from '../../services/management/taxrecords.js';
|
||||||
|
|
||||||
// list of tax records
|
// list of tax records
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newTaxRecordRouteHandler(req, res);
|
newTaxRecordRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get tax record stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getTaxRecordStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get tax record history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getTaxRecordHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getTaxRecordRouteHandler(req, res);
|
getTaxRecordRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import {
|
|||||||
listUsersByPropertiesRouteHandler,
|
listUsersByPropertiesRouteHandler,
|
||||||
getUserRouteHandler,
|
getUserRouteHandler,
|
||||||
editUserRouteHandler,
|
editUserRouteHandler,
|
||||||
|
getUserStatsRouteHandler,
|
||||||
|
getUserHistoryRouteHandler,
|
||||||
} from '../../services/management/users.js';
|
} from '../../services/management/users.js';
|
||||||
|
|
||||||
// list of document templates
|
// list of document templates
|
||||||
@ -29,6 +31,16 @@ router.get('/properties', isAuthenticated, (req, res) => {
|
|||||||
listUsersByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
|
listUsersByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get user stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getUserStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get user history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getUserHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getUserRouteHandler(req, res);
|
getUserRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import {
|
|||||||
newVendorRouteHandler,
|
newVendorRouteHandler,
|
||||||
deleteVendorRouteHandler,
|
deleteVendorRouteHandler,
|
||||||
listVendorsByPropertiesRouteHandler,
|
listVendorsByPropertiesRouteHandler,
|
||||||
|
getVendorStatsRouteHandler,
|
||||||
|
getVendorHistoryRouteHandler,
|
||||||
} from '../../services/management/vendors.js';
|
} from '../../services/management/vendors.js';
|
||||||
|
|
||||||
// list of vendors
|
// list of vendors
|
||||||
@ -31,6 +33,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newVendorRouteHandler(req, res);
|
newVendorRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get vendor stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getVendorStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get vendors history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getVendorHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getVendorRouteHandler(req, res);
|
getVendorRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,8 +6,11 @@ import {
|
|||||||
editNoteRouteHandler,
|
editNoteRouteHandler,
|
||||||
newNoteRouteHandler,
|
newNoteRouteHandler,
|
||||||
deleteNoteRouteHandler,
|
deleteNoteRouteHandler,
|
||||||
|
listNotesByPropertiesRouteHandler,
|
||||||
|
getNoteStatsRouteHandler,
|
||||||
|
getNoteHistoryRouteHandler,
|
||||||
} from '../../services/misc/notes.js';
|
} from '../../services/misc/notes.js';
|
||||||
import { getFilter } from '../../utils.js';
|
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@ -31,6 +34,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newNoteRouteHandler(req, res);
|
newNoteRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get note stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getNoteStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get note history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getNoteHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getNoteRouteHandler(req, res);
|
getNoteRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import {
|
|||||||
newGCodeFileRouteHandler,
|
newGCodeFileRouteHandler,
|
||||||
listGCodeFilesByPropertiesRouteHandler,
|
listGCodeFilesByPropertiesRouteHandler,
|
||||||
getGCodeFileContentRouteHandler,
|
getGCodeFileContentRouteHandler,
|
||||||
|
getGCodeFileStatsRouteHandler,
|
||||||
} from '../../services/production/gcodefiles.js';
|
} from '../../services/production/gcodefiles.js';
|
||||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||||
|
|
||||||
@ -32,6 +33,11 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newGCodeFileRouteHandler(req, res);
|
newGCodeFileRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get gcodeFile stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getGCodeFileStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getGCodeFileRouteHandler(req, res);
|
getGCodeFileRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import {
|
|||||||
newJobRouteHandler,
|
newJobRouteHandler,
|
||||||
deleteJobRouteHandler,
|
deleteJobRouteHandler,
|
||||||
getJobStatsRouteHandler,
|
getJobStatsRouteHandler,
|
||||||
|
getJobHistoryRouteHandler,
|
||||||
} from '../../services/production/jobs.js';
|
} from '../../services/production/jobs.js';
|
||||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||||
|
|
||||||
@ -31,6 +32,16 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newJobRouteHandler(req, res);
|
newJobRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get job stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getJobStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get job history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getJobHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getJobRouteHandler(req, res);
|
getJobRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
@ -39,9 +50,4 @@ router.delete('/:id', isAuthenticated, async (req, res) => {
|
|||||||
deleteJobRouteHandler(req, res);
|
deleteJobRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
// get printer stats
|
|
||||||
router.get('/stats', isAuthenticated, (req, res) => {
|
|
||||||
getJobStatsRouteHandler(req, res);
|
|
||||||
});
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import {
|
|||||||
newPrinterRouteHandler,
|
newPrinterRouteHandler,
|
||||||
getPrinterStatsRouteHandler,
|
getPrinterStatsRouteHandler,
|
||||||
listPrintersByPropertiesRouteHandler,
|
listPrintersByPropertiesRouteHandler,
|
||||||
|
getPrinterHistoryRouteHandler,
|
||||||
} from '../../services/production/printers.js';
|
} from '../../services/production/printers.js';
|
||||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||||
|
|
||||||
@ -32,6 +33,11 @@ router.post('/', isAuthenticated, (req, res) => {
|
|||||||
newPrinterRouteHandler(req, res);
|
newPrinterRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get printer history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getPrinterHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
// get printer stats
|
// get printer stats
|
||||||
router.get('/stats', isAuthenticated, (req, res) => {
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
getPrinterStatsRouteHandler(req, res);
|
getPrinterStatsRouteHandler(req, res);
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import {
|
|||||||
listSubJobsRouteHandler,
|
listSubJobsRouteHandler,
|
||||||
listSubJobsByPropertiesRouteHandler,
|
listSubJobsByPropertiesRouteHandler,
|
||||||
getSubJobRouteHandler,
|
getSubJobRouteHandler,
|
||||||
|
getSubJobStatsRouteHandler,
|
||||||
|
getSubJobHistoryRouteHandler,
|
||||||
} from '../../services/production/subjobs.js';
|
} from '../../services/production/subjobs.js';
|
||||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||||
|
|
||||||
@ -24,6 +26,16 @@ router.get('/properties', isAuthenticated, (req, res) => {
|
|||||||
listSubJobsByPropertiesRouteHandler(req, res, properties, filter);
|
listSubJobsByPropertiesRouteHandler(req, res, properties, filter);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get sub job stats
|
||||||
|
router.get('/stats', isAuthenticated, (req, res) => {
|
||||||
|
getSubJobStatsRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// get sub job history
|
||||||
|
router.get('/history', isAuthenticated, (req, res) => {
|
||||||
|
getSubJobHistoryRouteHandler(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/:id', isAuthenticated, (req, res) => {
|
router.get('/:id', isAuthenticated, (req, res) => {
|
||||||
getSubJobRouteHandler(req, res);
|
getSubJobRouteHandler(req, res);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { filamentStockModel } from '../../schemas/inventory/filamentstock.schema.js';
|
import { filamentStockModel } from '../../database/schemas/inventory/filamentstock.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -157,3 +159,25 @@ export const deleteFilamentStockRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getFilamentStockStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: filamentStockModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching filament stock stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Filament stock stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getFilamentStockHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: filamentStockModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching filament stock history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Filament stock history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { orderItemModel } from '../../schemas/inventory/orderitem.schema.js';
|
import { orderItemModel } from '../../database/schemas/inventory/orderitem.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -45,11 +47,11 @@ export const listOrderItemsRouteHandler = async (
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'item',
|
path: 'item',
|
||||||
populate: { path: 'costTaxRate' },
|
populate: { path: 'costTaxRate', strictPopulate: false },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'item',
|
path: 'item',
|
||||||
populate: { path: 'priceTaxRate' },
|
populate: { path: 'priceTaxRate', strictPopulate: false },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -104,11 +106,13 @@ export const getOrderItemRouteHandler = async (req, res) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'item',
|
path: 'item',
|
||||||
populate: { path: 'costTaxRate' },
|
populate: { path: 'costTaxRate', strictPopulate: false },
|
||||||
|
strictPopulate: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'item',
|
path: 'item',
|
||||||
populate: { path: 'priceTaxRate' },
|
populate: { path: 'priceTaxRate', strictPopulate: false },
|
||||||
|
strictPopulate: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -128,9 +132,10 @@ export const editOrderItemRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
const updateData = {
|
const updateData = {
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
purchaseOrder: req.body.purchaseOrder,
|
|
||||||
itemType: req.body.itemType,
|
itemType: req.body.itemType,
|
||||||
item: req.body.item,
|
item: req.body.item,
|
||||||
|
orderType: req.body.orderType,
|
||||||
|
order: req.body.order,
|
||||||
syncAmount: req.body.syncAmount,
|
syncAmount: req.body.syncAmount,
|
||||||
itemAmount: req.body.itemAmount,
|
itemAmount: req.body.itemAmount,
|
||||||
quantity: req.body.quantity,
|
quantity: req.body.quantity,
|
||||||
@ -161,6 +166,7 @@ export const newOrderItemRouteHandler = async (req, res) => {
|
|||||||
const newData = {
|
const newData = {
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
purchaseOrder: req.body.purchaseOrder,
|
purchaseOrder: req.body.purchaseOrder,
|
||||||
|
state: { type: 'draft' },
|
||||||
itemType: req.body.itemType,
|
itemType: req.body.itemType,
|
||||||
item: req.body.item,
|
item: req.body.item,
|
||||||
orderType: req.body.orderType,
|
orderType: req.body.orderType,
|
||||||
@ -207,3 +213,25 @@ export const deleteOrderItemRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getOrderItemStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: orderItemModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching order item stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Order item stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getOrderItemHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: orderItemModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching order item history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Order item history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { partStockModel } from '../../schemas/inventory/partstock.schema.js';
|
import { partStockModel } from '../../database/schemas/inventory/partstock.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -157,3 +159,25 @@ export const deletePartStockRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getPartStockStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: partStockModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching part stock stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Part stock stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPartStockHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: partStockModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching part stock history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Part stock history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { purchaseOrderModel } from '../../schemas/inventory/purchaseorder.schema.js';
|
import { purchaseOrderModel } from '../../database/schemas/inventory/purchaseorder.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -78,7 +80,7 @@ export const getPurchaseOrderRouteHandler = async (req, res) => {
|
|||||||
const result = await getObject({
|
const result = await getObject({
|
||||||
model: purchaseOrderModel,
|
model: purchaseOrderModel,
|
||||||
id,
|
id,
|
||||||
populate: ['vendor', 'items.item', 'items.taxRate'],
|
populate: ['vendor'],
|
||||||
});
|
});
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
logger.warn(`Purchase Order not found with supplied id.`);
|
logger.warn(`Purchase Order not found with supplied id.`);
|
||||||
@ -97,8 +99,6 @@ export const editPurchaseOrderRouteHandler = async (req, res) => {
|
|||||||
const updateData = {
|
const updateData = {
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
vendor: req.body.vendor,
|
vendor: req.body.vendor,
|
||||||
items: req.body.items,
|
|
||||||
cost: req.body.cost,
|
|
||||||
};
|
};
|
||||||
// Create audit log before updating
|
// Create audit log before updating
|
||||||
const result = await editObject({
|
const result = await editObject({
|
||||||
@ -123,8 +123,6 @@ export const newPurchaseOrderRouteHandler = async (req, res) => {
|
|||||||
const newData = {
|
const newData = {
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
vendor: req.body.vendor,
|
vendor: req.body.vendor,
|
||||||
items: req.body.items,
|
|
||||||
cost: req.body.cost,
|
|
||||||
};
|
};
|
||||||
const result = await newObject({
|
const result = await newObject({
|
||||||
model: purchaseOrderModel,
|
model: purchaseOrderModel,
|
||||||
@ -161,3 +159,25 @@ export const deletePurchaseOrderRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getPurchaseOrderStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: purchaseOrderModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching purchase order stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Purchase order stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPurchaseOrderHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: purchaseOrderModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching purchase order history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Purchase order history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { shipmentModel } from '../../schemas/inventory/shipment.schema.js';
|
import { shipmentModel } from '../../database/schemas/inventory/shipment.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -175,3 +177,25 @@ export const deleteShipmentRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getShipmentStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: shipmentModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching shipment stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Shipment stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getShipmentHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: shipmentModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching shipment history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Shipment history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { stockAuditModel } from '../../schemas/inventory/stockaudit.schema.js';
|
import { stockAuditModel } from '../../database/schemas/inventory/stockaudit.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import { getAuditLogs } from '../../utils.js';
|
import { getAuditLogs } from '../../utils.js';
|
||||||
|
import { getModelStats, getModelHistory } from '../../database/database.js';
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -168,3 +169,25 @@ export const deleteStockAuditRouteHandler = async (req, res) => {
|
|||||||
res.status(500).send({ error: error.message });
|
res.status(500).send({ error: error.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getStockAuditStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: stockAuditModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching stock audit stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Stock audit stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStockAuditHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: stockAuditModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching stock audit history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Stock audit history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { stockEventModel } from '../../schemas/inventory/stockevent.schema.js';
|
import { stockEventModel } from '../../database/schemas/inventory/stockevent.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -165,3 +167,25 @@ export const deleteStockEventRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getStockEventStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: stockEventModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching stock event stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Stock event stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStockEventHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: stockEventModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching stock event history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Stock event history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { auditLogModel } from '../../schemas/management/auditlog.schema.js';
|
import { auditLogModel } from '../../database/schemas/management/auditlog.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
|
import { getModelStats, getModelHistory } from '../../database/database.js';
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const logger = log4js.getLogger('AuditLogs');
|
const logger = log4js.getLogger('AuditLogs');
|
||||||
@ -88,3 +89,25 @@ export const getAuditLogRouteHandler = async (req, res) => {
|
|||||||
res.status(500).send({ error: error.message });
|
res.status(500).send({ error: error.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getAuditLogStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: auditLogModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching audit log stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Audit log stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAuditLogHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: auditLogModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching audit log history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Audit log history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { courierModel } from '../../schemas/management/courier.schema.js';
|
import { courierModel } from '../../database/schemas/management/courier.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -162,3 +164,25 @@ export const deleteCourierRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getCourierStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: courierModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching courier stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Courier stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getCourierHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: courierModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching courier history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Courier history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { courierServiceModel } from '../../schemas/management/courierservice.schema.js';
|
import { courierServiceModel } from '../../database/schemas/management/courierservice.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -165,3 +167,25 @@ export const deleteCourierServiceRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getCourierServiceStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: courierServiceModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching courier service stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Courier service stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getCourierServiceHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: courierServiceModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching courier service history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Courier service history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { documentJobModel } from '../../schemas/management/documentjob.schema.js';
|
import { documentJobModel } from '../../database/schemas/management/documentjob.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -158,3 +160,25 @@ export const deleteDocumentJobRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getDocumentJobStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: documentJobModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching document job stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Document job stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDocumentJobHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: documentJobModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching document job history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Document job history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { documentPrinterModel } from '../../schemas/management/documentprinter.schema.js';
|
import { documentPrinterModel } from '../../database/schemas/management/documentprinter.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -167,3 +169,25 @@ export const deleteDocumentPrinterRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getDocumentPrinterStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: documentPrinterModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching document printer stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Document printer stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDocumentPrinterHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: documentPrinterModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching document printer history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Document printer history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { documentSizeModel } from '../../schemas/management/documentsize.schema.js';
|
import { documentSizeModel } from '../../database/schemas/management/documentsize.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -158,3 +160,25 @@ export const deleteDocumentSizeRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getDocumentSizeStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: documentSizeModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching document size stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Document size stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDocumentSizeHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: documentSizeModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching document size history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Document size history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { documentTemplateModel } from '../../schemas/management/documenttemplate.schema.js';
|
import { documentTemplateModel } from '../../database/schemas/management/documenttemplate.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -184,3 +186,25 @@ export const deleteDocumentTemplateRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getDocumentTemplateStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: documentTemplateModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching document template stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Document template stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDocumentTemplateHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: documentTemplateModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching document template history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Document template history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv, { populate } from 'dotenv';
|
import dotenv, { populate } from 'dotenv';
|
||||||
import { filamentModel } from '../../schemas/management/filament.schema.js';
|
import { filamentModel } from '../../database/schemas/management/filament.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -8,6 +8,8 @@ import {
|
|||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
@ -34,7 +36,7 @@ export const listFilamentsRouteHandler = async (
|
|||||||
search,
|
search,
|
||||||
sort,
|
sort,
|
||||||
order,
|
order,
|
||||||
populate: ['vendor'],
|
populate: ['vendor', 'costTaxRate'],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
@ -75,7 +77,7 @@ export const getFilamentRouteHandler = async (req, res) => {
|
|||||||
const result = await getObject({
|
const result = await getObject({
|
||||||
model: filamentModel,
|
model: filamentModel,
|
||||||
id,
|
id,
|
||||||
populate: 'vendor',
|
populate: ['vendor', 'costTaxRate'],
|
||||||
});
|
});
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
logger.warn(`Filament not found with supplied id.`);
|
logger.warn(`Filament not found with supplied id.`);
|
||||||
@ -101,6 +103,8 @@ export const editFilamentRouteHandler = async (req, res) => {
|
|||||||
vendor: req.body.vendor,
|
vendor: req.body.vendor,
|
||||||
type: req.body.type,
|
type: req.body.type,
|
||||||
cost: req.body.cost,
|
cost: req.body.cost,
|
||||||
|
costTaxRate: req.body.costTaxRate,
|
||||||
|
costWithTax: req.body.costWithTax,
|
||||||
diameter: req.body.diameter,
|
diameter: req.body.diameter,
|
||||||
density: req.body.density,
|
density: req.body.density,
|
||||||
emptySpoolWeight: req.body.emptySpoolWeight,
|
emptySpoolWeight: req.body.emptySpoolWeight,
|
||||||
@ -135,6 +139,8 @@ export const newFilamentRouteHandler = async (req, res) => {
|
|||||||
vendor: req.body.vendor,
|
vendor: req.body.vendor,
|
||||||
type: req.body.type,
|
type: req.body.type,
|
||||||
cost: req.body.cost,
|
cost: req.body.cost,
|
||||||
|
costTaxRate: req.body.costTaxRate,
|
||||||
|
costWithTax: req.body.costWithTax,
|
||||||
diameter: req.body.diameter,
|
diameter: req.body.diameter,
|
||||||
density: req.body.density,
|
density: req.body.density,
|
||||||
emptySpoolWeight: req.body.emptySpoolWeight,
|
emptySpoolWeight: req.body.emptySpoolWeight,
|
||||||
@ -154,3 +160,25 @@ export const newFilamentRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getFilamentStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: filamentModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching filament stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Filament stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getFilamentHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: filamentModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching filament history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Filament history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { fileModel } from '../../schemas/management/file.schema.js';
|
import { fileModel } from '../../database/schemas/management/file.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import multer from 'multer';
|
import multer from 'multer';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@ -13,6 +13,8 @@ import {
|
|||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
flushFile,
|
flushFile,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
import {
|
import {
|
||||||
uploadFile,
|
uploadFile,
|
||||||
@ -421,3 +423,25 @@ export const parseFileHandler = async (req, res) => {
|
|||||||
res.status(500).send({ error: error.message });
|
res.status(500).send({ error: error.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getFileStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: fileModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching file stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('File stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getFileHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: fileModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching file history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('File history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { hostModel } from '../../schemas/management/host.schema.js';
|
import { hostModel } from '../../database/schemas/management/host.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -159,3 +161,25 @@ export const deleteHostRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getHostStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: hostModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching host stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Host stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getHostHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: hostModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching host history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Host history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { materialModel } from '../../schemas/management/material.schema.js';
|
import { materialModel } from '../../database/schemas/management/material.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
|
import { getModelStats, getModelHistory } from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
const logger = log4js.getLogger('Materials');
|
const logger = log4js.getLogger('Materials');
|
||||||
@ -128,3 +129,25 @@ export const newMaterialRouteHandler = async (req, res) => {
|
|||||||
res.status(500).send({ error: updateError.message });
|
res.status(500).send({ error: updateError.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getMaterialStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: materialModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching material stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Material stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getMaterialHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: materialModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching material history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Material history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { noteTypeModel } from '../../schemas/management/notetype.schema.js';
|
import { noteTypeModel } from '../../database/schemas/management/notetype.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -158,3 +160,25 @@ export const deleteNoteTypeRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getNoteTypeStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: noteTypeModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching note type stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Note type stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getNoteTypeHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: noteTypeModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching note type history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Note type history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { partModel } from '../../schemas/management/part.schema.js';
|
import { partModel } from '../../database/schemas/management/part.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -53,7 +55,20 @@ export const listPartsByPropertiesRouteHandler = async (req, res, properties = '
|
|||||||
model: partModel,
|
model: partModel,
|
||||||
properties,
|
properties,
|
||||||
filter,
|
filter,
|
||||||
populate: ['vendor', 'priceTaxRate', 'costTaxRate'],
|
populate: [
|
||||||
|
{
|
||||||
|
path: 'vendor',
|
||||||
|
from: 'vendors',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'priceTaxRate',
|
||||||
|
from: 'taxrates',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'costTaxRate',
|
||||||
|
from: 'taxrates',
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
@ -171,3 +186,25 @@ export const deletePartRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getPartStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: partModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching part stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Part stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPartHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: partModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching part history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Part history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { productModel } from '../../schemas/management/product.schema.js';
|
import { productModel } from '../../database/schemas/management/product.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -170,3 +172,25 @@ export const deleteProductRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getProductStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: productModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching product stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Product stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getProductHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: productModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching product history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Product history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,21 +1,21 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { jobModel } from '../../schemas/production/job.schema.js';
|
import { jobModel } from '../../database/schemas/production/job.schema.js';
|
||||||
import { subJobModel } from '../../schemas/production/subjob.schema.js';
|
import { subJobModel } from '../../database/schemas/production/subjob.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import { printerModel } from '../../schemas/production/printer.schema.js';
|
import { printerModel } from '../../database/schemas/production/printer.schema.js';
|
||||||
import { filamentModel } from '../../schemas/management/filament.schema.js';
|
import { filamentModel } from '../../database/schemas/management/filament.schema.js';
|
||||||
import { gcodeFileModel } from '../../schemas/production/gcodefile.schema.js';
|
import { gcodeFileModel } from '../../database/schemas/production/gcodefile.schema.js';
|
||||||
import { partModel } from '../../schemas/management/part.schema.js';
|
import { partModel } from '../../database/schemas/management/part.schema.js';
|
||||||
import { productModel } from '../../schemas/management/product.schema.js';
|
import { productModel } from '../../database/schemas/management/product.schema.js';
|
||||||
import { vendorModel } from '../../schemas/management/vendor.schema.js';
|
import { vendorModel } from '../../database/schemas/management/vendor.schema.js';
|
||||||
import { filamentStockModel } from '../../schemas/inventory/filamentstock.schema.js';
|
import { filamentStockModel } from '../../database/schemas/inventory/filamentstock.schema.js';
|
||||||
import { stockEventModel } from '../../schemas/inventory/stockevent.schema.js';
|
import { stockEventModel } from '../../database/schemas/inventory/stockevent.schema.js';
|
||||||
import { stockAuditModel } from '../../schemas/inventory/stockaudit.schema.js';
|
import { stockAuditModel } from '../../database/schemas/inventory/stockaudit.schema.js';
|
||||||
import { partStockModel } from '../../schemas/inventory/partstock.schema.js';
|
import { partStockModel } from '../../database/schemas/inventory/partstock.schema.js';
|
||||||
import { auditLogModel } from '../../schemas/management/auditlog.schema.js';
|
import { auditLogModel } from '../../database/schemas/management/auditlog.schema.js';
|
||||||
import { userModel } from '../../schemas/management/user.schema.js';
|
import { userModel } from '../../database/schemas/management/user.schema.js';
|
||||||
import { noteTypeModel } from '../../schemas/management/notetype.schema.js';
|
import { noteTypeModel } from '../../database/schemas/management/notetype.schema.js';
|
||||||
import { noteModel } from '../../schemas/misc/note.schema.js';
|
import { noteModel } from '../../database/schemas/misc/note.schema.js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { taxRateModel } from '../../schemas/management/taxrates.schema.js';
|
import { taxRateModel } from '../../database/schemas/management/taxrates.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -166,3 +168,25 @@ export const deleteTaxRateRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getTaxRateStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: taxRateModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching tax rate stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Tax rate stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTaxRateHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: taxRateModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching tax rate history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Tax rate history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { taxRecordModel } from '../../schemas/management/taxrecord.schema.js';
|
import { taxRecordModel } from '../../database/schemas/management/taxrecord.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -162,3 +164,25 @@ export const deleteTaxRecordRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getTaxRecordStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: taxRecordModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching tax record stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Tax record stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTaxRecordHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: taxRecordModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching tax record history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Tax record history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { userModel } from '../../schemas/management/user.schema.js';
|
import { userModel } from '../../database/schemas/management/user.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -7,6 +7,8 @@ import {
|
|||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
getObject,
|
getObject,
|
||||||
editObject,
|
editObject,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
@ -117,3 +119,25 @@ export const editUserRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getUserStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: userModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching user stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('User stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getUserHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: userModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching user history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('User history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { vendorModel } from '../../schemas/management/vendor.schema.js';
|
import { vendorModel } from '../../database/schemas/management/vendor.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import {
|
import {
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
editObject,
|
editObject,
|
||||||
newObject,
|
newObject,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@ -166,3 +168,25 @@ export const deleteVendorRouteHandler = async (req, res) => {
|
|||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getVendorStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: vendorModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching vendor stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Vendor stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getVendorHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: vendorModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching vendor history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Vendor history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import dotenv from 'dotenv';
|
|||||||
import { keycloak } from '../../keycloak.js';
|
import { keycloak } from '../../keycloak.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { userModel } from '../../schemas/management/user.schema.js';
|
import { userModel } from '../../database/schemas/management/user.schema.js';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import NodeCache from 'node-cache';
|
import NodeCache from 'node-cache';
|
||||||
@ -32,16 +32,16 @@ const lookupUserByToken = async (token) => {
|
|||||||
// Check cache first
|
// Check cache first
|
||||||
const cachedUser = tokenUserCache.get(token);
|
const cachedUser = tokenUserCache.get(token);
|
||||||
if (cachedUser) {
|
if (cachedUser) {
|
||||||
logger.debug(`User found in token cache for token: ${token.substring(0, 20)}...`);
|
logger.trace(`User found in token cache for token: ${token.substring(0, 20)}...`);
|
||||||
return cachedUser;
|
return cachedUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not in cache, decode token and lookup user
|
// If not in cache, decode token and lookup user
|
||||||
logger.debug(`User not in token cache, decoding token: ${token.substring(0, 20)}...`);
|
logger.trace(`User not in token cache, decoding token: ${token.substring(0, 20)}...`);
|
||||||
const decodedToken = jwt.decode(token);
|
const decodedToken = jwt.decode(token);
|
||||||
|
|
||||||
if (!decodedToken || !decodedToken.preferred_username) {
|
if (!decodedToken || !decodedToken.preferred_username) {
|
||||||
logger.warn('Invalid token or missing preferred_username');
|
logger.trace('Invalid token or missing preferred_username');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ const lookupUserByToken = async (token) => {
|
|||||||
if (user) {
|
if (user) {
|
||||||
// Store in cache using token as key
|
// Store in cache using token as key
|
||||||
tokenUserCache.set(token, user);
|
tokenUserCache.set(token, user);
|
||||||
logger.debug(`User stored in token cache for token: ${token.substring(0, 20)}...`);
|
logger.trace(`User stored in token cache for token: ${token.substring(0, 20)}...`);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { models } from '../../schemas/models.js';
|
import { models } from '../../database/schemas/models.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all models from the PREFIX_MODEL_MAP
|
* Get all models from the PREFIX_MODEL_MAP
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { noteModel } from '../../schemas/misc/note.schema.js';
|
import { noteModel } from '../../database/schemas/misc/note.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import {
|
import {
|
||||||
deleteObject,
|
deleteObject,
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
newObject,
|
newObject,
|
||||||
recursivelyDeleteChildObjects,
|
recursivelyDeleteChildObjects,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
|
|
||||||
@ -73,7 +75,7 @@ export const getNoteRouteHandler = async (req, res) => {
|
|||||||
const result = await getObject({
|
const result = await getObject({
|
||||||
model: noteModel,
|
model: noteModel,
|
||||||
id,
|
id,
|
||||||
populate: ['noteType', 'user'],
|
populate: ['noteType', 'user', 'parent'],
|
||||||
});
|
});
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
logger.warn(`Note not found with supplied id.`);
|
logger.warn(`Note not found with supplied id.`);
|
||||||
@ -161,3 +163,25 @@ export const deleteNoteRouteHandler = async (req, res) => {
|
|||||||
status: 'ok',
|
status: 'ok',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getNoteStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: noteModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching note stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Note stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getNoteHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: noteModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching note history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Note history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { gcodeFileModel } from '../../schemas/production/gcodefile.schema.js';
|
import { gcodeFileModel } from '../../database/schemas/production/gcodefile.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import {
|
import {
|
||||||
deleteObject,
|
deleteObject,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import { jobModel } from '../../schemas/production/job.schema.js';
|
import { jobModel } from '../../database/schemas/production/job.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import {
|
import {
|
||||||
deleteObject,
|
deleteObject,
|
||||||
@ -8,8 +8,10 @@ import {
|
|||||||
listObjects,
|
listObjects,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
newObject,
|
newObject,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
import { subJobModel } from '../../schemas/production/subjob.schema.js';
|
import { subJobModel } from '../../database/schemas/production/subjob.schema.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
const logger = log4js.getLogger('Jobs');
|
const logger = log4js.getLogger('Jobs');
|
||||||
@ -161,26 +163,24 @@ export const deleteJobRouteHandler = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getJobStatsRouteHandler = async (req, res) => {
|
export const getJobStatsRouteHandler = async (req, res) => {
|
||||||
try {
|
console.log('Getting job stats');
|
||||||
const stats = await jobModel.aggregate([
|
const result = await getModelStats({ model: jobModel });
|
||||||
{
|
if (result?.error) {
|
||||||
$group: {
|
logger.error('Error fetching job stats:', result.error);
|
||||||
_id: '$state.type',
|
return res.status(result.code).send(result);
|
||||||
count: { $sum: 1 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Transform the results into a more readable format
|
|
||||||
const formattedStats = stats.reduce((acc, curr) => {
|
|
||||||
acc[curr._id] = curr.count;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
logger.trace('Print job stats by state:', formattedStats);
|
|
||||||
res.send(formattedStats);
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('Error fetching print job stats:', error);
|
|
||||||
res.status(500).send({ error: error.message });
|
|
||||||
}
|
}
|
||||||
|
logger.trace('Job stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getJobHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: jobModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching job history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Job history:', result);
|
||||||
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { printerModel } from '../../schemas/production/printer.schema.js';
|
import { printerModel } from '../../database/schemas/production/printer.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import {
|
import {
|
||||||
deleteObject,
|
deleteObject,
|
||||||
@ -8,6 +8,8 @@ import {
|
|||||||
listObjects,
|
listObjects,
|
||||||
listObjectsByProperties,
|
listObjectsByProperties,
|
||||||
newObject,
|
newObject,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
} from '../../database/database.js';
|
} from '../../database/database.js';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
|
|
||||||
@ -169,26 +171,24 @@ export const deletePrinterRouteHandler = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getPrinterStatsRouteHandler = async (req, res) => {
|
export const getPrinterStatsRouteHandler = async (req, res) => {
|
||||||
try {
|
const result = await getModelStats({ model: printerModel });
|
||||||
const stats = await printerModel.aggregate([
|
console.log(result);
|
||||||
{
|
if (!result) {
|
||||||
$group: {
|
logger.error('Error fetching printer stats:', result.error);
|
||||||
_id: '$state.type',
|
return res.status(result.code).send(result);
|
||||||
count: { $sum: 1 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Transform the results into a more readable format
|
|
||||||
const formattedStats = stats.reduce((acc, curr) => {
|
|
||||||
acc[curr._id] = curr.count;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
logger.trace('Printer stats by state:', formattedStats);
|
|
||||||
res.send(formattedStats);
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('Error fetching printer stats:', error);
|
|
||||||
res.status(500).send({ error: error.message });
|
|
||||||
}
|
}
|
||||||
|
logger.trace('Printer stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPrinterHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: printerModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching printer history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Printer history:', result);
|
||||||
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { subJobModel } from '../../schemas/production/subjob.schema.js';
|
import { subJobModel } from '../../database/schemas/production/subjob.schema.js';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
import { getObject, listObjects, listObjectsByProperties } from '../../database/database.js';
|
import {
|
||||||
|
getObject,
|
||||||
|
listObjects,
|
||||||
|
listObjectsByProperties,
|
||||||
|
getModelStats,
|
||||||
|
getModelHistory,
|
||||||
|
} from '../../database/database.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
const logger = log4js.getLogger('Sub Jobs');
|
const logger = log4js.getLogger('Sub Jobs');
|
||||||
@ -27,7 +33,7 @@ export const listSubJobsRouteHandler = async (
|
|||||||
search,
|
search,
|
||||||
sort,
|
sort,
|
||||||
order,
|
order,
|
||||||
populate: ['printer'],
|
populate: ['printer', 'job'],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
@ -69,6 +75,7 @@ export const getSubJobRouteHandler = async (req, res) => {
|
|||||||
const result = await getObject({
|
const result = await getObject({
|
||||||
model: subJobModel,
|
model: subJobModel,
|
||||||
id,
|
id,
|
||||||
|
populate: ['printer'],
|
||||||
});
|
});
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
logger.warn(`Sub job not found with supplied id.`);
|
logger.warn(`Sub job not found with supplied id.`);
|
||||||
@ -77,3 +84,25 @@ export const getSubJobRouteHandler = async (req, res) => {
|
|||||||
logger.debug(`Retreived sub job with ID: ${id}`);
|
logger.debug(`Retreived sub job with ID: ${id}`);
|
||||||
res.send(result);
|
res.send(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getSubJobStatsRouteHandler = async (req, res) => {
|
||||||
|
const result = await getModelStats({ model: subJobModel });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching sub job stats:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Sub job stats:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getSubJobHistoryRouteHandler = async (req, res) => {
|
||||||
|
const from = req.query.from;
|
||||||
|
const to = req.query.to;
|
||||||
|
const result = await getModelHistory({ model: subJobModel, from, to });
|
||||||
|
if (result?.error) {
|
||||||
|
logger.error('Error fetching sub job history:', result.error);
|
||||||
|
return res.status(result.code).send(result);
|
||||||
|
}
|
||||||
|
logger.trace('Sub job history:', result);
|
||||||
|
res.send(result);
|
||||||
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user