@sedoo/unidoo 0.0.81 → 0.0.84

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": "@sedoo/unidoo",
3
- "version": "0.0.81",
3
+ "version": "0.0.84",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "build": "vue-cli-service build --target lib --name unidoo src/plugin.js",
@@ -16,6 +16,8 @@
16
16
  "src/**/*"
17
17
  ],
18
18
  "dependencies": {
19
+ "date-fns": "^2.28.0",
20
+ "date-fns-tz": "^1.3.6",
19
21
  "ol": "^6.8.1",
20
22
  "v-tooltip": "^2.1.3",
21
23
  "vue-axios": "3.2.4"
@@ -25,7 +27,7 @@
25
27
  "@vue/cli-plugin-eslint": "4.5.7",
26
28
  "@vue/cli-service": "4.5.7",
27
29
  "@vue/eslint-config-standard": "5.1.2",
28
- "axios": "0.19.2",
30
+ "axios": "0.21.2",
29
31
  "babel-eslint": "10.1.0",
30
32
  "core-js": "3.6.5",
31
33
  "eslint": "7.10.0",
@@ -13,7 +13,6 @@
13
13
 
14
14
  <script>
15
15
 
16
-
17
16
  export default {
18
17
  components: {
19
18
  },
@@ -45,23 +44,21 @@ export default {
45
44
  methods: {
46
45
 
47
46
  refresh() {
48
- this.text=""
47
+ this.text = ""
49
48
  this.generateCaptcha();
50
49
  },
51
50
 
52
51
  generateCaptcha() {
53
- let captcha = []
54
- let charsArray =
52
+ const captcha = []
53
+ const charsArray =
55
54
  "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@!#$%^&*";
56
- let size = Number.parseInt(this.size)
55
+ const size = Number.parseInt(this.size)
57
56
  for (var i = 0; i < size; i++) {
58
- //Eviter la repetition des characters
57
+ // Eviter la repetition des characters
59
58
  var index = Math.floor(Math.random() * charsArray.length + 1);
60
- if (captcha.indexOf(charsArray[index]) == -1)
61
- captcha.push(charsArray[index]);
62
- else i--;
59
+ if (captcha.indexOf(charsArray[index]) == -1) { captcha.push(charsArray[index]); } else i--;
63
60
  }
64
- this.width = 20*captcha.length;
61
+ this.width = 20 * captcha.length;
65
62
  this.captcha = captcha;
66
63
 
67
64
  var canv = document.createElement("canvas");
@@ -72,22 +69,18 @@ export default {
72
69
  ctx.font = "25px Georgia";
73
70
  ctx.strokeText(this.captcha.join(""), 0, 30);
74
71
 
75
- let captchaElement = this.$refs.captcha
72
+ const captchaElement = this.$refs.captcha
76
73
 
77
74
  if (captchaElement != null) {
78
75
  captchaElement.innerHTML = "";
79
76
  captchaElement.appendChild(canv);
80
77
  }
81
-
82
78
  }
83
79
  },
84
80
  beforeMount () {
85
81
  },
86
82
  mounted() {
87
83
  this.generateCaptcha()
88
-
89
-
90
-
91
84
  },
92
85
 
93
86
  props: {
@@ -117,5 +110,4 @@ export default {
117
110
 
118
111
  <style scoped>
119
112
 
120
-
121
113
  </style>
@@ -24,12 +24,12 @@ export default class CalendarHeatmap {
24
24
 
25
25
  get monthCalendar () {
26
26
  const year = this.year.getFullYear()
27
- const date = new Date(year, 0, 1)
27
+ const date = new Date(year, 0, 1).toUnidooUTC()
28
28
  let i = 0
29
29
  return Array.from({ length: 12 },
30
30
  () => Array.from({ length: this.daysInMonth(year, i++) },
31
31
  () => {
32
- const dDate = new Date(date.getFullYear(), date.getMonth(), date.getDate())
32
+ const dDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()).toUnidooUTC()
33
33
  const dayValues = this.activities[this._keyDayParser(dDate)]
34
34
  date.setDate(date.getDate() + 1)
35
35
  return {
@@ -43,12 +43,12 @@ export default class CalendarHeatmap {
43
43
  }
44
44
 
45
45
  daysInMonth (year, month) {
46
- return new Date(year, month + 1, 0).getDate()
46
+ return new Date(year, month + 1, 0).toUnidooUTC().getDate()
47
47
  }
48
48
 
49
49
  daysInYear(year) {
50
- const start = new Date(year, 0, 0)
51
- const end = new Date(year, 11, 31)
50
+ const start = new Date(year, 0, 0).toUnidooUTC()
51
+ const end = new Date(year, 11, 31).toUnidooUTC()
52
52
  const diff = end - start
53
53
  return Math.floor(diff / (1000 * 60 * 60 * 24))
54
54
  }
@@ -71,12 +71,12 @@ export default class CalendarHeatmap {
71
71
  const day = this.values.filter(d => d.date === sdate)[0];
72
72
  if (day) {
73
73
  return {
74
- date: new Date(day.date),
74
+ date: new Date(day.date).toUnidooUTC(),
75
75
  count: day.count,
76
76
  colorIndex: this.getColorIndex(day.count)
77
77
  };
78
78
  } else {
79
- return { date: new Date(entry), count: NaN, colorIndex: 0 };
79
+ return { date: new Date(entry).toUnidooUTC(), count: NaN, colorIndex: 0 };
80
80
  }
81
81
  }
82
82
  }
@@ -139,10 +139,10 @@ export default class CalendarHeatmap {
139
139
  }
140
140
 
141
141
  _getTimes (year) {
142
- const date = new Date(year, 0, 1)
142
+ const date = new Date(year, 0, 1).toUnidooUTC()
143
143
  return Array.from({ length: this.daysInYear(year) },
144
144
  () => {
145
- const dDate = new Date(date.getFullYear(), date.getMonth(), date.getDate())
145
+ const dDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()).toUnidooUTC()
146
146
  dDate.setHours(0, 0, 0)
147
147
  const dayValues = this.activities[this._keyDayParser(dDate)]
148
148
  date.setDate(date.getDate() + 1)
@@ -169,15 +169,15 @@ export default class CalendarHeatmap {
169
169
  _decodeDate (d) {
170
170
  if (!d) return null
171
171
  const sdate = d.slice(0, -1)
172
- return new Date(sdate)
172
+ return new Date(sdate).toUnidooUTC()
173
173
  }
174
174
 
175
175
  _parseDate (entry) {
176
- return (entry instanceof Date) ? entry : (new Date(entry))
176
+ return (entry instanceof Date) ? entry : (new Date(entry).toUnidooUTC())
177
177
  }
178
178
 
179
179
  _keyDayParser (date) {
180
180
  const day = this._parseDate(date)
181
181
  return `${day.getFullYear()}-${day.getMonth()}-${day.getDate()}`
182
182
  }
183
- }
183
+ }
@@ -31,6 +31,7 @@ import Plugin from '../../plugin.js'
31
31
  import { VTooltip } from 'v-tooltip'
32
32
  import Heatmap from './Heatmap'
33
33
  import { DEFAULT_LOCALE, DEFAULT_RANGE_COLOR, DEFAULT_TOOLTIP_UNIT } from './consts.js'
34
+ import { utcToZonedTime } from 'date-fns-tz'
34
35
 
35
36
  VTooltip.enabled = window.innerWidth > 768
36
37
 
@@ -86,10 +87,14 @@ export default {
86
87
  heatmapKey: {
87
88
  type: String,
88
89
  default: ""
90
+ },
91
+ timeZone: {
92
+ type: String,
93
+ default: "Europe/Paris"
89
94
  }
90
95
  },
91
96
  data: () => ({
92
- now: new Date(new Date().setHours(23, 59, 59, 999))
97
+
93
98
  }),
94
99
  watch: {
95
100
  dateValue (val) {
@@ -108,6 +113,9 @@ export default {
108
113
  }
109
114
  },
110
115
  computed: {
116
+ now() {
117
+ return new Date(new Date().setHours(23, 59, 59, 999)).toUnidooUTC();
118
+ },
111
119
  heatmap () {
112
120
  return new Heatmap(this.year, this.values, this.completeValue)
113
121
  },
@@ -132,6 +140,10 @@ export default {
132
140
  }
133
141
  },
134
142
  beforeMount () {
143
+ const self = this;
144
+ Date.prototype.toUnidooUTC = function() {
145
+ return utcToZonedTime(this, self.timeZone);
146
+ }
135
147
  Plugin.EventBus.$on("unidoo-heatmap-set-date", params => {
136
148
  if (this.heatmapKey) {
137
149
  if (params.key === this.heatmapKey && params.date) {
@@ -210,7 +222,7 @@ export default {
210
222
  hasPreviousDate (d) {
211
223
  if (!d || !this.isDateInYear(d)) return false;
212
224
  const syear = (this.year instanceof Date) ? this.year.getFullYear() : this.year;
213
- const firstDay = new Date(syear, 0, 1);
225
+ const firstDay = new Date(syear, 0, 1).toUnidooUTC();
214
226
  d.setHours(0, 0, 0, 0);
215
227
  if (d <= firstDay) return false;
216
228
  return true;
@@ -219,10 +231,10 @@ export default {
219
231
  if (!d || !this.isDateInYear(d)) return false;
220
232
  const syear = (this.year instanceof Date) ? this.year.getFullYear() : this.year;
221
233
  let lastDay = null;
222
- if (new Date(syear, 0, 1).getFullYear() === new Date().getFullYear()) {
223
- lastDay = new Date();
234
+ if (new Date(syear, 0, 1).toUnidooUTC().getFullYear() === new Date().toUnidooUTC().getFullYear()) {
235
+ lastDay = new Date().toUnidooUTC();
224
236
  } else {
225
- lastDay = new Date(syear, 11, 31);
237
+ lastDay = new Date(syear, 11, 31).toUnidooUTC();
226
238
  }
227
239
  lastDay.setHours(0, 0, 0, 0);
228
240
  if (d >= lastDay) return false;
@@ -282,7 +294,7 @@ export default {
282
294
  },
283
295
  formatDate (d) {
284
296
  if (!d) return ''
285
- const date = new Date(d)
297
+ const date = new Date(d).toUnidooUTC()
286
298
  if (!date) return ''
287
299
  const dd = date.getDate()
288
300
  const mm = date.getMonth() + 1
@@ -89,7 +89,7 @@ export default {
89
89
  switchDate(n) {
90
90
  if (this.cleanedDate && n) {
91
91
  if ((n > 0 && this.hasNext) || (n < 0 && this.hasPrevious)) {
92
- const newDate = new Date(this.cleanedDate);
92
+ const newDate = new Date(this.cleanedDate).toUnidooUTC();
93
93
  newDate.setDate(this.cleanedDate.getDate() + n);
94
94
  this.$unidooHeatmap.setDate(newDate, this.heatmapKey);
95
95
  }
@@ -110,7 +110,7 @@ export default {
110
110
  if (date instanceof Date) {
111
111
  return date;
112
112
  } else if (typeof date === 'string') {
113
- return new Date(date);
113
+ return new Date(date).toUnidooUTC();
114
114
  }
115
115
  }
116
116
  return null;
@@ -46,27 +46,27 @@ export default {
46
46
  default: 'frame'
47
47
  },
48
48
 
49
- data:{
49
+ data: {
50
50
  type: Object,
51
51
  default: () => null
52
52
  },
53
53
 
54
- noVisibleData:{
54
+ noVisibleData: {
55
55
  type: Boolean,
56
56
  default: false
57
57
  },
58
58
 
59
- noDataMessage:{
59
+ noDataMessage: {
60
60
  type: String,
61
61
  default: "No available data"
62
62
  },
63
63
 
64
- noVisibleDataMessage:{
64
+ noVisibleDataMessage: {
65
65
  type: String,
66
66
  default: "Existing data, no quicklook available"
67
67
  },
68
68
 
69
- isLoading:{
69
+ isLoading: {
70
70
  type: Boolean,
71
71
  default: false
72
72
  }
@@ -76,8 +76,8 @@ export default {
76
76
  entries: null
77
77
  }),
78
78
 
79
- computed:{
80
- hasData(){
79
+ computed: {
80
+ hasData() {
81
81
  return this.data && this.data.entries && this.data.entries.length;
82
82
  },
83
83
  }
@@ -177,10 +177,10 @@ export default {
177
177
  }
178
178
  },
179
179
 
180
- getLegend(value){
181
- if(value && this.data && this.data.legend){
180
+ getLegend(value) {
181
+ if (value && this.data && this.data.legend) {
182
182
  const legend = this.data.legend.find(el => (el.code && el.code.toUpperCase() === value.toUpperCase()));
183
- if(legend) {
183
+ if (legend) {
184
184
  return legend.label;
185
185
  } else {
186
186
  return null;
@@ -267,7 +267,6 @@ export default {
267
267
  }
268
268
  },
269
269
 
270
-
271
270
  sort(array) {
272
271
  if (array) {
273
272
  if (array.length > 1) {
@@ -154,9 +154,9 @@ export default {
154
154
  return this.max > 0 && this.loadedFrames >= this.max + 1
155
155
  },
156
156
 
157
- subBodyStyle(){
157
+ subBodyStyle() {
158
158
  const vh = (this.isZoomed) ? '75vh' : '43vh';
159
- return { gridTemplateRows: ((this.playerBarTop) ? '10px 120px 10px ' + vh + ' 10px' : '10px ' + vh + ' 10px 120px 10px')};
159
+ return { gridTemplateRows: ((this.playerBarTop) ? '10px 120px 10px ' + vh + ' 10px' : '10px ' + vh + ' 10px 120px 10px') };
160
160
  }
161
161
 
162
162
  },
@@ -190,15 +190,14 @@ export default {
190
190
  }
191
191
  },
192
192
 
193
- graduation(){
193
+ graduation() {
194
194
  this.initGraduation();
195
195
  },
196
196
 
197
- sliderSize(){
197
+ sliderSize() {
198
198
  this.initGraduation();
199
199
  }
200
200
 
201
-
202
201
  },
203
202
 
204
203
  created() {
@@ -348,17 +347,17 @@ export default {
348
347
  this.$emit('reload-frames');
349
348
  },
350
349
 
351
- initGraduation(){
352
- let result = [];
353
- if(this.graduation){
350
+ initGraduation() {
351
+ const result = [];
352
+ if (this.graduation) {
354
353
  const gradsLength = this.graduation.length;
355
354
  let delta = 1;
356
- if(this.sliderSize && gradsLength && this.graduation[0]){
355
+ if (this.sliderSize && gradsLength && this.graduation[0]) {
357
356
  const firstGrad = this.graduation[0].length * 9; // nb chars * number of pixels for 1 character
358
357
  let exceed = Math.ceil(this.sliderSize - (gradsLength * firstGrad) - 30); // add 30px of margin
359
- exceed = (exceed < 0) ? - exceed : 0;
358
+ exceed = (exceed < 0) ? -exceed : 0;
360
359
  const gradsExceed = exceed / firstGrad;
361
- if(gradsLength - gradsExceed){
360
+ if (gradsLength - gradsExceed) {
362
361
  delta = Math.ceil(gradsLength / (gradsLength - gradsExceed));
363
362
  } else {
364
363
  delta = Math.ceil(gradsLength);
@@ -379,38 +378,38 @@ export default {
379
378
  this.filteredGraduation = result;
380
379
  },
381
380
 
382
- initIframe(){
381
+ initIframe() {
383
382
  const iframe = this.$refs.sizeHandlerIframe;
384
- if(iframe){
383
+ if (iframe) {
385
384
  const box = iframe.getBoundingClientRect();
386
- this.sliderSize = box.width - 114 -9 -32 -10; // - padding and margin
385
+ this.sliderSize = box.width - 114 - 9 - 32 - 10; // - padding and margin
387
386
  const iframeWin = iframe.contentWindow;
388
387
  this.resizeListener = this.handleResize.bind(this);
389
388
  iframeWin.addEventListener('resize', this.resizeListener);
390
389
  }
391
390
  },
392
391
 
393
- clearIframe(){
392
+ clearIframe() {
394
393
  const iframe = this.$refs.sizeHandlerIframe;
395
- if(iframe){
394
+ if (iframe) {
396
395
  const iframeWin = iframe.contentWindow;
397
- if(iframeWin){
396
+ if (iframeWin) {
398
397
  iframeWin.removeEventListener('resize', this.resizeListener);
399
398
  }
400
399
  this.resizeListener = null;
401
400
  }
402
401
  },
403
402
 
404
- handleResize(){
403
+ handleResize() {
405
404
  // add a delay of 500ms to handle slider width resize
406
- if(this.timer !== null){
405
+ if (this.timer !== null) {
407
406
  clearTimeout(this.timer);
408
407
  }
409
408
  const self = this;
410
409
  this.timer = setTimeout(() => {
411
410
  const box = self.$refs.sizeHandlerIframe.getBoundingClientRect();
412
- const sliderWidth = box.width - 114 -9 -32 -10;
413
- if(self.sliderSize != sliderWidth){
411
+ const sliderWidth = box.width - 114 - 9 - 32 - 10;
412
+ if (self.sliderSize != sliderWidth) {
414
413
  self.sliderSize = sliderWidth;
415
414
  }
416
415
  self.time = null;
@@ -205,7 +205,7 @@ export default {
205
205
  }
206
206
  },
207
207
 
208
- refreshPreload(loadIndex){
208
+ refreshPreload(loadIndex) {
209
209
  this.lastFrameQualifier = this.currentQualifier;
210
210
  this.preloadFrames(loadIndex);
211
211
  },