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.
236 lines
7.5 KiB
236 lines
7.5 KiB
3 years ago
|
<template>
|
||
3 years ago
|
<div>
|
||
3 years ago
|
<v-icon color="grey" small> mdi-open-in-new </v-icon>
|
||
3 years ago
|
<span class="grey--text caption">
|
||
|
<!-- Shared base link -->
|
||
3 years ago
|
{{ $t('activity.shareBase.link') }}
|
||
3 years ago
|
</span>
|
||
3 years ago
|
<div class="nc-container">
|
||
3 years ago
|
<v-chip v-if="base.uuid" :color="colors[4]" style="" class="rounded pl-1 pr-0 d-100 nc-url-chip pr-3">
|
||
3 years ago
|
<div class="nc-url-wrapper d-flex mx-1 align-center d-100">
|
||
3 years ago
|
<span class="nc-url flex-grow-1 caption">{{ url }}</span>
|
||
3 years ago
|
<v-spacer />
|
||
3 years ago
|
<v-divider vertical />
|
||
3 years ago
|
|
||
|
<!-- tooltip="reload" -->
|
||
3 years ago
|
<x-icon :tooltip="$t('general.reload')" @click="recreate"> mdi-reload </x-icon>
|
||
3 years ago
|
|
||
|
<!-- tooltip="copy URL" -->
|
||
3 years ago
|
<x-icon :tooltip="$t('activity.copyUrl')" @click="copyUrl"> mdi-content-copy </x-icon>
|
||
3 years ago
|
|
||
|
<!-- tooltip="open new tab" -->
|
||
3 years ago
|
<x-icon :tooltip="$t('activity.openTab')" @click="navigateToSharedBase"> mdi-open-in-new </x-icon>
|
||
3 years ago
|
|
||
|
<!-- tooltip="copy embeddable HTML code" -->
|
||
3 years ago
|
<x-icon :tooltip="$t('activity.iFrame')" @click="generateEmbeddableIframe"> mdi-xml </x-icon>
|
||
3 years ago
|
</div>
|
||
3 years ago
|
</v-chip>
|
||
3 years ago
|
|
||
|
<div class="d-flex align-center px-2">
|
||
|
<div>
|
||
|
<v-menu offset-x>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
3 years ago
|
<div class="my-2" v-on="on">
|
||
3 years ago
|
<div class="font-weight-bold nc-disable-shared-base">
|
||
3 years ago
|
<span v-if="base.uuid">
|
||
3 years ago
|
<!-- Anyone with the link -->
|
||
3 years ago
|
{{ $t('activity.shareBase.enable') }}
|
||
3 years ago
|
</span>
|
||
|
<span v-else>
|
||
|
<!-- Disable shared base -->
|
||
3 years ago
|
{{ $t('activity.shareBase.disable') }}
|
||
3 years ago
|
</span>
|
||
3 years ago
|
<v-icon small> mdi-menu-down-outline </v-icon>
|
||
3 years ago
|
</div>
|
||
|
</div>
|
||
|
</template>
|
||
|
<v-list dense>
|
||
3 years ago
|
<v-list-item v-if="!base.uuid" dense @click="createSharedBase('viewer')">
|
||
3 years ago
|
<v-list-item-title>
|
||
3 years ago
|
<v-icon small class="mr-1"> mdi-link-variant </v-icon>
|
||
3 years ago
|
<span class="caption">
|
||
|
<!-- Anyone with the link -->
|
||
3 years ago
|
{{ $t('activity.shareBase.enable') }}
|
||
3 years ago
|
</span>
|
||
3 years ago
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-if="base.uuid" dense @click="disableSharedBase">
|
||
3 years ago
|
<v-list-item-title>
|
||
3 years ago
|
<v-icon small class="mr-1"> mdi-link-variant-off </v-icon>
|
||
3 years ago
|
<span class="caption">
|
||
|
<!-- Disable shared base -->
|
||
3 years ago
|
{{ $t('activity.shareBase.disable') }}
|
||
3 years ago
|
</span>
|
||
3 years ago
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
3 years ago
|
<div class="caption">
|
||
3 years ago
|
<template v-if="base.enabled">
|
||
3 years ago
|
<span v-if="base.roles === 'editor'">
|
||
|
Anyone on the internet with this link can edit
|
||
|
<!-- {{ $t('msg.info.shareBasePrivate') }} -->
|
||
|
</span>
|
||
|
<span v-else-if="base.roles === 'viewer'">
|
||
|
<!-- Anyone on the internet with this link can view -->
|
||
3 years ago
|
{{ $t('msg.info.shareBasePublic') }}
|
||
3 years ago
|
</span>
|
||
3 years ago
|
</template>
|
||
|
<template v-else>
|
||
3 years ago
|
<!-- Generate publicly shareable readonly base -->
|
||
3 years ago
|
{{ $t('msg.info.shareBasePrivate') }}
|
||
3 years ago
|
</template>
|
||
|
</div>
|
||
|
</div>
|
||
|
<v-spacer />
|
||
3 years ago
|
<div class="d-flex justify-center" style="width: 120px">
|
||
3 years ago
|
<v-menu v-if="base.uuid" offset-y>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
3 years ago
|
<div
|
||
3 years ago
|
class="text-capitalize my-2 font-weight-bold backgroundColorDefault py-2 px-4 rounded nc-shared-base-role"
|
||
3 years ago
|
v-on="on"
|
||
|
>
|
||
3 years ago
|
{{ base.roles || 'Viewer' }}
|
||
3 years ago
|
|
||
3 years ago
|
<v-icon small> mdi-menu-down-outline </v-icon>
|
||
3 years ago
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<v-list dense>
|
||
|
<v-list-item @click="createSharedBase('editor')">
|
||
|
<v-list-item-title>
|
||
3 years ago
|
<!-- Editor -->
|
||
3 years ago
|
{{ $t('objects.roleType.editor') }}
|
||
3 years ago
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
<v-list-item @click="createSharedBase('viewer')">
|
||
|
<v-list-item-title>
|
||
3 years ago
|
<!-- Viewer -->
|
||
3 years ago
|
{{ $t('objects.roleType.viewer') }}
|
||
3 years ago
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
|
</div>
|
||
|
</div>
|
||
3 years ago
|
</div>
|
||
3 years ago
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import colors from '~/mixins/colors';
|
||
|
import { copyTextToClipboard } from '~/helpers/xutils';
|
||
3 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'ShareBase',
|
||
3 years ago
|
mixins: [colors],
|
||
|
data: () => ({
|
||
|
base: {
|
||
3 years ago
|
enable: false,
|
||
|
},
|
||
3 years ago
|
}),
|
||
3 years ago
|
computed: {
|
||
|
url() {
|
||
3 years ago
|
return this.base && this.base.uuid ? `${this.dashboardUrl}#/nc/base/${this.base.uuid}` : null;
|
||
3 years ago
|
},
|
||
3 years ago
|
},
|
||
3 years ago
|
mounted() {
|
||
3 years ago
|
this.loadSharedBase();
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
|
async loadSharedBase() {
|
||
|
try {
|
||
3 years ago
|
// const sharedBase = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
// { dbAlias: 'db' }, 'getSharedBaseLink'])
|
||
3 years ago
|
const sharedBase = await this.$api.project.sharedBaseGet(this.$store.state.project.projectId);
|
||
3 years ago
|
|
||
3 years ago
|
this.base = sharedBase || {};
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async createSharedBase(roles = 'viewer') {
|
||
3 years ago
|
try {
|
||
3 years ago
|
// const sharedBase = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ dbAlias: 'db' }, 'createSharedBaseLink', { roles }])
|
||
3 years ago
|
const sharedBase = await this.$api.project.sharedBaseUpdate(this.$store.state.project.projectId, { roles });
|
||
3 years ago
|
|
||
3 years ago
|
this.base = sharedBase || {};
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('a:shared-base:enable', { role: roles });
|
||
3 years ago
|
},
|
||
|
async disableSharedBase() {
|
||
|
try {
|
||
3 years ago
|
await this.$api.project.sharedBaseDisable(this.$store.state.project.projectId);
|
||
3 years ago
|
this.base = {};
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('a:shared-base:disable');
|
||
3 years ago
|
},
|
||
|
async recreate() {
|
||
|
try {
|
||
3 years ago
|
const sharedBase = await this.$api.project.sharedBaseCreate(this.$store.state.project.projectId, {
|
||
|
roles: this.base.roles || 'viewer',
|
||
|
});
|
||
3 years ago
|
this.base = sharedBase || {};
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('a:shared-base:recreate');
|
||
3 years ago
|
},
|
||
|
copyUrl() {
|
||
3 years ago
|
copyTextToClipboard(this.url);
|
||
3 years ago
|
this.$toast.success('Copied shareable base url to clipboard!').goAway(3000);
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('c:shared-base:copy-url');
|
||
3 years ago
|
},
|
||
|
navigateToSharedBase() {
|
||
3 years ago
|
window.open(this.url, '_blank');
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('c:shared-base:open-url');
|
||
3 years ago
|
},
|
||
|
generateEmbeddableIframe() {
|
||
|
copyTextToClipboard(`<iframe
|
||
|
class="nc-embed"
|
||
3 years ago
|
src="${this.url}?embed"
|
||
|
frameborder="0"
|
||
|
width="100%"
|
||
|
height="700"
|
||
3 years ago
|
style="background: transparent; border: 1px solid #ddd"></iframe>`);
|
||
3 years ago
|
this.$toast.success('Copied embeddable html code!').goAway(3000);
|
||
3 years ago
|
|
||
3 years ago
|
this.$e('c:shared-base:copy-embed-frame');
|
||
3 years ago
|
},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
.nc-url-wrapper {
|
||
3 years ago
|
column-gap: 15px;
|
||
3 years ago
|
width: 100%;
|
||
3 years ago
|
}
|
||
|
|
||
|
.nc-url {
|
||
|
min-width: 0;
|
||
|
overflow: hidden;
|
||
|
text-overflow: ellipsis;
|
||
|
}
|
||
|
|
||
|
.nc-container {
|
||
|
border-radius: 4px;
|
||
|
border: 2px solid var(--v-backgroundColor-base);
|
||
3 years ago
|
background: var(--v-backgroundColor-base);
|
||
3 years ago
|
padding: 20px 20px;
|
||
|
}
|
||
3 years ago
|
|
||
|
/deep/ .nc-url-chip .v-chip__content {
|
||
3 years ago
|
width: 100%;
|
||
3 years ago
|
}
|
||
3 years ago
|
</style>
|