support data export

This commit is contained in:
MaysWind
2021-01-02 02:04:38 +08:00
parent 102c945aa0
commit 7d3e05c548
24 changed files with 515 additions and 42 deletions
+7 -1
View File
@@ -3,10 +3,12 @@ import moment from 'moment';
import userState from "./userstate.js";
import exchangeRates from "./exchangeRates.js";
const baseUrlPath = '/api';
let needBlockRequest = false;
let blockedRequests = [];
axios.defaults.baseURL = '/api';
axios.defaults.baseURL = baseUrlPath;
axios.interceptors.request.use(config => {
const token = userState.getToken();
@@ -121,6 +123,10 @@ export default {
blockedRequests.length = 0;
});
},
getDataExportUrl: () => {
const token = userState.getToken();
return `${baseUrlPath}/data/export.csv?token=${token}`;
},
getTokens: () => {
return axios.get('v1/tokens/list.json');
},
+1
View File
@@ -95,5 +95,6 @@ export default {
isEnableAutoDarkMode: () => getOption('autoDarkMode'),
setEnableAutoDarkMode: value => setOption('autoDarkMode', value),
isUserRegistrationEnabled: () => getServerSetting('r') === '1',
isDataExportingEnabled: () => getServerSetting('e') === '1',
clearSettings: clearSettings
};
+2
View File
@@ -574,6 +574,8 @@ export default {
'Nothing has been modified': 'Nothing has been modified',
'Your profile has been successfully updated': 'Your profile has been successfully updated',
'Unable to update user profile': 'Unable to update user profile',
'Data Management': 'Data Management',
'Export Data': 'Export Data',
'Device & Sessions': 'Device & Sessions',
'Logout All': 'Logout All',
'Unable to get session list': 'Unable to get session list',
+2
View File
@@ -574,6 +574,8 @@ export default {
'Nothing has been modified': '没有修改的项目',
'Your profile has been successfully updated': '您的用户信息更新成功',
'Unable to update user profile': '无法更新用户信息',
'Data Management': '数据管理',
'Export Data': '导出数据',
'Device & Sessions': '设备和会话',
'Logout All': '注销全部',
'Unable to get session list': '无法获取会话列表',
+6
View File
@@ -19,6 +19,7 @@ import ExchangeRatesPage from "../views/mobile/ExchangeRates.vue";
import AboutPage from "../views/mobile/About.vue";
import UserProfilePage from "../views/mobile/users/UserProfile.vue";
import DataManagementPage from "../views/mobile/users/DataManagement.vue";
import TwoFactorAuthPage from "../views/mobile/users/TwoFactorAuth.vue";
import SessionListPage from "../views/mobile/users/SessionList.vue";
@@ -199,6 +200,11 @@ const routes = [
component: UserProfilePage,
beforeEnter: checkLogin
},
{
path: '/user/data/management',
component: DataManagementPage,
beforeEnter: checkLogin
},
{
path: '/user/2fa',
component: TwoFactorAuthPage,
+4
View File
@@ -9,6 +9,7 @@
<f7-list-item :title="$t('User Profile')" link="/user/profile"></f7-list-item>
<f7-list-item :title="$t('Transaction Categories')" link="/category/all"></f7-list-item>
<f7-list-item :title="$t('Transaction Tags')" link="/tag/list"></f7-list-item>
<f7-list-item :title="$t('Data Management')" link="/user/data/management" v-if="isDataExportingEnabled"></f7-list-item>
<f7-list-item :title="$t('Two-Factor Authentication')" link="/user/2fa"></f7-list-item>
<f7-list-item :title="$t('Device & Sessions')" link="/user/sessions"></f7-list-item>
<f7-list-button :class="{ 'disabled': logouting }" @click="logout">{{ $t('Log Out') }}</f7-list-button>
@@ -107,6 +108,9 @@ export default {
this.exchangeRatesLastUpdateDate = this.getExchangeRatesLastUpdateDate();
}
},
isDataExportingEnabled() {
return this.$settings.isDataExportingEnabled();
},
isAutoUpdateExchangeRatesData: {
get: function () {
return this.$settings.isAutoUpdateExchangeRatesData();
+21
View File
@@ -0,0 +1,21 @@
<template>
<f7-page>
<f7-navbar :title="$t('Data Management')" :back-link="$t('Back')"></f7-navbar>
<f7-card>
<f7-card-content class="no-safe-areas" :padding="false">
<f7-list>
<f7-list-button external no-chevron target="_blank" :link="$services.getDataExportUrl()">{{ $t('Export Data') }}</f7-list-button>
</f7-list>
</f7-card-content>
</f7-card>
</f7-page>
</template>
<script>
export default {
data() {
return {};
}
};
</script>