11<template >
22 <view-layout >
3- <v-card color =" primary" class =" d-flex justify-center items-center mt-3 pa-3 text-center" >
4- <v-icon size =" 30" class =" pr-3" >mdi-cog</v-icon >
5- <v-card-title class =" pa-0" >Settings</v-card-title >
3+ <v-card
4+ color =" primary"
5+ class =" d-flex justify-center items-center mt-3 pa-3 text-center"
6+ >
7+ <v-icon
8+ size =" 30"
9+ class =" pr-3"
10+ >
11+ mdi-cog
12+ </v-icon >
13+ <v-card-title class =" pa-0" >
14+ Settings
15+ </v-card-title >
616 </v-card >
7- <v-card class =" my-5"
8- > <v-card-title >Theme</v-card-title > <v-card-text >Pick an application theme!</v-card-text >
17+ <v-card class =" my-5" >
18+ <v-card-title >Theme</v-card-title > <v-card-text >Pick an application theme!</v-card-text >
919
10- <v-select class =" pa-3 capitalize" :items =" themes" v-model =" selectedTheme" />
20+ <v-select
21+ v-model =" selectedTheme"
22+ class =" pa-3 capitalize"
23+ :items =" themes"
24+ />
1125
1226 <v-card-actions class =" justify-end mb-3 mx-3" >
13- <v-btn :disabled =" isCurrentTheme()" @click =" UpdateTheme" class =" justify-end ml-auto"
14- >Update</v-btn
15- ></v-card-actions
16- >
27+ <v-btn
28+ :disabled =" isCurrentTheme()"
29+ class =" justify-end ml-auto"
30+ @click =" UpdateTheme"
31+ >
32+ Update
33+ </v-btn >
34+ </v-card-actions >
1735 </v-card >
18- <v-card class =" my-5"
19- ><v-card-title >Password</v-card-title > <v-card-text >Change your password</v-card-text >
20- <form-validator ref =" passFormRef" v-model =" isValidPassword" >
36+ <v-card class =" my-5" >
37+ <v-card-title >Password</v-card-title > <v-card-text >Change your password</v-card-text >
38+ <form-validator
39+ ref =" passFormRef"
40+ v-model =" isValidPassword"
41+ >
2142 <PasswordInputWrapper #=" { props: passwordInputProps } " >
2243 <InputValidator
23- default-value=""
2444 v-model :value =" currentPassword "
45+ default-value=""
2546 :rules =" [
2647 validators .required (' Password is required.' ),
2748 validators .minLength (' Password must be at least 6 characters.' , 6 ),
3051 #=" { props: validationProps } "
3152 >
3253 <VTextField
33- label="Current Password"
3454 v-model =" currentPassword "
55+ label="Current Password"
3556 v-bind =" { ... passwordInputProps , ... validationProps } "
3657 autocomplete="off"
3758 class="pa-3"
4263
4364 <PasswordInputWrapper #=" { props: passwordInputProps } " >
4465 <InputValidator
45- default-value=""
4666 v-model :value =" newPassword "
67+ default-value=""
4768 :rules =" [
4869 validators .required (' Password is required.' ),
4970 validators .minLength (' Password must be at least 6 characters.' , 6 ),
5576 #=" { props: validationProps } "
5677 >
5778 <VTextField
58- label="New Password"
5979 v-model =" newPassword "
80+ label="New Password"
6081 v-bind =" { ... passwordInputProps , ... validationProps } "
6182 autocomplete="off"
6283 class="pa-3"
6687 </PasswordInputWrapper >
6788 <PasswordInputWrapper #=" { props: confirmPasswordInputProps } " >
6889 <InputValidator
69- default-value=" "
90+ ref="confirmPasswordInput "
7091 v-model :value =" confirmPassword "
92+ default-value=""
7193 :rules =" [
7294 validators .required (' A confirmation password is required.' ),
7395 validators .validateConfirmPassword (' Passwords should match.' , newPassword ),
7496 ] "
7597 #=" { props: validationProps } "
76- ref="confirmPasswordInput"
7798 >
7899 <VTextField
79- label="Confirm Password"
80100 v-model =" confirmPassword "
101+ label="Confirm Password"
81102 v-bind =" {
82103 ... confirmPasswordInputProps ,
83104 ... validationProps ,
90111 </PasswordInputWrapper >
91112 </form-validator >
92113 <v-card-actions class =" justify-end mb-3 mx-3" >
93- <v-btn :disabled =" !isValidPassword" @click =" UpdatePassword" class =" justify-end ml-auto"
94- >Update</v-btn
95- ></v-card-actions
96- >
114+ <v-btn
115+ :disabled =" !isValidPassword"
116+ class =" justify-end ml-auto"
117+ @click =" UpdatePassword"
118+ >
119+ Update
120+ </v-btn >
121+ </v-card-actions >
97122 </v-card >
98- <v-card class =" my-5"
99- > <v-card-title >Timeout</v-card-title >
123+ <v-card class =" my-5" >
124+ <v-card-title >Timeout</v-card-title >
100125
101126 <form-validator v-model =" isValidTimeout" >
102127 <v-card-text >
103128 Adjust Query Timeout
104129 <v-tooltip location =" end" >
105130 <template #activator =" { props: tooltipProps } " >
106- <v-icon v-bind =" tooltipProps" > mdi-information-outline </v-icon >
131+ <v-icon v-bind =" tooltipProps" >
132+ mdi-information-outline
133+ </v-icon >
107134 </template >
108135 <span >Set desired queries timeout in seconds</span >
109136 </v-tooltip >
110137 </v-card-text >
111138
112139 <input-validator
140+ ref =" timeoutQueryInput"
113141 :value =" selectedQueryTimeout"
114142 :rules =" [
115143 validators.required('Query timeout is required.'),
118146 validators.max('Query timeout maximum limit is 180 seconds', 3 * 60),
119147 ]"
120148 # =" { props }"
121- ref =" timeoutQueryInput"
122149 >
123150 <v-text-field
151+ v-bind =" props"
152+ v-model =" selectedQueryTimeout"
124153 label =" Enter Query timeout (sec)"
125154 class =" pa-3"
126- v-bind =" props"
127155 type =" number"
128- v-model =" selectedQueryTimeout"
129156 hide-details =" auto"
130- ></ v-text-field >
157+ / >
131158 </input-validator >
132159
133160 <v-card-text >
134161 Adjust Deployment Timeout
135162 <v-tooltip location =" end" >
136163 <template #activator =" { props: tooltipProps } " >
137- <v-icon v-bind =" tooltipProps" > mdi-information-outline </v-icon >
164+ <v-icon v-bind =" tooltipProps" >
165+ mdi-information-outline
166+ </v-icon >
138167 </template >
139168 <span >Set desired deployment timeout in seconds</span >
140169 </v-tooltip >
141170 </v-card-text >
142171 <input-validator
172+ ref =" timeoutDeploymentInput"
143173 :value =" selectedDeploymentTimeout"
144174 :rules =" [
145175 validators.required('Deployment timeout is required.'),
148178 validators.max('Deployment timeout maximum limit is 1800 seconds', 30 * 60),
149179 ]"
150180 # =" { props }"
151- ref =" timeoutDeploymentInput"
152181 >
153182 <v-text-field
183+ v-bind =" props"
184+ v-model =" selectedDeploymentTimeout"
154185 label =" Enter Deployment timeout (sec)"
155186 class =" pa-3"
156- v-bind =" props"
157187 type =" number"
158- v-model =" selectedDeploymentTimeout"
159188 hide-details =" auto"
160- ></ v-text-field >
189+ / >
161190 </input-validator >
162191 <v-card-actions class =" justify-end mb-3 mx-3" >
163- <v-tooltip location =" top" >
164- <template #activator =" { props: tooltipProps } " >
165- <v-btn @click =" ResetTimeoutToDefault" class =" mr-2" v-bind =" tooltipProps" >Set Default Values</v-btn >
166- </template >
167- <span >Sets query timeout to 30s and deployment timeout to 300s. Click Update to apply.</span >
168- </v-tooltip >
169- <v-btn :disabled =" !isValidTimeout || isCurrentTimeout()" @click =" UpdateTimeout" class =" justify-end"
170- >Update</v-btn
171- ></v-card-actions
172- >
192+ <div class =" d-inline-block" >
193+ <v-tooltip location =" top" >
194+ <template #activator =" { props: tooltipProps } " >
195+ <span v-bind =" tooltipProps" >
196+ <v-btn
197+ :disabled =" isOnDefaultTimeout"
198+ class =" mr-2"
199+ @click =" ResetTimeoutToDefault"
200+ >Set Default Values</v-btn >
201+ </span >
202+ </template >
203+ <span v-if =" isOnDefaultTimeout" >Values are already set to defaults (query: 120s, deployment: 600s)</span >
204+ <span v-else >Sets query timeout to 120s and deployment timeout to 600s. Click Update to apply.</span >
205+ </v-tooltip >
206+ </div >
207+ <v-btn
208+ :disabled =" !isValidTimeout || isCurrentTimeout()"
209+ class =" justify-end"
210+ @click =" UpdateTimeout"
211+ >
212+ Update
213+ </v-btn >
214+ </v-card-actions >
173215 </form-validator >
174216 </v-card >
175217 </view-layout >
176218</template >
177219<script lang="ts">
178220import type { GridClient } from " @threefold/grid_client" ;
179- import { nextTick , onMounted , ref , watch } from " vue" ;
221+ import { nextTick , onMounted , ref , watch , computed } from " vue" ;
180222import { useTheme } from " vuetify" ;
181223
182224import { useFormRef } from " @/hooks/form_validator" ;
@@ -196,6 +238,8 @@ import { updateCredentials } from "../utils/credentials";
196238export default {
197239 name: " Settings" ,
198240 setup() {
241+ const DEFAULT_QUERY_TIMEOUT = 120 ;
242+ const DEFAULT_DEPLOYMENT_TIMEOUT = 600 ;
199243 const theme = useTheme ();
200244
201245 const themes: string [] = [ThemeInterface .Dark , ThemeInterface .Light , ThemeInterface .System ];
@@ -296,10 +340,15 @@ export default {
296340 // This function only resets the input field values to defaults.
297341 // User still needs to click Update button to apply these changes.
298342 function ResetTimeoutToDefault() {
299- selectedQueryTimeout .value = 120 ;
300- selectedDeploymentTimeout .value = 600 ;
343+ selectedQueryTimeout .value = DEFAULT_QUERY_TIMEOUT ;
344+ selectedDeploymentTimeout .value = DEFAULT_DEPLOYMENT_TIMEOUT ;
301345 }
302-
346+ const isOnDefaultTimeout = computed (() => {
347+ return (
348+ selectedQueryTimeout .value == DEFAULT_QUERY_TIMEOUT &&
349+ selectedDeploymentTimeout .value == DEFAULT_DEPLOYMENT_TIMEOUT
350+ );
351+ });
303352 async function UpdateTimeout() {
304353 try {
305354 const client = gridStore .client as GridClient ;
@@ -348,6 +397,7 @@ export default {
348397 UpdatePassword ,
349398 UpdateTimeout ,
350399 ResetTimeoutToDefault ,
400+ isOnDefaultTimeout ,
351401 isCurrentTheme ,
352402 isCurrentTimeout ,
353403 confirmPasswordInput ,
0 commit comments