mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
293 lines
9.4 KiB
293 lines
9.4 KiB
4 years ago
|
<template>
|
||
3 years ago
|
<div class="mt-5">
|
||
|
<!-- <h3 class="text-center mb-5 grey--text text--darken-2">
|
||
|
<!– Metadata Operations –>
|
||
3 years ago
|
{{ $t('title.metaOperations') }}
|
||
3 years ago
|
</h3>-->
|
||
4 years ago
|
|
||
|
<v-simple-table class="ma-2 meta-table text-center mx-auto">
|
||
|
<tbody>
|
||
4 years ago
|
<tr>
|
||
|
<td>
|
||
|
<!-- Export project meta to zip file and download. -->
|
||
2 years ago
|
{{ $t('msg.info.exportZip') }}
|
||
4 years ago
|
</td>
|
||
|
<td>
|
||
|
<v-btn
|
||
3 years ago
|
v-t="['c:proj-meta:export']"
|
||
4 years ago
|
min-width="150"
|
||
|
color="primary"
|
||
|
small
|
||
|
outlined
|
||
|
:loading="loading === 'export-zip'"
|
||
|
@click="exportMetaZip()"
|
||
|
>
|
||
2 years ago
|
<v-icon small> mdi-export </v-icon>
|
||
4 years ago
|
<!-- Export zip -->
|
||
2 years ago
|
{{ $t('activity.exportZip') }}
|
||
4 years ago
|
</v-btn>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
<!-- Import project meta zip file and restart. -->
|
||
2 years ago
|
{{ $t('msg.info.importZip') }}
|
||
4 years ago
|
</td>
|
||
|
<td>
|
||
|
<v-btn
|
||
3 years ago
|
v-t="['a:proj-meta:import']"
|
||
4 years ago
|
min-width="150"
|
||
|
:loading="loading === 'import-zip'"
|
||
|
color="info"
|
||
|
small
|
||
|
outlined
|
||
|
@click="$refs.importFile.click()"
|
||
|
>
|
||
2 years ago
|
<v-icon small> mdi-import </v-icon>
|
||
4 years ago
|
|
||
4 years ago
|
<!-- Import Zip -->
|
||
2 years ago
|
{{ $t('activity.importZip') }}
|
||
4 years ago
|
</v-btn>
|
||
4 years ago
|
|
||
2 years ago
|
<input v-show="false" ref="importFile" type="file" accept=".zip" @change="importMetaZip" />
|
||
4 years ago
|
</td>
|
||
|
</tr>
|
||
3 years ago
|
<!-- <tr>-->
|
||
|
<!-- <td>-->
|
||
|
<!-- <!– Clear all metadata from meta tables. –>-->
|
||
|
<!-- {{ $t('tooltip.clearMetadata') }}-->
|
||
|
<!-- </td>-->
|
||
|
<!-- <td>-->
|
||
|
<!-- <v-btn-->
|
||
|
<!-- :loading="loading === 'reset-metadata'"-->
|
||
|
<!-- min-width="150"-->
|
||
|
<!-- color="error"-->
|
||
|
<!-- small-->
|
||
|
<!-- outlined-->
|
||
|
<!-- @click="resetMeta"-->
|
||
|
<!-- >-->
|
||
|
<!-- <v-icon small>-->
|
||
|
<!-- mdi-delete-variant-->
|
||
|
<!-- </v-icon> -->
|
||
|
<!-- <!– Reset –>-->
|
||
|
<!-- {{ $t('general.reset') }}-->
|
||
|
<!-- </v-btn>-->
|
||
|
<!-- </td>-->
|
||
|
<!-- </tr>-->
|
||
4 years ago
|
</tbody>
|
||
|
</v-simple-table>
|
||
|
|
||
|
<dlg-label-submit-cancel
|
||
|
v-if="dialogShow"
|
||
3 years ago
|
type="primary"
|
||
|
:actions-mtd="confirmAction"
|
||
|
:dialog-show="dialogShow"
|
||
4 years ago
|
:heading="confirmMessage"
|
||
3 years ago
|
/>
|
||
3 years ago
|
|
||
3 years ago
|
<!-- <import-template-->
|
||
|
<!-- :nodes="{dbAlias: 'db'}"-->
|
||
|
<!-- />-->
|
||
4 years ago
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import DlgLabelSubmitCancel from '~/components/utils/DlgLabelSubmitCancel';
|
||
3 years ago
|
// import ImportTemplate from '~/components/project/settings/importTemplate'
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'XcMeta',
|
||
4 years ago
|
components: {
|
||
3 years ago
|
// ImportTemplate,
|
||
2 years ago
|
DlgLabelSubmitCancel,
|
||
4 years ago
|
},
|
||
|
data: () => ({
|
||
|
loading: null,
|
||
|
dialogShow: false,
|
||
|
confirmAction: null,
|
||
2 years ago
|
confirmMessage: '',
|
||
4 years ago
|
}),
|
||
|
methods: {
|
||
3 years ago
|
async exportMeta() {
|
||
2 years ago
|
this.dialogShow = true;
|
||
3 years ago
|
// this.confirmMessage = 'Do you want to export metadata from meta tables?'
|
||
2 years ago
|
this.confirmMessage = `${this.$t('msg.info.exportMetadata')}`;
|
||
|
this.confirmAction = async act => {
|
||
3 years ago
|
if (act === 'hideDialog') {
|
||
2 years ago
|
this.dialogShow = false;
|
||
4 years ago
|
} else {
|
||
2 years ago
|
this.loading = 'export-file';
|
||
4 years ago
|
try {
|
||
3 years ago
|
// todo: set env based on `nodes` prop
|
||
3 years ago
|
await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
4 years ago
|
{
|
||
|
// dbAlias: 'db',
|
||
2 years ago
|
env: '_noco',
|
||
4 years ago
|
},
|
||
2 years ago
|
'xcMetaTablesExportDbToLocalFs',
|
||
|
]);
|
||
3 years ago
|
// this.$toast.success('Successfully exported metadata').goAway(3000)
|
||
2 years ago
|
this.$toast.success(`${this.$t('msg.toast.exportMetadata')}`).goAway(3000);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.dialogShow = false;
|
||
|
this.loading = null;
|
||
4 years ago
|
}
|
||
2 years ago
|
};
|
||
4 years ago
|
},
|
||
3 years ago
|
async exportMetaZip() {
|
||
2 years ago
|
this.dialogShow = true;
|
||
3 years ago
|
// this.confirmMessage = 'Do you want to export metadata from meta tables?'
|
||
2 years ago
|
this.confirmMessage = `${this.$t('msg.info.exportMetadata')}`;
|
||
|
this.confirmAction = async act => {
|
||
3 years ago
|
if (act === 'hideDialog') {
|
||
2 years ago
|
this.dialogShow = false;
|
||
4 years ago
|
} else {
|
||
2 years ago
|
this.loading = 'export-zip';
|
||
|
let data;
|
||
4 years ago
|
try {
|
||
3 years ago
|
data = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
4 years ago
|
{
|
||
|
// dbAlias: 'db',
|
||
2 years ago
|
env: '_noco',
|
||
4 years ago
|
},
|
||
3 years ago
|
'xcMetaTablesExportDbToZip',
|
||
4 years ago
|
null,
|
||
|
null,
|
||
|
{
|
||
2 years ago
|
responseType: 'blob',
|
||
|
},
|
||
|
]);
|
||
|
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/zip' }));
|
||
|
const link = document.createElement('a');
|
||
|
link.href = url;
|
||
|
link.setAttribute('download', 'meta.zip'); // or any other extension
|
||
|
document.body.appendChild(link);
|
||
|
link.click();
|
||
3 years ago
|
// this.$toast.success('Successfully exported metadata').goAway(3000)
|
||
2 years ago
|
this.$toast.success(`${this.$t('msg.toast.exportMetadata')}`).goAway(3000);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.dialogShow = false;
|
||
|
this.loading = null;
|
||
|
this.$e('a:proj-meta:export');
|
||
4 years ago
|
}
|
||
2 years ago
|
};
|
||
4 years ago
|
},
|
||
3 years ago
|
async resetMeta() {
|
||
2 years ago
|
this.dialogShow = true;
|
||
3 years ago
|
// this.confirmMessage = 'Do you want to clear metadata from meta tables?'
|
||
2 years ago
|
this.confirmMessage = `${this.$t('msg.info.clearMetadata')}`;
|
||
|
this.confirmAction = async act => {
|
||
3 years ago
|
if (act === 'hideDialog') {
|
||
2 years ago
|
this.dialogShow = false;
|
||
4 years ago
|
} else {
|
||
2 years ago
|
this.loading = 'reset-metadata';
|
||
4 years ago
|
try {
|
||
3 years ago
|
await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
4 years ago
|
{
|
||
|
// dbAlias: 'db',
|
||
2 years ago
|
env: '_noco',
|
||
4 years ago
|
},
|
||
2 years ago
|
'xcMetaTablesReset',
|
||
|
]);
|
||
3 years ago
|
// this.$toast.success('Metadata cleared successfully').goAway(3000)
|
||
2 years ago
|
this.$toast.success(`${this.$t('msg.toast.clearMetadata')}`).goAway(3000);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.dialogShow = false;
|
||
|
this.loading = null;
|
||
4 years ago
|
}
|
||
2 years ago
|
};
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
async importMeta() {
|
||
2 years ago
|
this.dialogShow = true;
|
||
3 years ago
|
// this.confirmMessage = 'Do you want to import metadata from meta directory?'
|
||
2 years ago
|
this.confirmMessage = `${this.$t('msg.info.importMetadata')}`;
|
||
|
this.confirmAction = async act => {
|
||
3 years ago
|
if (act === 'hideDialog') {
|
||
2 years ago
|
this.dialogShow = false;
|
||
4 years ago
|
} else {
|
||
2 years ago
|
this.loading = 'import-file';
|
||
4 years ago
|
try {
|
||
3 years ago
|
await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
4 years ago
|
{
|
||
2 years ago
|
env: '_noco',
|
||
4 years ago
|
},
|
||
2 years ago
|
'xcMetaTablesImportLocalFsToDb',
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
// this.$toast.success('Metadata imported successfully').goAway(3000)
|
||
2 years ago
|
this.$toast.success(`${this.$t('msg.toast.importMetadata')}`).goAway(3000);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.dialogShow = false;
|
||
|
this.loading = null;
|
||
4 years ago
|
}
|
||
2 years ago
|
};
|
||
4 years ago
|
},
|
||
3 years ago
|
async importMetaZip() {
|
||
2 years ago
|
if (this.$refs.importFile && this.$refs.importFile.files && this.$refs.importFile.files[0]) {
|
||
|
const zipFile = this.$refs.importFile.files[0];
|
||
|
this.loading = 'import-zip';
|
||
4 years ago
|
try {
|
||
2 years ago
|
this.$refs.importFile.value = '';
|
||
3 years ago
|
await this.$store.dispatch('sqlMgr/ActUploadOld', [
|
||
4 years ago
|
{
|
||
2 years ago
|
env: '_noco',
|
||
4 years ago
|
},
|
||
3 years ago
|
'xcMetaTablesImportZipToLocalFsAndDb',
|
||
3 years ago
|
{
|
||
2 years ago
|
importsToCurrentProject: true,
|
||
3 years ago
|
},
|
||
2 years ago
|
zipFile,
|
||
|
]);
|
||
3 years ago
|
// this.$toast.success('Successfully imported metadata').goAway(3000)
|
||
2 years ago
|
this.$toast.success(`${this.$t('msg.toast.importMetadata')}`).goAway(3000);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.dialogShow = false;
|
||
|
this.loading = null;
|
||
4 years ago
|
}
|
||
2 years ago
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
.meta-table {
|
||
|
max-width: 700px;
|
||
|
}
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
4 years ago
|
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
|
||
4 years ago
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|