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. 28
      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

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

@ -25,7 +25,10 @@
</v-btn> </v-btn>
</template> </template>
Home 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> </v-tooltip>
<template><span class="title"> {{ brandName }}</span> <template><span class="title"> {{ brandName }}</span>
</template> </template>
@ -235,7 +238,7 @@
<v-tooltip bottom> <v-tooltip bottom>
<template v-slot:activator="{ on }"> <template v-slot:activator="{ on }">
<v-icon @dblclick="showAppStore=true" @click="changeTheme" v-on="on" size="20" <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> </v-icon>
</template> </template>
<span class="caption"> <span class="caption">
@ -645,6 +648,13 @@
</v-list-item> </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 dense @click="MtdSignOut" v-ge="['Sign Out','']">
<v-list-item-title> <v-list-item-title>
@ -824,6 +834,7 @@ import 'splitpanes/dist/splitpanes.css'
import XBtn from "../components/global/xBtn"; import XBtn from "../components/global/xBtn";
import ChangeEnv from "../components/changeEnv"; import ChangeEnv from "../components/changeEnv";
import Discord from "@/components/discord"; import Discord from "@/components/discord";
import {copyTextToClipboard} from "@/helpers/xutils";
export default { export default {
components: { components: {
@ -971,7 +982,7 @@ export default {
'xc-auth': this.$store.state.users.token 'xc-auth': this.$store.state.users.token
} }
})).data; })).data;
const obj = Object.values(info).find(v => v.apiType === 'rest' ? v.swaggerUrl : v.gqlApiUrl); const obj = Object.values(info).find(v => v.apiType === 'rest' ? v.swaggerUrl : v.gqlApiUrl);
this.swaggerOrGraphiqlUrl = obj.apiType === 'rest' ? obj.swaggerUrl : obj.gqlApiUrl this.swaggerOrGraphiqlUrl = obj.apiType === 'rest' ? obj.swaggerUrl : obj.gqlApiUrl
} catch (e) { } catch (e) {
} }
@ -1296,6 +1307,15 @@ export default {
}, },
changeTheme() { changeTheme() {
this.$store.dispatch('windows/ActToggleDarkMode', !this.$store.state.windows.darkTheme); 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; animation-iteration-count: infinite;
} }
/deep/ .v-toolbar__items{ /deep/ .v-toolbar__items {
align-items: center; align-items: center;
} }

1
packages/nocodb/package.json

@ -124,6 +124,7 @@
"handlebars": "^4.7.6", "handlebars": "^4.7.6",
"import-fresh": "^3.2.1", "import-fresh": "^3.2.1",
"inflection": "^1.12.0", "inflection": "^1.12.0",
"is-docker": "^2.2.1",
"js-beautify": "^1.11.0", "js-beautify": "^1.11.0",
"json2csv": "^5.0.6", "json2csv": "^5.0.6",
"jsonfile": "^6.1.0", "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 ExpressXcTsRoutesBt from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesBt";
import ExpressXcTsRoutes from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutes"; import ExpressXcTsRoutes from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutes";
import NcPluginMgr from "../plugins/NcPluginMgr"; import NcPluginMgr from "../plugins/NcPluginMgr";
import isDocker from 'is-docker';
// import packageInfo from '../../../../package.json' // import packageInfo from '../../../../package.json'
// require('pkginfo')(module, 'version'); // require('pkginfo')(module, 'version');
const XC_PLUGIN_DET = 'XC_PLUGIN_DET'; const XC_PLUGIN_DET = 'XC_PLUGIN_DET';
let packageInfo:any = {}; let packageInfo: any = {};
try{ try {
packageInfo = JSON.parse(fs.readFileSync('package.json','utf8')); packageInfo = JSON.parse(fs.readFileSync('package.json', 'utf8'));
}catch (_e) {} } catch (_e) {
}
export default class NcMetaMgr { export default class NcMetaMgr {
public projectConfigs = {}; public projectConfigs = {};
@ -1083,6 +1084,9 @@ export default class NcMetaMgr {
case 'xcVirtualTableUpdate': case 'xcVirtualTableUpdate':
result = await this.xcVirtualTableUpdate(args); result = await this.xcVirtualTableUpdate(args);
break; break;
case 'ncProjectInfo':
result = await this.ncProjectInfo(args);
break;
case 'xcVirtualTableDelete': case 'xcVirtualTableDelete':
result = await this.xcVirtualTableDelete(args, req); result = await this.xcVirtualTableDelete(args, req);
break; 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> { protected async xcVirtualTableList(args): Promise<any> {
return (await this.xcMeta.metaList(this.getProjectId(args), this.getDbAlias(args), 'nc_models', { return (await this.xcMeta.metaList(this.getProjectId(args), this.getDbAlias(args), 'nc_models', {
xcCondition: { xcCondition: {

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

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

Loading…
Cancel
Save