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'" />
|
|
|
|
<!--
|
2021-11-24 14:38:13 +05:30
|
|
|
<Desk
|
|
|
|
class="flex-1"
|
|
|
|
v-if="activeScreen === 'Desk'"
|
|
|
|
@change-db-file="changeDbFile"
|
2022-04-21 18:38:36 +05:30
|
|
|
/>-->
|
2022-04-23 14:53:44 +05:30
|
|
|
<div
|
|
|
|
v-if="activeScreen === 'Desk'"
|
|
|
|
class="h-screen w-screen flex justify-center items-center bg-white"
|
|
|
|
>
|
|
|
|
<h1>Desk</h1>
|
|
|
|
</div>
|
|
|
|
|
2020-01-01 13:41:57 +05:30
|
|
|
<DatabaseSelector
|
|
|
|
v-if="activeScreen === 'DatabaseSelector'"
|
2022-04-22 16:32:03 +05:30
|
|
|
@file-selected="fileSelected"
|
2020-01-01 13:41:57 +05:30
|
|
|
/>
|
2022-04-22 16:32:03 +05:30
|
|
|
<SetupWizard
|
2020-01-01 13:41:57 +05:30
|
|
|
v-if="activeScreen === 'SetupWizard'"
|
2022-02-02 13:53:04 +05:30
|
|
|
@setup-complete="setupComplete"
|
2022-04-23 14:53:44 +05:30
|
|
|
@setup-canceled="changeDbFile"
|
2020-01-01 13:41:57 +05:30
|
|
|
/>
|
2022-02-16 16:07:09 +05:30
|
|
|
<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-23 14:53:44 +05:30
|
|
|
<TelemetryModal />
|
2018-06-01 18:05:51 +05:30
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-23 14:53:44 +05:30
|
|
|
import { ConfigKeys } from 'fyo/core/types';
|
|
|
|
import {
|
|
|
|
getSetupComplete,
|
|
|
|
incrementOpenCount,
|
|
|
|
startTelemetry
|
|
|
|
} from 'src/utils/misc';
|
|
|
|
import TelemetryModal from './components/once/TelemetryModal.vue';
|
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';
|
2022-04-23 14:53:44 +05:30
|
|
|
import setupInstance from './setup/setupInstance';
|
2022-03-11 15:15:43 +05:30
|
|
|
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',
|
2018-06-11 15:16:25 +05:30
|
|
|
data() {
|
|
|
|
return {
|
2021-11-04 15:03:51 +05:30
|
|
|
activeScreen: null,
|
2019-08-20 14:27:27 +05:30
|
|
|
};
|
2018-06-11 15:16:25 +05:30
|
|
|
},
|
2018-06-01 18:05:51 +05:30
|
|
|
components: {
|
2022-04-21 18:38:36 +05:30
|
|
|
// 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,
|
2022-04-23 14:53:44 +05:30
|
|
|
TelemetryModal,
|
2018-06-11 15:16:25 +05:30
|
|
|
},
|
2020-01-01 13:41:57 +05:30
|
|
|
async mounted() {
|
2022-04-21 18:38:36 +05:30
|
|
|
fyo.telemetry.platform = this.platform;
|
2021-11-06 01:11:39 +05:30
|
|
|
|
2022-04-23 14:53:44 +05:30
|
|
|
const lastSelectedFilePath = fyo.config.get(
|
|
|
|
ConfigKeys.LastSelectedFilePath,
|
|
|
|
null
|
|
|
|
);
|
2021-12-10 13:36:38 +05:30
|
|
|
|
|
|
|
if (lastSelectedFilePath) {
|
2022-04-23 14:53:44 +05:30
|
|
|
await this.fileSelected(lastSelectedFilePath, false);
|
|
|
|
return;
|
2018-10-23 18:12:36 +05:30
|
|
|
}
|
2021-12-10 13:36:38 +05:30
|
|
|
|
2022-04-23 14:53:44 +05:30
|
|
|
this.activeScreen = 'DatabaseSelector';
|
2020-01-01 13:41:57 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2022-04-23 14:53:44 +05:30
|
|
|
async setDesk() {
|
|
|
|
this.activeScreen = 'Desk';
|
|
|
|
incrementOpenCount();
|
|
|
|
await startTelemetry();
|
|
|
|
await checkForUpdates(false);
|
|
|
|
await this.setDeskRoute();
|
2022-02-02 13:53:04 +05:30
|
|
|
},
|
2022-04-22 16:32:03 +05:30
|
|
|
async fileSelected(filePath, isNew) {
|
2022-04-23 14:53:44 +05:30
|
|
|
fyo.config.set(ConfigKeys.LastSelectedFilePath, filePath);
|
2022-04-22 16:32:03 +05:30
|
|
|
if (isNew) {
|
|
|
|
this.activeScreen = 'SetupWizard';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
await this.showSetupWizardOrDesk(filePath);
|
|
|
|
},
|
2022-04-23 14:53:44 +05:30
|
|
|
async setupComplete(setupWizardOptions) {
|
|
|
|
const filePath = fyo.config.get(ConfigKeys.LastSelectedFilePath);
|
|
|
|
await setupInstance(filePath, setupWizardOptions);
|
|
|
|
await this.setDesk();
|
|
|
|
},
|
|
|
|
async showSetupWizardOrDesk(filePath) {
|
2022-04-22 16:32:03 +05:30
|
|
|
const countryCode = await fyo.db.connectToDatabase(filePath);
|
|
|
|
const setupComplete = await getSetupComplete();
|
|
|
|
|
2020-01-01 13:41:57 +05:30
|
|
|
if (!setupComplete) {
|
|
|
|
this.activeScreen = 'SetupWizard';
|
2022-04-22 16:32:03 +05:30
|
|
|
return;
|
2019-10-24 16:09:57 +05:30
|
|
|
}
|
2021-12-02 18:50:51 +05:30
|
|
|
|
2022-04-22 16:32:03 +05:30
|
|
|
await initializeInstance(filePath, false, countryCode);
|
2022-04-23 14:53:44 +05:30
|
|
|
await this.setDesk();
|
2022-04-22 16:32:03 +05:30
|
|
|
},
|
|
|
|
async setDeskRoute() {
|
|
|
|
const { onboardingComplete } = await fyo.doc.getSingle('GetStarted');
|
|
|
|
const { hideGetStarted } = await fyo.doc.getSingle('SystemSettings');
|
2021-12-02 18:50:51 +05:30
|
|
|
|
|
|
|
if (hideGetStarted || onboardingComplete) {
|
2021-11-24 14:38:13 +05:30
|
|
|
routeTo('/');
|
2021-12-02 18:50:51 +05:30
|
|
|
} else {
|
|
|
|
routeTo('/get-started');
|
2019-12-16 17:04:22 +05:30
|
|
|
}
|
2019-12-27 12:07:39 +05:30
|
|
|
},
|
2022-03-17 17:16:49 +05:30
|
|
|
async changeDbFile() {
|
2022-04-21 18:38:36 +05:30
|
|
|
fyo.config.set('lastSelectedFilePath', null);
|
2022-04-22 16:32:03 +05:30
|
|
|
fyo.telemetry.stop();
|
|
|
|
fyo.purgeCache();
|
2021-11-24 14:38:13 +05:30
|
|
|
this.activeScreen = 'DatabaseSelector';
|
|
|
|
},
|
2021-11-04 15:03:51 +05:30
|
|
|
},
|
2019-08-20 14:27:27 +05:30
|
|
|
};
|
2018-06-01 18:05:51 +05:30
|
|
|
</script>
|