File tree Expand file tree Collapse file tree 3 files changed +42
-2
lines changed
src/components/schedule/auto-mode/auto-mode-button Expand file tree Collapse file tree 3 files changed +42
-2
lines changed Original file line number Diff line number Diff line change 11<template >
22 <Component :is =" menuComponent" >
33 <template #activator =" { props } " >
4- <VBtn v-bind =" props" variant =" tonal" color =" tertiary" > Auto Mode: Queue </VBtn >
4+ <VBtn v-bind =" props" :loading =" pulling" variant =" tonal" color =" tertiary" >
5+ Auto Mode: Queue
6+ </VBtn >
57 </template >
68 <div >
79 <Dialog class =" dialog" ></Dialog >
@@ -15,9 +17,13 @@ import { useDisplay } from "vuetify";
1517import { VBottomSheet } from " vuetify/components/VBottomSheet" ;
1618import { VMenu } from " vuetify/components/VMenu" ;
1719
20+ import { usePulling } from " ../../usePulling" ;
1821import Dialog from " ./Dialog.vue" ;
22+
1923const { mobile } = useDisplay ();
2024const menuComponent = computed (() => (mobile .value ? VBottomSheet : VMenu ));
25+
26+ const { pulling } = await usePulling ();
2127 </script >
2228
2329<style scoped>
Original file line number Diff line number Diff line change 11<template >
22 <Component :is =" menuComponent" >
33 <template #activator =" { props } " >
4- <VBtn v-bind =" props" variant =" tonal" color =" tertiary" >
4+ <VBtn v-bind =" props" :loading = " pulling " variant =" tonal" color =" tertiary" >
55 Auto Mode: Scheduler
66 </VBtn >
77 </template >
@@ -17,9 +17,13 @@ import { useDisplay } from "vuetify";
1717import { VBottomSheet } from " vuetify/components/VBottomSheet" ;
1818import { VMenu } from " vuetify/components/VMenu" ;
1919
20+ import { usePulling } from " ../../usePulling" ;
2021import Dialog from " ./Dialog.vue" ;
22+
2123const { mobile } = useDisplay ();
2224const menuComponent = computed (() => (mobile .value ? VBottomSheet : VMenu ));
25+
26+ const { pulling } = await usePulling ();
2327 </script >
2428
2529<style scoped>
Original file line number Diff line number Diff line change 1+ import { computed } from "vue" ;
2+ import type { Ref } from "vue" ;
3+
4+ import { useSubscribeScheduleAutoModeState } from "@/api" ;
5+
6+ interface _UsePullingReturn {
7+ pulling : Ref < boolean > ;
8+ }
9+
10+ type UsePullingReturn = _UsePullingReturn & PromiseLike < _UsePullingReturn > ;
11+
12+ export function usePulling ( ) : UsePullingReturn {
13+ const subscription = useSubscribeScheduleAutoModeState ( ) ;
14+
15+ // e.g., "off", "auto_pulling", "auto_running"
16+ const state = subscription . autoModeState ;
17+
18+ // true if the second part of the state is "pulling"
19+ const pulling = computed ( ( ) => state . value ?. split ( "_" ) [ 1 ] === "pulling" ) ;
20+
21+ const ret = { pulling } ;
22+
23+ return {
24+ ...ret ,
25+ async then ( onFulfilled , onRejected ) {
26+ await subscription ;
27+ return Promise . resolve ( ret ) . then ( onFulfilled , onRejected ) ;
28+ } ,
29+ } ;
30+ }
You can’t perform that action at this time.
0 commit comments