Skip to content

Commit

Permalink
add config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Nov 29, 2018
1 parent 5411ccd commit d3d6f99
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 30 deletions.
31 changes: 23 additions & 8 deletions dashboard/src/pages/Settings.vue
Expand Up @@ -2,27 +2,42 @@
<v-layout>
<v-flex md8="md8">
<v-form>
<v-text-field v-model="name" :counter="10" label="Name" required></v-text-field>
<v-text-field v-model="email" label="E-mail" required></v-text-field>
<v-switch label="Developer Mode" v-model="config.developerMode">
</v-switch>
<v-text-field v-model="config.endpoint" label="Endpoint" required></v-text-field>
</v-form>
</v-flex>
<v-flex md4="md4">
</v-flex>
<v-flex md4="md4"></v-flex>
<v-btn primary @click="writeConfig()">Save</v-btn>
</v-layout>
</template>

<script>
import { configService } from '@/services/config'
export default {
data: () => ({
name: '',
email: ''
isTest: true,
endpoint: '',
config: configService
}),
methods: {
onSubmit () {},
onSuccess (data) {}
onSuccess (data) {},
loadConfig () {
configService.read()
},
writeConfig () {
configService.write()
}
},
mounted () {
this.loadConfig()
}
}
</script>

<style>
<style scoped>
.tooltip {
flex: 1 1 auto
}
</style>
28 changes: 27 additions & 1 deletion dashboard/src/services/config.js
@@ -1,7 +1,33 @@
class ConfigService {
read () {
const persistConfig = JSON.parse(localStorage.getItem('cvpm-config'))
if (persistConfig === null) {
this.loadDefault()
} else {
this.endpoint = persistConfig['endpoint']
this.developerMode = persistConfig['developerMode']
}
}
loadDefault () {
this.endpoint = 'http://127.0.0.1:10590'
this.developerMode = false
}
write () {
const persistConfig = {
'endpoint': this.endpoint,
'developerMode': this.developerMode
}
localStorage.setItem('cvpm-config', JSON.stringify(persistConfig))
}
}

const configService = new ConfigService()

const discoveryConfig = {
'endpoint': 'http://127.0.0.1:3000'
}

export {
discoveryConfig
discoveryConfig,
configService
}
21 changes: 0 additions & 21 deletions dashboard/src/services/mock.js

This file was deleted.

5 changes: 5 additions & 0 deletions dashboard/src/services/system.js
@@ -0,0 +1,5 @@
import { configService } from './config'

class SystemService {

}

0 comments on commit d3d6f99

Please sign in to comment.