-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ShiranAbir/feature/settings-support
Feature/settings support
- Loading branch information
Showing
15 changed files
with
303 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
<template> | ||
<mainView :callConnecting="callConnecting" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import mainView from '@/views/mainView.vue' | ||
</script> | ||
|
||
<template> | ||
<mainView/> | ||
</template> | ||
|
||
|
||
<script lang="ts"> | ||
export default { | ||
data(){ | ||
return{ | ||
callConnecting:false | ||
} | ||
}, | ||
async created() { | ||
await this.$store.dispatch({ type: 'loadSettings' }) | ||
const isConnected = await this.$store.dispatch({ type: 'initBackend' }) | ||
if (!isConnected){ | ||
this.callConnecting = true | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<template> | ||
<div> | ||
<b-modal v-model="showModal" id="settingsMenu" title="Settings" ok-title="Save" @hide="$emit('settingsClosed')" @ok="handleOk"> | ||
<b-form-group | ||
id="fieldset-horizontal" | ||
label-cols="2" | ||
content-cols="9" | ||
label="Username:" | ||
label-for="input-horizontal" | ||
> | ||
<b-form-input type="email" v-model="username" placeholder="Enter your email"/> | ||
</b-form-group> | ||
<b-form-group | ||
id="fieldset-horizontal" | ||
label-cols="2" | ||
content-cols="9" | ||
label="Password:" | ||
label-for="input-horizontal" | ||
> | ||
<b-form-input type="password" v-model="password" placeholder="Enter your password"/> | ||
</b-form-group> | ||
<b-form-group | ||
label="Account type:" | ||
label-cols="3" | ||
v-slot="{ ariaDescribedby }" | ||
> | ||
<b-form-radio-group | ||
class="pt-2" | ||
v-model="accountType" | ||
:options="['Normal', 'Google', 'Microsoft']" | ||
:aria-describedby="ariaDescribedby" | ||
/> | ||
</b-form-group> | ||
<b-form-group | ||
label="Read answers:" | ||
label-cols="4" | ||
label-for="input-horizontal" | ||
> | ||
<b-form-checkbox | ||
id="checkbox-1" | ||
v-model="shouldRead" | ||
name="checkbox-1" | ||
switch | ||
size="lg" | ||
/> | ||
</b-form-group> | ||
</b-modal> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
export default { | ||
props: { | ||
showSettings: Boolean | ||
}, | ||
data(){ | ||
return{ | ||
showModal: false, | ||
username: '', | ||
password: '', | ||
accountType: 'Normal', | ||
shouldRead: false, | ||
settingsChanged: false | ||
} | ||
}, | ||
async created() { | ||
// Load settings from electron store | ||
const settings = await window.ipcRenderer.send('electron-store-get', 'settings') | ||
if (!settings.username) return | ||
this.username = settings.username | ||
this.password = settings.password | ||
this.accountType = settings.accountType | ||
this.shouldRead = settings.shouldRead | ||
this.$watch('username', () => { this.settingsChanged = true }) | ||
this.$watch('password', () => { this.settingsChanged = true}) | ||
this.$watch('accountType', () => { this.settingsChanged = true}) | ||
}, | ||
methods:{ | ||
async handleOk() { | ||
const settings = { | ||
username: this.username, | ||
password: this.password, | ||
accountType: this.accountType, | ||
shouldRead: this.shouldRead | ||
} | ||
await window.ipcRenderer.send('electron-store-set', 'settings', settings) | ||
await this.$store.dispatch({ type: 'loadSettings' }) | ||
if (this.settingsChanged){ | ||
this.settingsChanged = false | ||
await this.$store.dispatch({ type: 'initBackend' }) | ||
} | ||
}, | ||
}, | ||
watch: { | ||
showSettings: { | ||
handler(newValue, oldValue) { | ||
this.showModal = newValue | ||
}, | ||
immediate: true | ||
} | ||
}, | ||
computed:{ | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
</style> |
Oops, something went wrong.