forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgress.vue
More file actions
83 lines (71 loc) · 2.14 KB
/
Progress.vue
File metadata and controls
83 lines (71 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<template>
<div class="q-pa-md q-gutter-sm">
<q-btn label="Default progress" color="primary" @click="showDefault" />
<q-btn label="Custom progress" color="primary" @click="showCustom" />
</div>
</template>
<script>
import { useQuasar, QSpinnerGears } from 'quasar'
export default {
setup () {
const $q = useQuasar()
function showDefault () {
const dialog = $q.dialog({
message: 'Uploading... 0%',
progress: true, // we enable default settings
persistent: true, // we want the user to not be able to close it
ok: false // we want the user to not be able to close it
})
// we simulate some progress here...
let percentage = 0
const interval = setInterval(() => {
percentage = Math.min(100, percentage + Math.floor(Math.random() * 22))
// we update the dialog
dialog.update({
message: `Uploading... ${percentage}%`
})
// if we are done, we're gonna close it
if (percentage === 100) {
clearInterval(interval)
setTimeout(() => {
dialog.hide()
}, 350)
}
}, 500)
}
function showCustom () {
const dialog = $q.dialog({
title: 'Uploading...',
dark: true,
message: '0%',
progress: {
spinner: QSpinnerGears,
color: 'amber'
},
persistent: true, // we want the user to not be able to close it
ok: false // we want the user to not be able to close it
})
// we simulate some progress here...
let percentage = 0
const interval = setInterval(() => {
percentage = Math.min(100, percentage + Math.floor(Math.random() * 22))
// we update the dialog
dialog.update({
message: `${percentage}%`
})
// if we are done...
if (percentage === 100) {
clearInterval(interval)
dialog.update({
title: 'Done!',
message: 'Upload completed successfully',
progress: false,
ok: true
})
}
}, 500)
}
return { showDefault, showCustom }
}
}
</script>