Browse Source

feat: show not found if a view doesn't exist

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/644/head
Pranav C 3 years ago
parent
commit
6cc85d00f8
  1. 16
      packages/nc-gui/components/project/spreadsheet/public/xcForm.vue
  2. 68
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

16
packages/nc-gui/components/project/spreadsheet/public/xcForm.vue

@ -1,6 +1,10 @@
<template>
<v-container class="h-100 j-excel-container">
<v-row :class="{'d-flex justify-center': submitted}">
<v-alert v-if="notFound" type="warning" class="mx-auto mt-10" outlined max-width="300">
Not found
</v-alert>
<v-row v-else :class="{'d-flex justify-center': submitted}">
<template v-if="submitted">
<v-col class="d-flex justify-center">
<div v-if="localParams && localParams.submit" style="min-width: 350px">
@ -226,7 +230,8 @@ export default {
dbAlias: '',
virtual: {},
metas: {},
secondsRemain: null
secondsRemain: null,
notFound: false
}
},
computed: {
@ -314,8 +319,11 @@ export default {
this.localParams = (this.query_params.extraViewParams && this.query_params.extraViewParams.formParams) || {}
} catch (e) {
console.log(e)
this.showPasswordModal = true
if (e.message === 'Not found') {
this.notFound = true
} else {
this.showPasswordModal = true
}
}
this.loadingData = false

68
packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

@ -3537,48 +3537,48 @@ export default class NcMetaMgr {
}
protected async sharedViewGet(_req, args: any): Promise<any> {
const viewMeta = await this.xcMeta
.knex('nc_shared_views')
.where({
view_id: args.args.view_id
})
.first();
if (!viewMeta) {
throw new Error('Not found');
}
// todo : filter out columns of related table
try {
const viewMeta = await this.xcMeta
.knex('nc_shared_views')
.where({
view_id: args.args.view_id
})
.first();
const apiBuilder = this.app?.projectBuilders
?.find(pb => pb.id === viewMeta.project_id)
?.apiBuilders?.find(ab => ab.dbAlias === viewMeta.db_alias);
// todo : filter out columns of related table
try {
const apiBuilder = this.app?.projectBuilders
?.find(pb => pb.id === viewMeta.project_id)
?.apiBuilders?.find(ab => ab.dbAlias === viewMeta.db_alias);
const tableMeta = JSON.parse(viewMeta.meta);
const relatedTableMetas = {};
for (const v of tableMeta.v) {
let tn;
if (v.bt) {
tn = v.bt.rtn;
} else if (v.hm) {
tn = v.hm.tn;
} else if (v.mm) {
tn = v.mm.rtn;
relatedTableMetas[v.mm.vtn] = apiBuilder?.getMeta(v.mm.vtn);
}
relatedTableMetas[tn] = apiBuilder?.getMeta(tn);
}
const tableMeta = JSON.parse(viewMeta.meta);
viewMeta.client = apiBuilder?.client;
const relatedTableMetas = {};
viewMeta.relatedTableMetas = relatedTableMetas;
} catch (e) {
console.log(e);
for (const v of tableMeta.v) {
let tn;
if (v.bt) {
tn = v.bt.rtn;
} else if (v.hm) {
tn = v.hm.tn;
} else if (v.mm) {
tn = v.mm.rtn;
relatedTableMetas[v.mm.vtn] = apiBuilder?.getMeta(v.mm.vtn);
}
relatedTableMetas[tn] = apiBuilder?.getMeta(tn);
}
return viewMeta;
viewMeta.client = apiBuilder?.client;
viewMeta.relatedTableMetas = relatedTableMetas;
} catch (e) {
throw e;
console.log(e);
}
return viewMeta;
}
protected async xcAuthHookGet(args: any): Promise<any> {

Loading…
Cancel
Save