discourse/app/assets/javascripts/admin/templates/components
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
..
site-settings DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
ace-editor.hbs FIX: ace editor was buggy in the latest Ember release 2016-11-28 11:29:56 -05:00
admin-editable-field.hbs icons deprecations fixes (#6920) 2019-01-22 12:02:02 +01:00
admin-form-row.hbs FEATURE: New "Dropdown" user field type 2015-07-28 12:30:21 -04:00
admin-nav.hbs Removing old bootstrap columns 2018-02-14 12:27:34 -05:00
admin-report-chart.hbs FEATURE: part 2 of dashboard improvements 2018-07-19 14:33:11 -04:00
admin-report-counters.hbs FIX: better handling of no prev30Days (#6301) 2018-08-22 18:00:11 +02:00
admin-report-counts.hbs FIX: makes format number round the value before using parseInt 2018-06-07 10:44:21 +02:00
admin-report-inline-table.hbs FEATURE: part 2 of dashboard improvements 2018-07-19 14:33:11 -04:00
admin-report-per-day-counts.hbs FIX: Broken link on admin dashboard 2015-05-19 13:13:31 -04:00
admin-report-stacked-chart.hbs FIX: better handling of resizing in stacked charts (#6921) 2019-01-22 11:20:50 +01:00
admin-report-storage-stats.hbs FEATURE: Improve backup stats on admin dashboard 2018-12-17 11:35:11 +01:00
admin-report-table-cell.hbs FIX: improves number/percent support in reports 2018-08-01 18:40:59 -04:00
admin-report-table-header.hbs FIX: quality/bugfix dashboard/reports pass (#6283) 2018-08-17 16:19:25 +02:00
admin-report-table-row.hbs FIX: improves number/percent support in reports 2018-08-01 18:40:59 -04:00
admin-report-table.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
admin-report-trust-level-counts.hbs UX: Display large numbers with delimiters. 2017-01-09 15:56:02 +08:00
admin-report.hbs FEATURE: Exposing a way to add a generic report filter (#6816) 2019-03-15 12:15:38 +00:00
admin-theme-editor.hbs FIX: Hide advanced theme fields behind a flag, pending UI improvement 2019-02-19 22:25:00 +00:00
admin-user-field-item.hbs REFACTOR: admin-user-field-item (#7016) 2019-02-19 09:30:38 +01:00
admin-web-hook-event-chooser.hbs FEATURE: Webhooks. 2016-09-05 18:44:00 +08:00
admin-web-hook-event.hbs DEV: Rename some icons with deprecated names 2019-02-28 13:03:14 -05:00
embeddable-host.hbs icons deprecations fixes (#6920) 2019-01-22 12:02:02 +01:00
embedding-setting.hbs Remove example CSS selectors from locale file 2015-10-11 14:48:37 +02:00
flag-user-lists.hbs FEATURE: Track how many user flags are agreed/disagreed/ignored 2018-11-01 09:59:50 -04:00
flag-user.hbs Add raw date to title attribute on old flags page (#6349) 2018-08-31 11:01:10 +10:00
flagged-post-response.hbs UX: Improve interface for flagging with many flaggers 2017-09-25 12:28:00 -04:00
flagged-post-title.hbs FEATURE: Show the current reply count of the flagged post 2018-04-05 14:03:02 +02:00
flagged-post.hbs DEV: fix some deprecated SVG icon refs 2019-01-22 14:42:00 -05:00
flagged-posts.hbs Extensibility point for claiming flagged posts 2018-01-15 13:11:11 -05:00
flagged-topic-users.hbs FIX: Link from flagged topics to user was broken 2017-11-28 13:10:30 -05:00
highlighted-code.hbs Can edit settings on the embedding page 2015-08-20 15:56:05 -04:00
inline-edit-checkbox.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
install-theme-item.hbs UX: List popular themes and components in admin panel (#6997) 2019-02-20 14:58:31 -05:00
moderation-history-item.hbs FEATURE: Show a button to Staff for "Moderation History" on posts/topics 2017-12-05 15:20:20 -05:00
penalty-post-action.hbs Many enhancements to the flagging / suspending interface. 2018-02-01 17:13:02 -05:00
permalink-form.hbs DEV: refactoring permalink-form (#6925) 2019-01-22 15:09:21 +01:00
save-controls.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
screened-ip-address-form.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
secret-value-list.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
setting-validation-message.hbs Rename `{{fa-icon}}` to `{{d-icon}}` so it can be more generic 2017-07-27 14:55:41 -04:00
silence-details.hbs Allow silence details to be overwritten via plugin 2018-01-10 13:19:53 -05:00
site-customization-change-details.hbs Remove the last of the admin view classes 2016-11-16 16:41:15 -05:00
site-customization-change-field.hbs Remove the last of the admin view classes 2016-11-16 16:41:15 -05:00
site-setting.hbs icons deprecations fixes (#6920) 2019-01-22 12:02:02 +01:00
site-text-summary.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
suspension-details.hbs Add extensibility for suspension reasons 2018-01-10 12:52:31 -05:00
tags-uploader.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
themes-list-item.hbs DEV: fix some deprecated SVG icon refs 2019-01-22 14:42:00 -05:00
themes-list.hbs UX: List popular themes and components in admin panel (#6997) 2019-02-20 14:58:31 -05:00
user-flag-percentage.hbs FEATURE: Track how many user flags are agreed/disagreed/ignored 2018-11-01 09:59:50 -04:00
value-list.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
watched-word-form.hbs DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
watched-word-uploader.hbs Add btn-default class to all default buttons (#6521) 2018-10-24 16:09:36 -04:00