diff --git a/backend/controllers/shared/pageSettings.js b/backend/controllers/shared/pageSettings.js
index abfc2ef2..09ccd913 100644
--- a/backend/controllers/shared/pageSettings.js
+++ b/backend/controllers/shared/pageSettings.js
@@ -17,51 +17,6 @@ export const getPageSettings = (req, res, next) => {
};
export const savePageSettings = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Saving Page Settings..' });
- req.body = [
- {
- tables: [
- {
- tableId: "payments",
- recordsPerPage: 25,
- sortBy: "created_at",
- sortOrder: "Ascending",
- showColumns: [
- "msatoshi",
- ],
- },
- {
- tableId: "payments2",
- sortBy: "created_at",
- sortOrder: "Ascending",
- showColumns: [
- "created_at",
- "type",
- "payment_hash",
- "msatoshi_sent",
- "msatoshi",
- ],
- },
- ],
- },
- {
- pageId: "invoices",
- tables: [
- {
- tableId: "invoices3",
- sortBy: "expires_at",
- sortOrder: "Descending",
- showColumns: [
- "expires_at",
- "paid_at",
- "type",
- "description",
- "msatoshi",
- "msatoshi_received",
- ],
- },
- ],
- }
- ];
return Promise.all(req.body.map((page) => databaseService.update(req.session.selectedNode, CollectionsEnum.PAGE_SETTINGS, page, CollectionFieldsEnum.PAGE_ID, page.pageId))).
then((values) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'PayRequest', msg: 'Payment List Decoded', data: values });
diff --git a/backend/models/database.model.js b/backend/models/database.model.js
index 1d3da57c..4881c507 100644
--- a/backend/models/database.model.js
+++ b/backend/models/database.model.js
@@ -28,16 +28,16 @@ export const validateDocument = (collectionName, documentToValidate) => {
};
export const validateOffer = (documentToValidate) => {
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.BOLT12)) {
- return ({ isValid: false, error: CollectionFieldsEnum.BOLT12 + ' is mandatory.' });
+ return ({ isValid: false, error: 'Bolt12 is mandatory.' });
}
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.AMOUNTMSAT)) {
- return ({ isValid: false, error: CollectionFieldsEnum.AMOUNTMSAT + ' is mandatory.' });
+ return ({ isValid: false, error: 'Amount mSat is mandatory.' });
}
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.TITLE)) {
- return ({ isValid: false, error: CollectionFieldsEnum.TITLE + ' is mandatory.' });
+ return ({ isValid: false, error: 'Title is mandatory.' });
}
if ((typeof documentToValidate[CollectionFieldsEnum.AMOUNTMSAT] !== 'number')) {
- return ({ isValid: false, error: CollectionFieldsEnum.AMOUNTMSAT + ' should be a number.' });
+ return ({ isValid: false, error: 'Amount mSat should be a number.' });
}
return ({ isValid: true });
};
@@ -77,37 +77,37 @@ export class PageSettings {
export const validatePageSettings = (documentToValidate) => {
let errorMessages = '';
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.PAGE_ID)) {
- errorMessages = errorMessages + CollectionFieldsEnum.PAGE_ID + ' is mandatory.';
+ errorMessages = errorMessages + 'Page ID is mandatory.';
}
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.TABLES)) {
- errorMessages = errorMessages + CollectionFieldsEnum.TABLES + ' is mandatory.';
+ errorMessages = errorMessages + 'Tables is mandatory.';
}
const tablesMessages = documentToValidate.tables.reduce((tableAcc, table, tableIdx) => {
let errMsg = '';
if (!table.hasOwnProperty(CollectionFieldsEnum.TABLE_ID)) {
- errMsg = errMsg + CollectionFieldsEnum.TABLE_ID + ' is mandatory.';
+ errMsg = errMsg + 'Table ID is mandatory.';
}
if (!table.hasOwnProperty(CollectionFieldsEnum.SORT_BY)) {
- errMsg = errMsg + CollectionFieldsEnum.SORT_BY + ' is mandatory.';
+ errMsg = errMsg + 'Sort By is mandatory.';
}
if (!table.hasOwnProperty(CollectionFieldsEnum.SORT_ORDER)) {
- errMsg = errMsg + CollectionFieldsEnum.SORT_ORDER + ' is mandatory.';
+ errMsg = errMsg + 'Sort Order is mandatory.';
}
if (!table.hasOwnProperty(CollectionFieldsEnum.RECORDS_PER_PAGE)) {
- errMsg = errMsg + CollectionFieldsEnum.RECORDS_PER_PAGE + ' is mandatory.';
+ errMsg = errMsg + 'Records/Page is mandatory.';
}
if (!table.hasOwnProperty(CollectionFieldsEnum.SHOW_COLUMNS)) {
- errMsg = errMsg + CollectionFieldsEnum.SHOW_COLUMNS + ' is mandatory.';
+ errMsg = errMsg + 'Show Columns is mandatory.';
}
if (table[CollectionFieldsEnum.SHOW_COLUMNS].length < 2) {
- errMsg = errMsg + CollectionFieldsEnum.SHOW_COLUMNS + ' should have at least 2 fields.';
+ errMsg = errMsg + 'Show Columns should have at least 2 fields.';
}
if (errMsg.trim() !== '') {
tableAcc.push({ table: (table.hasOwnProperty(CollectionFieldsEnum.TABLE_ID) ? table[CollectionFieldsEnum.TABLE_ID] : (tableIdx + 1)), message: errMsg });
}
return tableAcc;
}, []);
- if (errorMessages.trim() === '' && tablesMessages.length && tablesMessages.length === 0) {
+ if (errorMessages.trim() === '' && tablesMessages.length === 0) {
return ({ isValid: true });
}
else {
diff --git a/backend/utils/database.js b/backend/utils/database.js
index 71c5ae40..d7fcc57d 100644
--- a/backend/utils/database.js
+++ b/backend/utils/database.js
@@ -214,7 +214,9 @@ export class DatabaseAdapter {
}
}
insertSession(id = '') {
- this.userSessions.push(id);
+ if (!this.userSessions.includes(id)) {
+ this.userSessions.push(id);
+ }
}
removeSession(sessionID = '') {
this.userSessions.splice(this.userSessions.findIndex((sId) => sId === sessionID), 1);
diff --git a/server/controllers/shared/pageSettings.ts b/server/controllers/shared/pageSettings.ts
index 1b7dfbcc..97c8f613 100644
--- a/server/controllers/shared/pageSettings.ts
+++ b/server/controllers/shared/pageSettings.ts
@@ -20,51 +20,6 @@ export const getPageSettings = (req, res, next) => {
export const savePageSettings = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Saving Page Settings..' });
- req.body = [
- {
- tables: [
- {
- tableId: "payments",
- recordsPerPage: 25,
- sortBy: "created_at",
- sortOrder: "Ascending",
- showColumns: [
- "msatoshi",
- ],
- },
- {
- tableId: "payments2",
- sortBy: "created_at",
- sortOrder: "Ascending",
- showColumns: [
- "created_at",
- "type",
- "payment_hash",
- "msatoshi_sent",
- "msatoshi",
- ],
- },
- ],
- },
- {
- pageId: "invoices",
- tables: [
- {
- tableId: "invoices3",
- sortBy: "expires_at",
- sortOrder: "Descending",
- showColumns: [
- "expires_at",
- "paid_at",
- "type",
- "description",
- "msatoshi",
- "msatoshi_received",
- ],
- },
- ],
- }
- ];
return Promise.all(req.body.map((page) => databaseService.update(req.session.selectedNode, CollectionsEnum.PAGE_SETTINGS, page, CollectionFieldsEnum.PAGE_ID, page.pageId))).
then((values) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'PayRequest', msg: 'Payment List Decoded', data: values });
diff --git a/server/models/database.model.ts b/server/models/database.model.ts
index e868696d..6b98dccd 100644
--- a/server/models/database.model.ts
+++ b/server/models/database.model.ts
@@ -32,16 +32,16 @@ export const validateDocument = (collectionName: CollectionsEnum, documentToVali
export const validateOffer = (documentToValidate): any => {
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.BOLT12)) {
- return ({ isValid: false, error: CollectionFieldsEnum.BOLT12 + ' is mandatory.' });
+ return ({ isValid: false, error: 'Bolt12 is mandatory.' });
}
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.AMOUNTMSAT)) {
- return ({ isValid: false, error: CollectionFieldsEnum.AMOUNTMSAT + ' is mandatory.' });
+ return ({ isValid: false, error: 'Amount mSat is mandatory.' });
}
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.TITLE)) {
- return ({ isValid: false, error: CollectionFieldsEnum.TITLE + ' is mandatory.' });
+ return ({ isValid: false, error: 'Title is mandatory.' });
}
if ((typeof documentToValidate[CollectionFieldsEnum.AMOUNTMSAT] !== 'number')) {
- return ({ isValid: false, error: CollectionFieldsEnum.AMOUNTMSAT + ' should be a number.' });
+ return ({ isValid: false, error: 'Amount mSat should be a number.' });
}
return ({ isValid: true });
};
@@ -88,37 +88,37 @@ export class PageSettings {
export const validatePageSettings = (documentToValidate): any => {
let errorMessages = '';
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.PAGE_ID)) {
- errorMessages = errorMessages + CollectionFieldsEnum.PAGE_ID + ' is mandatory.';
+ errorMessages = errorMessages + 'Page ID is mandatory.';
}
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.TABLES)) {
- errorMessages = errorMessages + CollectionFieldsEnum.TABLES + ' is mandatory.';
+ errorMessages = errorMessages + 'Tables is mandatory.';
}
const tablesMessages = documentToValidate.tables.reduce((tableAcc, table: TableSetting, tableIdx) => {
let errMsg = '';
if (!table.hasOwnProperty(CollectionFieldsEnum.TABLE_ID)) {
- errMsg = errMsg + CollectionFieldsEnum.TABLE_ID + ' is mandatory.';
+ errMsg = errMsg + 'Table ID is mandatory.';
}
if (!table.hasOwnProperty(CollectionFieldsEnum.SORT_BY)) {
- errMsg = errMsg + CollectionFieldsEnum.SORT_BY + ' is mandatory.';
+ errMsg = errMsg + 'Sort By is mandatory.';
}
if (!table.hasOwnProperty(CollectionFieldsEnum.SORT_ORDER)) {
- errMsg = errMsg + CollectionFieldsEnum.SORT_ORDER + ' is mandatory.';
+ errMsg = errMsg + 'Sort Order is mandatory.';
}
if (!table.hasOwnProperty(CollectionFieldsEnum.RECORDS_PER_PAGE)) {
- errMsg = errMsg + CollectionFieldsEnum.RECORDS_PER_PAGE + ' is mandatory.';
+ errMsg = errMsg + 'Records/Page is mandatory.';
}
if (!table.hasOwnProperty(CollectionFieldsEnum.SHOW_COLUMNS)) {
- errMsg = errMsg + CollectionFieldsEnum.SHOW_COLUMNS + ' is mandatory.';
+ errMsg = errMsg + 'Show Columns is mandatory.';
}
if (table[CollectionFieldsEnum.SHOW_COLUMNS].length < 2) {
- errMsg = errMsg + CollectionFieldsEnum.SHOW_COLUMNS + ' should have at least 2 fields.';
+ errMsg = errMsg + 'Show Columns should have at least 2 fields.';
}
if (errMsg.trim() !== '') {
tableAcc.push({ table: (table.hasOwnProperty(CollectionFieldsEnum.TABLE_ID) ? table[CollectionFieldsEnum.TABLE_ID] : (tableIdx + 1)), message: errMsg });
}
return tableAcc;
}, []);
- if (errorMessages.trim() === '' && tablesMessages.length && tablesMessages.length === 0) {
+ if (errorMessages.trim() === '' && tablesMessages.length === 0) {
return ({ isValid: true });
} else {
const errObj = { page: (documentToValidate.hasOwnProperty(CollectionFieldsEnum.PAGE_ID) ? documentToValidate[CollectionFieldsEnum.PAGE_ID] : 'Unknown') };
diff --git a/server/utils/database.ts b/server/utils/database.ts
index f5af9d15..2c1293d1 100644
--- a/server/utils/database.ts
+++ b/server/utils/database.ts
@@ -212,7 +212,9 @@ export class DatabaseAdapter {
}
insertSession(id: string = '') {
- this.userSessions.push(id);
+ if (!this.userSessions.includes(id)) {
+ this.userSessions.push(id);
+ }
}
removeSession(sessionID: string = '') {
diff --git a/src/app/cln/store/cln.effects.ts b/src/app/cln/store/cln.effects.ts
index 67e9257b..d7c9a0fc 100644
--- a/src/app/cln/store/cln.effects.ts
+++ b/src/app/cln/store/cln.effects.ts
@@ -944,7 +944,7 @@ export class CLNEffects implements OnDestroy {
this.store.dispatch(updateCLAPICallStatus({ payload: { action: 'FetchPageSettings', status: APICallStatusEnum.COMPLETED } }));
return {
type: CLNActions.SET_PAGE_SETTINGS_CLN,
- payload: pageSettings
+ payload: pageSettings || []
};
}),
catchError((err: any) => {
@@ -966,9 +966,10 @@ export class CLNEffects implements OnDestroy {
this.logger.info(postRes);
this.store.dispatch(updateCLAPICallStatus({ payload: { action: 'SavePageSettings', status: APICallStatusEnum.COMPLETED } }));
this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.UPDATE_PAGE_SETTINGS }));
+ this.store.dispatch(openSnackBar({ payload: 'Page Layout Updated Successfully!' }));
return {
type: CLNActions.SET_PAGE_SETTINGS_CLN,
- payload: postRes
+ payload: postRes || []
};
}),
catchError((err: any) => {
diff --git a/src/app/shared/components/node-config/page-settings/page-settings.component.html b/src/app/shared/components/node-config/page-settings/page-settings.component.html
index f49f39fc..5e8cdf36 100644
--- a/src/app/shared/components/node-config/page-settings/page-settings.component.html
+++ b/src/app/shared/components/node-config/page-settings/page-settings.component.html
@@ -4,57 +4,63 @@