diff --git a/addon/controllers/users.js b/addon/controllers/users.js
index 38c17ecb..a9ef412d 100644
--- a/addon/controllers/users.js
+++ b/addon/controllers/users.js
@@ -1,24 +1,8 @@
import Controller from "@ember/controller";
import { inject as service } from "@ember/service";
-import { task } from "ember-concurrency";
-import { saveAs } from "file-saver";
-
-import { handleTaskErrors } from "ember-emeis/-private/decorators";
export default class UsersController extends Controller {
@service notification;
@service intl;
@service fetch;
-
- @task
- @handleTaskErrors
- *export() {
- const response = yield this.fetch.fetch(`/api/v1/users/export`);
-
- const filename = response.headers
- .get("content-disposition")
- .match(/filename="(.*)"/)[1];
-
- saveAs(yield response.blob(), filename);
- }
}
diff --git a/addon/controllers/users/index.js b/addon/controllers/users/index.js
index 1ffe93db..136b51f1 100644
--- a/addon/controllers/users/index.js
+++ b/addon/controllers/users/index.js
@@ -2,6 +2,7 @@ import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { tracked } from "@glimmer/tracking";
import { task } from "ember-concurrency";
+import { saveAs } from "file-saver";
import { confirmTask } from "../../decorators/confirm-task";
@@ -12,6 +13,7 @@ export default class UsersIndexController extends PaginationController {
@service emeisOptions;
@service notification;
@service intl;
+ @service fetch;
@tracked filter_active = true;
@@ -53,4 +55,25 @@ export default class UsersIndexController extends PaginationController {
yield model.destroyRecord();
this.notification.success(this.intl.t("emeis.form.delete-success"));
}
+
+ @task
+ @handleTaskErrors
+ *export() {
+ const filters = Object.fromEntries(
+ Object.entries(this.filters).map(([key, value]) => [
+ `filter[${key}]`,
+ value,
+ ])
+ );
+ const queryParams = new URLSearchParams(filters).toString();
+ const response = yield this.fetch.fetch(
+ `/api/v1/users/export?${queryParams}`
+ );
+
+ const filename = response.headers
+ .get("content-disposition")
+ .match(/filename="(.*)"/)[1];
+
+ saveAs(yield response.blob(), filename);
+ }
}
diff --git a/addon/templates/users.hbs b/addon/templates/users.hbs
index 5eb5f8ee..e2147cab 100644
--- a/addon/templates/users.hbs
+++ b/addon/templates/users.hbs
@@ -1,3 +1 @@
-
-
{{outlet}}
\ No newline at end of file
diff --git a/addon/templates/users/index.hbs b/addon/templates/users/index.hbs
index 84aa85bc..3b11c64a 100644
--- a/addon/templates/users/index.hbs
+++ b/addon/templates/users/index.hbs
@@ -1,3 +1,5 @@
+
+