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