forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdatable.vue
More file actions
49 lines (43 loc) · 1.25 KB
/
Updatable.vue
File metadata and controls
49 lines (43 loc) · 1.25 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
<template>
<div class="q-pa-md">
<q-btn no-caps color="purple" @click="showNotif" label="Show updatable notification" />
</div>
</template>
<script>
import { useQuasar } from 'quasar'
export default {
setup () {
const $q = useQuasar()
return {
showNotif () {
const notif = $q.notify({
group: false, // required to be updatable
timeout: 0, // we want to be in control when it gets dismissed
spinner: true,
message: 'Uploading file...',
caption: '0%'
})
// 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
notif({
caption: `${percentage}%`
})
// if we are done...
if (percentage === 100) {
notif({
icon: 'done', // we add an icon
spinner: false, // we reset the spinner setting so the icon can be displayed
message: 'Uploading done!',
timeout: 2500 // we will timeout it in 2.5s
})
clearInterval(interval)
}
}, 500)
}
}
}
}
</script>