Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter notification list by severity #3036

Closed
mueller-ma opened this issue Sep 17, 2022 · 5 comments
Closed

Filter notification list by severity #3036

mueller-ma opened this issue Sep 17, 2022 · 5 comments
Labels
enhancement Indicates new feature requests

Comments

@mueller-ma
Copy link
Member

Is your feature request related to a problem? Please describe.

I'd like to have an overview of all notifications with a specific severity.

Describe the solution you'd like

Add an action bar item to filter notification list by severity. It should default to "all notifications".

@mueller-ma mueller-ma added the enhancement Indicates new feature requests label Sep 17, 2022
@maniac103
Copy link
Contributor

Does openhab-cloud allow for that? The notifications are fetched in pages, which means the backend needs to do that filtering.

@mueller-ma
Copy link
Member Author

I first thought about doing the filtering on the client, but it makes indeed more sense on the server: openhab/openhab-cloud#383

@iPavel89-work
Copy link

file routes/api.js

exports.notificationsget = function (req, res) {
    var limit = req.query.limit > 0 ? parseInt(req.query.limit) : 10,
        skip = req.query.skip > 0 ? parseInt(req.query.skip) : 0;
    var filter = { user: req.user.id };

    // Добавляем фильтр по параметру severity, если он указан в запросе
    if (req.query.severity) {
        filter.severity = req.query.severity;
    }
    
    Notification.find(filter, '-user')
        .limit(limit)
        .skip(skip)
        .sort({ created: 'desc' })
        .exec(function (error, notifications) {
            if (!error) {
                res.status(200).json(notifications);
            } else {
                return res.status(500).json({
                    errors: [{
                        message: "Error getting notifications"
                    }]
                });
            }
        });
};

@mueller-ma
Copy link
Member Author

What do you want to say with that?

@iPavel89-work
Copy link

What do you want to say with that?

solution for filtering notifications by severity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

3 participants