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) {
console.log(ev, this.isProgrammaticMove);
if (!this.isProgrammaticMove) {
this.showRecenterButton();
}

View File

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

View File

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

View File

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

View File

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