Let user disable sleep prevention

This commit is contained in:
Lucas Verney 2018-07-03 19:01:56 +02:00
parent 37413a7e21
commit 4cd2d49db9
5 changed files with 29 additions and 3 deletions

View File

@ -148,7 +148,6 @@ export default {
} }
}, },
onMoveStart(ev) { onMoveStart(ev) {
console.log(ev, this.isProgrammaticMove);
if (!this.isProgrammaticMove) { if (!this.isProgrammaticMove) {
this.showRecenterButton(); this.showRecenterButton();
} }

View File

@ -35,6 +35,7 @@ export default {
}, },
settings: { settings: {
locale: 'Language', locale: 'Language',
preventSuspend: 'Prevent device from going to sleep',
save: 'Save', save: 'Save',
}, },
}; };

View File

@ -12,6 +12,9 @@ export default {
fetching: 'En attente de votre position…', fetching: 'En attente de votre position…',
unavailable: "Désolé, la géolocalisation n'est pas disponible dans votre navigateur.", unavailable: "Désolé, la géolocalisation n'est pas disponible dans votre navigateur.",
}, },
intro: {
start: "C'est parti !",
},
menu: { menu: {
About: 'Aide', About: 'Aide',
Map: 'Carte', Map: 'Carte',
@ -32,6 +35,7 @@ export default {
}, },
settings: { settings: {
locale: 'Langue', locale: 'Langue',
preventSuspend: "Empêcher l'appareil de passer en veille",
save: 'Sauver', save: 'Sauver',
}, },
}; };

View File

@ -138,8 +138,17 @@ export default {
this.accuracy = position.coords.accuracy ? position.coords.accuracy : null; this.accuracy = position.coords.accuracy ? position.coords.accuracy : null;
}, },
setNoSleep() { setNoSleep() {
this.noSleep = new NoSleep(); let preventSuspend = localStorage.getItem('preventSuspend');
this.noSleep.enable(); if (preventSuspend) {
preventSuspend = JSON.parse(preventSuspend);
} else {
preventSuspend = true;
}
if (preventSuspend) {
this.noSleep = new NoSleep();
this.noSleep.enable();
}
}, },
disableNoSleep() { disableNoSleep() {
if (this.noSleep) { if (this.noSleep) {

View File

@ -11,6 +11,11 @@
required required
></v-select> ></v-select>
<v-checkbox
:label="$t('settings.preventSuspend')"
v-model="preventSuspend"
></v-checkbox>
<v-btn @click="submit">{{ $t('settings.save') }}</v-btn> <v-btn @click="submit">{{ $t('settings.save') }}</v-btn>
</form> </form>
</v-flex> </v-flex>
@ -24,15 +29,23 @@ import { storageAvailable } from '@/tools';
export default { export default {
data() { data() {
let preventSuspend = localStorage.getItem('preventSuspend');
if (preventSuspend) {
preventSuspend = JSON.parse(preventSuspend);
} else {
preventSuspend = true;
}
return { return {
i18nItems: Object.keys(messages), i18nItems: Object.keys(messages),
i18nSelect: this.$i18n.locale, i18nSelect: this.$i18n.locale,
preventSuspend,
}; };
}, },
methods: { methods: {
submit() { submit() {
if (storageAvailable('localStorage')) { if (storageAvailable('localStorage')) {
localStorage.setItem('i18nSetting', this.i18nSelect); localStorage.setItem('i18nSetting', this.i18nSelect);
localStorage.setItem('preventSuspend', JSON.stringify(this.preventSuspend));
} }
this.$i18n.locale = this.i18nSelect; this.$i18n.locale = this.i18nSelect;
}, },