#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>
|
||||
<v-container
|
||||
class="_fill-height"
|
||||
fluid
|
||||
<setup-panel
|
||||
back
|
||||
@back="stepBack"
|
||||
>
|
||||
<v-row
|
||||
no-gutters
|
||||
justify="center"
|
||||
>
|
||||
<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>
|
||||
<template #icon />
|
||||
<template #headline>
|
||||
Appearance
|
||||
</template>
|
||||
|
||||
<v-radio-group
|
||||
v-model="settings.device.theme"
|
||||
row
|
||||
>
|
||||
<v-radio
|
||||
label="Light"
|
||||
value="white"
|
||||
/>
|
||||
<v-radio
|
||||
label="Dark"
|
||||
value="black"
|
||||
/>
|
||||
</v-radio-group>
|
||||
<v-radio-group
|
||||
v-model="form.theme"
|
||||
row
|
||||
>
|
||||
<v-radio
|
||||
label="Light"
|
||||
value="white"
|
||||
/>
|
||||
<v-radio
|
||||
label="Dark"
|
||||
value="black"
|
||||
/>
|
||||
</v-radio-group>
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn
|
||||
depressed
|
||||
block
|
||||
color="primary"
|
||||
@click="commitStep()"
|
||||
>
|
||||
Continue
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
<template #actions>
|
||||
<v-btn
|
||||
depressed
|
||||
block
|
||||
color="primary"
|
||||
@click="commitStep()"
|
||||
>
|
||||
Continue
|
||||
</v-btn>
|
||||
</template>
|
||||
</setup-panel>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import apiDevice from '@/api/device'
|
||||
import { mapState, mapMutations, mapActions } from 'vuex'
|
||||
import SetupPanel from '@/components/SetupPanel'
|
||||
|
||||
export default {
|
||||
components: { SetupPanel },
|
||||
data: () => ({
|
||||
isLoading: true,
|
||||
isSaving: false,
|
||||
settings: null,
|
||||
isProcessing: false,
|
||||
form: {
|
||||
theme: '',
|
||||
},
|
||||
}),
|
||||
computed: {
|
||||
...mapState([
|
||||
'settings',
|
||||
]),
|
||||
},
|
||||
created () {
|
||||
apiDevice.getSettings(settings => {
|
||||
this.settings = settings
|
||||
|
||||
this.isLoading = false
|
||||
})
|
||||
this.resetChanges()
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['updateSettings']),
|
||||
...mapActions(['saveSettings']),
|
||||
|
||||
commitStep () {
|
||||
this.isSaving = true
|
||||
this.isProcessing = true
|
||||
|
||||
apiDevice.putSettings({ device: this.settings.device }, () => {
|
||||
this.isSaving = false
|
||||
this.updateSettings({
|
||||
device: {
|
||||
theme: this.form.theme,
|
||||
},
|
||||
})
|
||||
|
||||
/*
|
||||
this.saveSettings().then(() => {
|
||||
this.nextStep()
|
||||
})
|
||||
*/
|
||||
|
||||
this.nextStep()
|
||||
},
|
||||
resetChanges () {
|
||||
this.form.theme = this.settings.device.theme
|
||||
},
|
||||
nextStep () {
|
||||
this.$router.push('/setup/done')
|
||||
},
|
||||
stepBack () {
|
||||
this.$router.push('/setup/weather')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
@ -1,52 +1,48 @@
|
||||
<template>
|
||||
<v-container
|
||||
class="_fill-height"
|
||||
fluid
|
||||
<setup-panel
|
||||
back
|
||||
@back="stepBack"
|
||||
>
|
||||
<v-card
|
||||
flat
|
||||
class="mx-auto"
|
||||
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>
|
||||
<template #headline>
|
||||
Hello {{ settings.device.name }}
|
||||
</template>
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn
|
||||
outlined
|
||||
block
|
||||
color="primary"
|
||||
@click="onStart"
|
||||
>
|
||||
Let's start
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-container>
|
||||
<template #actions>
|
||||
<v-btn
|
||||
outlined
|
||||
block
|
||||
color="primary"
|
||||
@click="onStart"
|
||||
>
|
||||
Let's start
|
||||
</v-btn>
|
||||
</template>
|
||||
</setup-panel>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import apiDevice from '@/api/device'
|
||||
import { mapState } from 'vuex'
|
||||
import SetupPanel from '@/components/SetupPanel'
|
||||
|
||||
export default {
|
||||
components: { SetupPanel },
|
||||
data: () => ({
|
||||
isLoading: true,
|
||||
isSaving: false,
|
||||
settings: null,
|
||||
}),
|
||||
computed: {
|
||||
...mapState([
|
||||
'settings',
|
||||
]),
|
||||
},
|
||||
created () {
|
||||
apiDevice.getSettings(settings => {
|
||||
this.settings = settings
|
||||
|
||||
this.isLoading = false
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
onStart () {
|
||||
this.$router.push('/')
|
||||
},
|
||||
stepBack () {
|
||||
this.$router.push('/setup/appearance')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
@ -1,127 +1,123 @@
|
||||
<template>
|
||||
<v-container
|
||||
class="_fill-height"
|
||||
fluid
|
||||
<setup-panel
|
||||
back
|
||||
@back="stepBack"
|
||||
>
|
||||
<v-row
|
||||
no-gutters
|
||||
justify="center"
|
||||
>
|
||||
<v-col
|
||||
lg="5"
|
||||
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 #icon>
|
||||
$wb_sunny
|
||||
</template>
|
||||
<template #headline>
|
||||
Weather
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<v-card-text>
|
||||
<v-text-field
|
||||
v-model="settings.weather.api"
|
||||
label="i8n:OpenWeatherMap API key"
|
||||
>
|
||||
<template #append-outer>
|
||||
<v-icon @click="registerApiKey()">
|
||||
$open_in_new
|
||||
</v-icon>
|
||||
</template>
|
||||
</v-text-field>
|
||||
<v-text-field
|
||||
v-model="form.api"
|
||||
label="OpenWeatherMap API key"
|
||||
>
|
||||
<template #append-outer>
|
||||
<v-icon @click="registerApiKey()">
|
||||
$open_in_new
|
||||
</v-icon>
|
||||
</template>
|
||||
</v-text-field>
|
||||
|
||||
<weather-find-location
|
||||
:api="settings.weather.api"
|
||||
:location.sync="settings.weather.location"
|
||||
:lang="lang"
|
||||
:unit="unit"
|
||||
/>
|
||||
</v-card-text>
|
||||
<weather-find-location
|
||||
:api="form.api"
|
||||
:location.sync="form.location"
|
||||
:search.sync="form.name"
|
||||
:lang="lang"
|
||||
:unit="unit"
|
||||
/>
|
||||
|
||||
<v-card-actions class="flex-column">
|
||||
<v-btn
|
||||
:disabled="!isLocationValid"
|
||||
depressed
|
||||
block
|
||||
color="primary"
|
||||
@click="commitStep()"
|
||||
>
|
||||
Continue
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="ma-0 mt-3"
|
||||
text
|
||||
block
|
||||
color="primary"
|
||||
@click="nextStep()"
|
||||
>
|
||||
Set Up Later in Settings
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</template>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
<template #actions>
|
||||
<v-btn
|
||||
:disabled="!isLocationValid"
|
||||
depressed
|
||||
block
|
||||
color="primary"
|
||||
@click="commitStep()"
|
||||
>
|
||||
Continue
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="ma-0 mt-3"
|
||||
text
|
||||
block
|
||||
color="primary"
|
||||
@click="nextStep()"
|
||||
>
|
||||
Set Up Later in Settings
|
||||
</v-btn>
|
||||
</template>
|
||||
</setup-panel>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import apiDevice from '@/api/device'
|
||||
import { mapState, mapMutations, mapActions } from 'vuex'
|
||||
import weatherFindLocation from '@/components/WeatherFindLocation'
|
||||
import SetupPanel from '@/components/SetupPanel'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SetupPanel,
|
||||
weatherFindLocation,
|
||||
},
|
||||
data: () => ({
|
||||
isLoading: true,
|
||||
settings: null,
|
||||
form: {
|
||||
api: '',
|
||||
name: '',
|
||||
location: 0,
|
||||
},
|
||||
}),
|
||||
computed: {
|
||||
...mapState([
|
||||
'settings',
|
||||
]),
|
||||
lang () {
|
||||
return this.settings.language || 'EN'
|
||||
return this.settings.weather.language || 'EN'
|
||||
},
|
||||
unit () {
|
||||
return this.settings.language === 'EN' ? '' : 'metric'
|
||||
return this.lang === 'EN' ? '' : 'metric'
|
||||
},
|
||||
isLocationValid () {
|
||||
return this.settings.weather.location > 0
|
||||
},
|
||||
},
|
||||
created () {
|
||||
apiDevice.getSettings(settings => {
|
||||
this.settings = settings
|
||||
|
||||
this.isLoading = false
|
||||
})
|
||||
this.resetChanges()
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapMutations(['updateSettings']),
|
||||
...mapActions(['saveSettings']),
|
||||
|
||||
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()
|
||||
},
|
||||
resetChanges () {
|
||||
this.form.api = this.settings.weather.api
|
||||
this.form.location = this.settings.weather.location
|
||||
this.form.name = this.settings.weather.name
|
||||
},
|
||||
nextStep () {
|
||||
this.$router.push('/setup/name')
|
||||
},
|
||||
registerApiKey () {
|
||||
window.open('http://openweathermap.org/')
|
||||
},
|
||||
stepBack () {
|
||||
this.$router.push('/setup/')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue