Browse Source

feat: add project info option to copy project details

Signed-off-by: Pranav C Balan <pranavxc@gmail.com>
pull/262/head
Pranav C Balan 4 years ago
parent
commit
2f7e854c28
  1. 26
      packages/nc-gui/layouts/default.vue
  2. 1
      packages/nocodb/package.json
  3. 27
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts
  4. 2
      packages/nocodb/src/lib/sqlMgr/SqlMgr.ts

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

@ -25,7 +25,10 @@
</v-btn>
</template>
Home
<span class="caption ml-1 font-weight-light">(v{{$store.state.project.projectInfo && $store.state.project.projectInfo.version}})</span>
<span
class="caption ml-1 font-weight-light">(v{{
$store.state.project.projectInfo && $store.state.project.projectInfo.version
}})</span>
</v-tooltip>
<template><span class="title"> {{ brandName }}</span>
</template>
@ -235,7 +238,7 @@
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon @dblclick="showAppStore=true" @click="changeTheme" v-on="on" size="20"
class="ml-3"> {{$vuetify.theme.dark ? 'mdi-weather-sunny':'mdi-weather-night'}}
class="ml-3"> {{ $vuetify.theme.dark ? 'mdi-weather-sunny' : 'mdi-weather-night' }}
</v-icon>
</template>
<span class="caption">
@ -645,6 +648,13 @@
</v-list-item>
<v-list-item v-if="isDashboard" dense @click="copyProjectInfo" v-ge="['Sign Out','']">
<v-list-item-title>
<v-icon small>info</v-icon>&nbsp; <span class="font-weight-regular">Copy Project info</span>
</v-list-item-title>
</v-list-item>
<v-list-item dense @click="MtdSignOut" v-ge="['Sign Out','']">
<v-list-item-title>
@ -824,6 +834,7 @@ import 'splitpanes/dist/splitpanes.css'
import XBtn from "../components/global/xBtn";
import ChangeEnv from "../components/changeEnv";
import Discord from "@/components/discord";
import {copyTextToClipboard} from "@/helpers/xutils";
export default {
components: {
@ -1296,6 +1307,15 @@ export default {
},
changeTheme() {
this.$store.dispatch('windows/ActToggleDarkMode', !this.$store.state.windows.darkTheme);
},
async copyProjectInfo() {
try {
const data = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'ncProjectInfo'])
copyTextToClipboard(Object.entries(data).map(([k, v]) => `${k}: **${v}**`).join('\n'));
this.$toast.info('Copied project info to clipboard').goAway(3000);
} catch (e) {
this.$toast.error(e.message).goAway(3000);
}
}
},
@ -1344,7 +1364,7 @@ a {
animation-iteration-count: infinite;
}
/deep/ .v-toolbar__items{
/deep/ .v-toolbar__items {
align-items: center;
}

1
packages/nocodb/package.json

@ -124,6 +124,7 @@
"handlebars": "^4.7.6",
"import-fresh": "^3.2.1",
"inflection": "^1.12.0",
"is-docker": "^2.2.1",
"js-beautify": "^1.11.0",
"json2csv": "^5.0.6",
"jsonfile": "^6.1.0",

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

@ -38,17 +38,18 @@ import ExpressXcTsRoutesHm from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoute
import ExpressXcTsRoutesBt from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesBt";
import ExpressXcTsRoutes from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutes";
import NcPluginMgr from "../plugins/NcPluginMgr";
import isDocker from 'is-docker';
// import packageInfo from '../../../../package.json'
// require('pkginfo')(module, 'version');
const XC_PLUGIN_DET = 'XC_PLUGIN_DET';
let packageInfo:any = {};
try{
packageInfo = JSON.parse(fs.readFileSync('package.json','utf8'));
}catch (_e) {}
let packageInfo: any = {};
try {
packageInfo = JSON.parse(fs.readFileSync('package.json', 'utf8'));
} catch (_e) {
}
export default class NcMetaMgr {
public projectConfigs = {};
@ -1083,6 +1084,9 @@ export default class NcMetaMgr {
case 'xcVirtualTableUpdate':
result = await this.xcVirtualTableUpdate(args);
break;
case 'ncProjectInfo':
result = await this.ncProjectInfo(args);
break;
case 'xcVirtualTableDelete':
result = await this.xcVirtualTableDelete(args, req);
break;
@ -3106,6 +3110,19 @@ export default class NcMetaMgr {
}
protected async ncProjectInfo(args) {
const config = this.projectConfigs[this.getProjectId(args)];
return {
node: process.version,
arch: process.arch,
platform: process.platform,
docker: isDocker(),
database: config.envs?.[process.env.NODE_ENV || 'dev']?.db?.[0]?.client,
packageVersion: packageInfo?.version
}
}
protected async xcVirtualTableList(args): Promise<any> {
return (await this.xcMeta.metaList(this.getProjectId(args), this.getDbAlias(args), 'nc_models', {
xcCondition: {

2
packages/nocodb/src/lib/sqlMgr/SqlMgr.ts

@ -820,7 +820,7 @@ export default class SqlMgr {
migrationSteps: 9999,
folder: this.currentProjectFolder
};
console.log(`Migration up args for '${op}'`, migrationArgs);
// console.log(`Migration up args for '${op}'`, migrationArgs);
await this.migrator().migrationsUp(migrationArgs);
}

Loading…
Cancel
Save