diff --git a/client/src/components/Apps/AppTable/AppTable.module.css b/client/src/components/Apps/AppTable/AppTable.module.css index fc79b68..ee9c9a8 100644 --- a/client/src/components/Apps/AppTable/AppTable.module.css +++ b/client/src/components/Apps/AppTable/AppTable.module.css @@ -9,4 +9,21 @@ .TableAction:hover { cursor: pointer; +} + +.Message { + width: 100%; + display: flex; + justify-content: center; + align-items: baseline; + color: var(--color-primary); + margin-bottom: 20px; +} + +.Message span { + color: var(--color-accent); +} + +.Message span:hover { + cursor: pointer; } \ No newline at end of file diff --git a/client/src/components/Apps/Apps.tsx b/client/src/components/Apps/Apps.tsx index 9f3adff..88c3fff 100644 --- a/client/src/components/Apps/Apps.tsx +++ b/client/src/components/Apps/Apps.tsx @@ -44,6 +44,7 @@ const Apps = (props: ComponentProps): JSX.Element => { url: 'string', icon: 'string', isPinned: false, + orderId: 0, id: 0, createdAt: new Date(), updatedAt: new Date() diff --git a/client/src/interfaces/App.ts b/client/src/interfaces/App.ts index ed8842a..e4314a5 100644 --- a/client/src/interfaces/App.ts +++ b/client/src/interfaces/App.ts @@ -5,6 +5,7 @@ export interface App extends Model { url: string; icon: string; isPinned: boolean; + orderId: number; } export interface NewApp { diff --git a/client/src/interfaces/Forms.ts b/client/src/interfaces/Forms.ts index 52f62c8..360dae1 100644 --- a/client/src/interfaces/Forms.ts +++ b/client/src/interfaces/Forms.ts @@ -10,4 +10,5 @@ export interface SettingsForm { pinAppsByDefault: number; pinCategoriesByDefault: number; hideHeader: number; + useOrdering: string; } \ No newline at end of file diff --git a/client/src/utility/searchConfig.ts b/client/src/utility/searchConfig.ts index fe4db57..4e46091 100644 --- a/client/src/utility/searchConfig.ts +++ b/client/src/utility/searchConfig.ts @@ -18,7 +18,7 @@ export const searchConfig = (key: string, _default: any) => { } else { return pair.value; } - } else { - return _default; } + + return _default; } \ No newline at end of file diff --git a/controllers/apps.js b/controllers/apps.js index 95c7fdd..4f50f96 100644 --- a/controllers/apps.js +++ b/controllers/apps.js @@ -36,13 +36,24 @@ exports.createApp = asyncWrapper(async (req, res, next) => { // @route GET /api/apps // @access Public exports.getApps = asyncWrapper(async (req, res, next) => { - // const apps = await App.findAll({ - // order: [[ Sequelize.fn('lower', Sequelize.col('name')), 'ASC' ]] - // }); - const apps = await App.findAll({ - order: [[ 'orderId', 'ASC' ]] + // Get config from database + const useOrdering = await Config.findOne({ + where: { key: 'useOrdering' } }); + const orderType = useOrdering ? useOrdering.value : 'createdAt'; + let apps; + + if (orderType == 'name') { + apps = await App.findAll({ + order: [[ Sequelize.fn('lower', Sequelize.col('name')), 'ASC' ]] + }); + } else { + apps = await App.findAll({ + order: [[ orderType, 'ASC' ]] + }); + } + res.status(200).json({ success: true, data: apps diff --git a/utils/initialConfig.json b/utils/initialConfig.json index eface5d..09bf4b8 100644 --- a/utils/initialConfig.json +++ b/utils/initialConfig.json @@ -31,6 +31,10 @@ { "key": "hideHeader", "value": false + }, + { + "key": "useOrdering", + "value": "createdAt" } ] } \ No newline at end of file