Browse Source

chore(publish): v0.83.8

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/872/head 0.83.8
Pranav C 3 years ago
parent
commit
aa3348ae16
  1. 18
      packages/nc-gui/components/project/spreadsheet/components/editColumn/lookupOptions.vue
  2. 16
      packages/nc-gui/components/project/spreadsheet/components/editColumn/rollupOptions.vue
  3. 70
      packages/nc-gui/components/utils/betterUX.vue
  4. 5
      packages/nc-gui/layouts/default.vue
  5. 2
      packages/nc-lib-gui/package.json
  6. 8
      packages/nocodb/package-lock.json
  7. 4
      packages/nocodb/package.json
  8. 2
      packages/nocodb/src/lib/noco/Noco.ts
  9. 25
      packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts
  10. 113
      packages/nocodb/src/lib/noco/common/jobs/ncRemoveDuplicatedRelationRows.ts
  11. 7
      packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts
  12. 7
      packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts

18
packages/nc-gui/components/project/spreadsheet/components/editColumn/lookupOptions.vue

@ -59,11 +59,12 @@ export default {
mm: 'Many To Many',
hm: 'Has Many',
bt: 'Belongs To'
}
},
tables: []
}),
computed: {
refTables() {
return this.meta
return (this.meta
? [
...(this.meta.belongsTo || []).map(({ rtn, _rtn, rcn, tn, cn }) => ({
type: 'bt',
@ -106,7 +107,7 @@ export default {
_ltn: _rtn
}))
]
: []
: []).filter(t => this.tables.includes(t.ltn))
},
columnList() {
return ((
@ -121,7 +122,18 @@ export default {
}))
}
},
async mounted() {
await this.loadTablesList()
},
methods: {
async loadTablesList() {
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
env: this.nodes.env,
dbAlias: this.nodes.dbAlias
}, 'tableList'])
this.tables = result.data.list.map(({ tn }) => tn)
},
checkLookupExist(v) {
return (this.lookup.table && (this.meta.v || []).every(c => !(
c.lk &&

16
packages/nc-gui/components/project/spreadsheet/components/editColumn/rollupOptions.vue

@ -70,6 +70,7 @@ export default {
data: () => ({
rollup: {},
loadingColumns: false,
tables: [],
relationNames: {
mm: 'Many To Many',
hm: 'Has Many'
@ -89,7 +90,7 @@ export default {
}),
computed: {
refTables() {
return this.meta
return (this.meta
? [
// ...(this.meta.belongsTo || []).map(({ rtn, _rtn, rcn, tn, cn }) => ({
// type: 'bt',
@ -132,7 +133,7 @@ export default {
_rltn: _rtn
}))
]
: []
: []).filter(t => this.tables.includes(t.rltn))
},
columnList() {
return ((
@ -147,7 +148,18 @@ export default {
}))
}
},
async mounted() {
await this.loadTablesList()
},
methods: {
async loadTablesList() {
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
env: this.nodes.env,
dbAlias: this.nodes.dbAlias
}, 'tableList'])
this.tables = result.data.list.map(({ tn }) => tn)
},
async onTableChange() {
this.loadingColumns = true
if (this.rollup.table) {

70
packages/nc-gui/components/utils/betterUX.vue

@ -0,0 +1,70 @@
<template>
<div class="px-2">
<v-chip x-small>
Clicks : {{ clickCount }}
</v-chip>
<v-chip x-small>
Keystrokes : {{ keystrokeCount }}
</v-chip>
<v-chip x-small>
{{ (timer/ 1000).toFixed(1) }}
</v-chip>
<v-icon v-if="!pause" small @click="pause = true">
mdi-pause-circle-outline
</v-icon>
<v-icon v-else small @click="pause = false">
mdi-play-circle-outline
</v-icon>
<v-icon small @click="reset">
mdi-close-circle-outline
</v-icon>
</div>
</template>
<script>
export default {
name: 'BetterUX',
data() {
return {
pause: false,
clickCount: 0,
keystrokeCount: 0,
timer: 0,
interval: null
}
},
created() {
this.interval = setInterval(() => { if (!this.pause) { this.timer += 100 } }, 100)
document.addEventListener('click', this.onClick, true)
document.addEventListener('contextmenu', this.onClick, true)
document.addEventListener('keypress', this.onKeypress, true)
},
beforeDestroy() {
clearInterval(this.interval)
document.removeEventListener('click', this.onClick, true)
document.removeEventListener('contextmenu', this.onClick, true)
document.removeEventListener('keypress', this.onKeypress, true)
},
methods: {
reset() {
this.clickCount = 0
this.keystrokeCount = 0
this.timer = 0
},
onClick() {
if (!this.pause) {
this.clickCount++
}
},
onKeypress() {
if (!this.pause) {
this.keystrokeCount++
}
}
}
}
</script>
<style scoped>
</style>

5
packages/nc-gui/layouts/default.vue

@ -49,6 +49,8 @@
target="_blank"
>Docs</a>
<templates-modal v-if="isDashboard && _isUIAllowed('template-import')" v-model="templateModal" class="align-self-center" />
<!-- <better-u-x v-if="clickCount" />-->
</v-toolbar-items>
<!-- <template v-if="!isThisMobile ">
@ -582,9 +584,11 @@ import Snackbar from '~/components/snackbar'
import Language from '~/components/utils/language'
import Loader from '~/components/loader'
import TemplatesModal from '~/components/templates/templatesModal'
import BetterUX from '~/components/utils/betterUX'
export default {
components: {
BetterUX,
TemplatesModal,
Loader,
ReleaseInfo,
@ -598,6 +602,7 @@ export default {
xTerm
},
data: () => ({
clickCount: true,
templateModal: false,
ghStarText: 'Star',
swaggerOrGraphiqlUrl: null,

2
packages/nc-lib-gui/package.json

@ -1,6 +1,6 @@
{
"name": "nc-lib-gui",
"version": "0.83.119",
"version": "0.83.120",
"description": "> TODO: description",
"author": "“pranavxc” <pranavxc@gmail.com>",
"homepage": "https://gitlab.com/xgenecloud-ts/xgenecloud-ts#readme",

8
packages/nocodb/package-lock.json generated

@ -1,6 +1,6 @@
{
"name": "nocodb",
"version": "0.83.5",
"version": "0.83.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -12378,9 +12378,9 @@
}
},
"nc-lib-gui": {
"version": "0.83.119",
"resolved": "https://registry.npmjs.org/nc-lib-gui/-/nc-lib-gui-0.83.119.tgz",
"integrity": "sha512-T5DYY1xMa0OJgJdV3GuM36fLuF1tvNfudH6tuYqciUjE1/Odql3J92jSTOSwCsga2ySHth+5diKckLgh+FWGZA==",
"version": "0.83.120",
"resolved": "https://registry.npmjs.org/nc-lib-gui/-/nc-lib-gui-0.83.120.tgz",
"integrity": "sha512-lNDSNDa7AXYY8uWTy5DnfPui09Ff+o669AzKqnRpMMN/SKVABUBuUGs0dx9HFV+S8QFp+gJr5HyRm4p3VFZV2g==",
"requires": {
"axios": "^0.19.2",
"body-parser": "^1.19.0",

4
packages/nocodb/package.json

@ -1,6 +1,6 @@
{
"name": "nocodb",
"version": "0.83.6",
"version": "0.83.8",
"description": "xc-cli",
"main": "dist/bundle.js",
"repository": "https://github.com/nocodb/nocodb",
@ -148,7 +148,7 @@
"nanoid": "^3.1.20",
"nc-common": "0.0.6",
"nc-help": "^0.2.18",
"nc-lib-gui": "0.83.119",
"nc-lib-gui": "0.83.120",
"nc-plugin": "^0.1.1",
"ncp": "^2.0.0",
"nodemailer": "^6.4.10",

2
packages/nocodb/src/lib/noco/Noco.ts

@ -90,7 +90,7 @@ export default class Noco {
constructor() {
process.env.PORT = process.env.PORT || '8080';
// todo: move
process.env.NC_VERSION = '0083007';
process.env.NC_VERSION = '0083008';
this.router = express.Router();
this.projectRouter = express.Router();

25
packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

@ -30,6 +30,7 @@ import updateColumnNameInFormula from './helpers/updateColumnNameInFormula';
import addErrorOnColumnDeleteInFormula from './helpers/addErrorOnColumnDeleteInFormula';
import ncModelsOrderUpgrader from './jobs/ncModelsOrderUpgrader';
import ncParentModelTitleUpgrader from './jobs/ncParentModelTitleUpgrader';
import ncRemoveDuplicatedRelationRows from './jobs/ncRemoveDuplicatedRelationRows';
const log = debug('nc:api:base');
@ -1270,7 +1271,8 @@ export default abstract class BaseApiBuilder<T extends Noco>
{ name: '0009000', handler: null },
{ name: '0009044', handler: this.ncUpManyToMany.bind(this) },
{ name: '0083006', handler: ncModelsOrderUpgrader },
{ name: '0083007', handler: ncParentModelTitleUpgrader }
{ name: '0083007', handler: ncParentModelTitleUpgrader },
{ name: '0083008', handler: ncRemoveDuplicatedRelationRows }
];
if (!(await this.xcMeta?.knex?.schema?.hasTable?.('nc_store'))) {
return;
@ -1303,13 +1305,13 @@ export default abstract class BaseApiBuilder<T extends Noco>
});
// update version in meta after each upgrade
config.version = version.name;
configObj.version = version.name;
await this.xcMeta.metaUpdate(
this.projectId,
this.dbAlias,
'nc_store',
{
value: JSON.stringify(config)
value: JSON.stringify(configObj)
},
{
key: 'NC_CONFIG'
@ -1322,11 +1324,18 @@ export default abstract class BaseApiBuilder<T extends Noco>
break;
}
}
config.version = process.env.NC_VERSION;
await this.xcMeta.metaInsert(this.projectId, this.dbAlias, 'nc_store', {
key: 'NC_CONFIG',
value: JSON.stringify(config)
});
configObj.version = process.env.NC_VERSION;
await this.xcMeta.metaUpdate(
this.projectId,
this.dbAlias,
'nc_store',
{
value: JSON.stringify(configObj)
},
{
key: 'NC_CONFIG'
}
);
}
} else {
this.baseLog(`xcUpgrade : Inserting config to meta database`);

113
packages/nocodb/src/lib/noco/common/jobs/ncRemoveDuplicatedRelationRows.ts

@ -0,0 +1,113 @@
import { NcBuilderUpgraderCtx } from '../BaseApiBuilder';
export default async function(ctx: NcBuilderUpgraderCtx) {
try {
const relations = await ctx.xcMeta.metaList(
ctx.projectId,
ctx.dbAlias,
'nc_relations'
);
const duplicates = [];
for (const relation of relations) {
if (relation.type !== 'real' || duplicates.includes(relation)) continue;
const duplicateRelIndex = relations.findIndex(
rel =>
rel !== relation &&
rel.tn === relation.tn &&
rel.rtn === relation.rtn &&
rel.cn === relation.cn &&
rel.rcn === relation.rcn &&
rel.type === 'real'
);
if (duplicateRelIndex > -1) duplicates.push(relations[duplicateRelIndex]);
}
// delete relation
for (const dupRelation of duplicates) {
await ctx.xcMeta.metaDelete(
ctx.projectId,
ctx.dbAlias,
'nc_relations',
dupRelation.id
);
{
const tnModel = await ctx.xcMeta.metaGet(
ctx.projectId,
ctx.dbAlias,
'nc_models',
{
type: 'table',
title: dupRelation.tn
}
);
const meta = JSON.parse(tnModel.meta);
const duplicateBts = meta.belongsTo.filter(
bt =>
bt.tn === dupRelation.tn &&
bt.rtn === dupRelation.rtn &&
bt.cn === dupRelation.cn &&
bt.rcn === dupRelation.rcn &&
bt.type === 'real'
);
if (duplicateBts?.length > 1) {
meta.belongsTo.splice(meta.belongsTo.indexOf(duplicateBts[1]), 1);
}
await ctx.xcMeta.metaUpdate(
ctx.projectId,
ctx.dbAlias,
'nc_models',
{ meta: JSON.stringify(meta) },
{
type: 'table',
title: dupRelation.tn
}
);
}
{
const rtnModel = await ctx.xcMeta.metaGet(
ctx.projectId,
ctx.dbAlias,
'nc_models',
{
type: 'table',
title: dupRelation.rtn
}
);
const meta = JSON.parse(rtnModel.meta);
const duplicateHms = meta.hasMany.filter(
bt =>
bt.tn === dupRelation.tn &&
bt.rtn === dupRelation.rtn &&
bt.cn === dupRelation.cn &&
bt.rcn === dupRelation.rcn &&
bt.type === 'real'
);
if (duplicateHms?.length > 1) {
meta.hasMany.splice(meta.hasMany.indexOf(duplicateHms[1]), 1);
}
await ctx.xcMeta.metaUpdate(
ctx.projectId,
ctx.dbAlias,
'nc_models',
{ meta: JSON.stringify(meta) },
{
type: 'table',
title: dupRelation.rtn
}
);
}
}
} catch (e) {
console.log(e);
}
}

7
packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts

@ -730,11 +730,12 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr {
let tables;
/* Get all relations */
let [
/* let [
relations,
missingRelations
] = await this.getRelationsAndMissingRelations();
relations = relations.concat(missingRelations);
relations = relations.concat(missingRelations);*/
const relations = await this.relationsSyncAndGet();
// set table name alias
relations.forEach(r => {
@ -850,7 +851,7 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr {
}
this.tablesCount = tables.length;
await this.syncRelations();
// await this.syncRelations();
if (tables.length) {
relations.forEach(rel => (rel.enabled = true));

7
packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts

@ -356,13 +356,14 @@ export class RestApiBuilder extends BaseApiBuilder<Noco> {
const swaggerRefs: { [table: string]: any[] } = {};
let order = await this.getOrderVal();
/* Get all relations */
/* /!* Get all relations *!/
let [
relations,
// eslint-disable-next-line prefer-const
missingRelations
] = await this.getRelationsAndMissingRelations();
relations = relations.concat(missingRelations);
relations = relations.concat(missingRelations);*/
const relations = await this.relationsSyncAndGet();
// set table name alias
relations.forEach(r => {
@ -455,7 +456,7 @@ export class RestApiBuilder extends BaseApiBuilder<Noco> {
r._rtn = this.getTableNameAlias(r.rtn);
});
this.syncRelations();
// await this.syncRelations();
const tableRoutes = tables.map(table => {
return async () => {

Loading…
Cancel
Save