reduce wildcard imports
parent
c9beb16e51
commit
15e6fc3d66
12
bin/www.js
12
bin/www.js
|
|
@ -5,11 +5,11 @@ import { fileURLToPath } from 'node:url';
|
||||||
import ntfyPublish from '@cityssm/ntfy-publish';
|
import ntfyPublish from '@cityssm/ntfy-publish';
|
||||||
import Debug from 'debug';
|
import Debug from 'debug';
|
||||||
import exitHook from 'exit-hook';
|
import exitHook from 'exit-hook';
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
const debug = Debug(`lot-occupancy-system:www:${process.pid}`);
|
const debug = Debug(`lot-occupancy-system:www:${process.pid}`);
|
||||||
const directoryName = dirname(fileURLToPath(import.meta.url));
|
const directoryName = dirname(fileURLToPath(import.meta.url));
|
||||||
const processCount = Math.min(configFunctions.getConfigProperty('application.maximumProcesses'), os.cpus().length);
|
const processCount = Math.min(getConfigProperty('application.maximumProcesses'), os.cpus().length);
|
||||||
process.title = `${configFunctions.getConfigProperty('application.applicationName')} (Primary)`;
|
process.title = `${getConfigProperty('application.applicationName')} (Primary)`;
|
||||||
debug(`Primary pid: ${process.pid}`);
|
debug(`Primary pid: ${process.pid}`);
|
||||||
debug(`Primary title: ${process.title}`);
|
debug(`Primary title: ${process.title}`);
|
||||||
debug(`Launching ${processCount} processes`);
|
debug(`Launching ${processCount} processes`);
|
||||||
|
|
@ -37,19 +37,19 @@ cluster.on('exit', (worker) => {
|
||||||
debug('Starting another worker');
|
debug('Starting another worker');
|
||||||
cluster.fork();
|
cluster.fork();
|
||||||
});
|
});
|
||||||
const ntfyStartupConfig = configFunctions.getConfigProperty('application.ntfyStartup');
|
const ntfyStartupConfig = getConfigProperty('application.ntfyStartup');
|
||||||
if (ntfyStartupConfig !== undefined) {
|
if (ntfyStartupConfig !== undefined) {
|
||||||
const topic = ntfyStartupConfig.topic;
|
const topic = ntfyStartupConfig.topic;
|
||||||
const server = ntfyStartupConfig.server;
|
const server = ntfyStartupConfig.server;
|
||||||
const ntfyStartupMessage = {
|
const ntfyStartupMessage = {
|
||||||
topic,
|
topic,
|
||||||
title: configFunctions.getConfigProperty('application.applicationName'),
|
title: getConfigProperty('application.applicationName'),
|
||||||
message: 'Application Started',
|
message: 'Application Started',
|
||||||
tags: ['arrow_up']
|
tags: ['arrow_up']
|
||||||
};
|
};
|
||||||
const ntfyShutdownMessage = {
|
const ntfyShutdownMessage = {
|
||||||
topic,
|
topic,
|
||||||
title: configFunctions.getConfigProperty('application.applicationName'),
|
title: getConfigProperty('application.applicationName'),
|
||||||
message: 'Application Shut Down',
|
message: 'Application Shut Down',
|
||||||
tags: ['arrow_down']
|
tags: ['arrow_down']
|
||||||
};
|
};
|
||||||
|
|
|
||||||
14
bin/www.ts
14
bin/www.ts
|
|
@ -7,7 +7,7 @@ import ntfyPublish, { type NtfyMessageOptions } from '@cityssm/ntfy-publish'
|
||||||
import Debug from 'debug'
|
import Debug from 'debug'
|
||||||
import exitHook from 'exit-hook'
|
import exitHook from 'exit-hook'
|
||||||
|
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
import type { WorkerMessage } from '../types/applicationTypes.js'
|
import type { WorkerMessage } from '../types/applicationTypes.js'
|
||||||
|
|
||||||
const debug = Debug(`lot-occupancy-system:www:${process.pid}`)
|
const debug = Debug(`lot-occupancy-system:www:${process.pid}`)
|
||||||
|
|
@ -15,13 +15,11 @@ const debug = Debug(`lot-occupancy-system:www:${process.pid}`)
|
||||||
const directoryName = dirname(fileURLToPath(import.meta.url))
|
const directoryName = dirname(fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
const processCount = Math.min(
|
const processCount = Math.min(
|
||||||
configFunctions.getConfigProperty('application.maximumProcesses'),
|
getConfigProperty('application.maximumProcesses'),
|
||||||
os.cpus().length
|
os.cpus().length
|
||||||
)
|
)
|
||||||
|
|
||||||
process.title = `${configFunctions.getConfigProperty(
|
process.title = `${getConfigProperty('application.applicationName')} (Primary)`
|
||||||
'application.applicationName'
|
|
||||||
)} (Primary)`
|
|
||||||
|
|
||||||
debug(`Primary pid: ${process.pid}`)
|
debug(`Primary pid: ${process.pid}`)
|
||||||
debug(`Primary title: ${process.title}`)
|
debug(`Primary title: ${process.title}`)
|
||||||
|
|
@ -59,7 +57,7 @@ cluster.on('exit', (worker) => {
|
||||||
cluster.fork()
|
cluster.fork()
|
||||||
})
|
})
|
||||||
|
|
||||||
const ntfyStartupConfig = configFunctions.getConfigProperty('application.ntfyStartup')
|
const ntfyStartupConfig = getConfigProperty('application.ntfyStartup')
|
||||||
|
|
||||||
if (ntfyStartupConfig !== undefined) {
|
if (ntfyStartupConfig !== undefined) {
|
||||||
const topic = ntfyStartupConfig.topic
|
const topic = ntfyStartupConfig.topic
|
||||||
|
|
@ -67,14 +65,14 @@ if (ntfyStartupConfig !== undefined) {
|
||||||
|
|
||||||
const ntfyStartupMessage: NtfyMessageOptions = {
|
const ntfyStartupMessage: NtfyMessageOptions = {
|
||||||
topic,
|
topic,
|
||||||
title: configFunctions.getConfigProperty('application.applicationName'),
|
title: getConfigProperty('application.applicationName'),
|
||||||
message: 'Application Started',
|
message: 'Application Started',
|
||||||
tags: ['arrow_up']
|
tags: ['arrow_up']
|
||||||
}
|
}
|
||||||
|
|
||||||
const ntfyShutdownMessage: NtfyMessageOptions = {
|
const ntfyShutdownMessage: NtfyMessageOptions = {
|
||||||
topic,
|
topic,
|
||||||
title: configFunctions.getConfigProperty('application.applicationName'),
|
title: getConfigProperty('application.applicationName'),
|
||||||
message: 'Application Shut Down',
|
message: 'Application Shut Down',
|
||||||
tags: ['arrow_down']
|
tags: ['arrow_down']
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import http from 'node:http';
|
||||||
import Debug from 'debug';
|
import Debug from 'debug';
|
||||||
import exitHook from 'exit-hook';
|
import exitHook from 'exit-hook';
|
||||||
import { app } from '../app.js';
|
import { app } from '../app.js';
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
const debug = Debug(`lot-occupancy-system:wwwProcess:${process.pid}`);
|
const debug = Debug(`lot-occupancy-system:wwwProcess:${process.pid}`);
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
if (error.syscall !== 'listen') {
|
if (error.syscall !== 'listen') {
|
||||||
|
|
@ -29,8 +29,8 @@ function onListening(server) {
|
||||||
debug(`HTTP Listening on ${bind}`);
|
debug(`HTTP Listening on ${bind}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process.title = `${configFunctions.getConfigProperty('application.applicationName')} (Worker)`;
|
process.title = `${getConfigProperty('application.applicationName')} (Worker)`;
|
||||||
const httpPort = configFunctions.getConfigProperty('application.httpPort');
|
const httpPort = getConfigProperty('application.httpPort');
|
||||||
const httpServer = http.createServer(app);
|
const httpServer = http.createServer(app);
|
||||||
httpServer.listen(httpPort);
|
httpServer.listen(httpPort);
|
||||||
httpServer.on('error', onError);
|
httpServer.on('error', onError);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import Debug from 'debug'
|
||||||
import exitHook from 'exit-hook'
|
import exitHook from 'exit-hook'
|
||||||
|
|
||||||
import { app } from '../app.js'
|
import { app } from '../app.js'
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
const debug = Debug(`lot-occupancy-system:wwwProcess:${process.pid}`)
|
const debug = Debug(`lot-occupancy-system:wwwProcess:${process.pid}`)
|
||||||
|
|
||||||
|
|
@ -58,11 +58,11 @@ function onListening(server: http.Server): void {
|
||||||
* Initialize HTTP
|
* Initialize HTTP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
process.title = `${configFunctions.getConfigProperty(
|
process.title = `${getConfigProperty(
|
||||||
'application.applicationName'
|
'application.applicationName'
|
||||||
)} (Worker)`
|
)} (Worker)`
|
||||||
|
|
||||||
const httpPort = configFunctions.getConfigProperty('application.httpPort')
|
const httpPort = getConfigProperty('application.httpPort')
|
||||||
|
|
||||||
const httpServer = http.createServer(app)
|
const httpServer = http.createServer(app)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import * as configFunctions from '../../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../../helpers/functions.config.js';
|
||||||
import { testUpdate } from '../../../test/_globals.js';
|
import { testUpdate } from '../../../test/_globals.js';
|
||||||
import { logout, login } from '../../support/index.js';
|
import { login, logout } from '../../support/index.js';
|
||||||
describe('Update - Maps', () => {
|
describe('Update - Maps', () => {
|
||||||
beforeEach('Loads page', () => {
|
beforeEach('Loads page', () => {
|
||||||
logout();
|
logout();
|
||||||
|
|
@ -37,8 +37,8 @@ describe('Update - Maps', () => {
|
||||||
.type(mapJSON.mapLongitude.toString());
|
.type(mapJSON.mapLongitude.toString());
|
||||||
});
|
});
|
||||||
cy.log('Ensure the default city and province are used');
|
cy.log('Ensure the default city and province are used');
|
||||||
cy.get("input[name='mapCity']").should('have.value', configFunctions.getConfigProperty('settings.map.mapCityDefault'));
|
cy.get("input[name='mapCity']").should('have.value', getConfigProperty('settings.map.mapCityDefault'));
|
||||||
cy.get("input[name='mapProvince']").should('have.value', configFunctions.getConfigProperty('settings.map.mapProvinceDefault'));
|
cy.get("input[name='mapProvince']").should('have.value', getConfigProperty('settings.map.mapProvinceDefault'));
|
||||||
cy.log('Submit the form');
|
cy.log('Submit the form');
|
||||||
cy.get('#form--map').submit();
|
cy.get('#form--map').submit();
|
||||||
cy.wait(1000);
|
cy.wait(1000);
|
||||||
|
|
@ -50,8 +50,8 @@ describe('Update - Maps', () => {
|
||||||
cy.get("textarea[name='mapDescription']").should('have.value', mapJSON.mapDescription);
|
cy.get("textarea[name='mapDescription']").should('have.value', mapJSON.mapDescription);
|
||||||
cy.get("input[name='mapAddress1']").should('have.value', mapJSON.mapAddress1);
|
cy.get("input[name='mapAddress1']").should('have.value', mapJSON.mapAddress1);
|
||||||
cy.get("input[name='mapAddress2']").should('have.value', mapJSON.mapAddress2);
|
cy.get("input[name='mapAddress2']").should('have.value', mapJSON.mapAddress2);
|
||||||
cy.get("input[name='mapCity']").should('have.value', configFunctions.getConfigProperty('settings.map.mapCityDefault'));
|
cy.get("input[name='mapCity']").should('have.value', getConfigProperty('settings.map.mapCityDefault'));
|
||||||
cy.get("input[name='mapProvince']").should('have.value', configFunctions.getConfigProperty('settings.map.mapProvinceDefault'));
|
cy.get("input[name='mapProvince']").should('have.value', getConfigProperty('settings.map.mapProvinceDefault'));
|
||||||
cy.get("input[name='mapPostalCode']").should('have.value', mapJSON.mapPostalCode);
|
cy.get("input[name='mapPostalCode']").should('have.value', mapJSON.mapPostalCode);
|
||||||
cy.get("input[name='mapPhoneNumber']").should('have.value', mapJSON.mapPhoneNumber);
|
cy.get("input[name='mapPhoneNumber']").should('have.value', mapJSON.mapPhoneNumber);
|
||||||
cy.get("input[name='mapLatitude']").should('have.value', mapJSON.mapLatitude.toString());
|
cy.get("input[name='mapLatitude']").should('have.value', mapJSON.mapLatitude.toString());
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
|
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
import * as configFunctions from '../../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../../helpers/functions.config.js'
|
||||||
import { testUpdate } from '../../../test/_globals.js'
|
import { testUpdate } from '../../../test/_globals.js'
|
||||||
import type { MapRecord } from '../../../types/recordTypes.js'
|
import type { MapRecord } from '../../../types/recordTypes.js'
|
||||||
import { logout, login } from '../../support/index.js'
|
import { login, logout } from '../../support/index.js'
|
||||||
|
|
||||||
describe('Update - Maps', () => {
|
describe('Update - Maps', () => {
|
||||||
beforeEach('Loads page', () => {
|
beforeEach('Loads page', () => {
|
||||||
|
|
@ -56,12 +56,12 @@ describe('Update - Maps', () => {
|
||||||
|
|
||||||
cy.get("input[name='mapCity']").should(
|
cy.get("input[name='mapCity']").should(
|
||||||
'have.value',
|
'have.value',
|
||||||
configFunctions.getConfigProperty('settings.map.mapCityDefault')
|
getConfigProperty('settings.map.mapCityDefault')
|
||||||
)
|
)
|
||||||
|
|
||||||
cy.get("input[name='mapProvince']").should(
|
cy.get("input[name='mapProvince']").should(
|
||||||
'have.value',
|
'have.value',
|
||||||
configFunctions.getConfigProperty('settings.map.mapProvinceDefault')
|
getConfigProperty('settings.map.mapProvinceDefault')
|
||||||
)
|
)
|
||||||
|
|
||||||
cy.log('Submit the form')
|
cy.log('Submit the form')
|
||||||
|
|
@ -93,11 +93,11 @@ describe('Update - Maps', () => {
|
||||||
|
|
||||||
cy.get("input[name='mapCity']").should(
|
cy.get("input[name='mapCity']").should(
|
||||||
'have.value',
|
'have.value',
|
||||||
configFunctions.getConfigProperty('settings.map.mapCityDefault')
|
getConfigProperty('settings.map.mapCityDefault')
|
||||||
)
|
)
|
||||||
cy.get("input[name='mapProvince']").should(
|
cy.get("input[name='mapProvince']").should(
|
||||||
'have.value',
|
'have.value',
|
||||||
configFunctions.getConfigProperty('settings.map.mapProvinceDefault')
|
getConfigProperty('settings.map.mapProvinceDefault')
|
||||||
)
|
)
|
||||||
|
|
||||||
cy.get("input[name='mapPostalCode']").should(
|
cy.get("input[name='mapPostalCode']").should(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
|
||||||
import Debug from 'debug';
|
import Debug from 'debug';
|
||||||
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
const debug = Debug('lot-occupancy-system:databasePaths');
|
const debug = Debug('lot-occupancy-system:databasePaths');
|
||||||
export const useTestDatabases = configFunctions.getConfigProperty('application.useTestDatabases') ||
|
export const useTestDatabases = getConfigProperty('application.useTestDatabases') ||
|
||||||
process.env.TEST_DATABASES === 'true';
|
process.env.TEST_DATABASES === 'true';
|
||||||
if (useTestDatabases) {
|
if (useTestDatabases) {
|
||||||
debug('Using "-testing" databases.');
|
debug('Using "-testing" databases.');
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
|
||||||
|
|
||||||
import Debug from 'debug'
|
import Debug from 'debug'
|
||||||
|
|
||||||
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
const debug = Debug('lot-occupancy-system:databasePaths')
|
const debug = Debug('lot-occupancy-system:databasePaths')
|
||||||
|
|
||||||
// Determine if test databases should be used
|
// Determine if test databases should be used
|
||||||
|
|
||||||
export const useTestDatabases =
|
export const useTestDatabases =
|
||||||
configFunctions.getConfigProperty('application.useTestDatabases') ||
|
getConfigProperty('application.useTestDatabases') ||
|
||||||
process.env.TEST_DATABASES === 'true'
|
process.env.TEST_DATABASES === 'true'
|
||||||
|
|
||||||
if (useTestDatabases) {
|
if (useTestDatabases) {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export default async function cleanupDatabase(user) {
|
export default async function cleanupDatabase(user) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const recordDeleteTimeMillisMin = rightNowMillis -
|
const recordDeleteTimeMillisMin = rightNowMillis -
|
||||||
configFunctions.getConfigProperty('settings.adminCleanup.recordDeleteAgeDays') *
|
getConfigProperty('settings.adminCleanup.recordDeleteAgeDays') *
|
||||||
86_400 *
|
86_400 *
|
||||||
1000;
|
1000;
|
||||||
let inactivatedRecordCount = 0;
|
let inactivatedRecordCount = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@ export default async function cleanupDatabase(
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
const recordDeleteTimeMillisMin =
|
const recordDeleteTimeMillisMin =
|
||||||
rightNowMillis -
|
rightNowMillis -
|
||||||
configFunctions.getConfigProperty('settings.adminCleanup.recordDeleteAgeDays') *
|
getConfigProperty('settings.adminCleanup.recordDeleteAgeDays') *
|
||||||
86_400 *
|
86_400 *
|
||||||
1000
|
1000
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
|
import { DateString } from '@cityssm/utils-datetime';
|
||||||
import type { PoolConnection } from 'better-sqlite-pool';
|
import type { PoolConnection } from 'better-sqlite-pool';
|
||||||
import type { LotOccupancy } from '../types/recordTypes.js';
|
import type { LotOccupancy } from '../types/recordTypes.js';
|
||||||
interface GetLotOccupanciesFilters {
|
interface GetLotOccupanciesFilters {
|
||||||
lotId?: number | string;
|
lotId?: number | string;
|
||||||
occupancyTime?: '' | 'past' | 'current' | 'future';
|
occupancyTime?: '' | 'past' | 'current' | 'future';
|
||||||
occupancyStartDateString?: string;
|
occupancyStartDateString?: DateString;
|
||||||
occupancyEffectiveDateString?: string;
|
occupancyEffectiveDateString?: string;
|
||||||
occupantName?: string;
|
occupantName?: string;
|
||||||
occupancyTypeId?: number | string;
|
occupancyTypeId?: number | string;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
import { dateIntegerToString, dateStringToInteger } from '@cityssm/utils-datetime';
|
||||||
import { getOccupancyTypeById } from '../helpers/functions.cache.js';
|
import { getOccupancyTypeById } from '../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
import { getLotNameWhereClause, getOccupancyTimeWhereClause, getOccupantNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
||||||
import { getLotOccupancyFees } from './getLotOccupancyFees.js';
|
import { getLotOccupancyFees } from './getLotOccupancyFees.js';
|
||||||
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
|
import { getLotOccupancyOccupants } from './getLotOccupancyOccupants.js';
|
||||||
|
|
@ -116,7 +116,7 @@ export async function getLotOccupancies(filters, options, connectedDatabase) {
|
||||||
const occupancyType = await getOccupancyTypeById(lotOccupancy.occupancyTypeId);
|
const occupancyType = await getOccupancyTypeById(lotOccupancy.occupancyTypeId);
|
||||||
if (occupancyType !== undefined) {
|
if (occupancyType !== undefined) {
|
||||||
lotOccupancy.printEJS = (occupancyType.occupancyTypePrints ?? []).includes('*')
|
lotOccupancy.printEJS = (occupancyType.occupancyTypePrints ?? []).includes('*')
|
||||||
? configFunctions.getConfigProperty('settings.lotOccupancy.prints')[0]
|
? getConfigProperty('settings.lotOccupancy.prints')[0]
|
||||||
: occupancyType.occupancyTypePrints[0];
|
: occupancyType.occupancyTypePrints[0];
|
||||||
}
|
}
|
||||||
await addInclusions(lotOccupancy, options, database);
|
await addInclusions(lotOccupancy, options, database);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
import {
|
import {
|
||||||
|
DateString,
|
||||||
dateIntegerToString,
|
dateIntegerToString,
|
||||||
dateStringToInteger
|
dateStringToInteger
|
||||||
} from '@cityssm/utils-datetime'
|
} from '@cityssm/utils-datetime'
|
||||||
import type { PoolConnection } from 'better-sqlite-pool'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import { getOccupancyTypeById } from '../helpers/functions.cache.js'
|
import { getOccupancyTypeById } from '../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
import {
|
import {
|
||||||
getLotNameWhereClause,
|
getLotNameWhereClause,
|
||||||
getOccupancyTimeWhereClause,
|
getOccupancyTimeWhereClause,
|
||||||
|
|
@ -21,7 +22,7 @@ import { acquireConnection } from './pool.js'
|
||||||
interface GetLotOccupanciesFilters {
|
interface GetLotOccupanciesFilters {
|
||||||
lotId?: number | string
|
lotId?: number | string
|
||||||
occupancyTime?: '' | 'past' | 'current' | 'future'
|
occupancyTime?: '' | 'past' | 'current' | 'future'
|
||||||
occupancyStartDateString?: string
|
occupancyStartDateString?: DateString
|
||||||
occupancyEffectiveDateString?: string
|
occupancyEffectiveDateString?: string
|
||||||
occupantName?: string
|
occupantName?: string
|
||||||
occupancyTypeId?: number | string
|
occupancyTypeId?: number | string
|
||||||
|
|
@ -87,7 +88,9 @@ function buildWhereClause(filters: GetLotOccupanciesFilters): {
|
||||||
|
|
||||||
if ((filters.occupancyStartDateString ?? '') !== '') {
|
if ((filters.occupancyStartDateString ?? '') !== '') {
|
||||||
sqlWhereClause += ' and o.occupancyStartDate = ?'
|
sqlWhereClause += ' and o.occupancyStartDate = ?'
|
||||||
sqlParameters.push(dateStringToInteger(filters.occupancyStartDateString!))
|
sqlParameters.push(
|
||||||
|
dateStringToInteger(filters.occupancyStartDateString as DateString)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((filters.occupancyEffectiveDateString ?? '') !== '') {
|
if ((filters.occupancyEffectiveDateString ?? '') !== '') {
|
||||||
|
|
@ -96,8 +99,8 @@ function buildWhereClause(filters: GetLotOccupanciesFilters): {
|
||||||
or (o.occupancyStartDate <= ? and o.occupancyEndDate >= ?)
|
or (o.occupancyStartDate <= ? and o.occupancyEndDate >= ?)
|
||||||
)`
|
)`
|
||||||
sqlParameters.push(
|
sqlParameters.push(
|
||||||
dateStringToInteger(filters.occupancyEffectiveDateString!),
|
dateStringToInteger(filters.occupancyEffectiveDateString as DateString),
|
||||||
dateStringToInteger(filters.occupancyEffectiveDateString!)
|
dateStringToInteger(filters.occupancyEffectiveDateString as DateString)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -222,7 +225,7 @@ export async function getLotOccupancies(
|
||||||
lotOccupancy.printEJS = (
|
lotOccupancy.printEJS = (
|
||||||
occupancyType.occupancyTypePrints ?? []
|
occupancyType.occupancyTypePrints ?? []
|
||||||
).includes('*')
|
).includes('*')
|
||||||
? configFunctions.getConfigProperty('settings.lotOccupancy.prints')[0]
|
? getConfigProperty('settings.lotOccupancy.prints')[0]
|
||||||
: occupancyType.occupancyTypePrints![0]
|
: occupancyType.occupancyTypePrints![0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetime';
|
import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetime';
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
import * as gpFunctions from '../helpers/functions.dynamicsGP.js';
|
import * as gpFunctions from '../helpers/functions.dynamicsGP.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export async function getLotOccupancyTransactions(lotOccupancyId, options, connectedDatabase) {
|
export async function getLotOccupancyTransactions(lotOccupancyId, options, connectedDatabase) {
|
||||||
|
|
@ -20,7 +20,7 @@ export async function getLotOccupancyTransactions(lotOccupancyId, options, conne
|
||||||
database.release();
|
database.release();
|
||||||
}
|
}
|
||||||
if ((options?.includeIntegrations ?? false) &&
|
if ((options?.includeIntegrations ?? false) &&
|
||||||
configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
for (const transaction of lotOccupancyTransactions) {
|
for (const transaction of lotOccupancyTransactions) {
|
||||||
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
||||||
const gpDocument = await gpFunctions.getDynamicsGPDocument(transaction.externalReceiptNumber ?? '');
|
const gpDocument = await gpFunctions.getDynamicsGPDocument(transaction.externalReceiptNumber ?? '');
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {
|
||||||
} from '@cityssm/utils-datetime'
|
} from '@cityssm/utils-datetime'
|
||||||
import type { PoolConnection } from 'better-sqlite-pool'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
import * as gpFunctions from '../helpers/functions.dynamicsGP.js'
|
import * as gpFunctions from '../helpers/functions.dynamicsGP.js'
|
||||||
import type { LotOccupancyTransaction } from '../types/recordTypes.js'
|
import type { LotOccupancyTransaction } from '../types/recordTypes.js'
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ export async function getLotOccupancyTransactions(
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(options?.includeIntegrations ?? false) &&
|
(options?.includeIntegrations ?? false) &&
|
||||||
configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')
|
getConfigProperty('settings.dynamicsGP.integrationIsEnabled')
|
||||||
) {
|
) {
|
||||||
for (const transaction of lotOccupancyTransactions) {
|
for (const transaction of lotOccupancyTransactions) {
|
||||||
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
if ((transaction.externalReceiptNumber ?? '') !== '') {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { dateToInteger } from '@cityssm/utils-datetime';
|
import { dateToInteger } from '@cityssm/utils-datetime';
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
function buildWhereClause(filters) {
|
function buildWhereClause(filters) {
|
||||||
|
|
@ -61,7 +61,7 @@ export async function getLots(filters, options, connectedDatabase) {
|
||||||
let lots = [];
|
let lots = [];
|
||||||
if (options.limit === -1 || count > 0) {
|
if (options.limit === -1 || count > 0) {
|
||||||
const includeLotOccupancyCount = options.includeLotOccupancyCount ?? true;
|
const includeLotOccupancyCount = options.includeLotOccupancyCount ?? true;
|
||||||
database.function('userFn_lotNameSortName', configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction'));
|
database.function('userFn_lotNameSortName', getConfigProperty('settings.lot.lotNameSortNameFunction'));
|
||||||
if (includeLotOccupancyCount) {
|
if (includeLotOccupancyCount) {
|
||||||
sqlParameters.unshift(currentDate, currentDate);
|
sqlParameters.unshift(currentDate, currentDate);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { dateToInteger } from '@cityssm/utils-datetime'
|
import { dateToInteger } from '@cityssm/utils-datetime'
|
||||||
import type { PoolConnection } from 'better-sqlite-pool'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js'
|
import { getLotNameWhereClause } from '../helpers/functions.sqlFilters.js'
|
||||||
import type { Lot } from '../types/recordTypes.js'
|
import type { Lot } from '../types/recordTypes.js'
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ export async function getLots(
|
||||||
|
|
||||||
database.function(
|
database.function(
|
||||||
'userFn_lotNameSortName',
|
'userFn_lotNameSortName',
|
||||||
configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction')
|
getConfigProperty('settings.lot.lotNameSortNameFunction')
|
||||||
)
|
)
|
||||||
|
|
||||||
if (includeLotOccupancyCount) {
|
if (includeLotOccupancyCount) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export async function getNextLotId(lotId) {
|
export async function getNextLotId(lotId) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
database.function('userFn_lotNameSortName', configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction'));
|
database.function('userFn_lotNameSortName', getConfigProperty('settings.lot.lotNameSortNameFunction'));
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`select lotId
|
.prepare(`select lotId
|
||||||
from Lots
|
from Lots
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ export async function getNextLotId(
|
||||||
|
|
||||||
database.function(
|
database.function(
|
||||||
'userFn_lotNameSortName',
|
'userFn_lotNameSortName',
|
||||||
configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction')
|
getConfigProperty('settings.lot.lotNameSortNameFunction')
|
||||||
)
|
)
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export async function getNextWorkOrderNumber(connectedDatabase) {
|
export async function getNextWorkOrderNumber(connectedDatabase) {
|
||||||
const database = connectedDatabase ?? (await acquireConnection());
|
const database = connectedDatabase ?? (await acquireConnection());
|
||||||
const paddingLength = configFunctions.getConfigProperty('settings.workOrders.workOrderNumberLength');
|
const paddingLength = getConfigProperty('settings.workOrders.workOrderNumberLength');
|
||||||
const currentYearString = new Date().getFullYear().toString();
|
const currentYearString = new Date().getFullYear().toString();
|
||||||
const regex = new RegExp('^' + currentYearString + '-\\d+$');
|
const regex = new RegExp(`^${currentYearString}-\\d+$`);
|
||||||
database.function('userFn_matchesWorkOrderNumberSyntax', (workOrderNumber) => {
|
database.function('userFn_matchesWorkOrderNumberSyntax', (workOrderNumber) => {
|
||||||
return regex.test(workOrderNumber) ? 1 : 0;
|
return regex.test(workOrderNumber) ? 1 : 0;
|
||||||
});
|
});
|
||||||
|
|
@ -21,8 +21,6 @@ export async function getNextWorkOrderNumber(connectedDatabase) {
|
||||||
workOrderNumberIndex = Number.parseInt(workOrderNumberRecord.workOrderNumber.split('-')[1], 10);
|
workOrderNumberIndex = Number.parseInt(workOrderNumberRecord.workOrderNumber.split('-')[1], 10);
|
||||||
}
|
}
|
||||||
workOrderNumberIndex += 1;
|
workOrderNumberIndex += 1;
|
||||||
return (currentYearString +
|
return `${currentYearString}-${workOrderNumberIndex.toString().padStart(paddingLength, '0')}`;
|
||||||
'-' +
|
|
||||||
workOrderNumberIndex.toString().padStart(paddingLength, '0'));
|
|
||||||
}
|
}
|
||||||
export default getNextWorkOrderNumber;
|
export default getNextWorkOrderNumber;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { PoolConnection } from 'better-sqlite-pool'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
|
|
@ -9,12 +9,12 @@ export async function getNextWorkOrderNumber(
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const database = connectedDatabase ?? (await acquireConnection())
|
const database = connectedDatabase ?? (await acquireConnection())
|
||||||
|
|
||||||
const paddingLength = configFunctions.getConfigProperty(
|
const paddingLength = getConfigProperty(
|
||||||
'settings.workOrders.workOrderNumberLength'
|
'settings.workOrders.workOrderNumberLength'
|
||||||
)
|
)
|
||||||
const currentYearString = new Date().getFullYear().toString()
|
const currentYearString = new Date().getFullYear().toString()
|
||||||
|
|
||||||
const regex = new RegExp('^' + currentYearString + '-\\d+$')
|
const regex = new RegExp(`^${currentYearString}-\\d+$`)
|
||||||
|
|
||||||
database.function(
|
database.function(
|
||||||
'userFn_matchesWorkOrderNumberSyntax',
|
'userFn_matchesWorkOrderNumberSyntax',
|
||||||
|
|
@ -48,11 +48,7 @@ export async function getNextWorkOrderNumber(
|
||||||
|
|
||||||
workOrderNumberIndex += 1
|
workOrderNumberIndex += 1
|
||||||
|
|
||||||
return (
|
return `${currentYearString}-${workOrderNumberIndex.toString().padStart(paddingLength, '0')}`
|
||||||
currentYearString +
|
|
||||||
'-' +
|
|
||||||
workOrderNumberIndex.toString().padStart(paddingLength, '0')
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getNextWorkOrderNumber
|
export default getNextWorkOrderNumber
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
const availablePrints = configFunctions.getConfigProperty('settings.lotOccupancy.prints');
|
const availablePrints = getConfigProperty('settings.lotOccupancy.prints');
|
||||||
const userFunction_configContainsPrintEJS = (printEJS) => {
|
const userFunction_configContainsPrintEJS = (printEJS) => {
|
||||||
if (printEJS === '*' || availablePrints.includes(printEJS)) {
|
if (printEJS === '*' || availablePrints.includes(printEJS)) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
import type { PoolConnection } from 'better-sqlite-pool'
|
import type { PoolConnection } from 'better-sqlite-pool'
|
||||||
|
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
const availablePrints = configFunctions.getConfigProperty(
|
const availablePrints = getConfigProperty('settings.lotOccupancy.prints')
|
||||||
'settings.lotOccupancy.prints'
|
|
||||||
)
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
const userFunction_configContainsPrintEJS = (printEJS: string): number => {
|
const userFunction_configContainsPrintEJS = (printEJS: string): number => {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
export async function getPreviousLotId(lotId) {
|
export async function getPreviousLotId(lotId) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
database.function('userFn_lotNameSortName', configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction'));
|
database.function('userFn_lotNameSortName', getConfigProperty('settings.lot.lotNameSortNameFunction'));
|
||||||
const result = database
|
const result = database
|
||||||
.prepare(`select lotId from Lots
|
.prepare(`select lotId from Lots
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ export async function getPreviousLotId(
|
||||||
|
|
||||||
database.function(
|
database.function(
|
||||||
'userFn_lotNameSortName',
|
'userFn_lotNameSortName',
|
||||||
configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction')
|
getConfigProperty('settings.lot.lotNameSortNameFunction')
|
||||||
)
|
)
|
||||||
|
|
||||||
const result = database
|
const result = database
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
import * as dateTimeFunctions from '@cityssm/utils-datetime';
|
||||||
import camelCase from 'camelcase';
|
import camelCase from 'camelcase';
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
import { acquireConnection } from './pool.js';
|
import { acquireConnection } from './pool.js';
|
||||||
const mapCamelCase = camelCase(configFunctions.getConfigProperty('aliases.map'));
|
const mapCamelCase = camelCase(getConfigProperty('aliases.map'));
|
||||||
const mapNameAlias = `${mapCamelCase}Name`;
|
const mapNameAlias = `${mapCamelCase}Name`;
|
||||||
const mapDescriptionAlias = `${mapCamelCase}Description`;
|
const mapDescriptionAlias = `${mapCamelCase}Description`;
|
||||||
const mapAddress1Alias = `${mapCamelCase}Address1`;
|
const mapAddress1Alias = `${mapCamelCase}Address1`;
|
||||||
|
|
@ -11,17 +11,17 @@ const mapCityAlias = `${mapCamelCase}City`;
|
||||||
const mapProvinceAlias = `${mapCamelCase}Province`;
|
const mapProvinceAlias = `${mapCamelCase}Province`;
|
||||||
const mapPostalCodeAlias = `${mapCamelCase}PostalCode`;
|
const mapPostalCodeAlias = `${mapCamelCase}PostalCode`;
|
||||||
const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber`;
|
const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber`;
|
||||||
const lotCamelCase = camelCase(configFunctions.getConfigProperty('aliases.lot'));
|
const lotCamelCase = camelCase(getConfigProperty('aliases.lot'));
|
||||||
const lotIdAlias = `${lotCamelCase}Id`;
|
const lotIdAlias = `${lotCamelCase}Id`;
|
||||||
const lotNameAlias = `${lotCamelCase}Name`;
|
const lotNameAlias = `${lotCamelCase}Name`;
|
||||||
const lotTypeAlias = `${lotCamelCase}Type`;
|
const lotTypeAlias = `${lotCamelCase}Type`;
|
||||||
const lotStatusAlias = `${lotCamelCase}Status`;
|
const lotStatusAlias = `${lotCamelCase}Status`;
|
||||||
const occupancyCamelCase = camelCase(configFunctions.getConfigProperty('aliases.occupancy'));
|
const occupancyCamelCase = camelCase(getConfigProperty('aliases.occupancy'));
|
||||||
const lotOccupancyIdAlias = `${occupancyCamelCase}Id`;
|
const lotOccupancyIdAlias = `${occupancyCamelCase}Id`;
|
||||||
const occupancyTypeAlias = `${occupancyCamelCase}Type`;
|
const occupancyTypeAlias = `${occupancyCamelCase}Type`;
|
||||||
const occupancyStartDateAlias = `${occupancyCamelCase}StartDate`;
|
const occupancyStartDateAlias = `${occupancyCamelCase}StartDate`;
|
||||||
const occupancyEndDateAlias = `${occupancyCamelCase}EndDate`;
|
const occupancyEndDateAlias = `${occupancyCamelCase}EndDate`;
|
||||||
const occupantCamelCase = camelCase(configFunctions.getConfigProperty('aliases.occupant'));
|
const occupantCamelCase = camelCase(getConfigProperty('aliases.occupant'));
|
||||||
const lotOccupantIndexAlias = `${occupantCamelCase}Index`;
|
const lotOccupantIndexAlias = `${occupantCamelCase}Index`;
|
||||||
const lotOccupantTypeAlias = `${occupantCamelCase}Type`;
|
const lotOccupantTypeAlias = `${occupantCamelCase}Type`;
|
||||||
const occupantNameAlias = `${occupantCamelCase}Name`;
|
const occupantNameAlias = `${occupantCamelCase}Name`;
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@
|
||||||
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
import * as dateTimeFunctions from '@cityssm/utils-datetime'
|
||||||
import camelCase from 'camelcase'
|
import camelCase from 'camelcase'
|
||||||
|
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
import { acquireConnection } from './pool.js'
|
import { acquireConnection } from './pool.js'
|
||||||
|
|
||||||
export type ReportParameters = Record<string, string | number>
|
export type ReportParameters = Record<string, string | number>
|
||||||
|
|
||||||
const mapCamelCase = camelCase(configFunctions.getConfigProperty('aliases.map'))
|
const mapCamelCase = camelCase(getConfigProperty('aliases.map'))
|
||||||
const mapNameAlias = `${mapCamelCase}Name`
|
const mapNameAlias = `${mapCamelCase}Name`
|
||||||
const mapDescriptionAlias = `${mapCamelCase}Description`
|
const mapDescriptionAlias = `${mapCamelCase}Description`
|
||||||
const mapAddress1Alias = `${mapCamelCase}Address1`
|
const mapAddress1Alias = `${mapCamelCase}Address1`
|
||||||
|
|
@ -20,23 +20,19 @@ const mapProvinceAlias = `${mapCamelCase}Province`
|
||||||
const mapPostalCodeAlias = `${mapCamelCase}PostalCode`
|
const mapPostalCodeAlias = `${mapCamelCase}PostalCode`
|
||||||
const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber`
|
const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber`
|
||||||
|
|
||||||
const lotCamelCase = camelCase(configFunctions.getConfigProperty('aliases.lot'))
|
const lotCamelCase = camelCase(getConfigProperty('aliases.lot'))
|
||||||
const lotIdAlias = `${lotCamelCase}Id`
|
const lotIdAlias = `${lotCamelCase}Id`
|
||||||
const lotNameAlias = `${lotCamelCase}Name`
|
const lotNameAlias = `${lotCamelCase}Name`
|
||||||
const lotTypeAlias = `${lotCamelCase}Type`
|
const lotTypeAlias = `${lotCamelCase}Type`
|
||||||
const lotStatusAlias = `${lotCamelCase}Status`
|
const lotStatusAlias = `${lotCamelCase}Status`
|
||||||
|
|
||||||
const occupancyCamelCase = camelCase(
|
const occupancyCamelCase = camelCase(getConfigProperty('aliases.occupancy'))
|
||||||
configFunctions.getConfigProperty('aliases.occupancy')
|
|
||||||
)
|
|
||||||
const lotOccupancyIdAlias = `${occupancyCamelCase}Id`
|
const lotOccupancyIdAlias = `${occupancyCamelCase}Id`
|
||||||
const occupancyTypeAlias = `${occupancyCamelCase}Type`
|
const occupancyTypeAlias = `${occupancyCamelCase}Type`
|
||||||
const occupancyStartDateAlias = `${occupancyCamelCase}StartDate`
|
const occupancyStartDateAlias = `${occupancyCamelCase}StartDate`
|
||||||
const occupancyEndDateAlias = `${occupancyCamelCase}EndDate`
|
const occupancyEndDateAlias = `${occupancyCamelCase}EndDate`
|
||||||
|
|
||||||
const occupantCamelCase = camelCase(
|
const occupantCamelCase = camelCase(getConfigProperty('aliases.occupant'))
|
||||||
configFunctions.getConfigProperty('aliases.occupant')
|
|
||||||
)
|
|
||||||
const lotOccupantIndexAlias = `${occupantCamelCase}Index`
|
const lotOccupantIndexAlias = `${occupantCamelCase}Index`
|
||||||
const lotOccupantTypeAlias = `${occupantCamelCase}Type`
|
const lotOccupantTypeAlias = `${occupantCamelCase}Type`
|
||||||
const occupantNameAlias = `${occupantCamelCase}Name`
|
const occupantNameAlias = `${occupantCamelCase}Name`
|
||||||
|
|
@ -235,7 +231,7 @@ export async function getReportData(
|
||||||
|
|
||||||
sqlParameters.push(
|
sqlParameters.push(
|
||||||
dateTimeFunctions.dateStringToInteger(
|
dateTimeFunctions.dateStringToInteger(
|
||||||
reportParameters.transactionDateString as string
|
reportParameters.transactionDateString as dateTimeFunctions.DateString
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { getLotTypes } from '../../helpers/functions.cache.js';
|
import { getLotTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(_request, response) {
|
export default async function handler(_request, response) {
|
||||||
const lotTypes = await getLotTypes();
|
const lotTypes = await getLotTypes();
|
||||||
response.render('admin-lotTypes', {
|
response.render('admin-lotTypes', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.lot')} Type Management`,
|
headTitle: `${getConfigProperty('aliases.lot')} Type Management`,
|
||||||
lotTypes
|
lotTypes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getLotTypes } from '../../helpers/functions.cache.js'
|
import { getLotTypes } from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
_request: Request,
|
_request: Request,
|
||||||
|
|
@ -10,7 +10,7 @@ export default async function handler(
|
||||||
const lotTypes = await getLotTypes()
|
const lotTypes = await getLotTypes()
|
||||||
|
|
||||||
response.render('admin-lotTypes', {
|
response.render('admin-lotTypes', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.lot')} Type Management`,
|
headTitle: `${getConfigProperty('aliases.lot')} Type Management`,
|
||||||
lotTypes
|
lotTypes
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default function handler(_request, response) {
|
export default function handler(_request, response) {
|
||||||
if (configFunctions.getConfigProperty('application.ntfyStartup') === undefined) {
|
if (getConfigProperty('application.ntfyStartup') === undefined) {
|
||||||
response.redirect(configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=ntfyNotConfigured`);
|
||||||
'/dashboard/?error=ntfyNotConfigured');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.render('admin-ntfyStartup', {
|
response.render('admin-ntfyStartup', {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default function handler(_request: Request, response: Response): void {
|
export default function handler(_request: Request, response: Response): void {
|
||||||
if (
|
if (getConfigProperty('application.ntfyStartup') === undefined) {
|
||||||
configFunctions.getConfigProperty('application.ntfyStartup') === undefined
|
|
||||||
) {
|
|
||||||
response.redirect(
|
response.redirect(
|
||||||
configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=ntfyNotConfigured`
|
||||||
'/dashboard/?error=ntfyNotConfigured'
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import { getAllOccupancyTypeFields, getOccupancyTypes } from '../../helpers/functions.cache.js';
|
import { getAllOccupancyTypeFields, getOccupancyTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
import * as printFunctions from '../../helpers/functions.print.js';
|
import * as printFunctions from '../../helpers/functions.print.js';
|
||||||
export default async function handler(_request, response) {
|
export default async function handler(_request, response) {
|
||||||
const occupancyTypes = await getOccupancyTypes();
|
const occupancyTypes = await getOccupancyTypes();
|
||||||
const allOccupancyTypeFields = await getAllOccupancyTypeFields();
|
const allOccupancyTypeFields = await getAllOccupancyTypeFields();
|
||||||
const occupancyTypePrints = configFunctions.getConfigProperty('settings.lotOccupancy.prints');
|
const occupancyTypePrints = getConfigProperty('settings.lotOccupancy.prints');
|
||||||
const occupancyTypePrintTitles = {};
|
const occupancyTypePrintTitles = {};
|
||||||
for (const printEJS of occupancyTypePrints) {
|
for (const printEJS of occupancyTypePrints) {
|
||||||
const printConfig = printFunctions.getPrintConfig(printEJS);
|
const printConfig = printFunctions.getPrintConfig(printEJS);
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function handler(_request, response) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response.render('admin-occupancyTypes', {
|
response.render('admin-occupancyTypes', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} Type Management`,
|
headTitle: `${getConfigProperty('aliases.occupancy')} Type Management`,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
allOccupancyTypeFields,
|
allOccupancyTypeFields,
|
||||||
occupancyTypePrintTitles
|
occupancyTypePrintTitles
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {
|
||||||
getAllOccupancyTypeFields,
|
getAllOccupancyTypeFields,
|
||||||
getOccupancyTypes
|
getOccupancyTypes
|
||||||
} from '../../helpers/functions.cache.js'
|
} from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import * as printFunctions from '../../helpers/functions.print.js'
|
import * as printFunctions from '../../helpers/functions.print.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
|
|
@ -14,9 +14,7 @@ export default async function handler(
|
||||||
const occupancyTypes = await getOccupancyTypes()
|
const occupancyTypes = await getOccupancyTypes()
|
||||||
const allOccupancyTypeFields = await getAllOccupancyTypeFields()
|
const allOccupancyTypeFields = await getAllOccupancyTypeFields()
|
||||||
|
|
||||||
const occupancyTypePrints = configFunctions.getConfigProperty(
|
const occupancyTypePrints = getConfigProperty('settings.lotOccupancy.prints')
|
||||||
'settings.lotOccupancy.prints'
|
|
||||||
)
|
|
||||||
|
|
||||||
const occupancyTypePrintTitles = {}
|
const occupancyTypePrintTitles = {}
|
||||||
|
|
||||||
|
|
@ -29,7 +27,7 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
response.render('admin-occupancyTypes', {
|
response.render('admin-occupancyTypes', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} Type Management`,
|
headTitle: `${getConfigProperty('aliases.occupancy')} Type Management`,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
allOccupancyTypeFields,
|
allOccupancyTypeFields,
|
||||||
occupancyTypePrintTitles
|
occupancyTypePrintTitles
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import ical, { ICalEventStatus } from 'ical-generator';
|
import ical, { ICalEventStatus } from 'ical-generator';
|
||||||
import { getWorkOrderMilestones } from '../../database/getWorkOrderMilestones.js';
|
import { getWorkOrderMilestones } from '../../database/getWorkOrderMilestones.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
import { getPrintConfig } from '../../helpers/functions.print.js';
|
import { getPrintConfig } from '../../helpers/functions.print.js';
|
||||||
const calendarCompany = 'cityssm.github.io';
|
const calendarCompany = 'cityssm.github.io';
|
||||||
const calendarProduct = configFunctions.getConfigProperty('application.applicationName');
|
const calendarProduct = getConfigProperty('application.applicationName');
|
||||||
const timeStringSplitRegex = /[ :-]/;
|
const timeStringSplitRegex = /[ :-]/;
|
||||||
function escapeHTML(stringToEscape) {
|
function escapeHTML(stringToEscape) {
|
||||||
return stringToEscape.replaceAll(/[^\d a-z]/gi, (c) => `&#${c.codePointAt(0)};`);
|
return stringToEscape.replaceAll(/[^\d a-z]/gi, (c) => `&#${c.codePointAt(0)};`);
|
||||||
|
|
@ -11,10 +11,10 @@ function escapeHTML(stringToEscape) {
|
||||||
function getUrlRoot(request) {
|
function getUrlRoot(request) {
|
||||||
return ('http://' +
|
return ('http://' +
|
||||||
request.hostname +
|
request.hostname +
|
||||||
(configFunctions.getConfigProperty('application.httpPort') === 80
|
(getConfigProperty('application.httpPort') === 80
|
||||||
? ''
|
? ''
|
||||||
: `:${configFunctions.getConfigProperty('application.httpPort')}`) +
|
: `:${getConfigProperty('application.httpPort')}`) +
|
||||||
configFunctions.getConfigProperty('reverseProxy.urlPrefix'));
|
getConfigProperty('reverseProxy.urlPrefix'));
|
||||||
}
|
}
|
||||||
function getWorkOrderUrl(request, milestone) {
|
function getWorkOrderUrl(request, milestone) {
|
||||||
return `${getUrlRoot(request)}/workOrders/${milestone.workOrderId}`;
|
return `${getUrlRoot(request)}/workOrders/${milestone.workOrderId}`;
|
||||||
|
|
@ -25,8 +25,8 @@ function buildEventSummary(milestone) {
|
||||||
? milestone.workOrderMilestoneDescription ?? ''
|
? milestone.workOrderMilestoneDescription ?? ''
|
||||||
: milestone.workOrderMilestoneType ?? '').trim();
|
: milestone.workOrderMilestoneType ?? '').trim();
|
||||||
let occupantCount = 0;
|
let occupantCount = 0;
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies) {
|
for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants) {
|
for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) {
|
||||||
occupantCount += 1;
|
occupantCount += 1;
|
||||||
if (occupantCount === 1) {
|
if (occupantCount === 1) {
|
||||||
if (summary !== '') {
|
if (summary !== '') {
|
||||||
|
|
@ -49,22 +49,22 @@ function buildEventDescriptionHTML_occupancies(request, milestone) {
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML = `<h2>
|
descriptionHTML = `<h2>
|
||||||
Related ${escapeHTML(configFunctions.getConfigProperty('aliases.occupancies'))}
|
Related ${escapeHTML(getConfigProperty('aliases.occupancies'))}
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th>${escapeHTML(configFunctions.getConfigProperty('aliases.occupancy'))} Type</th>
|
<th>${escapeHTML(getConfigProperty('aliases.occupancy'))} Type</th>
|
||||||
<th>${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))}</th>
|
<th>${escapeHTML(getConfigProperty('aliases.lot'))}</th>
|
||||||
<th>Start Date</th>
|
<th>Start Date</th>
|
||||||
<th>End Date</th>
|
<th>End Date</th>
|
||||||
<th>${escapeHTML(configFunctions.getConfigProperty('aliases.occupants'))}</th>
|
<th>${escapeHTML(getConfigProperty('aliases.occupants'))}</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`;
|
<tbody>`;
|
||||||
for (const occupancy of milestone.workOrderLotOccupancies) {
|
for (const occupancy of milestone.workOrderLotOccupancies ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lotOccupancies/${occupancy.lotOccupancyId}">
|
<a href="${urlRoot}/lotOccupancies/${occupancy.lotOccupancyId}">
|
||||||
${escapeHTML(occupancy.occupancyType)}
|
${escapeHTML(occupancy.occupancyType ?? '')}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
@ -79,8 +79,8 @@ function buildEventDescriptionHTML_occupancies(request, milestone) {
|
||||||
: '(No End Date)'}
|
: '(No End Date)'}
|
||||||
</td>
|
</td>
|
||||||
<td>`;
|
<td>`;
|
||||||
for (const occupant of occupancy.lotOccupancyOccupants) {
|
for (const occupant of occupancy.lotOccupancyOccupants ?? []) {
|
||||||
descriptionHTML += `${escapeHTML(occupant.lotOccupantType)}: ${escapeHTML(occupant.occupantName)} ${escapeHTML(occupant.occupantFamilyName)}<br />`;
|
descriptionHTML += `${escapeHTML(occupant.lotOccupantType)}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(occupant.occupantFamilyName ?? '')}<br />`;
|
||||||
}
|
}
|
||||||
descriptionHTML += '</td></tr>';
|
descriptionHTML += '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
@ -93,22 +93,22 @@ function buildEventDescriptionHTML_lots(request, milestone) {
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML += `<h2>
|
descriptionHTML += `<h2>
|
||||||
Related ${escapeHTML(configFunctions.getConfigProperty('aliases.lots'))}
|
Related ${escapeHTML(getConfigProperty('aliases.lots'))}
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1"><thead><tr>
|
<table border="1"><thead><tr>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Type
|
${escapeHTML(getConfigProperty('aliases.lot'))} Type
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getConfigProperty('aliases.map'))}
|
${escapeHTML(getConfigProperty('aliases.map'))}
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Type
|
${escapeHTML(getConfigProperty('aliases.lot'))} Type
|
||||||
</th>
|
</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`;
|
<tbody>`;
|
||||||
for (const lot of milestone.workOrderLots) {
|
for (const lot of milestone.workOrderLots ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lots/${lot.lotId.toString()}">
|
<a href="${urlRoot}/lots/${lot.lotId.toString()}">
|
||||||
|
|
@ -126,7 +126,7 @@ function buildEventDescriptionHTML_lots(request, milestone) {
|
||||||
}
|
}
|
||||||
function buildEventDescriptionHTML_prints(request, milestone) {
|
function buildEventDescriptionHTML_prints(request, milestone) {
|
||||||
let descriptionHTML = '';
|
let descriptionHTML = '';
|
||||||
const prints = configFunctions.getConfigProperty('settings.workOrders.prints');
|
const prints = getConfigProperty('settings.workOrders.prints');
|
||||||
if (prints.length > 0) {
|
if (prints.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request);
|
const urlRoot = getUrlRoot(request);
|
||||||
descriptionHTML += '<h2>Prints</h2>';
|
descriptionHTML += '<h2>Prints</h2>';
|
||||||
|
|
@ -167,7 +167,7 @@ function buildEventCategoryList(milestone) {
|
||||||
function buildEventLocation(milestone) {
|
function buildEventLocation(milestone) {
|
||||||
const lotNames = [];
|
const lotNames = [];
|
||||||
if (milestone.workOrderLots.length > 0) {
|
if (milestone.workOrderLots.length > 0) {
|
||||||
for (const lot of milestone.workOrderLots) {
|
for (const lot of milestone.workOrderLots ?? []) {
|
||||||
lotNames.push(`${lot.mapName ?? ''}: ${lot.lotName ?? ''}`);
|
lotNames.push(`${lot.mapName ?? ''}: ${lot.lotName ?? ''}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -240,18 +240,18 @@ export default async function handler(request, response) {
|
||||||
calendarEvent.location(location);
|
calendarEvent.location(location);
|
||||||
if (milestone.workOrderLotOccupancies.length > 0) {
|
if (milestone.workOrderLotOccupancies.length > 0) {
|
||||||
let organizerSet = false;
|
let organizerSet = false;
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies) {
|
for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants) {
|
for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) {
|
||||||
if (organizerSet) {
|
if (organizerSet) {
|
||||||
calendarEvent.createAttendee({
|
calendarEvent.createAttendee({
|
||||||
name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`,
|
name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`,
|
||||||
email: configFunctions.getConfigProperty('settings.workOrders.calendarEmailAddress')
|
email: getConfigProperty('settings.workOrders.calendarEmailAddress')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
calendarEvent.organizer({
|
calendarEvent.organizer({
|
||||||
name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`,
|
name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`,
|
||||||
email: configFunctions.getConfigProperty('settings.workOrders.calendarEmailAddress')
|
email: getConfigProperty('settings.workOrders.calendarEmailAddress')
|
||||||
});
|
});
|
||||||
organizerSet = true;
|
organizerSet = true;
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +261,7 @@ export default async function handler(request, response) {
|
||||||
else {
|
else {
|
||||||
calendarEvent.organizer({
|
calendarEvent.organizer({
|
||||||
name: milestone.recordCreate_userName,
|
name: milestone.recordCreate_userName,
|
||||||
email: configFunctions.getConfigProperty('settings.workOrders.calendarEmailAddress')
|
email: getConfigProperty('settings.workOrders.calendarEmailAddress')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,21 +7,19 @@ import {
|
||||||
type WorkOrderMilestoneFilters,
|
type WorkOrderMilestoneFilters,
|
||||||
getWorkOrderMilestones
|
getWorkOrderMilestones
|
||||||
} from '../../database/getWorkOrderMilestones.js'
|
} from '../../database/getWorkOrderMilestones.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import { getPrintConfig } from '../../helpers/functions.print.js'
|
import { getPrintConfig } from '../../helpers/functions.print.js'
|
||||||
import type { WorkOrderMilestone } from '../../types/recordTypes.js'
|
import type { WorkOrderMilestone } from '../../types/recordTypes.js'
|
||||||
|
|
||||||
const calendarCompany = 'cityssm.github.io'
|
const calendarCompany = 'cityssm.github.io'
|
||||||
const calendarProduct = configFunctions.getConfigProperty(
|
const calendarProduct = getConfigProperty('application.applicationName')
|
||||||
'application.applicationName'
|
|
||||||
)
|
|
||||||
|
|
||||||
const timeStringSplitRegex = /[ :-]/
|
const timeStringSplitRegex = /[ :-]/
|
||||||
|
|
||||||
function escapeHTML(stringToEscape: string): string {
|
function escapeHTML(stringToEscape: string): string {
|
||||||
return stringToEscape.replaceAll(
|
return stringToEscape.replaceAll(
|
||||||
/[^\d a-z]/gi,
|
/[^\d a-z]/gi,
|
||||||
(c) => `&#${c.codePointAt(0)!};`
|
(c) => `&#${c.codePointAt(0)};`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,10 +27,10 @@ function getUrlRoot(request: Request): string {
|
||||||
return (
|
return (
|
||||||
'http://' +
|
'http://' +
|
||||||
request.hostname +
|
request.hostname +
|
||||||
(configFunctions.getConfigProperty('application.httpPort') === 80
|
(getConfigProperty('application.httpPort') === 80
|
||||||
? ''
|
? ''
|
||||||
: `:${configFunctions.getConfigProperty('application.httpPort')}`) +
|
: `:${getConfigProperty('application.httpPort')}`) +
|
||||||
configFunctions.getConfigProperty('reverseProxy.urlPrefix')
|
getConfigProperty('reverseProxy.urlPrefix')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,7 +38,7 @@ function getWorkOrderUrl(
|
||||||
request: Request,
|
request: Request,
|
||||||
milestone: WorkOrderMilestone
|
milestone: WorkOrderMilestone
|
||||||
): string {
|
): string {
|
||||||
return `${getUrlRoot(request)}/workOrders/${milestone.workOrderId!}`
|
return `${getUrlRoot(request)}/workOrders/${milestone.workOrderId}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEventSummary(milestone: WorkOrderMilestone): string {
|
function buildEventSummary(milestone: WorkOrderMilestone): string {
|
||||||
|
|
@ -53,8 +51,8 @@ function buildEventSummary(milestone: WorkOrderMilestone): string {
|
||||||
|
|
||||||
let occupantCount = 0
|
let occupantCount = 0
|
||||||
|
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies!) {
|
for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants!) {
|
for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) {
|
||||||
occupantCount += 1
|
occupantCount += 1
|
||||||
|
|
||||||
if (occupantCount === 1) {
|
if (occupantCount === 1) {
|
||||||
|
|
@ -88,47 +86,45 @@ function buildEventDescriptionHTML_occupancies(
|
||||||
const urlRoot = getUrlRoot(request)
|
const urlRoot = getUrlRoot(request)
|
||||||
|
|
||||||
descriptionHTML = `<h2>
|
descriptionHTML = `<h2>
|
||||||
Related ${escapeHTML(configFunctions.getConfigProperty('aliases.occupancies'))}
|
Related ${escapeHTML(getConfigProperty('aliases.occupancies'))}
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th>${escapeHTML(
|
<th>${escapeHTML(getConfigProperty('aliases.occupancy'))} Type</th>
|
||||||
configFunctions.getConfigProperty('aliases.occupancy')
|
<th>${escapeHTML(getConfigProperty('aliases.lot'))}</th>
|
||||||
)} Type</th>
|
|
||||||
<th>${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))}</th>
|
|
||||||
<th>Start Date</th>
|
<th>Start Date</th>
|
||||||
<th>End Date</th>
|
<th>End Date</th>
|
||||||
<th>${escapeHTML(configFunctions.getConfigProperty('aliases.occupants'))}</th>
|
<th>${escapeHTML(getConfigProperty('aliases.occupants'))}</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`
|
<tbody>`
|
||||||
|
|
||||||
for (const occupancy of milestone.workOrderLotOccupancies!) {
|
for (const occupancy of milestone.workOrderLotOccupancies ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lotOccupancies/${occupancy.lotOccupancyId!}">
|
<a href="${urlRoot}/lotOccupancies/${occupancy.lotOccupancyId}">
|
||||||
${escapeHTML(occupancy.occupancyType!)}
|
${escapeHTML(occupancy.occupancyType ?? '')}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${occupancy.lotName ? escapeHTML(occupancy.lotName) : '(Not Set)'}
|
${occupancy.lotName ? escapeHTML(occupancy.lotName) : '(Not Set)'}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${occupancy.occupancyStartDateString!}
|
${occupancy.occupancyStartDateString}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${
|
${
|
||||||
occupancy.occupancyEndDate
|
occupancy.occupancyEndDate
|
||||||
? occupancy.occupancyEndDateString!
|
? occupancy.occupancyEndDateString
|
||||||
: '(No End Date)'
|
: '(No End Date)'
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td>`
|
<td>`
|
||||||
|
|
||||||
for (const occupant of occupancy.lotOccupancyOccupants!) {
|
for (const occupant of occupancy.lotOccupancyOccupants ?? []) {
|
||||||
descriptionHTML += `${escapeHTML(
|
descriptionHTML += `${escapeHTML(
|
||||||
occupant.lotOccupantType!
|
occupant.lotOccupantType!
|
||||||
)}: ${escapeHTML(occupant.occupantName!)} ${escapeHTML(
|
)}: ${escapeHTML(occupant.occupantName ?? '')} ${escapeHTML(
|
||||||
occupant.occupantFamilyName!
|
occupant.occupantFamilyName ?? ''
|
||||||
)}<br />`
|
)}<br />`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,23 +148,23 @@ function buildEventDescriptionHTML_lots(
|
||||||
const urlRoot = getUrlRoot(request)
|
const urlRoot = getUrlRoot(request)
|
||||||
|
|
||||||
descriptionHTML += `<h2>
|
descriptionHTML += `<h2>
|
||||||
Related ${escapeHTML(configFunctions.getConfigProperty('aliases.lots'))}
|
Related ${escapeHTML(getConfigProperty('aliases.lots'))}
|
||||||
</h2>
|
</h2>
|
||||||
<table border="1"><thead><tr>
|
<table border="1"><thead><tr>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Type
|
${escapeHTML(getConfigProperty('aliases.lot'))} Type
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getConfigProperty('aliases.map'))}
|
${escapeHTML(getConfigProperty('aliases.map'))}
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Type
|
${escapeHTML(getConfigProperty('aliases.lot'))} Type
|
||||||
</th>
|
</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>`
|
<tbody>`
|
||||||
|
|
||||||
for (const lot of milestone.workOrderLots!) {
|
for (const lot of milestone.workOrderLots ?? []) {
|
||||||
descriptionHTML += `<tr>
|
descriptionHTML += `<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="${urlRoot}/lots/${lot.lotId.toString()}">
|
<a href="${urlRoot}/lots/${lot.lotId.toString()}">
|
||||||
|
|
@ -194,7 +190,7 @@ function buildEventDescriptionHTML_prints(
|
||||||
): string {
|
): string {
|
||||||
let descriptionHTML = ''
|
let descriptionHTML = ''
|
||||||
|
|
||||||
const prints = configFunctions.getConfigProperty('settings.workOrders.prints')
|
const prints = getConfigProperty('settings.workOrders.prints')
|
||||||
|
|
||||||
if (prints.length > 0) {
|
if (prints.length > 0) {
|
||||||
const urlRoot = getUrlRoot(request)
|
const urlRoot = getUrlRoot(request)
|
||||||
|
|
@ -256,7 +252,7 @@ function buildEventLocation(milestone: WorkOrderMilestone): string {
|
||||||
const lotNames: string[] = []
|
const lotNames: string[] = []
|
||||||
|
|
||||||
if (milestone.workOrderLots!.length > 0) {
|
if (milestone.workOrderLots!.length > 0) {
|
||||||
for (const lot of milestone.workOrderLots!) {
|
for (const lot of milestone.workOrderLots ?? []) {
|
||||||
lotNames.push(`${lot.mapName ?? ''}: ${lot.lotName ?? ''}`)
|
lotNames.push(`${lot.mapName ?? ''}: ${lot.lotName ?? ''}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -388,14 +384,14 @@ export default async function handler(
|
||||||
// Set organizer / attendees
|
// Set organizer / attendees
|
||||||
if (milestone.workOrderLotOccupancies!.length > 0) {
|
if (milestone.workOrderLotOccupancies!.length > 0) {
|
||||||
let organizerSet = false
|
let organizerSet = false
|
||||||
for (const lotOccupancy of milestone.workOrderLotOccupancies!) {
|
for (const lotOccupancy of milestone.workOrderLotOccupancies ?? []) {
|
||||||
for (const occupant of lotOccupancy.lotOccupancyOccupants!) {
|
for (const occupant of lotOccupancy.lotOccupancyOccupants ?? []) {
|
||||||
if (organizerSet) {
|
if (organizerSet) {
|
||||||
calendarEvent.createAttendee({
|
calendarEvent.createAttendee({
|
||||||
name: `${occupant.occupantName ?? ''} ${
|
name: `${occupant.occupantName ?? ''} ${
|
||||||
occupant.occupantFamilyName ?? ''
|
occupant.occupantFamilyName ?? ''
|
||||||
}`,
|
}`,
|
||||||
email: configFunctions.getConfigProperty(
|
email: getConfigProperty(
|
||||||
'settings.workOrders.calendarEmailAddress'
|
'settings.workOrders.calendarEmailAddress'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
@ -404,7 +400,7 @@ export default async function handler(
|
||||||
name: `${occupant.occupantName ?? ''} ${
|
name: `${occupant.occupantName ?? ''} ${
|
||||||
occupant.occupantFamilyName ?? ''
|
occupant.occupantFamilyName ?? ''
|
||||||
}`,
|
}`,
|
||||||
email: configFunctions.getConfigProperty(
|
email: getConfigProperty(
|
||||||
'settings.workOrders.calendarEmailAddress'
|
'settings.workOrders.calendarEmailAddress'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
@ -415,13 +411,10 @@ export default async function handler(
|
||||||
} else {
|
} else {
|
||||||
calendarEvent.organizer({
|
calendarEvent.organizer({
|
||||||
name: milestone.recordCreate_userName!,
|
name: milestone.recordCreate_userName!,
|
||||||
email: configFunctions.getConfigProperty(
|
email: getConfigProperty('settings.workOrders.calendarEmailAddress')
|
||||||
'settings.workOrders.calendarEmailAddress'
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calendar.serve(response)
|
calendar.serve(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { getLotOccupancy } from '../../database/getLotOccupancy.js';
|
import { getLotOccupancy } from '../../database/getLotOccupancy.js';
|
||||||
import { getMaps } from '../../database/getMaps.js';
|
import { getMaps } from '../../database/getMaps.js';
|
||||||
import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypePrintsById, getOccupancyTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypePrintsById, getOccupancyTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lotOccupancy = await getLotOccupancy(request.params.lotOccupancyId);
|
const lotOccupancy = await getLotOccupancy(request.params.lotOccupancyId);
|
||||||
if (lotOccupancy === undefined) {
|
if (lotOccupancy === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/lotOccupancies/?error=lotOccupancyIdNotFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lotOccupancies/?error=lotOccupancyIdNotFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const occupancyTypePrints = await getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
const occupancyTypePrints = await getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
||||||
|
|
@ -16,7 +16,7 @@ export default async function handler(request, response) {
|
||||||
const maps = await getMaps();
|
const maps = await getMaps();
|
||||||
const workOrderTypes = await getWorkOrderTypes();
|
const workOrderTypes = await getWorkOrderTypes();
|
||||||
response.render('lotOccupancy-edit', {
|
response.render('lotOccupancy-edit', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} Update`,
|
headTitle: `${getConfigProperty('aliases.occupancy')} Update`,
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypePrints,
|
occupancyTypePrints,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,17 @@ import {
|
||||||
getOccupancyTypes,
|
getOccupancyTypes,
|
||||||
getWorkOrderTypes
|
getWorkOrderTypes
|
||||||
} from '../../helpers/functions.cache.js'
|
} from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(request: Request, response: Response): Promise<void> {
|
export default async function handler(
|
||||||
|
request: Request,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
const lotOccupancy = await getLotOccupancy(request.params.lotOccupancyId)
|
const lotOccupancy = await getLotOccupancy(request.params.lotOccupancyId)
|
||||||
|
|
||||||
if (lotOccupancy === undefined) {
|
if (lotOccupancy === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lotOccupancies/?error=lotOccupancyIdNotFound`
|
)}/lotOccupancies/?error=lotOccupancyIdNotFound`
|
||||||
)
|
)
|
||||||
|
|
@ -36,7 +39,7 @@ export default async function handler(request: Request, response: Response): Pro
|
||||||
const workOrderTypes = await getWorkOrderTypes()
|
const workOrderTypes = await getWorkOrderTypes()
|
||||||
|
|
||||||
response.render('lotOccupancy-edit', {
|
response.render('lotOccupancy-edit', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} Update`,
|
headTitle: `${getConfigProperty('aliases.occupancy')} Update`,
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypePrints,
|
occupancyTypePrints,
|
||||||
|
|
||||||
|
|
@ -50,4 +53,3 @@ export default async function handler(request: Request, response: Response): Pro
|
||||||
isCreate: false
|
isCreate: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { dateToInteger, dateToString } from '@cityssm/utils-datetime';
|
||||||
import { getLot } from '../../database/getLot.js';
|
import { getLot } from '../../database/getLot.js';
|
||||||
import { getMaps } from '../../database/getMaps.js';
|
import { getMaps } from '../../database/getMaps.js';
|
||||||
import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypes } from '../../helpers/functions.cache.js';
|
import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const startDate = new Date();
|
const startDate = new Date();
|
||||||
const lotOccupancy = {
|
const lotOccupancy = {
|
||||||
|
|
@ -24,7 +24,7 @@ export default async function handler(request, response) {
|
||||||
const lotStatuses = await getLotStatuses();
|
const lotStatuses = await getLotStatuses();
|
||||||
const maps = await getMaps();
|
const maps = await getMaps();
|
||||||
response.render('lotOccupancy-edit', {
|
response.render('lotOccupancy-edit', {
|
||||||
headTitle: `Create a New ${configFunctions.getConfigProperty('aliases.occupancy')} Record`,
|
headTitle: `Create a New ${getConfigProperty('aliases.occupancy')} Record`,
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
lotOccupantTypes,
|
lotOccupantTypes,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { dateToInteger, dateToString } from '@cityssm/utils-datetime'
|
||||||
dateToInteger,
|
|
||||||
dateToString
|
|
||||||
} from '@cityssm/utils-datetime'
|
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getLot } from '../../database/getLot.js'
|
import { getLot } from '../../database/getLot.js'
|
||||||
|
|
@ -12,7 +9,7 @@ import {
|
||||||
getLotTypes,
|
getLotTypes,
|
||||||
getOccupancyTypes
|
getOccupancyTypes
|
||||||
} from '../../helpers/functions.cache.js'
|
} from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import type { LotOccupancy } from '../../types/recordTypes.js'
|
import type { LotOccupancy } from '../../types/recordTypes.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
|
|
@ -44,9 +41,7 @@ export default async function handler(
|
||||||
const maps = await getMaps()
|
const maps = await getMaps()
|
||||||
|
|
||||||
response.render('lotOccupancy-edit', {
|
response.render('lotOccupancy-edit', {
|
||||||
headTitle: `Create a New ${configFunctions.getConfigProperty(
|
headTitle: `Create a New ${getConfigProperty('aliases.occupancy')} Record`,
|
||||||
'aliases.occupancy'
|
|
||||||
)} Record`,
|
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
|
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
|
|
@ -58,4 +53,3 @@ export default async function handler(
|
||||||
isCreate: true
|
isCreate: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { getMaps } from '../../database/getMaps.js';
|
import { getMaps } from '../../database/getMaps.js';
|
||||||
import { getLotTypes, getOccupancyTypes } from '../../helpers/functions.cache.js';
|
import { getLotTypes, getOccupancyTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const maps = await getMaps();
|
const maps = await getMaps();
|
||||||
const lotTypes = await getLotTypes();
|
const lotTypes = await getLotTypes();
|
||||||
const occupancyTypes = await getOccupancyTypes();
|
const occupancyTypes = await getOccupancyTypes();
|
||||||
response.render('lotOccupancy-search', {
|
response.render('lotOccupancy-search', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} Search`,
|
headTitle: `${getConfigProperty('aliases.occupancy')} Search`,
|
||||||
maps,
|
maps,
|
||||||
lotTypes,
|
lotTypes,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
getLotTypes,
|
getLotTypes,
|
||||||
getOccupancyTypes
|
getOccupancyTypes
|
||||||
} from '../../helpers/functions.cache.js'
|
} from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -16,11 +16,10 @@ export default async function handler(
|
||||||
const occupancyTypes = await getOccupancyTypes()
|
const occupancyTypes = await getOccupancyTypes()
|
||||||
|
|
||||||
response.render('lotOccupancy-search', {
|
response.render('lotOccupancy-search', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} Search`,
|
headTitle: `${getConfigProperty('aliases.occupancy')} Search`,
|
||||||
maps,
|
maps,
|
||||||
lotTypes,
|
lotTypes,
|
||||||
occupancyTypes,
|
occupancyTypes,
|
||||||
mapId: request.query.mapId
|
mapId: request.query.mapId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
import { getLotOccupancy } from '../../database/getLotOccupancy.js';
|
import { getLotOccupancy } from '../../database/getLotOccupancy.js';
|
||||||
import { getOccupancyTypePrintsById } from '../../helpers/functions.cache.js';
|
import { getOccupancyTypePrintsById } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lotOccupancy = await getLotOccupancy(request.params.lotOccupancyId);
|
const lotOccupancy = await getLotOccupancy(request.params.lotOccupancyId);
|
||||||
if (lotOccupancy === undefined) {
|
if (lotOccupancy === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/lotOccupancies/?error=lotOccupancyIdNotFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lotOccupancies/?error=lotOccupancyIdNotFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const occupancyTypePrints = await getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
const occupancyTypePrints = await getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
||||||
response.render('lotOccupancy-view', {
|
response.render('lotOccupancy-view', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} View`,
|
headTitle: `${getConfigProperty('aliases.occupancy')} View`,
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypePrints
|
occupancyTypePrints
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getLotOccupancy } from '../../database/getLotOccupancy.js'
|
import { getLotOccupancy } from '../../database/getLotOccupancy.js'
|
||||||
import { getOccupancyTypePrintsById } from '../../helpers/functions.cache.js'
|
import { getOccupancyTypePrintsById } from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -12,7 +12,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (lotOccupancy === undefined) {
|
if (lotOccupancy === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lotOccupancies/?error=lotOccupancyIdNotFound`
|
)}/lotOccupancies/?error=lotOccupancyIdNotFound`
|
||||||
)
|
)
|
||||||
|
|
@ -24,9 +24,8 @@ export default async function handler(
|
||||||
)
|
)
|
||||||
|
|
||||||
response.render('lotOccupancy-view', {
|
response.render('lotOccupancy-view', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} View`,
|
headTitle: `${getConfigProperty('aliases.occupancy')} View`,
|
||||||
lotOccupancy,
|
lotOccupancy,
|
||||||
occupancyTypePrints
|
occupancyTypePrints
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
import { getLot } from '../../database/getLot.js';
|
import { getLot } from '../../database/getLot.js';
|
||||||
import { getMaps } from '../../database/getMaps.js';
|
import { getMaps } from '../../database/getMaps.js';
|
||||||
import * as cacheFunctions from '../../helpers/functions.cache.js';
|
import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lot = await getLot(request.params.lotId);
|
const lot = await getLot(request.params.lotId);
|
||||||
if (lot === undefined) {
|
if (lot === undefined) {
|
||||||
response.redirect(configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
response.redirect(getConfigProperty('reverseProxy.urlPrefix') + '/lots/?error=lotIdNotFound');
|
||||||
'/lots/?error=lotIdNotFound');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const maps = await getMaps();
|
const maps = await getMaps();
|
||||||
const lotTypes = await cacheFunctions.getLotTypes();
|
const lotTypes = await getLotTypes();
|
||||||
const lotStatuses = await cacheFunctions.getLotStatuses();
|
const lotStatuses = await getLotStatuses();
|
||||||
response.render('lot-edit', {
|
response.render('lot-edit', {
|
||||||
headTitle: lot.lotName,
|
headTitle: lot.lotName,
|
||||||
lot,
|
lot,
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getLot } from '../../database/getLot.js'
|
import { getLot } from '../../database/getLot.js'
|
||||||
import { getMaps } from '../../database/getMaps.js'
|
import { getMaps } from '../../database/getMaps.js'
|
||||||
import * as cacheFunctions from '../../helpers/functions.cache.js'
|
import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -13,15 +13,14 @@ export default async function handler(
|
||||||
|
|
||||||
if (lot === undefined) {
|
if (lot === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
getConfigProperty('reverseProxy.urlPrefix') + '/lots/?error=lotIdNotFound'
|
||||||
'/lots/?error=lotIdNotFound'
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const maps = await getMaps()
|
const maps = await getMaps()
|
||||||
const lotTypes = await cacheFunctions.getLotTypes()
|
const lotTypes = await getLotTypes()
|
||||||
const lotStatuses = await cacheFunctions.getLotStatuses()
|
const lotStatuses = await getLotStatuses()
|
||||||
|
|
||||||
response.render('lot-edit', {
|
response.render('lot-edit', {
|
||||||
headTitle: lot.lotName,
|
headTitle: lot.lotName,
|
||||||
|
|
@ -32,4 +31,3 @@ export default async function handler(
|
||||||
lotStatuses
|
lotStatuses
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { getMaps } from '../../database/getMaps.js';
|
import { getMaps } from '../../database/getMaps.js';
|
||||||
import * as cacheFunctions from '../../helpers/functions.cache.js';
|
import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lot = {
|
const lot = {
|
||||||
lotId: -1,
|
lotId: -1,
|
||||||
|
|
@ -17,10 +17,10 @@ export default async function handler(request, response) {
|
||||||
lot.mapName = map.mapName;
|
lot.mapName = map.mapName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const lotTypes = await cacheFunctions.getLotTypes();
|
const lotTypes = await getLotTypes();
|
||||||
const lotStatuses = await cacheFunctions.getLotStatuses();
|
const lotStatuses = await getLotStatuses();
|
||||||
response.render('lot-edit', {
|
response.render('lot-edit', {
|
||||||
headTitle: `Create a New ${configFunctions.getConfigProperty('aliases.lot')}`,
|
headTitle: `Create a New ${getConfigProperty('aliases.lot')}`,
|
||||||
lot,
|
lot,
|
||||||
isCreate: true,
|
isCreate: true,
|
||||||
maps,
|
maps,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getMaps } from '../../database/getMaps.js'
|
import { getMaps } from '../../database/getMaps.js'
|
||||||
import * as cacheFunctions from '../../helpers/functions.cache.js'
|
import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import type { Lot } from '../../types/recordTypes.js'
|
import type { Lot } from '../../types/recordTypes.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
|
|
@ -29,11 +29,11 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lotTypes = await cacheFunctions.getLotTypes()
|
const lotTypes = await getLotTypes()
|
||||||
const lotStatuses = await cacheFunctions.getLotStatuses()
|
const lotStatuses = await getLotStatuses()
|
||||||
|
|
||||||
response.render('lot-edit', {
|
response.render('lot-edit', {
|
||||||
headTitle: `Create a New ${configFunctions.getConfigProperty('aliases.lot')}`,
|
headTitle: `Create a New ${getConfigProperty('aliases.lot')}`,
|
||||||
lot,
|
lot,
|
||||||
isCreate: true,
|
isCreate: true,
|
||||||
maps,
|
maps,
|
||||||
|
|
@ -41,4 +41,3 @@ export default async function handler(
|
||||||
lotStatuses
|
lotStatuses
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
import { getNextLotId } from '../../helpers/functions.lots.js';
|
import { getNextLotId } from '../../helpers/functions.lots.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lotId = Number.parseInt(request.params.lotId, 10);
|
const lotId = Number.parseInt(request.params.lotId, 10);
|
||||||
const nextLotId = await getNextLotId(lotId);
|
const nextLotId = await getNextLotId(lotId);
|
||||||
if (nextLotId === undefined) {
|
if (nextLotId === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=noNextLotIdFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=noNextLotIdFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/lots/${nextLotId.toString()}`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/${nextLotId.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import { getNextLotId } from '../../helpers/functions.lots.js'
|
import { getNextLotId } from '../../helpers/functions.lots.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (nextLotId === undefined) {
|
if (nextLotId === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lots/?error=noNextLotIdFound`
|
)}/lots/?error=noNextLotIdFound`
|
||||||
)
|
)
|
||||||
|
|
@ -21,9 +21,8 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lots/${nextLotId.toString()}`
|
)}/lots/${nextLotId.toString()}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
import { getPreviousLotId } from '../../helpers/functions.lots.js';
|
import { getPreviousLotId } from '../../helpers/functions.lots.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lotId = Number.parseInt(request.params.lotId, 10);
|
const lotId = Number.parseInt(request.params.lotId, 10);
|
||||||
const previousLotId = await getPreviousLotId(lotId);
|
const previousLotId = await getPreviousLotId(lotId);
|
||||||
if (previousLotId === undefined) {
|
if (previousLotId === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=noPreviousLotIdFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=noPreviousLotIdFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/lots/${previousLotId.toString()}`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/${previousLotId.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import { getPreviousLotId } from '../../helpers/functions.lots.js'
|
import { getPreviousLotId } from '../../helpers/functions.lots.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (previousLotId === undefined) {
|
if (previousLotId === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lots/?error=noPreviousLotIdFound`
|
)}/lots/?error=noPreviousLotIdFound`
|
||||||
)
|
)
|
||||||
|
|
@ -21,9 +21,8 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/lots/${previousLotId.toString()}`
|
)}/lots/${previousLotId.toString()}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { getMaps } from '../../database/getMaps.js';
|
import { getMaps } from '../../database/getMaps.js';
|
||||||
import { getLotTypes, getLotStatuses } from '../../helpers/functions.cache.js';
|
import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const maps = await getMaps();
|
const maps = await getMaps();
|
||||||
const lotTypes = await getLotTypes();
|
const lotTypes = await getLotTypes();
|
||||||
const lotStatuses = await getLotStatuses();
|
const lotStatuses = await getLotStatuses();
|
||||||
response.render('lot-search', {
|
response.render('lot-search', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.lot')} Search`,
|
headTitle: `${getConfigProperty('aliases.lot')} Search`,
|
||||||
maps,
|
maps,
|
||||||
lotTypes,
|
lotTypes,
|
||||||
lotStatuses,
|
lotStatuses,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getMaps } from '../../database/getMaps.js'
|
import { getMaps } from '../../database/getMaps.js'
|
||||||
import { getLotTypes, getLotStatuses } from '../../helpers/functions.cache.js'
|
import { getLotStatuses, getLotTypes } from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function handler(
|
||||||
const lotStatuses = await getLotStatuses()
|
const lotStatuses = await getLotStatuses()
|
||||||
|
|
||||||
response.render('lot-search', {
|
response.render('lot-search', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.lot')} Search`,
|
headTitle: `${getConfigProperty('aliases.lot')} Search`,
|
||||||
maps,
|
maps,
|
||||||
lotTypes,
|
lotTypes,
|
||||||
lotStatuses,
|
lotStatuses,
|
||||||
|
|
@ -22,4 +22,3 @@ export default async function handler(
|
||||||
lotStatusId: request.query.lotStatusId
|
lotStatusId: request.query.lotStatusId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import { getLot } from '../../database/getLot.js';
|
import { getLot } from '../../database/getLot.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js';
|
import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const lot = await getLot(request.params.lotId);
|
const lot = await getLot(request.params.lotId);
|
||||||
if (lot === undefined) {
|
if (lot === undefined) {
|
||||||
response.redirect(configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`);
|
||||||
'/lots/?error=lotIdNotFound');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.render('lot-view', {
|
response.render('lot-view', {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getLot } from '../../database/getLot.js'
|
import { getLot } from '../../database/getLot.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js'
|
import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
|
|
@ -12,8 +12,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (lot === undefined) {
|
if (lot === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
`${getConfigProperty('reverseProxy.urlPrefix')}/lots/?error=lotIdNotFound`
|
||||||
'/lots/?error=lotIdNotFound'
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -28,4 +27,3 @@ export default async function handler(
|
||||||
void getPreviousLotId(lot.lotId)
|
void getPreviousLotId(lot.lotId)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { getLotStatusSummary } from '../../database/getLotStatusSummary.js';
|
import { getLotStatusSummary } from '../../database/getLotStatusSummary.js';
|
||||||
import { getLotTypeSummary } from '../../database/getLotTypeSummary.js';
|
import { getLotTypeSummary } from '../../database/getLotTypeSummary.js';
|
||||||
import { getMap } from '../../database/getMap.js';
|
import { getMap } from '../../database/getMap.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
import { getMapSVGs } from '../../helpers/functions.map.js';
|
import { getMapSVGs } from '../../helpers/functions.map.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const map = await getMap(request.params.mapId);
|
const map = await getMap(request.params.mapId);
|
||||||
if (map === undefined) {
|
if (map === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=mapIdNotFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=mapIdNotFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const mapSVGs = await getMapSVGs();
|
const mapSVGs = await getMapSVGs();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import type { Request, Response } from 'express'
|
||||||
import { getLotStatusSummary } from '../../database/getLotStatusSummary.js'
|
import { getLotStatusSummary } from '../../database/getLotStatusSummary.js'
|
||||||
import { getLotTypeSummary } from '../../database/getLotTypeSummary.js'
|
import { getLotTypeSummary } from '../../database/getLotTypeSummary.js'
|
||||||
import { getMap } from '../../database/getMap.js'
|
import { getMap } from '../../database/getMap.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import { getMapSVGs } from '../../helpers/functions.map.js'
|
import { getMapSVGs } from '../../helpers/functions.map.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
|
|
@ -14,9 +14,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (map === undefined) {
|
if (map === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=mapIdNotFound`
|
||||||
'reverseProxy.urlPrefix'
|
|
||||||
)}/maps/?error=mapIdNotFound`
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -40,4 +38,3 @@ export default async function handler(
|
||||||
lotStatusSummary
|
lotStatusSummary
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
import { getMapSVGs } from '../../helpers/functions.map.js';
|
import { getMapSVGs } from '../../helpers/functions.map.js';
|
||||||
export default async function handler(_request, response) {
|
export default async function handler(_request, response) {
|
||||||
const map = {
|
const map = {
|
||||||
mapCity: configFunctions.getConfigProperty('settings.map.mapCityDefault'),
|
mapCity: getConfigProperty('settings.map.mapCityDefault'),
|
||||||
mapProvince: configFunctions.getConfigProperty('settings.map.mapProvinceDefault')
|
mapProvince: getConfigProperty('settings.map.mapProvinceDefault')
|
||||||
};
|
};
|
||||||
const mapSVGs = await getMapSVGs();
|
const mapSVGs = await getMapSVGs();
|
||||||
response.render('map-edit', {
|
response.render('map-edit', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.map')} Create`,
|
headTitle: `${getConfigProperty('aliases.map')} Create`,
|
||||||
isCreate: true,
|
isCreate: true,
|
||||||
map,
|
map,
|
||||||
mapSVGs
|
mapSVGs
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import { getMapSVGs } from '../../helpers/functions.map.js'
|
import { getMapSVGs } from '../../helpers/functions.map.js'
|
||||||
import type { MapRecord } from '../../types/recordTypes.js'
|
import type { MapRecord } from '../../types/recordTypes.js'
|
||||||
|
|
||||||
|
|
@ -9,17 +9,16 @@ export default async function handler(
|
||||||
response: Response
|
response: Response
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const map: MapRecord = {
|
const map: MapRecord = {
|
||||||
mapCity: configFunctions.getConfigProperty('settings.map.mapCityDefault'),
|
mapCity: getConfigProperty('settings.map.mapCityDefault'),
|
||||||
mapProvince: configFunctions.getConfigProperty('settings.map.mapProvinceDefault')
|
mapProvince: getConfigProperty('settings.map.mapProvinceDefault')
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapSVGs = await getMapSVGs()
|
const mapSVGs = await getMapSVGs()
|
||||||
|
|
||||||
response.render('map-edit', {
|
response.render('map-edit', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.map')} Create`,
|
headTitle: `${getConfigProperty('aliases.map')} Create`,
|
||||||
isCreate: true,
|
isCreate: true,
|
||||||
map,
|
map,
|
||||||
mapSVGs
|
mapSVGs
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { getNextMapId } from '../../database/getNextMapId.js';
|
import { getNextMapId } from '../../database/getNextMapId.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const mapId = Number.parseInt(request.params.mapId, 10);
|
const mapId = Number.parseInt(request.params.mapId, 10);
|
||||||
const nextMapId = await getNextMapId(mapId);
|
const nextMapId = await getNextMapId(mapId);
|
||||||
if (nextMapId === undefined) {
|
if (nextMapId === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=noNextMapIdFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=noNextMapIdFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/${nextMapId.toString()}`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/maps/${nextMapId.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getNextMapId } from '../../database/getNextMapId.js'
|
import { getNextMapId } from '../../database/getNextMapId.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (nextMapId === undefined) {
|
if (nextMapId === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/maps/?error=noNextMapIdFound`
|
)}/maps/?error=noNextMapIdFound`
|
||||||
)
|
)
|
||||||
|
|
@ -21,9 +21,8 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/maps/${nextMapId.toString()}`
|
)}/maps/${nextMapId.toString()}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { getPreviousMapId } from '../../database/getPreviousMapId.js';
|
import { getPreviousMapId } from '../../database/getPreviousMapId.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const mapId = Number.parseInt(request.params.mapId, 10);
|
const mapId = Number.parseInt(request.params.mapId, 10);
|
||||||
const previousMapId = await getPreviousMapId(mapId);
|
const previousMapId = await getPreviousMapId(mapId);
|
||||||
if (previousMapId === undefined) {
|
if (previousMapId === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=noPreviousMapIdFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=noPreviousMapIdFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/${previousMapId.toString()}`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/maps/${previousMapId.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getPreviousMapId } from '../../database/getPreviousMapId.js'
|
import { getPreviousMapId } from '../../database/getPreviousMapId.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (previousMapId === undefined) {
|
if (previousMapId === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/maps/?error=noPreviousMapIdFound`
|
)}/maps/?error=noPreviousMapIdFound`
|
||||||
)
|
)
|
||||||
|
|
@ -21,9 +21,8 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/maps/${previousMapId.toString()}`
|
)}/maps/${previousMapId.toString()}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { getMaps } from '../../database/getMaps.js';
|
import { getMaps } from '../../database/getMaps.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(_request, response) {
|
export default async function handler(_request, response) {
|
||||||
const maps = await getMaps();
|
const maps = await getMaps();
|
||||||
response.render('map-search', {
|
response.render('map-search', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.map')} Search`,
|
headTitle: `${getConfigProperty('aliases.map')} Search`,
|
||||||
maps
|
maps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getMaps } from '../../database/getMaps.js'
|
import { getMaps } from '../../database/getMaps.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(_request: Request, response: Response): Promise<void> {
|
export default async function handler(
|
||||||
|
_request: Request,
|
||||||
|
response: Response
|
||||||
|
): Promise<void> {
|
||||||
const maps = await getMaps()
|
const maps = await getMaps()
|
||||||
|
|
||||||
response.render('map-search', {
|
response.render('map-search', {
|
||||||
headTitle: `${configFunctions.getConfigProperty('aliases.map')} Search`,
|
headTitle: `${getConfigProperty('aliases.map')} Search`,
|
||||||
maps
|
maps
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { getLotStatusSummary } from '../../database/getLotStatusSummary.js';
|
import { getLotStatusSummary } from '../../database/getLotStatusSummary.js';
|
||||||
import { getLotTypeSummary } from '../../database/getLotTypeSummary.js';
|
import { getLotTypeSummary } from '../../database/getLotTypeSummary.js';
|
||||||
import { getMap } from '../../database/getMap.js';
|
import { getMap } from '../../database/getMap.js';
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const map = await getMap(request.params.mapId);
|
const map = await getMap(request.params.mapId);
|
||||||
if (map === undefined) {
|
if (map === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=mapIdNotFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=mapIdNotFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const lotTypeSummary = await getLotTypeSummary({
|
const lotTypeSummary = await getLotTypeSummary({
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import type { Request, Response } from 'express'
|
||||||
import { getLotStatusSummary } from '../../database/getLotStatusSummary.js'
|
import { getLotStatusSummary } from '../../database/getLotStatusSummary.js'
|
||||||
import { getLotTypeSummary } from '../../database/getLotTypeSummary.js'
|
import { getLotTypeSummary } from '../../database/getLotTypeSummary.js'
|
||||||
import { getMap } from '../../database/getMap.js'
|
import { getMap } from '../../database/getMap.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (map === undefined) {
|
if (map === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=mapIdNotFound`
|
`${getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=mapIdNotFound`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -33,4 +33,3 @@ export default async function handler(
|
||||||
lotStatusSummary
|
lotStatusSummary
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
/// <reference types="cookie-parser" />
|
/// <reference types="cookie-parser" />
|
||||||
import type { NextFunction, Request, Response } from 'express';
|
import type { NextFunction, Request, Response } from 'express';
|
||||||
export default function handler(request: Request, response: Response, next: NextFunction): Promise<void>;
|
export declare function handler(request: Request, response: Response, next: NextFunction): Promise<void>;
|
||||||
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import * as configFunctions from '../../helpers/functions.config.js';
|
||||||
import * as lotOccupancyFunctions from '../../helpers/functions.lotOccupancy.js';
|
import * as lotOccupancyFunctions from '../../helpers/functions.lotOccupancy.js';
|
||||||
import { getPdfPrintConfig, getReportData } from '../../helpers/functions.print.js';
|
import { getPdfPrintConfig, getReportData } from '../../helpers/functions.print.js';
|
||||||
const attachmentOrInline = configFunctions.getConfigProperty('settings.printPdf.contentDisposition');
|
const attachmentOrInline = configFunctions.getConfigProperty('settings.printPdf.contentDisposition');
|
||||||
export default async function handler(request, response, next) {
|
export async function handler(request, response, next) {
|
||||||
const printName = request.params.printName;
|
const printName = request.params.printName;
|
||||||
if (!configFunctions
|
if (!configFunctions
|
||||||
.getConfigProperty('settings.lotOccupancy.prints')
|
.getConfigProperty('settings.lotOccupancy.prints')
|
||||||
|
|
@ -48,3 +48,4 @@ export default async function handler(request, response, next) {
|
||||||
reportData.lotOccupancyFunctions = lotOccupancyFunctions;
|
reportData.lotOccupancyFunctions = lotOccupancyFunctions;
|
||||||
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction);
|
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction);
|
||||||
}
|
}
|
||||||
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ const attachmentOrInline = configFunctions.getConfigProperty(
|
||||||
'settings.printPdf.contentDisposition'
|
'settings.printPdf.contentDisposition'
|
||||||
)
|
)
|
||||||
|
|
||||||
export default async function handler(
|
export async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response,
|
response: Response,
|
||||||
next: NextFunction
|
next: NextFunction
|
||||||
|
|
@ -90,3 +90,4 @@ export default async function handler(
|
||||||
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction)
|
await ejs.renderFile(reportPath, reportData, {}, ejsCallbackFunction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default handler
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
import { getReportData, getScreenPrintConfig } from '../../helpers/functions.print.js';
|
import { getReportData, getScreenPrintConfig } from '../../helpers/functions.print.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const printName = request.params.printName;
|
const printName = request.params.printName;
|
||||||
if (!configFunctions
|
if (!getConfigProperty('settings.lotOccupancy.prints').includes(`screen/${printName}`) &&
|
||||||
.getConfigProperty('settings.lotOccupancy.prints')
|
!getConfigProperty('settings.workOrders.prints').includes(`screen/${printName}`)) {
|
||||||
.includes(`screen/${printName}`) &&
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotAllowed`);
|
||||||
!configFunctions
|
|
||||||
.getConfigProperty('settings.workOrders.prints')
|
|
||||||
.includes(`screen/${printName}`)) {
|
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/dashboard/?error=printConfigNotAllowed`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const printConfig = getScreenPrintConfig(printName);
|
const printConfig = getScreenPrintConfig(printName);
|
||||||
if (printConfig === undefined) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
response.redirect(getConfigProperty('reverseProxy.urlPrefix') +
|
||||||
'/dashboard/?error=printConfigNotFound');
|
'/dashboard/?error=printConfigNotFound');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import {
|
import {
|
||||||
getReportData,
|
getReportData,
|
||||||
getScreenPrintConfig
|
getScreenPrintConfig
|
||||||
|
|
@ -13,15 +13,15 @@ export default async function handler(
|
||||||
const printName = request.params.printName
|
const printName = request.params.printName
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!configFunctions
|
!getConfigProperty('settings.lotOccupancy.prints').includes(
|
||||||
.getConfigProperty('settings.lotOccupancy.prints')
|
`screen/${printName}`
|
||||||
.includes(`screen/${printName}`) &&
|
) &&
|
||||||
!configFunctions
|
!getConfigProperty('settings.workOrders.prints').includes(
|
||||||
.getConfigProperty('settings.workOrders.prints')
|
`screen/${printName}`
|
||||||
.includes(`screen/${printName}`)
|
)
|
||||||
) {
|
) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/dashboard/?error=printConfigNotAllowed`
|
)}/dashboard/?error=printConfigNotAllowed`
|
||||||
)
|
)
|
||||||
|
|
@ -32,7 +32,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (printConfig === undefined) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
configFunctions.getConfigProperty('reverseProxy.urlPrefix') +
|
getConfigProperty('reverseProxy.urlPrefix') +
|
||||||
'/dashboard/?error=printConfigNotFound'
|
'/dashboard/?error=printConfigNotFound'
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
@ -42,4 +42,3 @@ export default async function handler(
|
||||||
|
|
||||||
response.render(`print/screen/${printName}`, reportData)
|
response.render(`print/screen/${printName}`, reportData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { getLotStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
|
||||||
import { getWorkOrder } from '../../database/getWorkOrder.js';
|
import { getWorkOrder } from '../../database/getWorkOrder.js';
|
||||||
|
import { getLotStatuses, getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
||||||
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
||||||
includeLotsAndLotOccupancies: true,
|
includeLotsAndLotOccupancies: true,
|
||||||
|
|
@ -8,11 +8,11 @@ export default async function handler(request, response) {
|
||||||
includeMilestones: true
|
includeMilestones: true
|
||||||
});
|
});
|
||||||
if (workOrder === undefined) {
|
if (workOrder === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/workOrders/?error=workOrderIdNotFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/workOrders/?error=workOrderIdNotFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (workOrder.workOrderCloseDate) {
|
if (workOrder.workOrderCloseDate) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/workOrders/${workOrder.workOrderId.toString()}/?error=workOrderIsClosed`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/workOrders/${workOrder.workOrderId.toString()}/?error=workOrderIsClosed`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const workOrderTypes = await getWorkOrderTypes();
|
const workOrderTypes = await getWorkOrderTypes();
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import { getWorkOrder } from '../../database/getWorkOrder.js'
|
||||||
import {
|
import {
|
||||||
getLotStatuses,
|
getLotStatuses,
|
||||||
getWorkOrderMilestoneTypes,
|
getWorkOrderMilestoneTypes,
|
||||||
getWorkOrderTypes
|
getWorkOrderTypes
|
||||||
} from '../../helpers/functions.cache.js'
|
} from '../../helpers/functions.cache.js'
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
import { getWorkOrder } from '../../database/getWorkOrder.js'
|
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -20,7 +20,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (workOrder === undefined) {
|
if (workOrder === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/workOrders/?error=workOrderIdNotFound`
|
)}/workOrders/?error=workOrderIdNotFound`
|
||||||
)
|
)
|
||||||
|
|
@ -29,9 +29,9 @@ export default async function handler(
|
||||||
|
|
||||||
if (workOrder.workOrderCloseDate) {
|
if (workOrder.workOrderCloseDate) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/workOrders/${workOrder.workOrderId!.toString()}/?error=workOrderIsClosed`
|
)}/workOrders/${workOrder.workOrderId.toString()}/?error=workOrderIsClosed`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +43,7 @@ export default async function handler(
|
||||||
const lotStatuses = await getLotStatuses()
|
const lotStatuses = await getLotStatuses()
|
||||||
|
|
||||||
response.render('workOrder-edit', {
|
response.render('workOrder-edit', {
|
||||||
headTitle: `Work Order #${workOrder.workOrderNumber!}`,
|
headTitle: `Work Order #${workOrder.workOrderNumber}`,
|
||||||
workOrder,
|
workOrder,
|
||||||
isCreate: false,
|
isCreate: false,
|
||||||
workOrderTypes,
|
workOrderTypes,
|
||||||
|
|
@ -51,4 +51,3 @@ export default async function handler(
|
||||||
lotStatuses
|
lotStatuses
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import * as configFunctions from '../../helpers/functions.config.js';
|
|
||||||
import { getWorkOrder } from '../../database/getWorkOrder.js';
|
import { getWorkOrder } from '../../database/getWorkOrder.js';
|
||||||
|
import { getConfigProperty } from '../../helpers/functions.config.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
const workOrder = await getWorkOrder(request.params.workOrderId, {
|
||||||
includeLotsAndLotOccupancies: true,
|
includeLotsAndLotOccupancies: true,
|
||||||
|
|
@ -7,7 +7,7 @@ export default async function handler(request, response) {
|
||||||
includeMilestones: true
|
includeMilestones: true
|
||||||
});
|
});
|
||||||
if (workOrder === undefined) {
|
if (workOrder === undefined) {
|
||||||
response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/workOrders/?error=workOrderIdNotFound`);
|
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/workOrders/?error=workOrderIdNotFound`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.render('workOrder-view', {
|
response.render('workOrder-view', {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import * as configFunctions from '../../helpers/functions.config.js'
|
|
||||||
import { getWorkOrder } from '../../database/getWorkOrder.js'
|
import { getWorkOrder } from '../../database/getWorkOrder.js'
|
||||||
|
import { getConfigProperty } from '../../helpers/functions.config.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
@ -15,7 +15,7 @@ export default async function handler(
|
||||||
|
|
||||||
if (workOrder === undefined) {
|
if (workOrder === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
`${configFunctions.getConfigProperty(
|
`${getConfigProperty(
|
||||||
'reverseProxy.urlPrefix'
|
'reverseProxy.urlPrefix'
|
||||||
)}/workOrders/?error=workOrderIdNotFound`
|
)}/workOrders/?error=workOrderIdNotFound`
|
||||||
)
|
)
|
||||||
|
|
@ -23,8 +23,7 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
response.render('workOrder-view', {
|
response.render('workOrder-view', {
|
||||||
headTitle: `Work Order #${workOrder.workOrderNumber!}`,
|
headTitle: `Work Order #${workOrder.workOrderNumber}`,
|
||||||
workOrder
|
workOrder
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import ActiveDirectory from 'activedirectory2';
|
import ActiveDirectory from 'activedirectory2';
|
||||||
import * as configFunctions from './functions.config.js';
|
import { getConfigProperty } from './functions.config.js';
|
||||||
const userDomain = configFunctions.getConfigProperty('application.userDomain');
|
const userDomain = getConfigProperty('application.userDomain');
|
||||||
const activeDirectoryConfig = configFunctions.getConfigProperty('activeDirectory');
|
const activeDirectoryConfig = getConfigProperty('activeDirectory');
|
||||||
async function authenticateViaActiveDirectory(userName, password) {
|
async function authenticateViaActiveDirectory(userName, password) {
|
||||||
return await new Promise((resolve) => {
|
return await new Promise((resolve) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -46,7 +46,7 @@ const safeRedirects = new Set([
|
||||||
const recordUrl = /^\/(?:maps|lots|lotoccupancies|workorders)\/\d+(?:\/edit)?$/;
|
const recordUrl = /^\/(?:maps|lots|lotoccupancies|workorders)\/\d+(?:\/edit)?$/;
|
||||||
const printUrl = /^\/print\/(?:pdf|screen)\/[\d/=?A-Za-z-]+$/;
|
const printUrl = /^\/print\/(?:pdf|screen)\/[\d/=?A-Za-z-]+$/;
|
||||||
export function getSafeRedirectURL(possibleRedirectURL = '') {
|
export function getSafeRedirectURL(possibleRedirectURL = '') {
|
||||||
const urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix');
|
const urlPrefix = getConfigProperty('reverseProxy.urlPrefix');
|
||||||
if (typeof possibleRedirectURL === 'string') {
|
if (typeof possibleRedirectURL === 'string') {
|
||||||
const urlToCheck = possibleRedirectURL.startsWith(urlPrefix)
|
const urlToCheck = possibleRedirectURL.startsWith(urlPrefix)
|
||||||
? possibleRedirectURL.slice(urlPrefix.length)
|
? possibleRedirectURL.slice(urlPrefix.length)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import ActiveDirectory from 'activedirectory2'
|
import ActiveDirectory from 'activedirectory2'
|
||||||
|
|
||||||
import * as configFunctions from './functions.config.js'
|
import { getConfigProperty } from './functions.config.js'
|
||||||
|
|
||||||
const userDomain = configFunctions.getConfigProperty('application.userDomain')
|
const userDomain = getConfigProperty('application.userDomain')
|
||||||
|
|
||||||
const activeDirectoryConfig =
|
const activeDirectoryConfig = getConfigProperty('activeDirectory')
|
||||||
configFunctions.getConfigProperty('activeDirectory')
|
|
||||||
|
|
||||||
async function authenticateViaActiveDirectory(
|
async function authenticateViaActiveDirectory(
|
||||||
userName: string,
|
userName: string,
|
||||||
|
|
@ -65,7 +64,7 @@ const recordUrl = /^\/(?:maps|lots|lotoccupancies|workorders)\/\d+(?:\/edit)?$/
|
||||||
const printUrl = /^\/print\/(?:pdf|screen)\/[\d/=?A-Za-z-]+$/
|
const printUrl = /^\/print\/(?:pdf|screen)\/[\d/=?A-Za-z-]+$/
|
||||||
|
|
||||||
export function getSafeRedirectURL(possibleRedirectURL = ''): string {
|
export function getSafeRedirectURL(possibleRedirectURL = ''): string {
|
||||||
const urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix')
|
const urlPrefix = getConfigProperty('reverseProxy.urlPrefix')
|
||||||
|
|
||||||
if (typeof possibleRedirectURL === 'string') {
|
if (typeof possibleRedirectURL === 'string') {
|
||||||
const urlToCheck = possibleRedirectURL.startsWith(urlPrefix)
|
const urlToCheck = possibleRedirectURL.startsWith(urlPrefix)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { getOccupancyTypeFields as getOccupancyTypeFieldsFromDatabase } from '..
|
||||||
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from '../database/getOccupancyTypes.js';
|
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from '../database/getOccupancyTypes.js';
|
||||||
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from '../database/getWorkOrderMilestoneTypes.js';
|
import { getWorkOrderMilestoneTypes as getWorkOrderMilestoneTypesFromDatabase } from '../database/getWorkOrderMilestoneTypes.js';
|
||||||
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from '../database/getWorkOrderTypes.js';
|
import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from '../database/getWorkOrderTypes.js';
|
||||||
import * as configFunctions from './functions.config.js';
|
import { getConfigProperty } from './functions.config.js';
|
||||||
const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`);
|
const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`);
|
||||||
let lotOccupantTypes;
|
let lotOccupantTypes;
|
||||||
export async function getLotOccupantTypes() {
|
export async function getLotOccupantTypes() {
|
||||||
|
|
@ -114,7 +114,7 @@ export async function getOccupancyTypePrintsById(occupancyTypeId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (occupancyType.occupancyTypePrints.includes('*')) {
|
if (occupancyType.occupancyTypePrints.includes('*')) {
|
||||||
return configFunctions.getConfigProperty('settings.lotOccupancy.prints');
|
return getConfigProperty('settings.lotOccupancy.prints');
|
||||||
}
|
}
|
||||||
return occupancyType.occupancyTypePrints ?? [];
|
return occupancyType.occupancyTypePrints ?? [];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { getWorkOrderTypes as getWorkOrderTypesFromDatabase } from '../database/
|
||||||
import type { ClearCacheWorkerMessage } from '../types/applicationTypes.js'
|
import type { ClearCacheWorkerMessage } from '../types/applicationTypes.js'
|
||||||
import type * as recordTypes from '../types/recordTypes.js'
|
import type * as recordTypes from '../types/recordTypes.js'
|
||||||
|
|
||||||
import * as configFunctions from './functions.config.js'
|
import { getConfigProperty } from './functions.config.js'
|
||||||
|
|
||||||
const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`)
|
const debug = Debug(`lot-occupancy-system:functions.cache:${process.pid}`)
|
||||||
|
|
||||||
|
|
@ -205,7 +205,7 @@ export async function getOccupancyTypePrintsById(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (occupancyType.occupancyTypePrints.includes('*')) {
|
if (occupancyType.occupancyTypePrints.includes('*')) {
|
||||||
return configFunctions.getConfigProperty('settings.lotOccupancy.prints')
|
return getConfigProperty('settings.lotOccupancy.prints')
|
||||||
}
|
}
|
||||||
|
|
||||||
return occupancyType.occupancyTypePrints ?? []
|
return occupancyType.occupancyTypePrints ?? []
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { DynamicsGP } from '@cityssm/dynamics-gp';
|
import { DynamicsGP } from '@cityssm/dynamics-gp';
|
||||||
import * as configFunctions from './functions.config.js';
|
import { getConfigProperty } from './functions.config.js';
|
||||||
let gp;
|
let gp;
|
||||||
if (configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
gp = new DynamicsGP(configFunctions.getConfigProperty('settings.dynamicsGP.mssqlConfig'));
|
gp = new DynamicsGP(getConfigProperty('settings.dynamicsGP.mssqlConfig'));
|
||||||
}
|
}
|
||||||
function filterCashReceipt(cashReceipt) {
|
function filterCashReceipt(cashReceipt) {
|
||||||
const accountCodes = configFunctions.getConfigProperty('settings.dynamicsGP.accountCodes');
|
const accountCodes = getConfigProperty('settings.dynamicsGP.accountCodes');
|
||||||
if (accountCodes.length > 0) {
|
if (accountCodes.length > 0) {
|
||||||
for (const detail of cashReceipt.details) {
|
for (const detail of cashReceipt.details) {
|
||||||
if (accountCodes.includes(detail.accountCode)) {
|
if (accountCodes.includes(detail.accountCode)) {
|
||||||
|
|
@ -22,7 +22,7 @@ function filterCashReceipt(cashReceipt) {
|
||||||
return cashReceipt;
|
return cashReceipt;
|
||||||
}
|
}
|
||||||
function filterInvoice(invoice) {
|
function filterInvoice(invoice) {
|
||||||
const itemNumbers = configFunctions.getConfigProperty('settings.dynamicsGP.itemNumbers');
|
const itemNumbers = getConfigProperty('settings.dynamicsGP.itemNumbers');
|
||||||
for (const itemNumber of itemNumbers) {
|
for (const itemNumber of itemNumbers) {
|
||||||
const found = invoice.lineItems.some((itemRecord) => {
|
const found = invoice.lineItems.some((itemRecord) => {
|
||||||
return itemRecord.itemNumber === itemNumber;
|
return itemRecord.itemNumber === itemNumber;
|
||||||
|
|
@ -37,7 +37,7 @@ function filterExtendedInvoice(invoice) {
|
||||||
if (filterInvoice(invoice) === undefined) {
|
if (filterInvoice(invoice) === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const trialBalanceCodes = configFunctions.getConfigProperty('settings.dynamicsGP.trialBalanceCodes');
|
const trialBalanceCodes = getConfigProperty('settings.dynamicsGP.trialBalanceCodes');
|
||||||
if (trialBalanceCodes.length > 0 &&
|
if (trialBalanceCodes.length > 0 &&
|
||||||
trialBalanceCodes.includes(invoice.trialBalanceCode ?? '')) {
|
trialBalanceCodes.includes(invoice.trialBalanceCode ?? '')) {
|
||||||
return invoice;
|
return invoice;
|
||||||
|
|
@ -115,11 +115,11 @@ async function _getDynamicsGPDocument(documentNumber, lookupType) {
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
export async function getDynamicsGPDocument(documentNumber) {
|
export async function getDynamicsGPDocument(documentNumber) {
|
||||||
if (!configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
if (!getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let document;
|
let document;
|
||||||
for (const lookupType of configFunctions.getConfigProperty('settings.dynamicsGP.lookupOrder')) {
|
for (const lookupType of getConfigProperty('settings.dynamicsGP.lookupOrder')) {
|
||||||
document = await _getDynamicsGPDocument(documentNumber, lookupType);
|
document = await _getDynamicsGPDocument(documentNumber, lookupType);
|
||||||
if (document !== undefined) {
|
if (document !== undefined) {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,18 @@ import {
|
||||||
import type { DynamicsGPLookup } from '../types/configTypes.js'
|
import type { DynamicsGPLookup } from '../types/configTypes.js'
|
||||||
import type { DynamicsGPDocument } from '../types/recordTypes.js'
|
import type { DynamicsGPDocument } from '../types/recordTypes.js'
|
||||||
|
|
||||||
import * as configFunctions from './functions.config.js'
|
import { getConfigProperty } from './functions.config.js'
|
||||||
|
|
||||||
let gp: DynamicsGP
|
let gp: DynamicsGP
|
||||||
|
|
||||||
if (configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
gp = new DynamicsGP(
|
gp = new DynamicsGP(getConfigProperty('settings.dynamicsGP.mssqlConfig'))
|
||||||
configFunctions.getConfigProperty('settings.dynamicsGP.mssqlConfig')
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterCashReceipt(
|
function filterCashReceipt(
|
||||||
cashReceipt: DiamondCashReceipt
|
cashReceipt: DiamondCashReceipt
|
||||||
): DiamondCashReceipt | undefined {
|
): DiamondCashReceipt | undefined {
|
||||||
const accountCodes = configFunctions.getConfigProperty(
|
const accountCodes = getConfigProperty('settings.dynamicsGP.accountCodes')
|
||||||
'settings.dynamicsGP.accountCodes'
|
|
||||||
)
|
|
||||||
|
|
||||||
if (accountCodes.length > 0) {
|
if (accountCodes.length > 0) {
|
||||||
for (const detail of cashReceipt.details) {
|
for (const detail of cashReceipt.details) {
|
||||||
|
|
@ -47,9 +43,7 @@ function filterCashReceipt(
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterInvoice(invoice: GPInvoice): GPInvoice | undefined {
|
function filterInvoice(invoice: GPInvoice): GPInvoice | undefined {
|
||||||
const itemNumbers = configFunctions.getConfigProperty(
|
const itemNumbers = getConfigProperty('settings.dynamicsGP.itemNumbers')
|
||||||
'settings.dynamicsGP.itemNumbers'
|
|
||||||
)
|
|
||||||
|
|
||||||
for (const itemNumber of itemNumbers) {
|
for (const itemNumber of itemNumbers) {
|
||||||
const found = invoice.lineItems.some((itemRecord) => {
|
const found = invoice.lineItems.some((itemRecord) => {
|
||||||
|
|
@ -71,7 +65,7 @@ function filterExtendedInvoice(
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const trialBalanceCodes = configFunctions.getConfigProperty(
|
const trialBalanceCodes = getConfigProperty(
|
||||||
'settings.dynamicsGP.trialBalanceCodes'
|
'settings.dynamicsGP.trialBalanceCodes'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -143,9 +137,8 @@ async function _getDynamicsGPDocument(
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'diamond/extendedInvoice': {
|
case 'diamond/extendedInvoice': {
|
||||||
let invoice = await gp.getDiamondExtendedInvoiceByInvoiceNumber(
|
let invoice =
|
||||||
documentNumber
|
await gp.getDiamondExtendedInvoiceByInvoiceNumber(documentNumber)
|
||||||
)
|
|
||||||
|
|
||||||
if (invoice !== undefined) {
|
if (invoice !== undefined) {
|
||||||
invoice = filterExtendedInvoice(invoice)
|
invoice = filterExtendedInvoice(invoice)
|
||||||
|
|
@ -176,15 +169,13 @@ async function _getDynamicsGPDocument(
|
||||||
export async function getDynamicsGPDocument(
|
export async function getDynamicsGPDocument(
|
||||||
documentNumber: string
|
documentNumber: string
|
||||||
): Promise<DynamicsGPDocument | undefined> {
|
): Promise<DynamicsGPDocument | undefined> {
|
||||||
if (
|
if (!getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
!configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')
|
|
||||||
) {
|
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
let document: DynamicsGPDocument | undefined
|
let document: DynamicsGPDocument | undefined
|
||||||
|
|
||||||
for (const lookupType of configFunctions.getConfigProperty(
|
for (const lookupType of getConfigProperty(
|
||||||
'settings.dynamicsGP.lookupOrder'
|
'settings.dynamicsGP.lookupOrder'
|
||||||
)) {
|
)) {
|
||||||
document = await _getDynamicsGPDocument(documentNumber, lookupType)
|
document = await _getDynamicsGPDocument(documentNumber, lookupType)
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@ import { Router } from 'express';
|
||||||
import { useTestDatabases } from '../data/databasePaths.js';
|
import { useTestDatabases } from '../data/databasePaths.js';
|
||||||
import { getApiKey } from '../helpers/functions.api.js';
|
import { getApiKey } from '../helpers/functions.api.js';
|
||||||
import * as authenticationFunctions from '../helpers/functions.authentication.js';
|
import * as authenticationFunctions from '../helpers/functions.authentication.js';
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
const debug = Debug('lot-occupancy-system:login');
|
const debug = Debug('lot-occupancy-system:login');
|
||||||
export const router = Router();
|
export const router = Router();
|
||||||
function getHandler(request, response) {
|
function getHandler(request, response) {
|
||||||
const sessionCookieName = configFunctions.getConfigProperty('session.cookieName');
|
const sessionCookieName = getConfigProperty('session.cookieName');
|
||||||
if (request.session.user !== undefined &&
|
if (request.session.user !== undefined &&
|
||||||
request.cookies[sessionCookieName] !== undefined) {
|
request.cookies[sessionCookieName] !== undefined) {
|
||||||
const redirectURL = authenticationFunctions.getSafeRedirectURL((request.query.redirect ?? ''));
|
const redirectURL = authenticationFunctions.getSafeRedirectURL((request.query.redirect ?? ''));
|
||||||
|
|
@ -30,9 +30,7 @@ async function postHandler(request, response) {
|
||||||
let isAuthenticated = false;
|
let isAuthenticated = false;
|
||||||
if (userName.startsWith('*')) {
|
if (userName.startsWith('*')) {
|
||||||
if (useTestDatabases && userName === passwordPlain) {
|
if (useTestDatabases && userName === passwordPlain) {
|
||||||
isAuthenticated = configFunctions
|
isAuthenticated = getConfigProperty('users.testing').includes(userName);
|
||||||
.getConfigProperty('users.testing')
|
|
||||||
.includes(userName);
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
debug('Authenticated testing user: ' + userName);
|
debug('Authenticated testing user: ' + userName);
|
||||||
}
|
}
|
||||||
|
|
@ -44,20 +42,14 @@ async function postHandler(request, response) {
|
||||||
let userObject;
|
let userObject;
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
const userNameLowerCase = userName.toLowerCase();
|
const userNameLowerCase = userName.toLowerCase();
|
||||||
const canLogin = configFunctions
|
const canLogin = getConfigProperty('users.canLogin').some((currentUserName) => {
|
||||||
.getConfigProperty('users.canLogin')
|
|
||||||
.some((currentUserName) => {
|
|
||||||
return userNameLowerCase === currentUserName.toLowerCase();
|
return userNameLowerCase === currentUserName.toLowerCase();
|
||||||
});
|
});
|
||||||
if (canLogin) {
|
if (canLogin) {
|
||||||
const canUpdate = configFunctions
|
const canUpdate = getConfigProperty('users.canUpdate').some((currentUserName) => {
|
||||||
.getConfigProperty('users.canUpdate')
|
|
||||||
.some((currentUserName) => {
|
|
||||||
return userNameLowerCase === currentUserName.toLowerCase();
|
return userNameLowerCase === currentUserName.toLowerCase();
|
||||||
});
|
});
|
||||||
const isAdmin = configFunctions
|
const isAdmin = getConfigProperty('users.isAdmin').some((currentUserName) => {
|
||||||
.getConfigProperty('users.isAdmin')
|
|
||||||
.some((currentUserName) => {
|
|
||||||
return userNameLowerCase === currentUserName.toLowerCase();
|
return userNameLowerCase === currentUserName.toLowerCase();
|
||||||
});
|
});
|
||||||
const apiKey = await getApiKey(userNameLowerCase);
|
const apiKey = await getApiKey(userNameLowerCase);
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
import Debug from 'debug'
|
import Debug from 'debug'
|
||||||
import {
|
import {
|
||||||
Router,
|
|
||||||
type RequestHandler,
|
|
||||||
type Request,
|
type Request,
|
||||||
type Response
|
type RequestHandler,
|
||||||
|
type Response,
|
||||||
|
Router
|
||||||
} from 'express'
|
} from 'express'
|
||||||
|
|
||||||
import { useTestDatabases } from '../data/databasePaths.js'
|
import { useTestDatabases } from '../data/databasePaths.js'
|
||||||
import { getApiKey } from '../helpers/functions.api.js'
|
import { getApiKey } from '../helpers/functions.api.js'
|
||||||
import * as authenticationFunctions from '../helpers/functions.authentication.js'
|
import * as authenticationFunctions from '../helpers/functions.authentication.js'
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
const debug = Debug('lot-occupancy-system:login')
|
const debug = Debug('lot-occupancy-system:login')
|
||||||
|
|
||||||
export const router = Router()
|
export const router = Router()
|
||||||
|
|
||||||
function getHandler(request: Request, response: Response): void {
|
function getHandler(request: Request, response: Response): void {
|
||||||
const sessionCookieName = configFunctions.getConfigProperty('session.cookieName')
|
const sessionCookieName = getConfigProperty('session.cookieName')
|
||||||
|
|
||||||
if (
|
if (
|
||||||
request.session.user !== undefined &&
|
request.session.user !== undefined &&
|
||||||
|
|
@ -59,9 +59,7 @@ async function postHandler(
|
||||||
|
|
||||||
if (userName.startsWith('*')) {
|
if (userName.startsWith('*')) {
|
||||||
if (useTestDatabases && userName === passwordPlain) {
|
if (useTestDatabases && userName === passwordPlain) {
|
||||||
isAuthenticated = configFunctions
|
isAuthenticated = getConfigProperty('users.testing').includes(userName)
|
||||||
.getConfigProperty('users.testing')
|
|
||||||
.includes(userName)
|
|
||||||
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
debug('Authenticated testing user: ' + userName)
|
debug('Authenticated testing user: ' + userName)
|
||||||
|
|
@ -79,24 +77,24 @@ async function postHandler(
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
const userNameLowerCase = userName.toLowerCase()
|
const userNameLowerCase = userName.toLowerCase()
|
||||||
|
|
||||||
const canLogin = configFunctions
|
const canLogin = getConfigProperty('users.canLogin').some(
|
||||||
.getConfigProperty('users.canLogin')
|
(currentUserName) => {
|
||||||
.some((currentUserName) => {
|
|
||||||
return userNameLowerCase === currentUserName.toLowerCase()
|
return userNameLowerCase === currentUserName.toLowerCase()
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if (canLogin) {
|
if (canLogin) {
|
||||||
const canUpdate = configFunctions
|
const canUpdate = getConfigProperty('users.canUpdate').some(
|
||||||
.getConfigProperty('users.canUpdate')
|
(currentUserName) => {
|
||||||
.some((currentUserName) => {
|
|
||||||
return userNameLowerCase === currentUserName.toLowerCase()
|
return userNameLowerCase === currentUserName.toLowerCase()
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const isAdmin = configFunctions
|
const isAdmin = getConfigProperty('users.isAdmin').some(
|
||||||
.getConfigProperty('users.isAdmin')
|
(currentUserName) => {
|
||||||
.some((currentUserName) => {
|
|
||||||
return userNameLowerCase === currentUserName.toLowerCase()
|
return userNameLowerCase === currentUserName.toLowerCase()
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const apiKey = await getApiKey(userNameLowerCase)
|
const apiKey = await getApiKey(userNameLowerCase)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import handler_doUpdateLotOccupancyFeeQuantity from '../handlers/lotOccupancies-
|
||||||
import handler_doUpdateLotOccupancyOccupant from '../handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js';
|
import handler_doUpdateLotOccupancyOccupant from '../handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js';
|
||||||
import handler_doUpdateLotOccupancyTransaction from '../handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js';
|
import handler_doUpdateLotOccupancyTransaction from '../handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js';
|
||||||
import * as permissionHandlers from '../handlers/permissions.js';
|
import * as permissionHandlers from '../handlers/permissions.js';
|
||||||
import * as configFunctions from '../helpers/functions.config.js';
|
import { getConfigProperty } from '../helpers/functions.config.js';
|
||||||
export const router = Router();
|
export const router = Router();
|
||||||
router.get('/', handler_search);
|
router.get('/', handler_search);
|
||||||
router.post('/doSearchLotOccupancies', handler_doSearchLotOccupancies);
|
router.post('/doSearchLotOccupancies', handler_doSearchLotOccupancies);
|
||||||
|
|
@ -48,7 +48,7 @@ router.post('/doGetFees', permissionHandlers.updatePostHandler, handler_doGetFee
|
||||||
router.post('/doAddLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyFee);
|
router.post('/doAddLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyFee);
|
||||||
router.post('/doUpdateLotOccupancyFeeQuantity', permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancyFeeQuantity);
|
router.post('/doUpdateLotOccupancyFeeQuantity', permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancyFeeQuantity);
|
||||||
router.post('/doDeleteLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancyFee);
|
router.post('/doDeleteLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancyFee);
|
||||||
if (configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
router.post('/doGetDynamicsGPDocument', permissionHandlers.updatePostHandler, handler_doGetDynamicsGPDocument);
|
router.post('/doGetDynamicsGPDocument', permissionHandlers.updatePostHandler, handler_doGetDynamicsGPDocument);
|
||||||
}
|
}
|
||||||
router.post('/doAddLotOccupancyTransaction', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyTransaction);
|
router.post('/doAddLotOccupancyTransaction', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyTransaction);
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import handler_doUpdateLotOccupancyFeeQuantity from '../handlers/lotOccupancies-
|
||||||
import handler_doUpdateLotOccupancyOccupant from '../handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js'
|
import handler_doUpdateLotOccupancyOccupant from '../handlers/lotOccupancies-post/doUpdateLotOccupancyOccupant.js'
|
||||||
import handler_doUpdateLotOccupancyTransaction from '../handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js'
|
import handler_doUpdateLotOccupancyTransaction from '../handlers/lotOccupancies-post/doUpdateLotOccupancyTransaction.js'
|
||||||
import * as permissionHandlers from '../handlers/permissions.js'
|
import * as permissionHandlers from '../handlers/permissions.js'
|
||||||
import * as configFunctions from '../helpers/functions.config.js'
|
import { getConfigProperty } from '../helpers/functions.config.js'
|
||||||
|
|
||||||
export const router = Router()
|
export const router = Router()
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ router.post(
|
||||||
|
|
||||||
// Transactions
|
// Transactions
|
||||||
|
|
||||||
if (configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
router.post(
|
router.post(
|
||||||
'/doGetDynamicsGPDocument',
|
'/doGetDynamicsGPDocument',
|
||||||
permissionHandlers.updatePostHandler,
|
permissionHandlers.updatePostHandler,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue