@mapomodule/uikit 1.0.0-alpha.46 → 1.0.0-alpha.47

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/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.47](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.46...v1.0.0-alpha.47) (2023-06-24)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix media gallery keys ([f9fb666](https://github.com/lotrekagency/mapo/commit/f9fb6664456488b0b32b730ef7236d2e8bddea80))
12
+
13
+
14
+ ### Features
15
+
16
+ * improve media uloader progress ([bbc9628](https://github.com/lotrekagency/mapo/commit/bbc9628653c18ebbcb37011302e698d9dc8f29a8))
17
+ * update translations ([a51ae6d](https://github.com/lotrekagency/mapo/commit/a51ae6d86da32248b6377f1d4ce6bfab7fc413d1))
18
+
19
+
20
+
21
+
22
+
6
23
  # [1.0.0-alpha.46](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.45...v1.0.0-alpha.46) (2023-06-24)
7
24
 
8
25
 
@@ -140,6 +140,7 @@ export default {
140
140
  },
141
141
  },
142
142
  mounted() {
143
+ throw Error("TimeField is actually broken. Use something else.")
143
144
  this.model = this.setupModel(this.value);
144
145
  },
145
146
  };
@@ -8,7 +8,7 @@
8
8
  >
9
9
  <MediaPreview
10
10
  v-for="media in selection"
11
- :key="media.file"
11
+ :key="media.id"
12
12
  @click.native.stop="select(media)"
13
13
  :media="media"
14
14
  icon-size="20px"
@@ -53,7 +53,7 @@
53
53
  <div ref="masonry" class="media-gallery--masonry" v-if="medias.length">
54
54
  <div
55
55
  v-for="media in medias"
56
- :key="media.file"
56
+ :key="media.id"
57
57
  class="media-gallery--card"
58
58
  >
59
59
  <v-btn
@@ -179,7 +179,7 @@ $wcol: calc(100% / 6 - 12px);
179
179
  .media-gallery--masonry{
180
180
  grid-template-columns: $wcol $wcol;
181
181
  }
182
- }
182
+ }
183
183
 
184
184
  .media-gallery--empty{
185
185
  height: 100%;
@@ -224,7 +224,7 @@ $wcol: calc(100% / 6 - 12px);
224
224
  color: white;
225
225
  }
226
226
  }
227
-
227
+
228
228
  }
