Preparation for custom sorting
This commit is contained in:
parent
ce173f2c42
commit
8974fb3b49
7 changed files with 42 additions and 7 deletions
|
@ -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;
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -5,6 +5,7 @@ export interface App extends Model {
|
|||
url: string;
|
||||
icon: string;
|
||||
isPinned: boolean;
|
||||
orderId: number;
|
||||
}
|
||||
|
||||
export interface NewApp {
|
||||
|
|
|
@ -10,4 +10,5 @@ export interface SettingsForm {
|
|||
pinAppsByDefault: number;
|
||||
pinCategoriesByDefault: number;
|
||||
hideHeader: number;
|
||||
useOrdering: string;
|
||||
}
|
|
@ -18,7 +18,7 @@ export const searchConfig = (key: string, _default: any) => {
|
|||
} else {
|
||||
return pair.value;
|
||||
}
|
||||
} else {
|
||||
return _default;
|
||||
}
|
||||
|
||||
return _default;
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
{
|
||||
"key": "hideHeader",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "useOrdering",
|
||||
"value": "createdAt"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue