enrecipes/app/components/Settings.vue

561 lines
21 KiB
Vue
Raw Normal View History

2020-09-15 11:10:16 +00:00
<template>
<Page @loaded="onPageLoad">
<ActionBar :androidElevation="viewIsScrolled ? 4 : 0">
<GridLayout rows="*" columns="auto, *">
<MDButton class="bx left" variant="text" :text="icon.menu" automationText="Back" @tap="showDrawer" col="0" />
<Label class="title orkm" :text="'Settings' | L" col="1" />
</GridLayout>
</ActionBar>
<ScrollView @scroll="onScroll">
<StackLayout class="main-container">
2021-01-13 05:02:48 +00:00
<Label :text="'intf' | L" class="group-header orkm" />
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="selectAppLanguage" />
<Label col="0" verticalAlignment="center" class="bx" :text="icon.globe" />
<StackLayout col="1">
2021-01-13 05:02:48 +00:00
<Label :text="'lang' | L" />
<Label :text="appLanguage" class="info" />
</StackLayout>
2020-10-14 19:32:32 +00:00
</GridLayout>
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="selectThemes" />
<Label col="0" verticalAlignment="center" class="bx" :text="icon.theme" />
<StackLayout col="1">
<Label :text="'Theme' | L" />
<Label :text="`${appTheme}` | L" class="info" />
</StackLayout>
</GridLayout>
<StackLayout class="hr m-10"></StackLayout>
2021-01-13 05:02:48 +00:00
<Label :text="'opts' | L" class="group-header orkm" />
2020-12-29 10:35:19 +00:00
<GridLayout columns="auto, *, auto" class="option">
<Label col="0" verticalAlignment="center" class="bx" :text="icon.shuffle" />
<StackLayout col="1">
2021-01-13 05:02:48 +00:00
<Label :text="'sVw' | L" textWrap="true" />
<Label :text="`sVwInfo` | L" class="info" textWrap="true" />
2020-12-29 10:35:19 +00:00
</StackLayout>
<Switch :color="shakeEnabled ? '#ff5200' : appTheme==='Light' ? '#495057' : '#adb5bd'" verticalAlignment="center" col="2" :checked="shakeEnabled" @checkedChange="toggleShake" />
</GridLayout>
<StackLayout class="hr m-10"></StackLayout>
2021-01-13 05:02:48 +00:00
<Label :text="'db' | L" class="group-header orkm" />
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="exportCheck" />
<Label col="0" class="bx" :text="icon.export" />
<StackLayout col="1">
2021-01-13 05:02:48 +00:00
<Label :text="'expBu' | L" textWrap="true" />
<Label v-if="!backupInProgress" :text="'buInfo' | L" class="info" textWrap="true" />
<GridLayout class="progressContainer" v-else columns="*, 64">
<MDProgress col="0" :value="backupProgress" maxValue="100"></MDProgress>
<Label col="1" :text="` ${backupProgress}%`" />
</GridLayout>
</StackLayout>
</GridLayout>
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="importCheck" />
<Label col="0" class="bx" :text="icon.import" />
<StackLayout col="1">
2021-01-13 05:02:48 +00:00
<Label :text="'impBu' | L" textWrap="true" />
<Label :text="'impInfo' | L" class="info" textWrap="true" />
</StackLayout>
</GridLayout>
2020-12-29 10:35:19 +00:00
<StackLayout class="hr m-10"></StackLayout>
2021-01-13 05:02:48 +00:00
<Label :text="'rest' | L" class="group-header orkm" />
2020-12-29 10:35:19 +00:00
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="resetListItems('cuisines')" />
<Label col="0" class="bx" :text="icon.reset" />
2021-01-13 05:02:48 +00:00
<Label col="1" verticalAlignment="center" :text="'restCuiL' | L" textWrap="true" />
2020-12-29 10:35:19 +00:00
</GridLayout>
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="resetListItems('categories')" />
<Label col="0" class="bx" :text="icon.reset" />
2021-01-13 05:02:48 +00:00
<Label col="1" verticalAlignment="center" :text="'Reset category list' | L" textWrap="true" />
2020-12-29 10:35:19 +00:00
</GridLayout>
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="resetListItems('yieldUnits')" />
<Label col="0" class="bx" :text="icon.reset" />
2021-01-13 05:02:48 +00:00
<Label col="1" verticalAlignment="center" :text="'Reset yield unit list' | L" textWrap="true" />
2020-12-29 10:35:19 +00:00
</GridLayout>
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="resetListItems('units')" />
<Label col="0" class="bx" :text="icon.reset" />
2021-01-13 05:02:48 +00:00
<Label col="1" verticalAlignment="center" :text="'Reset unit list' | L" textWrap="true" />
2020-12-29 10:35:19 +00:00
</GridLayout>
2021-01-13 05:02:48 +00:00
<Label class="group-info" :text="'restInfo' | L" textWrap="true" />
<StackLayout class="hr m-10"></StackLayout>
<Label :text="'help' | L" class="group-header orkm" />
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="openURL('https://github.com/vishnuraghavb/EnRecipes/wiki/User-Guide')" />
<Label col="0" class="bx" :text="icon.compass" />
<Label verticalAlignment="center" col="1" :text="'guide' | L" textWrap="true" />
</GridLayout>
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="openURL('https://t.me/enrecipes')" />
<Label col="0" class="bx" :text="icon.telegram" />
<StackLayout col="1">
<Label :text="'joinTG' | L" textWrap="true" />
<Label :text="'tgInfo' | L" class="info" textWrap="true" />
</StackLayout>
</GridLayout>
<StackLayout class="hr m-10"></StackLayout>
<Label :text="'About' | L" class="group-header orkm" />
<GridLayout columns="auto, *" class="option">
<Label col="0" class="bx" :text="icon.info" />
<StackLayout col="1">
<Label :text="'ver' | L" />
<Label :text="getVersion" class="info" textWrap="true" />
</StackLayout>
</GridLayout>
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="openURL('https://github.com/vishnuraghavb/EnRecipes/blob/main/PRIVACY.md')" />
<Label col="0" class="bx" :text="icon.lock" />
<Label verticalAlignment="center" col="1" :text="'priv' | L" textWrap="true" />
</GridLayout>
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="openURL('https://github.com/vishnuraghavb/enrecipes')" />
<Label col="0" class="bx" :text="icon.github" />
<Label verticalAlignment="center" col="1" :text="'gh' | L" textWrap="true" />
</GridLayout>
<GridLayout columns="auto, *" class="option">
<MDRipple colSpan="2" @tap="openURL('https://www.vishnuraghav.com/donate')" />
<Label col="0" class="bx" :text="icon.donate" />
<Label verticalAlignment="center" col="1" :text="'donate' | L" textWrap="true" />
</GridLayout>
<Label class="group-info" :text="'appInfo' | L" textWrap="true" />
</StackLayout>
</ScrollView>
</Page>
2020-09-15 11:10:16 +00:00
</template>
<script>
import {
2021-01-13 05:02:48 +00:00
Application,
Utils,
ApplicationSettings,
path,
knownFolders,
File,
Folder,
Observable,
Device
}
from "@nativescript/core"
import * as Permissions from "@nativescript-community/perms"
import {
Zip
}
from "@nativescript/zip"
2020-10-26 20:49:54 +00:00
import * as Toast from "nativescript-toast"
import * as Filepicker from "nativescript-plugin-filepicker"
2020-10-14 19:32:32 +00:00
import Theme from "@nativescript/theme"
import {
localize,
overrideLocale
}
from "@nativescript/localize"
import {
mapState,
mapActions
}
from "vuex"
2020-10-21 17:54:45 +00:00
import ActionDialog from "./modal/ActionDialog.vue"
import ConfirmDialog from "./modal/ConfirmDialog.vue"
2020-11-23 09:49:58 +00:00
import * as utils from "~/shared/utils"
2020-09-15 11:10:16 +00:00
export default {
data() {
return {
2020-11-02 11:36:53 +00:00
viewIsScrolled: false,
appTheme: "Light",
appLanguage: "English",
2020-11-06 09:07:41 +00:00
backupProgress: 0,
backupInProgress: false,
2020-09-15 11:10:16 +00:00
}
},
2020-10-14 19:32:32 +00:00
computed: {
2020-12-29 10:35:19 +00:00
...mapState( [ "icon", "recipes", "cuisines", "categories", "yieldUnits", "units", "mealPlans", "currentComponent", "language", "shakeEnabled", "importSummary" ] ),
2021-01-13 05:02:48 +00:00
getVersion() {
let ctx = Application.android.context
return ctx.getPackageManager().getPackageInfo( ctx.getPackageName(), 0 ).versionName
},
2020-10-14 19:32:32 +00:00
},
2020-09-15 11:10:16 +00:00
methods: {
2020-12-29 10:35:19 +00:00
...mapActions( [ "setCurrentComponentAction", "importListItemsAction", "importRecipesAction", "importMealPlansAction", "resetListItemsAction", "setShakeAction", "unlinkBrokenImages" ] ),
onPageLoad( args ) {
const page = args.object;
page.bindingContext = new Observable();
this.setCurrentComponentAction( "Settings" )
2020-10-21 17:54:45 +00:00
},
2020-11-10 18:28:48 +00:00
// HELPERS
2020-11-23 09:49:58 +00:00
showDrawer() {
utils.showDrawer()
},
onScroll( args ) {
2020-11-28 19:21:57 +00:00
this.viewIsScrolled = args.scrollY ? true : false
2020-10-21 17:54:45 +00:00
},
2021-01-13 05:02:48 +00:00
openURL( url ) {
Utils.openUrl( url )
},
// LANGUAGE SELECTION
selectAppLanguage() {
let languages = this.language.map( e => e.title )
this.$showModal( ActionDialog, {
props: {
2021-01-13 05:02:48 +00:00
title: "lang",
list: [ ...languages ],
2020-12-29 10:35:19 +00:00
stretch: true,
2021-01-13 05:02:48 +00:00
helpIcon: 'globe',
},
} ).then( ( action ) => {
if ( action && action !== "Cancel" && this.appLanguage !== action ) {
let currentLocale = Device.language.split( '-' )[ 0 ]
let locale = this.language.filter( e => e.title === action )[ 0 ].locale
if ( currentLocale !== locale ) {
this.$showModal( ConfirmDialog, {
props: {
2021-01-13 05:02:48 +00:00
title: "appRst",
description: localize( "nLangInfo" ),
cancelButtonText: "cBtn",
okButtonText: "rst",
helpIcon: 'restart',
bgColor: '#ff5200',
},
} ).then( ( result ) => {
if ( result ) {
this.appLanguage = action
ApplicationSettings.setString( "appLanguage", action )
overrideLocale( locale )
2021-01-13 05:02:48 +00:00
setTimeout( utils.restartApp, 250 )
}
} )
}
}
} )
},
2020-11-10 18:28:48 +00:00
// THEME SELECTION
selectThemes() {
this.$showModal( ActionDialog, {
2020-10-21 17:54:45 +00:00
props: {
title: "Theme",
list: [ "Light", "Dark" ],
2021-01-13 05:02:48 +00:00
stretch: false,
helpIcon: 'theme',
2020-10-21 17:54:45 +00:00
},
} ).then( ( action ) => {
if ( action && action !== "Cancel" && this.appTheme !== action ) {
this.$showModal( ConfirmDialog, {
2020-10-21 17:54:45 +00:00
props: {
2021-01-13 05:02:48 +00:00
title: "appRst",
description: localize( "nThmInfo" ),
cancelButtonText: "cBtn",
okButtonText: "rst",
helpIcon: 'restart',
bgColor: '#ff5200',
2020-10-21 17:54:45 +00:00
},
} ).then( ( result ) => {
if ( result ) {
this.appTheme = action
ApplicationSettings.setString( "appTheme", action )
2021-01-13 05:02:48 +00:00
setTimeout( utils.restartApp, 250 )
2020-10-21 17:54:45 +00:00
}
} )
2020-10-21 17:54:45 +00:00
}
} )
2020-09-15 11:10:16 +00:00
},
2020-12-29 10:35:19 +00:00
// SHAKE VIEW RANDOM RECIPE
toggleShake( args ) {
let checked = args.object.checked
// let checked = !this.shakeEnabled
ApplicationSettings.setBoolean( 'shakeEnabled', checked )
this.setShakeAction( checked )
},
2020-11-10 18:28:48 +00:00
// EXPORT HANDLERS
exportCheck() {
if ( !this.recipes.length ) {
2021-01-13 05:02:48 +00:00
Toast.makeText( localize( "aFBu" ) ).show()
2020-12-29 10:35:19 +00:00
} else {
2021-01-13 05:02:48 +00:00
this.permissionCheck( this.permissionConfirmation, localize( "reqAcc" ), this.exportBackup )
2020-11-06 09:07:41 +00:00
}
},
2020-11-10 18:28:48 +00:00
exportBackup() {
this.exportFiles( "create" )
let date = new Date()
2020-12-29 10:35:19 +00:00
let formattedDate = date.getFullYear() + "-" + ( "0" + ( date.getMonth() + 1 ) ).slice( -2 ) + "-" + ( "0" + date.getDate() ).slice( -2 ) + "_" + ( "0" + date.getHours() ).slice( -2 ) + ( "0" + date.getMinutes() ).slice( -2 ) + ( "0" + date
.getSeconds() ).slice( -2 )
const sdDownloadPath = Folder.fromPath( android.os.Environment.getExternalStorageDirectory().getAbsolutePath() ).getFolder( "Download" ).path
let fromPath = path.join( knownFolders.documents().path, "EnRecipes" )
2020-12-29 10:35:19 +00:00
let destPath = path.join( sdDownloadPath, `EnRecipes-Backup_${formattedDate}.zip` )
2020-11-06 09:07:41 +00:00
this.backupInProgress = true
Zip.zip( {
directory: fromPath,
archive: destPath,
onProgress: ( progress ) => {
2020-11-06 09:07:41 +00:00
this.backupProgress = progress
},
} ).then( ( success ) => {
2020-12-29 10:35:19 +00:00
Toast.makeText( "Backup file successfully saved to Download folder", "long" ).show()
this.exportFiles( "delete" )
2021-01-13 05:02:48 +00:00
setTimeout( e => this.backupInProgress = false, 3000 )
} )
2020-09-15 11:10:16 +00:00
},
exportFiles( option ) {
const folder = path.join( knownFolders.documents().path, "EnRecipes" )
const EnRecipesFile = File.fromPath( path.join( folder, "recipes.json" ) )
2020-12-29 10:35:19 +00:00
let userCuisinesFile, userCategoriesFile, userYieldUnitsFile, userUnitsFile, mealPlansFile
if ( this.cuisines.length ) userCuisinesFile = File.fromPath( path.join( folder, "userCuisines.json" ) )
if ( this.categories.length ) userCategoriesFile = File.fromPath( path.join( folder, "userCategories.json" ) )
if ( this.yieldUnits.length ) userYieldUnitsFile = File.fromPath( path.join( folder, "userYieldUnits.json" ) )
if ( this.units.length ) userUnitsFile = File.fromPath( path.join( folder, "userUnits.json" ) )
if ( this.mealPlans.length ) mealPlansFile = File.fromPath( path.join( folder, "mealPlans.json" ) )
switch ( option ) {
2020-11-10 18:28:48 +00:00
case "create":
this.writeDataToFile( EnRecipesFile, this.recipes )
2020-12-29 10:35:19 +00:00
this.cuisines.length && this.writeDataToFile( userCuisinesFile, this.cuisines )
this.categories.length && this.writeDataToFile( userCategoriesFile, this.categories )
this.yieldUnits.length && this.writeDataToFile( userYieldUnitsFile, this.yieldUnits )
this.units.length && this.writeDataToFile( userUnitsFile, this.units )
this.mealPlans.length && this.writeDataToFile( mealPlansFile, this.mealPlans )
2020-11-10 18:28:48 +00:00
break
case "delete":
EnRecipesFile.remove()
2020-12-29 10:35:19 +00:00
this.cuisines.length && userCuisinesFile.remove()
this.categories.length && userCategoriesFile.remove()
this.yieldUnits.length && userYieldUnitsFile.remove()
this.units.length && userUnitsFile.remove()
2020-11-23 09:49:58 +00:00
this.mealPlans.length && mealPlansFile.remove()
2020-11-10 18:28:48 +00:00
break
default:
break
}
},
writeDataToFile( file, data ) {
file.writeText( JSON.stringify( data ) )
},
2020-11-10 18:28:48 +00:00
// IMPORT HANDLERS
importCheck() {
2021-01-13 05:02:48 +00:00
this.permissionCheck( this.permissionConfirmation, localize( "reqAcc" ), this.openFilePicker )
},
openFilePicker() {
Filepicker.create( {
2020-12-29 10:35:19 +00:00
mode: "single",
extensions: [ "zip" ],
} ).present().then( ( selection ) => {
2021-01-13 05:02:48 +00:00
Toast.makeText( localize( "vrfy" ) + '...' ).show()
2020-12-29 10:35:19 +00:00
let zipPath = selection[ 0 ]
this.validateZipContent( zipPath )
} )
2020-11-06 09:07:41 +00:00
},
importDataToDB( data, db, zipPath ) {
switch ( db ) {
2020-11-06 09:07:41 +00:00
case "EnRecipesDB":
this.importImages( zipPath )
this.importRecipesAction( data )
2020-11-06 09:07:41 +00:00
break
2020-12-29 10:35:19 +00:00
case "userCuisinesDB":
this.importListItemsAction( {
data,
listName: "cuisines",
} )
break
2020-11-06 09:07:41 +00:00
case "userCategoriesDB":
2020-12-29 10:35:19 +00:00
this.importListItemsAction( {
data,
listName: "categories",
} )
2020-11-06 09:07:41 +00:00
break
case "userYieldUnitsDB":
2020-12-29 10:35:19 +00:00
this.importListItemsAction( {
data,
listName: "yieldUnits",
} )
break
case "userUnitsDB":
this.importListItemsAction( {
data,
listName: "units",
} )
2020-11-06 09:07:41 +00:00
break
2020-11-23 09:49:58 +00:00
case "mealPlansDB":
this.importMealPlansAction( data )
2020-11-23 09:49:58 +00:00
break
2020-11-06 09:07:41 +00:00
default:
break
}
},
2020-12-29 10:35:19 +00:00
hasValidJSON( data ) {
try {
JSON.parse( data ) && Array.isArray( JSON.parse( data ) )
} catch ( e ) {
return false;
}
return true;
},
isFileDataValid( file ) {
2020-12-29 10:35:19 +00:00
const files = file.filter( e => File.exists( e.path ) )
if ( files.length ) {
let isValid = files.map( e => false )
files.forEach( ( file, i ) => {
File.fromPath( file.path ).readText().then( ( data ) => {
isValid[ i ] = this.hasValidJSON( data )
if ( !isValid[ i ] ) {
2021-01-13 05:02:48 +00:00
this.failedImport( `${localize("buMod")}\n\n${localize("invFile")}: ${file.file}` )
2020-12-29 10:35:19 +00:00
return 0;
}
if ( isValid.every( e => e === true ) ) {
files.forEach( ( file, i ) => {
File.fromPath( file.path ).readText().then( ( data ) => {
this.importDataToDB( JSON.parse( data ), file.db, file.zipPath )
} )
} )
}
} )
} )
} else {
2021-01-13 05:02:48 +00:00
this.failedImport( localize( "buEmp" ) )
2020-12-29 10:35:19 +00:00
}
},
failedImport( description ) {
this.$showModal( ConfirmDialog, {
props: {
2021-01-13 05:02:48 +00:00
title: "impFail",
2020-12-29 10:35:19 +00:00
description,
okButtonText: "OK",
2021-01-13 05:02:48 +00:00
helpIcon: 'error',
bgColor: '#c92a2a',
2020-12-29 10:35:19 +00:00
},
} )
},
validateZipContent( zipPath ) {
Zip.unzip( {
archive: zipPath,
overwrite: true,
} ).then( ( extractedFolderPath ) => {
2020-11-06 09:07:41 +00:00
let cacheFolderPath = extractedFolderPath + "/EnRecipes"
2020-11-23 09:49:58 +00:00
const EnRecipesFilePath = cacheFolderPath + "/recipes.json"
2020-12-29 10:35:19 +00:00
const userCuisinesFilePath = cacheFolderPath + "/userCuisines.json"
const userCategoriesFilePath = cacheFolderPath + "/userCategories.json"
const userYieldUnitsFilePath = cacheFolderPath + "/userYieldUnits.json"
2020-12-29 10:35:19 +00:00
const userUnitsFilePath = cacheFolderPath + "/userUnits.json"
2020-11-23 09:49:58 +00:00
const mealPlansFilePath = cacheFolderPath + "/mealPlans.json"
if ( Folder.exists( cacheFolderPath ) ) {
this.isFileDataValid( [ {
2020-12-29 10:35:19 +00:00
zipPath,
path: EnRecipesFilePath,
db: "EnRecipesDB",
file: "recipes.json"
}, {
zipPath,
path: userCuisinesFilePath,
db: "userCuisinesDB",
file: "userCuisines.json"
}, {
zipPath,
path: userCategoriesFilePath,
db: "userCategoriesDB",
file: "userCategories.json"
}, {
zipPath,
path: userYieldUnitsFilePath,
db: "userYieldUnitsDB",
file: "userYieldUnits.json"
}, {
zipPath,
path: userUnitsFilePath,
db: "userUnitsDB",
file: "userUnits.json"
}, {
zipPath,
path: mealPlansFilePath,
db: "mealPlansDB",
file: "mealPlans.json"
}, ] )
} else {
Folder.fromPath( extractedFolderPath ).remove()
2021-01-13 05:02:48 +00:00
this.failedImport( localize( "buInc" ) )
2020-11-06 09:07:41 +00:00
}
if ( Folder.exists( cacheFolderPath + "/Images" ) ) {
this.importImages( cacheFolderPath + "/Images" )
}
} )
},
importImages( sourcePath ) {
2020-11-06 09:07:41 +00:00
let dest = knownFolders.documents().path
Zip.unzip( {
2020-11-06 09:07:41 +00:00
archive: sourcePath,
directory: dest,
overwrite: true,
} ).then( ( res ) => {
2020-12-29 10:35:19 +00:00
this.showImportSummary()
this.unlinkBrokenImages()
} )
},
showImportSummary() {
let {
found,
imported,
updated
} = this.importSummary
2021-01-13 05:02:48 +00:00
let exists = Math.abs( found - imported - updated ) + updated
let importedNote = `\n${imported} ${localize('recI')}`
let existsNote = `\n${exists} ${localize('recE')}`
let updatedNote = `\n${updated} ${localize('recU')}`
2020-12-29 10:35:19 +00:00
this.$showModal( ConfirmDialog, {
props: {
2021-01-13 05:02:48 +00:00
title: "impSuc",
description: `${found} ${localize('recF')}${ importedNote}${existsNote}${updatedNote}`,
2020-12-29 10:35:19 +00:00
okButtonText: "OK",
2021-01-13 05:02:48 +00:00
helpIcon: 'success',
bgColor: '#94d82d',
2020-12-29 10:35:19 +00:00
},
} )
},
2020-11-10 18:28:48 +00:00
// PERMISSIONS HANDLER
permissionCheck( confirmation, description, action ) {
if ( !ApplicationSettings.getBoolean( "storagePermissionAsked", false ) ) {
confirmation( description ).then( ( e ) => {
if ( e ) {
Permissions.request( "photo" ).then( ( res ) => {
let status = res[ Object.keys( res )[ 0 ] ]
if ( status === "authorized" ) action()
2020-12-29 10:35:19 +00:00
if ( status !== "denied" ) ApplicationSettings.setBoolean( "storagePermissionAsked", true )
2021-01-13 05:02:48 +00:00
else Toast.makeText( localize( "dend" ) ).show()
} )
}
} )
2020-12-29 10:35:19 +00:00
} else {
Permissions.check( "photo" ).then( ( res ) => {
let status = res[ Object.keys( res )[ 0 ] ]
if ( status !== "authorized" ) {
confirmation( description ).then( ( e ) => {
2020-11-23 09:49:58 +00:00
e && utils.openAppSettingsPage()
} )
2020-12-29 10:35:19 +00:00
} else action()
} )
}
},
permissionConfirmation( description ) {
return this.$showModal( ConfirmDialog, {
2020-11-10 18:28:48 +00:00
props: {
2021-01-13 05:02:48 +00:00
title: "grant",
2020-11-10 18:28:48 +00:00
description,
2021-01-13 05:02:48 +00:00
cancelButtonText: "nNBtn",
okButtonText: "conBtn",
helpIcon: 'folder',
bgColor: '#ff5200',
2020-11-10 18:28:48 +00:00
},
} )
2020-11-10 18:28:48 +00:00
},
2020-12-29 10:35:19 +00:00
// RESET
resetListItems( listName ) {
this.resetListItemsAction( listName )
2021-01-13 05:02:48 +00:00
Toast.makeText( localize( "restDone" ) ).show()
2020-12-29 10:35:19 +00:00
}
2021-01-13 05:02:48 +00:00
2020-09-15 11:10:16 +00:00
},
2020-11-23 09:49:58 +00:00
mounted() {
this.appTheme = ApplicationSettings.getString( "appTheme", "Light" )
2021-01-13 05:02:48 +00:00
this.appLanguage = ApplicationSettings.getString( "appLanguage", localize( "sysDef" ) )
2020-10-14 19:32:32 +00:00
},
2020-09-15 11:10:16 +00:00
}
</script>