Refactor LockManager to standardize lock key format and enhance logging; add debug statement in TemplateManager for template rendering

This commit is contained in:
Tom Butcher 2025-11-16 17:11:15 +00:00
parent e1ba1f7871
commit 6be53349b5
7 changed files with 20 additions and 9 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
src/.DS_Store vendored

Binary file not shown.

0
src/auth/otpcomponent.js Normal file
View File

View File

@ -20,7 +20,7 @@ export class LockManager {
// Add a 'lock' event to the 'locks' stream
logger.debug('Locking object:', object._id);
try {
await etcdServer.setKey(`/${object.type}s/${object._id}/lock`, {
await etcdServer.setKey(`/locks/${object.type}s/${object._id}`, {
...object,
locked: true
});
@ -34,7 +34,7 @@ export class LockManager {
async unlockObject(object) {
// Add an 'unlock' event to the 'locks' stream
const key = `/${object.type}s/${object._id}/lock`;
const key = `/locks/${object.type}s/${object._id}`;
try {
logger.debug('Checking user can unlock:', object._id);
@ -56,7 +56,7 @@ export class LockManager {
// Get the current lock status of an object and broadcast it
logger.info('Getting lock status for object:', object._id);
try {
const lockKey = `/${object.type}s/${object._id}/lock`;
const lockKey = `/locks/${object.type}s/${object._id}`;
const lockValue = await etcdServer.getKey(lockKey);
if (lockValue) {
@ -87,7 +87,7 @@ export class LockManager {
(key, value) => {
const id = key.split('/').pop();
logger.debug('Lock object event:', id);
this.socketManager.broadcast('notify_lock_update', {
this.socketClient.socket.emit('lockUpdate', {
...value,
locked: true
});
@ -96,7 +96,7 @@ export class LockManager {
etcdServer.onPrefixDeleteEvent('/locks', this.socketClient.id, key => {
const id = key.split('/').pop();
logger.debug('Unlock object event:', id);
this.socketManager.broadcast('notify_lock_update', {
this.socketClient.socket.emit('lockUpdate', {
_id: id,
locked: false
});

View File

@ -15,14 +15,18 @@
</style>
<style>
body {
min-width: calc(<%= width || '50mm' %> + 100px);
min-height: calc(<%= height || '50mm' %> + 100px);
min-width: calc((<%= width || '50mm' %> * <%= scale || '1' %>) + 100px);
min-height: calc(
(<%= height || '50mm' %> * <%= scale || '1' %>) + 100px
);
}
.previewContainer {
transform: scale(<%= scale || '1' %>);
min-width: calc(<%= width || '50mm' %> + 100px);
min-height: calc(<%= height || '50mm' %> + 100px);
min-width: calc((<%= width || '50mm' %> + 100px) * <%= scale || '1' %>);
min-height: calc(
(<%= height || '50mm' %> + 100px) * <%= scale || '1' %>
);
}
.previewDocument {
width: <%= width || '50mm' %>;

View File

@ -11,6 +11,7 @@ body {
display: flex;
justify-content: center; /* Horizontal center */
align-items: center; /* Vertical center */
transform-origin: center center;
}
.previewDocument {
background: #ffffff;
@ -71,3 +72,8 @@ h4.documentTitle {
text-transform: uppercase;
font-weight: 700;
}
.documentBarcode {
width: 100% !important;
height: 100% !important;
}

View File

@ -225,6 +225,7 @@ export class TemplateManager {
async: true,
...options
};
logger.debug('Rendering template:', id);
const documentTemplate = await getObject({
model: documentTemplateModel,