discourse/app/assets/javascripts/admin/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 make code prettier 🎀 2018-07-18 13:09:16 +02:00
ace-editor.js.es6 Revert "DEV: Upgrade to Ember 3.7.0 (#6977)" (#7165) 2019-03-13 15:49:47 -03:00
admin-backups-logs.js.es6 DEV: s/this._super()/this._super(...arguments) (#6908) 2019-01-19 10:05:51 +01:00
admin-directory-toggle.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-editable-field.js.es6 FIX: Properly reset controller of admin-user-index. (#6760) 2018-12-17 15:28:29 +01:00
admin-form-row.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-graph.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-nav.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-report-chart.js.es6 minor cosmetic improvements to charts (#6919) 2019-01-22 10:22:41 +01:00
admin-report-counters.js.es6 FEATURE: displays report description when hovering activity metrics (#6983) 2019-02-07 13:33:05 +01:00
admin-report-counts.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-report-inline-table.js.es6 FEATURE: part 2 of dashboard improvements 2018-07-19 14:33:11 -04:00
admin-report-per-day-counts.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-report-stacked-chart.js.es6 FIX: better handling of resizing in stacked charts (#6921) 2019-01-22 11:20:50 +01:00
admin-report-storage-stats.js.es6 FEATURE: Improve backup stats on admin dashboard 2018-12-17 11:35:11 +01:00
admin-report-table-cell.js.es6 FIX: improves number/percent support in reports 2018-08-01 18:40:59 -04:00
admin-report-table-header.js.es6 FIX: improves number/percent support in reports 2018-08-01 18:40:59 -04:00
admin-report-table-row.js.es6 FIX: improves number/percent support in reports 2018-08-01 18:40:59 -04:00
admin-report-table.js.es6 FEATURE: Exposing a way to add a generic report filter (#6816) 2019-03-15 12:15:38 +00:00
admin-report-trust-level-counts.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-report.js.es6 FEATURE: Exposing a way to add a generic report filter (#6816) 2019-03-15 12:15:38 +00:00
admin-theme-editor.js.es6 DEV: Code style improvements following review 2019-02-19 20:02:29 +00:00
admin-user-field-item.js.es6 REFACTOR: admin-user-field-item (#7016) 2019-02-19 09:30:38 +01:00
admin-watched-word.js.es6 DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
admin-web-hook-event-chooser.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-web-hook-event.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-web-hook-status.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
admin-wrapper.js.es6 DEV: s/this._super()/this._super(...arguments) (#6908) 2019-01-19 10:05:51 +01:00
cancel-link.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
color-input.js.es6 DEV: s/Em/Ember (#6874) 2019-01-11 17:54:23 +01:00
embeddable-host.js.es6 DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
embedding-setting.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
flag-user-lists.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
flagged-post-response.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
flagged-post-title.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
flagged-post.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
highlighted-code.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
inline-edit-checkbox.js.es6 DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
install-theme-item.js.es6 UX: List popular themes and components in admin panel (#6997) 2019-02-20 14:58:31 -05:00
ip-lookup.js.es6 DEV: refactoring ip-lookup (#6923) 2019-01-22 15:09:04 +01:00
moderation-history-item.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
penalty-post-action.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
permalink-form.js.es6 DEV: refactoring permalink-form (#6925) 2019-01-22 15:09:21 +01:00
resumable-upload.js.es6 DEV: s/Em/Ember (#6874) 2019-01-11 17:54:23 +01:00
save-controls.js.es6 DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
screened-ip-address-form.js.es6 DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
secret-value-list.js.es6 FIX: don't allow adding a value containing vertical bar char to the secret list 2018-11-05 12:14:56 +01:00
silence-details.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
site-setting.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
site-settings-image-uploader.js.es6 FEATURE: Upload Site Settings. (#6573) 2018-11-14 15:03:02 +08:00
site-text-summary.js.es6 DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
staff-actions.js.es6 DEV: s/this._super()/this._super(...arguments) (#6908) 2019-01-19 10:05:51 +01:00
suspension-details.js.es6 DEV: introduces prettier for es6 files 2018-06-15 17:03:24 +02:00
tags-uploader.js.es6 DEV: s/Em/Ember (#6874) 2019-01-11 17:54:23 +01:00
theme-setting-editor.js.es6 FEATURE: Support for localized themes (#6848) 2019-01-17 11:46:11 +00:00
theme-translation.js.es6 FEATURE: Support for localized themes (#6848) 2019-01-17 11:46:11 +00:00
themes-list-item.js.es6 DEV: s/Em/Ember (#6874) 2019-01-11 17:54:23 +01:00
themes-list.js.es6 UX: Modifications to admin/customize layout 2019-02-07 22:27:35 -05:00
user-flag-percentage.js.es6 DEV: fix some deprecated SVG icon refs 2019-01-22 14:42:00 -05:00
value-list.js.es6 FIX: display select kit body if no choices (#6237) 2018-08-06 11:22:48 -04:00
watched-word-form.js.es6 DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808) 2019-01-10 11:06:01 +01:00
watched-word-uploader.js.es6 DEV: s/Em/Ember (#6874) 2019-01-11 17:54:23 +01:00