fixed errors, persist save of server (cordova)
This commit is contained in:
		
							parent
							
								
									797f7dd67a
								
							
						
					
					
						commit
						feaeb3f4e4
					
				|  | @ -3,6 +3,9 @@ import { boot } from 'quasar/wrappers'; | |||
| import config from '../config'; | ||||
| import { Store } from 'vuex'; | ||||
| import { StateInterface } from 'src/store'; | ||||
| import { LocalStorage } from 'quasar'; | ||||
| import {Notify} from 'quasar'; | ||||
| import {Router} from 'src/router'; | ||||
| 
 | ||||
| declare module 'vue/types/vue' { | ||||
|   interface Vue { | ||||
|  | @ -11,14 +14,27 @@ declare module 'vue/types/vue' { | |||
| } | ||||
| 
 | ||||
| export const setBaseUrl = (url: string) => { | ||||
|   LocalStorage.set('baseURL', url); | ||||
|   axios.defaults.baseURL = url; | ||||
|   Notify.create({ | ||||
|     message: "Serveraddresse gespeichert", | ||||
|     position: "bottom", | ||||
|     caption: `${url}`, | ||||
|     color: "positive" | ||||
|   }) | ||||
|   setTimeout(() => {window.location.reload()}, 5000) | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| export default boot<Store<StateInterface>>(({ Vue, store, router }) => { | ||||
|   // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
 | ||||
|   Vue.prototype.$axios = axios; | ||||
|   axios.defaults.baseURL = config.baseURL; | ||||
| 
 | ||||
|   const baseURL = <string | undefined>LocalStorage.getItem('baseURL'); | ||||
|   if (baseURL){ | ||||
|     axios.defaults.baseURL = baseURL | ||||
|   } else { | ||||
|     axios.defaults.baseURL = config.baseURL; | ||||
|   } | ||||
|   /*** | ||||
|    * Intercept requests and insert Token if available | ||||
|    */ | ||||
|  |  | |||
|  | @ -43,7 +43,7 @@ interface Props { | |||
|   label?: string; | ||||
|   readonly: boolean; | ||||
|   type: string; | ||||
|   rules: Array<any>; | ||||
|   rules: Array<string>; | ||||
| } | ||||
| 
 | ||||
| export default defineComponent({ | ||||
|  |  | |||
|  | @ -35,17 +35,25 @@ | |||
|             <q-btn label="Login" type="submit" color="primary" tabindex="3" /> | ||||
|           </div> | ||||
|         </q-form> | ||||
| 
 | ||||
|       </q-card-section> | ||||
|       <div class="row justify-end"> | ||||
|       <q-btn flat round icon="mdi-menu-down" class="cordova-only" @click="openServerSettings"/> | ||||
|       </div> | ||||
|         <q-slide-transition class="cordova-only"> | ||||
| 
 | ||||
|           <div v-show="visible"> | ||||
|       <q-separator /> | ||||
|       <q-card-section> | ||||
|         <q-separator class="q-mt-sm"/> | ||||
|         <div class="cordova-only q-my-sm"> | ||||
|           <div class="text-h6">Serversettings</div> | ||||
|         <q-form ref="ServerSettingsForm" @submit="changeUrl" class="q-gutter-md"> | ||||
|           <div class="text-h6">Servereinstellung</div> | ||||
|           <q-input filled label="Server" dense v-model="server" /> | ||||
|         </div> | ||||
|         <q-btn size="xs" dense color="primary" label="Speichern" type="submit" /> | ||||
|         </q-form> | ||||
|       </q-card-section> | ||||
|       <q-card-actions align="right"> | ||||
|         <q-btn dense color="primary" label="Speichern" @click="changeUrl" /> | ||||
|       </q-card-actions> | ||||
| 
 | ||||
|           </div> | ||||
|       </q-slide-transition> | ||||
|     </q-card> | ||||
|   </q-page> | ||||
| </template> | ||||
|  | @ -65,6 +73,11 @@ export default defineComponent({ | |||
|     const password = ref(''); | ||||
|     const rules = [(val: string) => (val && val.length > 0) || 'Feld darf nicht leer sein!']; | ||||
|     const server = ref<string|undefined>(root.$axios.defaults.baseURL) | ||||
|     const visible = ref(false); | ||||
| 
 | ||||
|     function openServerSettings() { | ||||
|       visible.value = !visible.value | ||||
|     } | ||||
| 
 | ||||
|     function changeUrl() { | ||||
|       if (server.value) { | ||||
|  | @ -134,7 +147,7 @@ export default defineComponent({ | |||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     return { userid, password, doLogin, doReset, rules, server, changeUrl }; | ||||
|     return { userid, password, doLogin, doReset, rules, server, changeUrl, visible, openServerSettings }; | ||||
|   } | ||||
| }); | ||||
| </script> | ||||
|  |  | |||
|  | @ -45,12 +45,12 @@ | |||
|             <job | ||||
|               :job="job" | ||||
|               :jobCanDelete="jobDeleteDisabled" | ||||
|               @setStart="setStart" | ||||
|               @setRequired="setRequired" | ||||
|               @setEnd="setEnd" | ||||
|               @setComment="setComment" | ||||
|               @setJobType="setJobType" | ||||
|               @removeJob="removeJob(index)" | ||||
|               @set-start="setStart" | ||||
|               @set-required="setRequired" | ||||
|               @set-end="setEnd" | ||||
|               @set-comment="setComment" | ||||
|               @set-job-type="setJobType" | ||||
|               @remove-job="removeJob(index)" | ||||
|             /> | ||||
|           </q-card> | ||||
|         </q-card-section> | ||||
|  | @ -149,7 +149,7 @@ export default defineComponent({ | |||
|       event.value.id = NaN; | ||||
|       event.value.start = new Date(); | ||||
|       event.value.description = ''; | ||||
|       delete event.value['type']; | ||||
|       event.value.type = {id: -1, name: ''}; | ||||
|       event.value.jobs = [Object.assign({}, newJob.value)]; | ||||
|     } | ||||
|     function notEmpty(val: string) { | ||||
|  |  | |||
|  | @ -89,33 +89,33 @@ export default defineComponent({ | |||
| 
 | ||||
|     function setStart(value: Date) { | ||||
|       // eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||||
|       emit('setStart', { job: props.job, value }); | ||||
|       emit('set-start', { job: props.job, value }); | ||||
|     } | ||||
| 
 | ||||
|     function setEnd(value: Date) { | ||||
|       // eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||||
|       emit('setEnd', { job: props.job, value }); | ||||
|       emit('set-end', { job: props.job, value }); | ||||
|     } | ||||
| 
 | ||||
|     function setComment(value: string) { | ||||
|       // eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||||
|       emit('setComment', { job: props.job, value }); | ||||
|       emit('set-comment', { job: props.job, value }); | ||||
|     } | ||||
| 
 | ||||
|     function setJobType(value: FG.JobType) { | ||||
|       // eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||||
|       console.log('setJobType', value); | ||||
|       emit('setJobType', { job: props.job, value }); | ||||
|       emit('set-job-type', { job: props.job, value }); | ||||
|     } | ||||
| 
 | ||||
|     function setRequired(value: number) { | ||||
|       // eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||||
|       emit('setRequired', { job: props.job, value }); | ||||
|       emit('set-required', { job: props.job, value }); | ||||
|     } | ||||
| 
 | ||||
|     function removeJob() { | ||||
|       // eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||||
|       emit('removeJob'); | ||||
|       emit('remove-job'); | ||||
|     } | ||||
| 
 | ||||
|     function notEmpty(val: string) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue