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.
331 lines
12 KiB
331 lines
12 KiB
4 years ago
|
<template>
|
||
|
<v-card class="d-100" style="overflow: scroll">
|
||
|
<v-toolbar height="40" class="elevation-0">
|
||
3 years ago
|
<v-spacer />
|
||
4 years ago
|
|
||
2 years ago
|
<x-btn outlined tooltip="Reload Project Info" color="primary" small @click="loadProjectApiInfo">
|
||
|
<v-icon small left> refresh </v-icon>
|
||
3 years ago
|
<!-- Reload -->
|
||
|
{{ $t('general.reload') }}
|
||
4 years ago
|
</x-btn>
|
||
|
</v-toolbar>
|
||
|
|
||
|
<!-- <div class="d-flex justify-center ">
|
||
|
<v-simple-table dense v-slot:default class="flex-shrink mt-3" v-if="info">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>Database</th>
|
||
|
<th>API Type</th>
|
||
|
<th>API Schema
|
||
|
<x-icon tooltip="Swagger URL / Proto file / Graphiql" small>mdi-information-outline</x-icon>
|
||
|
</th>
|
||
|
<th>API Base URL</th>
|
||
|
</tr>
|
||
|
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr v-for="(db,i) in dbAliasList" :key="i">
|
||
|
<td>{{ info[db.meta.dbAlias].database }}</td>
|
||
|
<td>
|
||
|
|
||
|
<img width="40" v-if="apiTypeIcon[info[db.meta.dbAlias].apiType].type === 'img'"
|
||
|
:src="apiTypeIcon[info[db.meta.dbAlias].apiType].src"/>
|
||
|
<template v-else>
|
||
|
<v-icon :color="apiTypeIcon[info[db.meta.dbAlias].apiType].iconColor">
|
||
|
{{ apiTypeIcon[info[db.meta.dbAlias].apiType].icon }}
|
||
|
</v-icon>
|
||
|
|
||
|
{{ info[db.meta.dbAlias].apiType }}
|
||
|
</template>
|
||
|
</td>
|
||
|
<td>
|
||
|
<a v-if="info[db.meta.dbAlias].apiType === 'rest'" :href="info[db.meta.dbAlias].swaggerUrl" target="_blank">{{
|
||
|
info[db.meta.dbAlias].swaggerUrl
|
||
|
}}</a>
|
||
|
<a v-else-if="info[db.meta.dbAlias].apiType === 'graphql'" :href="info[db.meta.dbAlias].gqlApiUrl"
|
||
|
target="_blank">{{ info[db.meta.dbAlias].gqlApiUrl }}</a>
|
||
|
<a v-else-if="info[db.meta.dbAlias].apiType === 'grpc'" @click.prevent="downloadProto">Download Proto
|
||
|
File</a>
|
||
|
|
||
|
</td>
|
||
|
<td>
|
||
|
<span v-if="info[db.meta.dbAlias].apiType === 'rest'">{{ info[db.meta.dbAlias].apiUrl }}</span>
|
||
|
<span v-else-if="info[db.meta.dbAlias].apiType === 'graphql'">{{ info[db.meta.dbAlias].gqlApiUrl }}</span>
|
||
|
<span v-else-if="info[db.meta.dbAlias].apiType === 'grpc'">{{ info[db.meta.dbAlias].grpcApiUrl }}</span>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</v-simple-table>
|
||
|
|
||
|
<v-skeleton-loader class="mt-2" v-else type="text,table-row-divider@3"></v-skeleton-loader>
|
||
|
|
||
|
</div>-->
|
||
|
|
||
3 years ago
|
<v-container v-if="aggregatedInfo" fluid dark>
|
||
4 years ago
|
<v-card class="pa-2 text-center elevation-10" dark>
|
||
2 years ago
|
<h3 class="title mb-3 mt-4">Total APIs Generated</h3>
|
||
4 years ago
|
<p>
|
||
|
<!-- <span class="display-3 font-weight-bold">{{ apisCount }}</span>-->
|
||
|
|
||
2 years ago
|
<IOdometer class="iOdometer display-3 font-weight-bold" :value="apisCount" />
|
||
4 years ago
|
|
||
2 years ago
|
<br />
|
||
3 years ago
|
<span class="subtitle grey--text text--lighten-1">within {{ timeTaken }} seconds</span>
|
||
|
</p>
|
||
4 years ago
|
</v-card>
|
||
|
|
||
2 years ago
|
<v-row v-for="(item, i) in aggregatedInfo.list" :key="i" class="align-stretch">
|
||
4 years ago
|
<v-col>
|
||
|
<v-row>
|
||
|
<v-col cols="12">
|
||
2 years ago
|
<v-card dark class="elevation-10 h-100">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> Database ({{ item.dbType }}) </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
2 years ago
|
<v-icon class="mr-1 mt-n1" color="info"> mdi-database </v-icon>
|
||
4 years ago
|
{{ item.databaseName }}
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<v-col cols="6">
|
||
2 years ago
|
<v-card dark class="elevation-10 h-100">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> # Tables </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
2 years ago
|
<v-icon class="mr-1 mt-n1" color="info"> mdi-table-large </v-icon>
|
||
4 years ago
|
<!-- {{ item.tablesCount }}-->
|
||
2 years ago
|
<IOdometer class="iOdometer" :value="item.tablesCount" />
|
||
4 years ago
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<v-col cols="6">
|
||
2 years ago
|
<v-card dark class="elevation-10 h-100">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> # Relations </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
2 years ago
|
<v-icon class="mr-1 mt-n1" color="secondary"> mdi-link </v-icon>
|
||
4 years ago
|
<!-- {{ item.relationsCount }}-->
|
||
2 years ago
|
<IOdometer class="iOdometer" :value="item.relationsCount" />
|
||
4 years ago
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<v-col cols="4">
|
||
2 years ago
|
<v-card dark class="elevation-10 h-100">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> # Views </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
2 years ago
|
<v-icon color="success" class="mt-n2 mr-1"> mdi-table-border </v-icon>
|
||
4 years ago
|
<!-- {{ item.viewsCount }}-->
|
||
2 years ago
|
<IOdometer class="iOdometer" :value="item.viewsCount" />
|
||
4 years ago
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<v-col cols="4">
|
||
2 years ago
|
<v-card dark class="elevation-10 h-100">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> # Functions </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
2 years ago
|
<v-icon color="success" class="mt-n2 mr-1"> mdi-function </v-icon>
|
||
4 years ago
|
<!-- {{ item.functionsCount }}-->
|
||
2 years ago
|
<IOdometer class="iOdometer" :value="item.functionsCount" />
|
||
4 years ago
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<v-col cols="4">
|
||
2 years ago
|
<v-card dark class="elevation-10 h-100">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> # Procedures </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
2 years ago
|
<v-icon color="success" class="mt-n2 mr-1"> mdi-code-braces </v-icon>
|
||
4 years ago
|
<!-- {{ item.proceduresCount }}-->
|
||
2 years ago
|
<IOdometer class="iOdometer" :value="item.proceduresCount" />
|
||
4 years ago
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<!--<v-col>
|
||
|
<v-card dark class=" elevation-10">
|
||
|
<v-card-text class="pb-0 font-weight-bold">Time Saved in Dev Hours</v-card-text>
|
||
|
<v-card-text class="display-1 white--text">
|
||
|
<v-icon class="mr-1 mt-n1" color="secondary">mdi-clock-fast</v-icon>
|
||
|
{{ hoursSaved }}
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<v-col>
|
||
|
<v-card dark class=" elevation-10">
|
||
|
<v-card-text class="pb-0 font-weight-bold">Cost Saved</v-card-text>
|
||
|
<v-card-text class="display-1 white--text">
|
||
|
<v-icon color="success" class="mt-n2 mr-1">mdi-currency-usd-circle-outline</v-icon>
|
||
|
{{ cost }}
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>-->
|
||
|
</v-row>
|
||
|
</v-col>
|
||
|
<v-col>
|
||
|
<v-row class="h-100">
|
||
|
<v-col cols="12" class="h-100">
|
||
|
<v-card class="pa-2 elevation-10 h-100" dark>
|
||
2 years ago
|
<v-card-text v-if="item.type === 'rest'" class="pb-0 font-weight-bold">
|
||
3 years ago
|
Swagger API specification
|
||
4 years ago
|
</v-card-text>
|
||
2 years ago
|
<v-card-text v-else-if="item.type === 'graphql'" class="pb-0 font-weight-bold">
|
||
3 years ago
|
Graphql Endpoint
|
||
4 years ago
|
</v-card-text>
|
||
2 years ago
|
<v-card-text class="title white--text">
|
||
|
<v-icon color="success" class="mr-1"> mdi-code-json </v-icon>
|
||
4 years ago
|
<a :href="`${origin}${item.apiEndpoint}`" target="_blank">{{ `${origin}${item.apiEndpoint}` }}</a>
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
|
|
||
|
<!-- <pre>
|
||
|
{{ aggregatedInfo }}
|
||
|
</pre>-->
|
||
|
|
||
2 years ago
|
<iframe v-if="iframeUrl && showinfoIFrame" style="background: white" width="100%" height="500px" :src="iframeUrl" />
|
||
4 years ago
|
</v-card>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import { mapGetters } from 'vuex';
|
||
4 years ago
|
|
||
2 years ago
|
import IOdometer from 'vue-odometer';
|
||
|
import 'odometer/themes/odometer-theme-default.css';
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'XcInfo',
|
||
4 years ago
|
components: {
|
||
2 years ago
|
IOdometer,
|
||
4 years ago
|
},
|
||
|
data: () => ({
|
||
|
showinfoIFrame: false,
|
||
|
iframeUrl: null,
|
||
|
info: null,
|
||
|
aggregatedInfo: null,
|
||
|
apiTypeIcon: {
|
||
3 years ago
|
rest: { icon: 'mdi-code-json', iconColor: 'green' },
|
||
|
graphql: { icon: 'mdi-graphql', iconColor: 'pink' },
|
||
2 years ago
|
grpc: { src: 'grpc-icon-color.png', type: 'img' },
|
||
4 years ago
|
},
|
||
2 years ago
|
apisCount: 0,
|
||
4 years ago
|
}),
|
||
|
computed: {
|
||
|
...mapGetters({
|
||
2 years ago
|
dbAliasList: 'project/GtrDbAliasList',
|
||
4 years ago
|
}),
|
||
3 years ago
|
origin() {
|
||
2 years ago
|
return location.origin;
|
||
|
},
|
||
4 years ago
|
},
|
||
3 years ago
|
async created() {
|
||
2 years ago
|
await this.loadProjectApiInfo();
|
||
4 years ago
|
try {
|
||
2 years ago
|
this.iframeUrl = `${this.$axios.defaults.baseURL}/dashboard/status`;
|
||
|
await this.$axios.get(this.iframeUrl);
|
||
|
this.showinfoIFrame = true;
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.showinfoIFrame = false;
|
||
4 years ago
|
}
|
||
|
},
|
||
2 years ago
|
mounted() {},
|
||
3 years ago
|
methods: {
|
||
3 years ago
|
async loadProjectApiInfo() {
|
||
4 years ago
|
try {
|
||
2 years ago
|
const { info, aggregatedInfo } = (
|
||
|
await this.$axios.get(`/nc/${this.$route.params.project_id}/projectApiInfo`, {
|
||
|
headers: {
|
||
|
'xc-auth': this.$store.state.users.token,
|
||
|
},
|
||
|
})
|
||
|
).data;
|
||
|
this.info = info;
|
||
|
const { aggregated, list } = aggregatedInfo;
|
||
4 years ago
|
|
||
|
this.aggregatedInfo = {
|
||
3 years ago
|
aggregated,
|
||
2 years ago
|
list: list.map(it => {
|
||
4 years ago
|
return {
|
||
|
...it,
|
||
|
functionsCount: 0,
|
||
|
proceduresCount: 0,
|
||
|
relationsCount: 0,
|
||
|
tablesCount: 0,
|
||
2 years ago
|
viewsCount: 0,
|
||
|
};
|
||
|
}),
|
||
|
};
|
||
|
const apisCount = aggregatedInfo.aggregated[4]; // +((
|
||
4 years ago
|
// aggregatedInfo.aggregated[4]
|
||
|
// + '').replace(/\d(?=(?:\d{3})+$)/g, '$&,')) || 0;
|
||
2 years ago
|
this.apisCount = 0;
|
||
4 years ago
|
|
||
|
this.$nextTick(() => {
|
||
2 years ago
|
this.apisCount = apisCount;
|
||
|
this.$set(this.aggregatedInfo, 'list', list);
|
||
|
});
|
||
4 years ago
|
|
||
2 years ago
|
this.timeTaken = aggregatedInfo.aggregated[5];
|
||
4 years ago
|
} catch (e) {
|
||
|
// this.$toast.error('Some error occurred').goAway(3000);
|
||
|
}
|
||
|
},
|
||
3 years ago
|
async downloadProto() {
|
||
2 years ago
|
this.loading = true;
|
||
|
let data;
|
||
4 years ago
|
try {
|
||
2 years ago
|
data = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
null,
|
||
|
'grpcProtoDownloadZip',
|
||
|
{},
|
||
|
null,
|
||
|
{
|
||
|
responseType: 'blob',
|
||
|
},
|
||
|
]);
|
||
|
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/zip' }));
|
||
|
const link = document.createElement('a');
|
||
|
link.href = url;
|
||
|
link.setAttribute('download', 'proto.zip'); // or any other extension
|
||
|
document.body.appendChild(link);
|
||
|
link.click();
|
||
3 years ago
|
// this.$toast.success('Successfully exported metadata').goAway(3000)
|
||
2 years ago
|
this.$toast.success(`${this.$t('msg.toast.exportMetadata')}`).goAway(3000);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error('Some internal error occurred').goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.loading = false;
|
||
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
iframe {
|
||
|
border: none;
|
||
|
}
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
4 years ago
|
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
|
||
4 years ago
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|