2
0
mirror of https://github.com/frappe/books.git synced 2025-02-04 13:08:29 +00:00
books/src/App.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

141 lines
3.6 KiB
Vue
Raw Normal View History

2018-06-01 18:05:51 +05:30
<template>
2020-01-28 13:50:42 +05:30
<div
id="app"
class="h-screen flex flex-col font-sans overflow-hidden antialiased"
>
2022-04-22 16:32:03 +05:30
<WindowsTitleBar v-if="platform === 'Windows'" />
<!--
<Desk
class="flex-1"
v-if="activeScreen === 'Desk'"
@change-db-file="changeDbFile"
/>-->
<DatabaseSelector
v-if="activeScreen === 'DatabaseSelector'"
2022-04-22 16:32:03 +05:30
@file-selected="fileSelected"
/>
2022-04-22 16:32:03 +05:30
<SetupWizard
v-if="activeScreen === 'SetupWizard'"
@setup-complete="setupComplete"
2021-12-20 15:22:31 +05:30
@setup-canceled="setupCanceled"
/>
<div
id="toast-container"
class="absolute bottom-0 flex flex-col items-end mb-3 pr-6"
style="width: 100%"
>
<div id="toast-target" />
</div>
2022-04-22 16:32:03 +05:30
<!-- TODO: check this and uncomment
<TelemetryModal />-->
2018-06-01 18:05:51 +05:30
</div>
</template>
<script>
2022-04-20 12:08:47 +05:30
import fs from 'fs/promises';
2022-04-22 16:32:03 +05:30
import WindowsTitleBar from './components/WindowsTitleBar.vue';
import { fyo, initializeInstance } from './initFyo';
import DatabaseSelector from './pages/DatabaseSelector.vue';
import SetupWizard from './pages/SetupWizard/SetupWizard.vue';
import './styles/index.css';
2022-04-22 16:32:03 +05:30
import { checkForUpdates } from './utils/ipcCalls';
import { routeTo } from './utils/ui';
2018-06-01 18:05:51 +05:30
export default {
name: 'App',
data() {
return {
activeScreen: null,
};
},
2018-06-01 18:05:51 +05:30
components: {
// Desk,
2022-04-22 16:32:03 +05:30
SetupWizard,
2019-10-19 19:56:13 +05:30
DatabaseSelector,
2022-04-22 16:32:03 +05:30
WindowsTitleBar,
// TelemetryModal,
},
async mounted() {
fyo.telemetry.platform = this.platform;
/*
const lastSelectedFilePath = fyo.config.get('lastSelectedFilePath', null);
const { connectionSuccess, reason } = await connectToLocalDatabase(
2021-11-06 01:11:39 +05:30
lastSelectedFilePath
);
if (connectionSuccess) {
this.showSetupWizardOrDesk(false);
return;
}
if (lastSelectedFilePath) {
const title = this.t`DB Connection Error`;
const content = `reason: ${reason}, filePath: ${lastSelectedFilePath}`;
await showErrorDialog(title, content);
2018-10-23 18:12:36 +05:30
}
*/
2022-04-22 16:32:03 +05:30
// this.activeScreen = 'DatabaseSelector';
this.activeScreen = 'SetupWizard';
},
methods: {
async setupComplete() {
// TODO: Complete this
// await postSetup();
2022-04-22 16:32:03 +05:30
// await this.showSetupWizardOrDesk(true);
},
2022-04-22 16:32:03 +05:30
async fileSelected(filePath, isNew) {
console.log('from App.vue', filePath, isNew);
if (isNew) {
this.activeScreen = 'SetupWizard';
return;
}
await this.showSetupWizardOrDesk(filePath);
},
async showSetupWizardOrDesk(filePath, resetRoute = false) {
const countryCode = await fyo.db.connectToDatabase(filePath);
const setupComplete = await getSetupComplete();
if (!setupComplete) {
this.activeScreen = 'SetupWizard';
2022-04-22 16:32:03 +05:30
return;
2019-10-24 16:09:57 +05:30
}
2022-04-22 16:32:03 +05:30
await initializeInstance(filePath, false, countryCode);
this.activeScreen = 'Desk';
await checkForUpdates(false);
if (!resetRoute) {
return;
}
2022-04-22 16:32:03 +05:30
await this.setDeskRoute();
},
async setDeskRoute() {
const { onboardingComplete } = await fyo.doc.getSingle('GetStarted');
const { hideGetStarted } = await fyo.doc.getSingle('SystemSettings');
if (hideGetStarted || onboardingComplete) {
routeTo('/');
} else {
routeTo('/get-started');
}
},
async changeDbFile() {
fyo.config.set('lastSelectedFilePath', null);
2022-04-22 16:32:03 +05:30
fyo.telemetry.stop();
fyo.purgeCache();
this.activeScreen = 'DatabaseSelector';
},
2021-12-20 15:22:31 +05:30
async setupCanceled() {
const filePath = fyo.config.get('lastSelectedFilePath');
2022-04-22 16:32:03 +05:30
if (filePath) {
await fs.unlink(filePath);
}
this.changeDbFile();
2021-12-20 15:22:31 +05:30
},
},
};
2018-06-01 18:05:51 +05:30
</script>