discourse/app/assets/javascripts/admin/templates
Tarek Khalil f8480ed911
FEATURE: Exposing a way to add a generic report filter (#6816)
* FEATURE: Exposing a way to add a generic report filter

## Why do we need this change?

Part of the work discussed [here](https://meta.discourse.org/t/gain-understanding-of-file-uploads-usage/104994), and implemented a first spike [here](https://github.com/discourse/discourse/pull/6809), I am trying to expose a single generic filter selector per report.

## How does this work?

We basically expose a simple, single generic filter that is computed and displayed based on backend values passed into the report.

This would be a simple contract between the frontend and the backend.

**Backend changes:** we simply need to return a list of dropdown / select options, and enable the report's newly introduced `custom_filtering` property.

For example, for our [Top Uploads](https://github.com/discourse/discourse/pull/6809/files#diff-3f97cbb8726f3310e0b0c386dbe89e22R1423) report, it can look like this on the backend:

```ruby
report.custom_filtering = true
report.custom_filter_options = [{ id: "any", name: "Any" }, { id: "jpg", name: "JPEG" } ]
```

In our javascript report HTTP call, it will look like:

```js
{
  "custom_filtering": true,
  "custom_filter_options": [
    {
      "id": "any",
      "name": "Any"
    },
    {
      "id": "jpg",
      "name": "JPG"
    }
  ]
}
```

**Frontend changes:** We introduced a generic `filter` param and a `combo-box` which hooks up into the existing framework for fetching a report.

This works alright, with the limitation of being a single custom filter per report. If we wanted to add, for an instance a `filesize filter`, this will not work for us. _I went through with this approach because it is hard to predict and build abstractions for requirements or problems we don't have yet, or might not have._

## How does it look like?

![a1ktg1odde](https://user-images.githubusercontent.com/45508821/50485875-f17edb80-09ee-11e9-92dd-1454ab041fbb.gif)

## More on the bigger picture

The major concern here I have is the solution I introduced might serve the `think small` version of the reporting work, but I don't think it serves the `think big`, I will try to shed some light into why.

Within the current design, It is hard to maintain QueryParams for dynamically generated params (based on the idea of introducing more than one custom filter per report).

To allow ourselves to have more than one generic filter, we will need to:

a. Use the Route's model to retrieve the report's payload (we are now dependent on changes of the QueryParams via computed properties)
b. After retrieving the payload, we can use the `setupController` to define our dynamic QueryParams based on the custom filters definitions we received from the backend
c. Load a custom filter specific Ember component based on the definitions we received from the backend
2019-03-15 12:15:38 +00:00
..
components FEATURE: Exposing a way to add a generic report filter (#6816) 2019-03-15 12:15:38 +00:00
logs UX: Make button icons use lighter color instead of opacity 2019-01-31 13:59:49 -05:00
modal DEV: Rename some icons with deprecated names 2019-02-28 13:03:14 -05:00
admin.hbs UX: Add link to Groups in admin dashboard. (#6480) 2018-10-12 10:34:47 +11:00
api-keys.hbs DEV: refactoring api-keys (#6931) 2019-01-23 17:40:05 +01:00
api.hbs UX: Various admin class and structure improvements for styling 2017-10-30 14:50:43 -04:00
backups-index.hbs DEV: refactoring admin-backups-index (#6933) 2019-01-23 17:40:24 +01:00
backups-logs.hbs Fixes some Ember Deprecations for 1.13: 2016-10-21 11:06:07 -04:00
backups.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
badges-index.hbs UX: admin badge page improvements 2019-01-23 11:29:51 +01:00
badges-show.hbs icons deprecations fixes (#6920) 2019-01-22 12:02:02 +01:00
badges.hbs UX: admin badge page improvements 2019-01-23 11:29:51 +01:00
customize-colors-index.hbs FEATURE: Native theme support 2017-04-12 10:53:49 -04:00
customize-colors-show.hbs icons deprecations fixes (#6920) 2019-01-22 12:02:02 +01:00
customize-colors.hbs REFACTOR: admin-customize-color (#7018) 2019-02-19 09:31:11 +01:00
customize-email-templates-edit.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
customize-email-templates-index.hbs FEATURE: Admin interface for editing email templates 2015-11-19 16:39:34 -05:00
customize-email-templates.hbs Removing old bootstrap columns 2018-02-14 12:27:34 -05:00
customize-themes-edit.hbs FEATURE: Added settings/translations support to theme editor UI (#7026) 2019-02-19 12:56:01 +00:00
customize-themes-index.hbs UX: List popular themes and components in admin panel (#6997) 2019-02-20 14:58:31 -05:00
customize-themes-show.hbs DEV: Rename some icons with deprecated names 2019-02-28 13:03:14 -05:00
customize-themes.hbs UX: List popular themes and components in admin panel (#6997) 2019-02-20 14:58:31 -05:00
customize.hbs UX: Various admin class and structure improvements for styling 2017-10-30 14:50:43 -04:00
dashboard-problems.hbs DEV: Rename some icons with deprecated names 2019-02-28 13:03:14 -05:00
dashboard.hbs fixes few icons deprecations warnings (#6915) 2019-01-21 16:56:05 +01:00
dashboard_next.hbs UX: Adding reports dashboard tab, new layout, report descriptions (#6790) 2018-12-19 14:44:43 +01:00
dashboard_next_general.hbs FEATURE: adds a new chart report to track pageviews (#6913) 2019-01-21 15:17:04 +01:00
dashboard_next_moderation.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
dashboard_next_reports.hbs UX: Adding reports dashboard tab, new layout, report descriptions (#6790) 2018-12-19 14:44:43 +01:00
dashboard_next_security.hbs FEATURE: adds security tab to dashboard (#6768) 2018-12-14 13:47:59 +01:00
email-advanced-test.hbs UX: Wrap pre element. 2018-12-05 21:56:18 +01:00
email-bounced.hbs FIX: prevents double network calls and other quirks on admin emails (#7074) 2019-02-26 17:53:52 +01:00
email-index.hbs UX: Improve email testing admin tool. (#6308) 2018-08-29 23:14:16 +02:00
email-preview-digest.hbs Add btn-default class to all default buttons (#6521) 2018-10-24 16:09:36 -04:00
email-received.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
email-rejected.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
email-sent.hbs FIX: prevents double network calls and other quirks on admin emails (#7074) 2019-02-26 17:53:52 +01:00
email-skipped.hbs FIX: prevents double network calls and other quirks on admin emails (#7074) 2019-02-26 17:53:52 +01:00
email.hbs FEATURE: Add 'Advanced Test' for admin panel. 2018-12-05 21:56:18 +01:00
embedding.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
emojis.hbs icons deprecations fixes (#6920) 2019-01-22 12:02:02 +01:00
flags-posts-active.hbs REFACTOR: Convert admin flagged posts to a component 2017-09-25 12:25:14 -04:00
flags-posts-old.hbs REFACTOR: Convert admin flagged posts to a component 2017-09-25 12:25:14 -04:00
flags-topics-index.hbs FIX: Add topic status to flagged topics list 2019-01-09 10:59:35 -05:00
flags-topics-show.hbs Add front end service for staff controls 2017-09-25 12:25:14 -04:00
flags.hbs FEATURE: Site Setting to determine whether flags defaults to topics 2017-10-20 12:37:20 -04:00
logs.hbs FEATURE: search log term details page (#5445) 2017-12-20 13:41:31 +11:00
permalinks.hbs icons deprecations fixes (#6920) 2019-01-22 12:02:02 +01:00
plugins-index.hbs icons deprecations fixes (#6920) 2019-01-22 12:02:02 +01:00
plugins.hbs icons deprecations fixes (#6920) 2019-01-22 12:02:02 +01:00
reports-show.hbs FIX: improves report-show mobile UI (#6229) 2018-08-01 19:54:27 -04:00
search-logs-index.hbs REFACTOR: Calculate CTR in SearchLog model and hide unique column (#6791) 2018-12-18 19:13:46 +05:30
search-logs-term.hbs FEATURE: show header search results on search log term details page 2018-01-17 12:47:16 +05:30
site-settings-category.hbs UX: show a message when more than 30 site settings matches the current filter 2018-05-16 15:37:40 +02:00
site-settings.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
site-text-edit.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
site-text-index.hbs FIX: Text content search warning if more than 50 results 2019-03-11 12:56:15 -04:00
site-text.hbs FEATURE: Can override any translation via an admin interface 2015-11-27 11:35:19 -05:00
user-badges.hbs SECURITY: fix possible XSS with badges (#6912) 2019-01-21 13:08:26 +01:00
user-fields.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
user-index.hbs FIX: removes legacy browsers-refresh button (#7028) 2019-02-19 16:38:21 +01:00
user-tl3-requirements.hbs FIX: Don't allow a user to become TL3 if they've ever been penalized 2018-04-24 15:15:32 -04:00
user.hbs Remove the `ScrollTop` Mixin 2016-11-10 15:25:04 -05:00
users-list-show.hbs DEV: fix some deprecated SVG icon refs 2019-01-22 14:42:00 -05:00
users-list.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
version-checks.hbs DEV: fix some deprecated SVG icon refs 2019-01-22 14:42:00 -05:00
watched-words-action.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
watched-words.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
web-hooks-show-events.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
web-hooks-show.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
web-hooks.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00