229
229
  .media-gallery--selected {
230
230
  &::after {
@@ -12,43 +12,30 @@
12
12
  </div>
13
13
  </template>
14
14
  <template v-slot:list-item.content.after="{ item }">
15
- <v-chip dense v-if="isTooLarge(item)" color="error">{{$t("mapo.mediaUploader.tooLarge")}}</v-chip>
15
+ <v-chip dense v-if="isTooLarge(item)" color="error">{{ $t("mapo.mediaUploader.tooLarge") }}</v-chip>
16
16
  </template>
17
17
  <template v-slot:editContent="{ editedItem }">
18
18
  <v-container>
19
19
  <v-row>
20
20
  <v-col cols="12">
21
- <v-select
22
- v-model="editedItem.folder"
23
- :items="folderOptions"
24
- :label="$t('mapo.folder')"
25
- ></v-select>
21
+ <v-select v-model="editedItem.folder" :items="folderOptions" :label="$t('mapo.folder')"></v-select>
26
22
  </v-col>
27
23
  <v-col cols="12">
28
- <v-text-field
29
- v-model="editedItem.title"
30
- :label="$t('titleTag')"
31
- ></v-text-field>
24
+ <v-text-field v-model="editedItem.title" :label="$t('titleTag')"></v-text-field>
32
25
  </v-col>
33
26
  <v-col cols="12">
34
- <v-text-field
35
- v-model="editedItem.description"
36
- :label="$t('mapo.description')"
37
- ></v-text-field>
27
+ <v-text-field v-model="editedItem.description" :label="$t('mapo.description')"></v-text-field>
38
28
  </v-col>
39
29
  <v-col cols="12">
40
- <v-text-field
41
- v-model="editedItem.alt_text"
42
- :label="$t('mapo.altTag')"
43
- ></v-text-field>
30
+ <v-text-field v-model="editedItem.alt_text" :label="$t('mapo.altTag')"></v-text-field>
44
31
  </v-col>
45
32
  </v-row>
46
33
  </v-container>
47
34
  </template>
48
35
  </drop-area>
49
36
  <div v-if="mediaList.length" class="mt-3">
50
- <p class="text-right mr-3 mb-2">{{ completed }}</p>
51
- <v-progress-linear :value="progress"></v-progress-linear>
37
+ <p class="text-right mr-3 mb-2">{{ bufferProgress >= 100 ? $t('mapo.mediaUploader.optimizingFiles') : (progress > 0 ? $t('mapo.mediaUploader.uploadingFiles'):'')}} {{ completed }}</p>
38
+ <v-progress-linear :stream="stream" :indeterminate="progress == 100" :value="progress" :buffer-value="bufferProgress"></v-progress-linear>
52
39
  </div>
53
40
  </v-container>
54
41
  </template>
@@ -69,8 +56,9 @@ export default {
69
56
  name: "MediaUploader",
70
57
  data() {
71
58
  return {
72
- count: 0,
73
- progress: 0,
59
+ buffer : 0,
60
+ stream: false,
61
+ responses: [],
74
62
  mediaList: [],
75
63
  _mediaFileCrud: null
76
64
  };
@@ -84,7 +72,7 @@ export default {
84
72
  return this._mediaFileCrud;
85
73
  },
86
74
  completed() {
87
- return `${this.count}/${this.mediaList.length}`;
75
+ return `${this.responses.length}/${this.mediaList.length}`;
88
76
  },
89
77
  folderOptions() {
90
78
  return [
@@ -97,11 +85,17 @@ export default {
97
85
  value: folder.id
98
86
  }))
99
87
  ];
88
+ },
89
+ progress(){
90
+ return this.responses.length/this.mediaList.length * 100;
91
+ },
92
+ bufferProgress(){
93
+ return this.buffer/this.mediaList.length * 100;
100
94
  }
101
95
  },
102
96
  methods: {
103
- isTooLarge({ info }){
104
- const {type} = info;
97
+ isTooLarge({ info }) {
98
+ const { type } = info;
105
99
  switch (type.split("/")[0]) {
106
100
  case "image":
107
101
  return info.rawsize > MAX_IMAGE_SIZE;
@@ -122,58 +116,47 @@ export default {
122
116
  (this.parentFolder && this.parentFolder.id) ||
123
117
  null;
124
118
  });
125
- this.count = 0;
126
- this.progress = 0;
119
+ this.responses = [];
120
+ this.buffer = 0;
121
+ this.stream = false
127
122
  },
128
- updateAll() {
129
- return Promise.all(
130
- this.mediaList.map(media =>
131
- this.uploadMedia(
132
- Object.assign(
133
- { file: media.blob },
134
- {
135
- title: media.info.title,
136
- alt_text: media.info.alt_text,
137
- description: media.info.description,
138
- folder: media.info.folder
139
- }
140
- )
123
+ async updateAll() {
124
+ this.stream = true
125
+ for (const media of this.mediaList) {
126
+ await this.uploadMedia(
127
+ Object.assign(
128
+ { file: media.blob },
129
+ {
130
+ title: media.info.title,
131
+ alt_text: media.info.alt_text,
132
+ description: media.info.description,
133
+ folder: media.info.folder
134
+ }
141
135
  )
142
- )
143
- ).then(response => {
144
- if (this.mediaList && this.mediaList.length) {
136
+ ).then(r => this.responses.push(r)).catch(error => {
145
137
  this.$mapo.$snack.open({
146
- message: this.$t("mapo.mediaUploader.success", {numberFiles: response.length || this.mediaList.length})
147
- });
148
- this.$emit("Upload", (response.length && response) || this.mediaList);
149
- this.$refs.closeButton.$el.click();
150
- }
151
- }).catch(error => {
152
- this.$mapo.$snack.open({
153
- message: error.response?.data?.detail || this.$t("mapo.genericError"),
154
- color: "error",
138
+ message: error.response?.data?.detail || this.$t("mapo.genericError"),
139
+ color: "error",
140
+ })
155
141
  })
156
- });
142
+ }
143
+ if (this.mediaList && this.mediaList.length) {
144
+ this.$mapo.$snack.open({
145
+ message: this.$t("mapo.mediaUploader.success", { numberFiles: this.responses.length || this.mediaList.length })
146
+ });
147
+ this.$emit("Upload", (this.responses.length && this.responses) || this.mediaList);
148
+ this.$refs.closeButton.$el.click();
149
+ }
157
150
  },
158
- uploadMedia(media) {
159
- const index = this.mediaList.findIndex(el => el.blob === media.file);
151
+ async uploadMedia(media) {
160
152
  const payload = this.$mapo.$api.multipart(media, ["file"]);
161
153
  const conf = {
162
154
  headers: { "Content-Type": "multipart/form-data" },
163
155
  onUploadProgress: function(event) {
164
- this.mediaList[index].progress = Math.ceil(
165
- (event.loaded / event.total) * 100
166
- );
167
- this.progress =
168
- this.mediaList.reduce((acc, media) => acc + media.progress, 0) /
169
- this.mediaList.length;
170
- this.count = this.mediaList.reduce(
171
- (acc, media) => acc + (media.progress === 100),
172
- 0
173
- );
156
+ this.buffer = Math.ceil(this.buffer) + (event.loaded / event.total)
174
157
  }.bind(this)
175
158
  };
176
- return this.mediaFileCrud.create(payload, conf);
159
+ return await this.mediaFileCrud.create(payload, conf);
177
160
  }
178
161
  }
179
162
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/uikit",
3
- "version": "1.0.0-alpha.46",
3
+ "version": "1.0.0-alpha.47",
4
4
  "license": "MIT",
5
5
  "description": "This is part of Mapo nuxt module. Injects Mapo ui components in the nuxt component discovery system.",
6
6
  "author": "bnznamco <gabriele.baldi.01@gmail.com>",
@@ -15,5 +15,5 @@
15
15
  "publishConfig": {
16
16
  "access": "public"
17
17
  },
18
- "gitHead": "7f8e3b34a2130d54797c52542fdb6a269dbc27ef"
18
+ "gitHead": "40ab5eb6bb2508c9e3a0e8f7cef850cf809a472e"
19
19
  }
@@ -162,6 +162,6 @@ export default {
162
162
  fileInfo: "File info succesfully updated",
163
163
  },
164
164
  // MediaManager/MediaUploader.vue
165
- mediaUploader: { success: "{numberFiles} files succesfully uploaded", tooLarge: "Warning! Optimize before upload!" },
165
+ mediaUploader: { optimizingFiles: "Optimizing files..", uploadingFiles: "Uploading files..", success: "{numberFiles} files succesfully uploaded", tooLarge: "Warning! Optimize before upload!" },
166
166
  },
167
167
  };
@@ -165,6 +165,6 @@ export default {
165
165
  fileInfo: "File info succesfully updated",
166
166
  },
167
167
  // MediaManager/MediaUploader.vue
168
- mediaUploader: { success: "{numberFiles} file caricati", tooLarge: "Attenzione! Ottimizza prima di caricare!" },
168
+ mediaUploader: { optimizingFiles: "Ottimizzazione dei file..", uploadingFiles: "Upload dei file..", success: "{numberFiles} file caricati", tooLarge: "Attenzione! Ottimizza prima di caricare!" },
169
169
  },
170
170
  };