@cloudron/pankow 3.5.3 → 3.5.4

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudron/pankow",
3
3
  "private": false,
4
- "version": "3.5.3",
4
+ "version": "3.5.4",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "types": "types/index.d.ts",
package/types/utils.d.ts CHANGED
@@ -12,6 +12,7 @@ declare namespace _default {
12
12
  export { prettyLongDate };
13
13
  export { prettyFileSize };
14
14
  export { prettyEmailAddresses };
15
+ export { prettyDuration };
15
16
  export { sanitize };
16
17
  export { pathJoin };
17
18
  export { download };
@@ -39,6 +40,7 @@ export function formatDate(format: any, value: any): any;
39
40
  export function prettyLongDate(value: any): string;
40
41
  export function prettyFileSize(value: any): string;
41
42
  export function prettyEmailAddresses(addresses: any): any;
43
+ export function prettyDuration(ms: any): any;
42
44
  export function sanitize(path: any): any;
43
45
  export function pathJoin(...args: any[]): any;
44
46
  export function download(entries: any, name: any): void;
package/utils.js CHANGED
@@ -183,6 +183,17 @@ function prettyEmailAddresses(addresses) {
183
183
  return addresses.slice(1, -1);
184
184
  }
185
185
 
186
+ function prettyDuration(ms) {
187
+ const totalSeconds = Math.floor(ms / 1000);
188
+ const days = Math.floor(totalSeconds / 86400);
189
+ const hours = Math.floor((totalSeconds % 86400) / 3600);
190
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
191
+ const seconds = totalSeconds % 60;
192
+
193
+ const df = new Intl.DurationFormat(undefined, { style: 'narrow' });
194
+ return df.format({ days, hours, minutes, seconds });
195
+ }
196
+
186
197
  function sanitize(path) {
187
198
  path = '/' + path;
188
199
  return path.replace(/\/+/g, '/');
@@ -432,6 +443,7 @@ export {
432
443
  prettyLongDate,
433
444
  prettyFileSize,
434
445
  prettyEmailAddresses,
446
+ prettyDuration,
435
447
  sanitize,
436
448
  pathJoin,
437
449
  download,
@@ -460,6 +472,7 @@ export default {
460
472
  prettyLongDate,
461
473
  prettyFileSize,
462
474
  prettyEmailAddresses,
475
+ prettyDuration,
463
476
  sanitize,
464
477
  pathJoin,
465
478
  download,
@@ -1,40 +0,0 @@
1
- <script setup>
2
-
3
- import { computed } from 'vue';
4
-
5
- const props = defineProps({
6
- values: Array,
7
- });
8
-
9
- // const normalizedValue = computed(() => {
10
- // if (props.value < 0) return 0;
11
- // if (props.value > 100) return 100;
12
- // return props.value;
13
- // });
14
-
15
- // we want 100 to be the circumverence so we can neatly use percentage: radius = 100 / ( 3,14159 * 2 ) = 15,9155
16
- const radius = 15.9155;
17
- const stroke = 10;
18
-
19
- function calculateViewbox() {
20
- return `0 0 ${radius*2+stroke} ${radius*2+stroke}`;
21
- }
22
-
23
- function calculateArcPath() {
24
- return `M${radius+stroke/2} ${stroke/2} a ${radius} ${radius} 0 0 1 0 ${radius*2} a ${radius} ${radius} 0 0 1 0 -${radius*2}`;
25
- }
26
-
27
- </script>
28
-
29
- <template>
30
- <div class="pankow-circle-chart">
31
- <svg :viewBox="calculateViewbox()" xmlns="http://www.w3.org/2000/svg">
32
- <path :d="calculateArcPath()" fill="none" stroke="red" :stroke-width="stroke" stroke-dasharray="75, 100" @click.stop="onClick('red')" />
33
- <path :d="calculateArcPath()" fill="none" stroke="green" :stroke-width="stroke" stroke-dasharray="30, 100" @click.stop="onClick('green') "/>
34
- </svg>
35
- </div>
36
- </template>
37
-
38
- <style>
39
-
40
- </style>