88 >
99 <v-card class =" pa-6 bg-grey-darken-4 bg-v-theme-surface" >
1010 <v-card-title class =" text-center mb-4" >
11- <span >Step {{ el }} of 4</span >
11+ <span data-test = " step-counter " >Step {{ el }} of 4</span >
1212 <v-divider class =" mt-2" />
1313 </v-card-title >
1414 <v-window v-model =" el" >
1515 <v-window-item :value =" 1" >
16- <v-card class =" bg-v-theme-surface" height =" 250px " >
16+ <v-card class =" bg-v-theme-surface" height =" 200px " :elevation = " 0 " data-test = " welcome-first-screen " >
1717 <WelcomeFirstScreen />
1818 </v-card >
1919 <v-card-actions class =" mt-4" >
20- <v-btn @click =" close" >Close</v-btn >
20+ <v-btn @click =" close" data-test = " close-btn " >Close</v-btn >
2121 <v-spacer />
2222 <v-btn
23- data-test =" firstClick -btn"
23+ data-test =" first-click -btn"
2424 color =" primary"
2525 @click =" activePollingDevices()"
2626 >Next</v-btn >
2727 </v-card-actions >
2828 </v-window-item >
2929
3030 <v-window-item :value =" 2" >
31- <v-card class =" bg-v-theme-surface" height =" 250px" >
31+ <v-card class =" bg-v-theme-surface" height =" 250px" :elevation = " 0 " data-test = " welcome-second-screen " >
3232 <WelcomeSecondScreen :command =" command()" />
3333 </v-card >
3434 <v-card-actions >
35- <v-btn data-test =" close -btn" @click =" close" >Close</v-btn >
35+ <v-btn data-test =" close2 -btn" @click =" close" >Close</v-btn >
3636 <v-spacer />
37- <v-btn @click =" goToPreviousStep" >Back</v-btn >
38- <v-btn v-if =" !enable" disabled >Waiting for Device</v-btn >
37+ <v-btn @click =" goToPreviousStep" data-test = " back-btn " >Back</v-btn >
38+ <v-btn v-if =" !enable" data-test = " waiting-message " disabled >Waiting for Device</v-btn >
3939 <v-btn
4040 v-else
4141 color =" primary"
42- data-test =" secondClick -btn"
42+ data-test =" next -btn"
4343 @click =" goToNextStep"
4444 >
4545 Next
4848 </v-window-item >
4949
5050 <v-window-item :value =" 3" >
51- <v-card class =" bg-v-theme-surface" height =" 250px" >
51+ <v-card class =" bg-v-theme-surface" height =" 250px" :elevation = " 0 " data-test = " welcome-third-screen " >
5252 <WelcomeThirdScreen v-if =" enable" />
5353 </v-card >
5454 <v-card-actions >
55- <v-btn variant =" text" data-test =" close -btn" @click =" close" >
55+ <v-btn variant =" text" data-test =" close3 -btn" @click =" close" >
5656 Close
5757 </v-btn >
5858 <v-spacer />
59- <v-btn variant =" text" @click =" goToPreviousStep" >Back</v-btn >
59+ <v-btn variant =" text" @click =" goToPreviousStep" data-test = " back2-btn " >Back</v-btn >
6060 <v-btn
6161 color =" primary"
6262 data-test =" accept-btn"
6868 </v-window-item >
6969
7070 <v-window-item :value =" 4" >
71- <v-card class =" bg-v-theme-surface" height =" 250px" >
71+ <v-card class =" bg-v-theme-surface" height =" 250px" :elevation = " 0 " data-test = " welcome-fourth-screen " >
7272 <WelcomeFourthScreen />
7373 </v-card >
7474 <v-card-actions >
8383 </v-dialog >
8484</template >
8585
86- <script lang="ts">
87- import { computed , defineComponent , ref } from " vue" ;
86+ <script setup lang="ts">
87+ import { computed , ref } from " vue" ;
8888import { INotificationsError } from " ../../interfaces/INotifications" ;
8989import { useStore } from " ../../store" ;
9090import WelcomeFirstScreen from " ./WelcomeFirstScreen.vue" ;
@@ -95,117 +95,95 @@ import handleError from "../../utils/handleError";
9595
9696type Timer = ReturnType <typeof setInterval >;
9797
98- export default defineComponent ({
99- props: {
100- show: {
101- type: Boolean ,
102- required: true ,
103- },
98+ const props = defineProps ({
99+ show: {
100+ type: Boolean ,
101+ required: true ,
104102 },
105- emits: [" update" ],
106- setup(props , { emit }) {
107- const store = useStore ();
108- const el = ref <number >(1 );
109- const polling = ref <Timer | undefined >(undefined );
110- const enable = ref (false );
111- const showWelcome = computed <boolean >({
112- get() {
113- return props .show ;
114- },
115- set(value ) {
116- emit (" update" , value );
117- },
118- });
119-
120- const curl = ref ({
121- hostname: window .location .hostname ,
122- tenant: store .getters [" auth/tenant" ],
123- });
124-
125- const pollingDevices = () => {
126- polling .value = setInterval (async () => {
127- try {
128- await store .dispatch (" stats/get" );
129-
130- enable .value = store .getters [" stats/stats" ].pending_devices !== 0 ;
131- if (enable .value ) {
132- el .value = 3 ;
133- clearTimeout (polling .value );
134- }
135- } catch (error : unknown ) {
136- store .dispatch (" snackbar/showSnackbarErrorDefault" );
137- handleError (error );
138- }
139- }, 3000 );
140- };
141-
142- const activePollingDevices = () => {
143- el .value = 2 ;
144- pollingDevices ();
145- };
146-
147- const acceptDevice = async () => {
148- const device = store .getters [" devices/getFirstPending" ];
149- try {
150- if (device ) {
151- await store .dispatch (" devices/accept" , device .uid );
152-
153- store .dispatch (" notifications/fetch" );
154- store .dispatch (" stats/get" );
155-
156- el .value = 4 ;
157- }
158- } catch (error : unknown ) {
159- store .dispatch (
160- " snackbar/showSnackbarErrorAction" ,
161- INotificationsError .deviceAccepting ,
162- );
163- handleError (error );
164- }
165- };
103+ });
104+ const emit = defineEmits ([" update" ]);
105+ const store = useStore ();
106+ const el = ref <number >(1 );
107+ const polling = ref <Timer | undefined >(undefined );
108+ const enable = ref (false );
109+ const showWelcome = computed <boolean >({
110+ get() {
111+ return props .show ;
112+ },
113+ set(value ) {
114+ emit (" update" , value );
115+ },
116+ });
166117
167- const command = () => {
168- const port = window .location .port ? ` :${window .location .port } ` : " " ;
169- const { hostname } = window .location ;
118+ const curl = ref ({
119+ hostname: window .location .hostname ,
120+ tenant: store .getters [" auth/tenant" ],
121+ });
170122
171- return ` curl -sSf "${window .location .protocol }//${hostname }${port }/install.sh?tenant_id=${curl .value .tenant }" | sh ` ;
172- };
123+ const pollingDevices = () => {
124+ polling .value = setInterval (async () => {
125+ try {
126+ await store .dispatch (" stats/get" );
173127
174- const close = () => {
175- emit (" update" , false );
176- showWelcome .value = false ;
177- if (polling .value ) {
128+ enable .value = store .getters [" stats/stats" ].pending_devices !== 0 ;
129+ if (enable .value ) {
130+ el .value = 3 ;
178131 clearTimeout (polling .value );
179132 }
180- };
181-
182- const goToPreviousStep = () => {
183- el .value -- ;
184- };
185-
186- const goToNextStep = () => {
187- el .value ++ ;
188- };
189-
190- return {
191- el ,
192- showWelcome ,
193- enable ,
194- polling ,
195- curl ,
196- close ,
197- activePollingDevices ,
198- acceptDevice ,
199- command ,
200- goToPreviousStep ,
201- goToNextStep ,
202- };
203- },
204- components: {
205- WelcomeFirstScreen ,
206- WelcomeSecondScreen ,
207- WelcomeThirdScreen ,
208- WelcomeFourthScreen ,
209- },
210- });
133+ } catch (error : unknown ) {
134+ store .dispatch (" snackbar/showSnackbarErrorDefault" );
135+ handleError (error );
136+ }
137+ }, 3000 );
138+ };
139+
140+ const activePollingDevices = () => {
141+ el .value = 2 ;
142+ pollingDevices ();
143+ };
144+
145+ const acceptDevice = async () => {
146+ const device = store .getters [" devices/getFirstPending" ];
147+ try {
148+ if (device ) {
149+ await store .dispatch (" devices/accept" , device .uid );
150+
151+ store .dispatch (" notifications/fetch" );
152+ store .dispatch (" stats/get" );
153+
154+ el .value = 4 ;
155+ }
156+ } catch (error : unknown ) {
157+ store .dispatch (
158+ " snackbar/showSnackbarErrorAction" ,
159+ INotificationsError .deviceAccepting ,
160+ );
161+ handleError (error );
162+ }
163+ };
164+
165+ const command = () => {
166+ const port = window .location .port ? ` :${window .location .port } ` : " " ;
167+ const { hostname } = window .location ;
168+
169+ return ` curl -sSf "${window .location .protocol }//${hostname }${port }/install.sh?tenant_id=${curl .value .tenant }" | sh ` ;
170+ };
171+
172+ const close = () => {
173+ emit (" update" , false );
174+ showWelcome .value = false ;
175+ if (polling .value ) {
176+ clearTimeout (polling .value );
177+ }
178+ };
179+
180+ const goToPreviousStep = () => {
181+ el .value -- ;
182+ };
183+
184+ const goToNextStep = () => {
185+ el .value ++ ;
186+ };
187+
188+ defineExpose ({ el , goToPreviousStep , goToNextStep , enable });
211189 </script >
0 commit comments