@oxygen-cms/ui 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxygen-cms/ui",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Various utilities for UI-building in Vue.js",
5
5
  "main": "none",
6
6
  "repository": {
package/src/api.js CHANGED
@@ -57,7 +57,7 @@ export class FetchBuilder {
57
57
  this.headers.set('X-XSRF-TOKEN', xsrfToken);
58
58
  }
59
59
 
60
- async fetch(url) {
60
+ async fetchRaw(url) {
61
61
  await this.setXsrfTokenHeader()
62
62
 
63
63
  let v = { ... this};
@@ -72,7 +72,11 @@ export class FetchBuilder {
72
72
  }
73
73
  }
74
74
 
75
- let response = await window.fetch(url.toString(), this);
75
+ return await window.fetch(url.toString(), this);
76
+ }
77
+
78
+ async fetch(url) {
79
+ let response = await this.fetchRaw(url);
76
80
 
77
81
  let data = {};
78
82
  try {
@@ -15,6 +15,7 @@
15
15
  <script>
16
16
  import {FetchBuilder} from "../api";
17
17
  import {API_ROOT} from "../CrudApi";
18
+ import download from "downloadjs";
18
19
 
19
20
  export default {
20
21
  name: "ImportExport",
@@ -26,15 +27,13 @@ export default {
26
27
  methods: {
27
28
  async processDownload() {
28
29
  this.exporting = true;
29
- let builder = (new FetchBuilder(this.$buefy, 'post'))
30
- .cookies();
31
- await builder.setXsrfTokenHeader();
32
- let response = await window.fetch(API_ROOT + "import-export/export", { ... builder });
30
+ let response = await (new FetchBuilder(this.$buefy, 'post'))
31
+ .cookies()
32
+ .fetchRaw(API_ROOT + "import-export/export");
33
33
  this.$buefy.notification.open({ message: 'Export successful', type: 'is-success', queue: false });
34
34
  let blob = await response.blob();
35
- let file = window.URL.createObjectURL(blob);
35
+ download(blob, 'database ' + (new Date()).toLocaleString() + '.zip');
36
36
  this.exporting = false;
37
- window.location.assign(file);
38
37
  }
39
38
  }
40
39
  }