Files
PhotonVision/photon-client/src/views/SettingsView.vue

126 lines
3.2 KiB
Vue
Raw Normal View History

2019-09-20 20:56:24 +03:00
<template>
<div>
<v-row
class="pa-3"
no-gutters
>
<v-col
cols="12"
style="max-width: 1400px"
>
<v-form
ref="form"
v-model="valid"
>
<v-card
v-for="item in tabList"
:key="item.name"
dark
class="mb-3 pr-6 pb-3"
style="background-color: #006492;"
>
<v-card-title>{{ item.name }}</v-card-title>
<component
:is="item"
class="ml-5"
/>
</v-card>
<v-btn
color="accent"
style="color: black; width: 100%;"
:disabled="!valid"
@click="sendGeneralSettings()"
>
Save
</v-btn>
</v-form>
</v-col>
</v-row>
<v-snackbar
v-model="snack"
top
:color="snackbar.color"
>
<span>{{ snackbar.text }}</span>
</v-snackbar>
</div>
2019-09-20 20:56:24 +03:00
</template>
<script>
import Networking from './SettingsViews/Networking'
import Lighting from "./SettingsViews/Lighting";
import cvImage from '../components/common/cv-image'
import General from "./SettingsViews/General";
2019-10-02 23:37:35 +03:00
2019-09-20 20:56:24 +03:00
export default {
2019-09-22 00:14:12 +03:00
name: 'SettingsTab',
2019-10-29 23:58:06 +02:00
components: {
cvImage,
// General,
2019-09-28 21:42:04 +03:00
},
2019-09-20 20:56:24 +03:00
data() {
return {
2019-10-29 23:58:06 +02:00
selectedTab: 0,
valid: true, // Are all settings valid
snack: false,
snackbar: {
color: "accent",
text: ""
},
2019-09-28 21:42:04 +03:00
}
},
2019-10-29 23:58:06 +02:00
computed: {
selectedComponent: {
get() {
return this.tabList[this.selectedTab];
2019-09-28 21:42:04 +03:00
}
2019-10-02 22:07:04 +03:00
},
settings: {
get() {
return this.$store.state.settings;
}
},
tabList: {
get() {
return [General, Networking].concat(this.$store.state.settings.lighting.supported ? Lighting : []);
}
}
},
methods: {
sendGeneralSettings() {
const self = this;
this.axios.post("http://" + this.$address + "/api/settings/general", this.settings).then(
function (response) {
if (response.status === 200) {
self.snackbar = {
color: "success",
text: "Settings updated successfully"
};
self.snack = true;
}
},
function (error) {
self.snackbar = {
color: "error",
text: (error.response || {data: "Couldn't save settings"}).data
};
self.snack = true;
}
)
},
2019-09-20 20:56:24 +03:00
}
}
</script>
<style scoped>
2019-10-29 23:58:06 +02:00
.videoClass {
2019-10-02 23:37:35 +03:00
text-align: center;
}
2019-10-29 23:58:06 +02:00
.videoClass img {
padding-top: 10px;
2019-10-02 23:37:35 +03:00
height: auto !important;
vertical-align: middle;
}
2019-09-20 20:56:24 +03:00
</style>