mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 19:49:37 +02:00
Preparation for custom sorting
This commit is contained in:
parent
ce173f2c42
commit
8974fb3b49
7 changed files with 42 additions and 7 deletions
|
@ -10,3 +10,20 @@
|
||||||
.TableAction:hover {
|
.TableAction:hover {
|
||||||
cursor: pointer;
|
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',
|
url: 'string',
|
||||||
icon: 'string',
|
icon: 'string',
|
||||||
isPinned: false,
|
isPinned: false,
|
||||||
|
orderId: 0,
|
||||||
id: 0,
|
id: 0,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date()
|
updatedAt: new Date()
|
||||||
|
|
|
@ -5,6 +5,7 @@ export interface App extends Model {
|
||||||
url: string;
|
url: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
isPinned: boolean;
|
isPinned: boolean;
|
||||||
|
orderId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NewApp {
|
export interface NewApp {
|
||||||
|
|
|
@ -10,4 +10,5 @@ export interface SettingsForm {
|
||||||
pinAppsByDefault: number;
|
pinAppsByDefault: number;
|
||||||
pinCategoriesByDefault: number;
|
pinCategoriesByDefault: number;
|
||||||
hideHeader: number;
|
hideHeader: number;
|
||||||
|
useOrdering: string;
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ export const searchConfig = (key: string, _default: any) => {
|
||||||
} else {
|
} else {
|
||||||
return pair.value;
|
return pair.value;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return _default;
|
return _default;
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -36,13 +36,24 @@ exports.createApp = asyncWrapper(async (req, res, next) => {
|
||||||
// @route GET /api/apps
|
// @route GET /api/apps
|
||||||
// @access Public
|
// @access Public
|
||||||
exports.getApps = asyncWrapper(async (req, res, next) => {
|
exports.getApps = asyncWrapper(async (req, res, next) => {
|
||||||
// const apps = await App.findAll({
|
// Get config from database
|
||||||
// order: [[ Sequelize.fn('lower', Sequelize.col('name')), 'ASC' ]]
|
const useOrdering = await Config.findOne({
|
||||||
// });
|
where: { key: 'useOrdering' }
|
||||||
const apps = await App.findAll({
|
|
||||||
order: [[ 'orderId', 'ASC' ]]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
data: apps
|
data: apps
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
{
|
{
|
||||||
"key": "hideHeader",
|
"key": "hideHeader",
|
||||||
"value": false
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "useOrdering",
|
||||||
|
"value": "createdAt"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue