#31 improve setup wizard base
parent
94339ea160
commit
1ad74f7664
@ -0,0 +1,83 @@
|
|||||||
|
<template>
|
||||||
|
<v-container
|
||||||
|
class="_fill-height"
|
||||||
|
fluid
|
||||||
|
>
|
||||||
|
<div v-if="back">
|
||||||
|
<v-btn
|
||||||
|
text
|
||||||
|
color="primary"
|
||||||
|
class="px-0"
|
||||||
|
@click="$emit('back')"
|
||||||
|
>
|
||||||
|
<v-icon>$prev</v-icon>
|
||||||
|
Back
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<v-row
|
||||||
|
no-gutters
|
||||||
|
justify="center"
|
||||||
|
>
|
||||||
|
<v-col
|
||||||
|
lg="5"
|
||||||
|
md="6"
|
||||||
|
sm="8"
|
||||||
|
>
|
||||||
|
<v-card flat>
|
||||||
|
<div
|
||||||
|
v-if="hasIconSlot"
|
||||||
|
class="justify-center text-center"
|
||||||
|
>
|
||||||
|
<v-icon
|
||||||
|
class="my-icon ma-10"
|
||||||
|
>
|
||||||
|
<slot name="icon" />
|
||||||
|
</v-icon>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<v-card-title
|
||||||
|
class="display-1 font-weight-bold mb-12 px-0 justify-center text-center"
|
||||||
|
>
|
||||||
|
<slot name="headline" />
|
||||||
|
</v-card-title>
|
||||||
|
</v-card>
|
||||||
|
|
||||||
|
<slot />
|
||||||
|
|
||||||
|
<v-card-actions
|
||||||
|
v-if="hasActionsSlot"
|
||||||
|
class="flex-column mt-16"
|
||||||
|
>
|
||||||
|
<slot name="actions" />
|
||||||
|
</v-card-actions>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'SetupPanel',
|
||||||
|
props: {
|
||||||
|
back: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
hasIconSlot () {
|
||||||
|
return !!this.$slots.icon
|
||||||
|
},
|
||||||
|
hasActionsSlot () {
|
||||||
|
return !!this.$slots.actions
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
>>> .my-icon > .v-icon__svg {
|
||||||
|
transform: scale(3);
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,81 +1,90 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container
|
<setup-panel
|
||||||
class="_fill-height"
|
back
|
||||||
fluid
|
@back="stepBack"
|
||||||
>
|
>
|
||||||
<v-row
|
<template #icon />
|
||||||
no-gutters
|
<template #headline>
|
||||||
justify="center"
|
Appearance
|
||||||
>
|
</template>
|
||||||
<v-col
|
|
||||||
lg="5"
|
|
||||||
md="6"
|
|
||||||
sm="8"
|
|
||||||
>
|
|
||||||
<v-card flat>
|
|
||||||
<v-card-title class="display-2 mb-12 justify-center text-center">
|
|
||||||
Appearance
|
|
||||||
</v-card-title>
|
|
||||||
|
|
||||||
<v-radio-group
|
<v-radio-group
|
||||||
v-model="settings.device.theme"
|
v-model="form.theme"
|
||||||
row
|
row
|
||||||
>
|
>
|
||||||
<v-radio
|
<v-radio
|
||||||
label="Light"
|
label="Light"
|
||||||
value="white"
|
value="white"
|
||||||
/>
|
/>
|
||||||
<v-radio
|
<v-radio
|
||||||
label="Dark"
|
label="Dark"
|
||||||
value="black"
|
value="black"
|
||||||
/>
|
/>
|
||||||
</v-radio-group>
|
</v-radio-group>
|
||||||
|
|
||||||
<v-card-actions>
|
<template #actions>
|
||||||
<v-btn
|
<v-btn
|
||||||
depressed
|
depressed
|
||||||
block
|
block
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="commitStep()"
|
@click="commitStep()"
|
||||||
>
|
>
|
||||||
Continue
|
Continue
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-actions>
|
</template>
|
||||||
</v-card>
|
</setup-panel>
|
||||||
</v-col>
|
|
||||||
</v-row>
|
|
||||||
</v-container>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import apiDevice from '@/api/device'
|
import { mapState, mapMutations, mapActions } from 'vuex'
|
||||||
|
import SetupPanel from '@/components/SetupPanel'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: { SetupPanel },
|
||||||
data: () => ({
|
data: () => ({
|
||||||
isLoading: true,
|
isProcessing: false,
|
||||||
isSaving: false,
|
form: {
|
||||||
settings: null,
|
theme: '',
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
|
computed: {
|
||||||
|
...mapState([
|
||||||
|
'settings',
|
||||||
|
]),
|
||||||
|
},
|
||||||
created () {
|
created () {
|
||||||
apiDevice.getSettings(settings => {
|
this.resetChanges()
|
||||||
this.settings = settings
|
|
||||||
|
|
||||||
this.isLoading = false
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapMutations(['updateSettings']),
|
||||||
|
...mapActions(['saveSettings']),
|
||||||
|
|
||||||
commitStep () {
|
commitStep () {
|
||||||
this.isSaving = true
|
this.isProcessing = true
|
||||||
|
|
||||||
apiDevice.putSettings({ device: this.settings.device }, () => {
|
this.updateSettings({
|
||||||
this.isSaving = false
|
device: {
|
||||||
|
theme: this.form.theme,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
this.saveSettings().then(() => {
|
||||||
this.nextStep()
|
this.nextStep()
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
|
|
||||||
|
this.nextStep()
|
||||||
|
},
|
||||||
|
resetChanges () {
|
||||||
|
this.form.theme = this.settings.device.theme
|
||||||
},
|
},
|
||||||
nextStep () {
|
nextStep () {
|
||||||
this.$router.push('/setup/done')
|
this.$router.push('/setup/done')
|
||||||
},
|
},
|
||||||
|
stepBack () {
|
||||||
|
this.$router.push('/setup/weather')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,52 +1,48 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container
|
<setup-panel
|
||||||
class="_fill-height"
|
back
|
||||||
fluid
|
@back="stepBack"
|
||||||
>
|
>
|
||||||
<v-card
|
<template #headline>
|
||||||
flat
|
Hello {{ settings.device.name }}
|
||||||
class="mx-auto"
|
</template>
|
||||||
width="540"
|
|
||||||
>
|
|
||||||
<!--<v-card-title class="display-2 mb-12 justify-center text-center">Welcome to paperdash</v-card-title>-->
|
|
||||||
<v-card-title class="display-2 mb-12 justify-center text-center">
|
|
||||||
Hello {{ settings.device.name }}
|
|
||||||
</v-card-title>
|
|
||||||
|
|
||||||
<v-card-actions>
|
<template #actions>
|
||||||
<v-btn
|
<v-btn
|
||||||
outlined
|
outlined
|
||||||
block
|
block
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="onStart"
|
@click="onStart"
|
||||||
>
|
>
|
||||||
Let's start
|
Let's start
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-actions>
|
</template>
|
||||||
</v-card>
|
</setup-panel>
|
||||||
</v-container>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import apiDevice from '@/api/device'
|
import { mapState } from 'vuex'
|
||||||
|
import SetupPanel from '@/components/SetupPanel'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: { SetupPanel },
|
||||||
data: () => ({
|
data: () => ({
|
||||||
isLoading: true,
|
|
||||||
isSaving: false,
|
|
||||||
settings: null,
|
|
||||||
}),
|
}),
|
||||||
|
computed: {
|
||||||
|
...mapState([
|
||||||
|
'settings',
|
||||||
|
]),
|
||||||
|
},
|
||||||
created () {
|
created () {
|
||||||
apiDevice.getSettings(settings => {
|
|
||||||
this.settings = settings
|
|
||||||
|
|
||||||
this.isLoading = false
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onStart () {
|
onStart () {
|
||||||
this.$router.push('/')
|
this.$router.push('/')
|
||||||
},
|
},
|
||||||
|
stepBack () {
|
||||||
|
this.$router.push('/setup/appearance')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,127 +1,123 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container
|
<setup-panel
|
||||||
class="_fill-height"
|
back
|
||||||
fluid
|
@back="stepBack"
|
||||||
>
|
>
|
||||||
<v-row
|
<template #icon>
|
||||||
no-gutters
|
$wb_sunny
|
||||||
justify="center"
|
</template>
|
||||||
>
|
<template #headline>
|
||||||
<v-col
|
Weather
|
||||||
lg="5"
|
</template>
|
||||||
md="6"
|
|
||||||
sm="8"
|
|
||||||
>
|
|
||||||
<v-card flat>
|
|
||||||
<div class="justify-center text-center">
|
|
||||||
<v-icon
|
|
||||||
view-box="0 0 24 24"
|
|
||||||
style="width: 64px; height: 64px; fill: #FF9800"
|
|
||||||
>
|
|
||||||
$wb_sunny
|
|
||||||
</v-icon>
|
|
||||||
</div>
|
|
||||||
<v-card-title class="display-2 mb-12 justify-center text-center">
|
|
||||||
Weather
|
|
||||||
</v-card-title>
|
|
||||||
|
|
||||||
<v-skeleton-loader
|
|
||||||
v-if="isLoading"
|
|
||||||
type="list-item-two-line,list-item-two-line"
|
|
||||||
class="mx-auto"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<template v-else>
|
<v-text-field
|
||||||
<v-card-text>
|
v-model="form.api"
|
||||||
<v-text-field
|
label="OpenWeatherMap API key"
|
||||||
v-model="settings.weather.api"
|
>
|
||||||
label="i8n:OpenWeatherMap API key"
|
<template #append-outer>
|
||||||
>
|
<v-icon @click="registerApiKey()">
|
||||||
<template #append-outer>
|
$open_in_new
|
||||||
<v-icon @click="registerApiKey()">
|
</v-icon>
|
||||||
$open_in_new
|
</template>
|
||||||
</v-icon>
|
</v-text-field>
|
||||||
</template>
|
|
||||||
</v-text-field>
|
|
||||||
|
|
||||||
<weather-find-location
|
<weather-find-location
|
||||||
:api="settings.weather.api"
|
:api="form.api"
|
||||||
:location.sync="settings.weather.location"
|
:location.sync="form.location"
|
||||||
:lang="lang"
|
:search.sync="form.name"
|
||||||
:unit="unit"
|
:lang="lang"
|
||||||
/>
|
:unit="unit"
|
||||||
</v-card-text>
|
/>
|
||||||
|
|
||||||
<v-card-actions class="flex-column">
|
<template #actions>
|
||||||
<v-btn
|
<v-btn
|
||||||
:disabled="!isLocationValid"
|
:disabled="!isLocationValid"
|
||||||
depressed
|
depressed
|
||||||
block
|
block
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="commitStep()"
|
@click="commitStep()"
|
||||||
>
|
>
|
||||||
Continue
|
Continue
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn
|
<v-btn
|
||||||
class="ma-0 mt-3"
|
class="ma-0 mt-3"
|
||||||
text
|
text
|
||||||
block
|
block
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="nextStep()"
|
@click="nextStep()"
|
||||||
>
|
>
|
||||||
Set Up Later in Settings
|
Set Up Later in Settings
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-actions>
|
</template>
|
||||||
</template>
|
</setup-panel>
|
||||||
</v-card>
|
|
||||||
</v-col>
|
|
||||||
</v-row>
|
|
||||||
</v-container>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import apiDevice from '@/api/device'
|
import { mapState, mapMutations, mapActions } from 'vuex'
|
||||||
import weatherFindLocation from '@/components/WeatherFindLocation'
|
import weatherFindLocation from '@/components/WeatherFindLocation'
|
||||||
|
import SetupPanel from '@/components/SetupPanel'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
SetupPanel,
|
||||||
weatherFindLocation,
|
weatherFindLocation,
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
isLoading: true,
|
form: {
|
||||||
settings: null,
|
api: '',
|
||||||
|
name: '',
|
||||||
|
location: 0,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState([
|
||||||
|
'settings',
|
||||||
|
]),
|
||||||
lang () {
|
lang () {
|
||||||
return this.settings.language || 'EN'
|
return this.settings.weather.language || 'EN'
|
||||||
},
|
},
|
||||||
unit () {
|
unit () {
|
||||||
return this.settings.language === 'EN' ? '' : 'metric'
|
return this.lang === 'EN' ? '' : 'metric'
|
||||||
},
|
},
|
||||||
isLocationValid () {
|
isLocationValid () {
|
||||||
return this.settings.weather.location > 0
|
return this.settings.weather.location > 0
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
apiDevice.getSettings(settings => {
|
this.resetChanges()
|
||||||
this.settings = settings
|
|
||||||
|
|
||||||
this.isLoading = false
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapMutations(['updateSettings']),
|
||||||
|
...mapActions(['saveSettings']),
|
||||||
|
|
||||||
commitStep () {
|
commitStep () {
|
||||||
// TODO sav
|
this.updateSettings({
|
||||||
|
weather: {
|
||||||
|
api: this.form.api,
|
||||||
|
name: this.form.name,
|
||||||
|
location: this.form.location,
|
||||||
|
lang: this.lang,
|
||||||
|
unit: this.unit,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
this.nextStep()
|
this.nextStep()
|
||||||
},
|
},
|
||||||
|
resetChanges () {
|
||||||
|
this.form.api = this.settings.weather.api
|
||||||
|
this.form.location = this.settings.weather.location
|
||||||
|
this.form.name = this.settings.weather.name
|
||||||
|
},
|
||||||
nextStep () {
|
nextStep () {
|
||||||
this.$router.push('/setup/name')
|
this.$router.push('/setup/name')
|
||||||
},
|
},
|
||||||
registerApiKey () {
|
registerApiKey () {
|
||||||
window.open('http://openweathermap.org/')
|
window.open('http://openweathermap.org/')
|
||||||
},
|
},
|
||||||
|
stepBack () {
|
||||||
|
this.$router.push('/setup/')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue