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.
217 lines
6.9 KiB
217 lines
6.9 KiB
4 years ago
|
<template>
|
||
3 years ago
|
<v-overlay absolute color="grey" opacity="0.4" class="create-project-overlay">
|
||
4 years ago
|
<div>
|
||
3 years ago
|
<v-card dark style="width: 100%; max-height: 100%; overflow: auto">
|
||
|
<v-container v-if="databaseCount" fluid style="min-height: 200px">
|
||
4 years ago
|
<v-card class="pa-2 text-center elevation-10" dark>
|
||
3 years ago
|
<h3 class="title mb-3 mt-4">APIs Generated</h3>
|
||
3 years ago
|
<p>
|
||
3 years ago
|
<span class="display-3 font-weight-bold">{{ apisCount }}</span
|
||
|
><br />
|
||
3 years ago
|
<span class="subtitle grey--text text--lighten-1">within {{ timeTaken }} seconds</span>
|
||
|
</p>
|
||
4 years ago
|
</v-card>
|
||
|
<v-row>
|
||
|
<v-col>
|
||
3 years ago
|
<v-card dark class="elevation-10">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> # Databases </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
3 years ago
|
<v-icon class="mt-n2 mr-1" color="info"> mdi-database-sync </v-icon>
|
||
4 years ago
|
|
||
|
{{ upCount }} / {{ databaseCount }}
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<v-col>
|
||
3 years ago
|
<v-card dark class="elevation-10">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> # Tables </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
3 years ago
|
<v-icon class="mr-1 mt-n1" color="info"> mdi-table-large </v-icon>
|
||
4 years ago
|
{{ tablesCount }}
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<v-col>
|
||
3 years ago
|
<v-card dark class="elevation-10">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> Time Saved in Dev Hours </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
3 years ago
|
<v-icon class="mr-1 mt-n1" color="secondary"> mdi-clock-fast </v-icon>
|
||
4 years ago
|
{{ hoursSaved }}
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
<v-col>
|
||
3 years ago
|
<v-card dark class="elevation-10">
|
||
|
<v-card-text class="pb-0 font-weight-bold"> Cost Saved </v-card-text>
|
||
4 years ago
|
<v-card-text class="display-1 white--text">
|
||
3 years ago
|
<v-icon color="success" class="mt-n2 mr-1"> mdi-currency-usd-circle-outline </v-icon>
|
||
4 years ago
|
{{ cost }}
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
<!-- <v-divider class="my-3 "></v-divider>-->
|
||
|
<div class="text-center">
|
||
3 years ago
|
<v-btn v-if="completed" class="my-2 mx-auto" color="primary" x-large to="/xc"> Goto Dashboard </v-btn>
|
||
4 years ago
|
</div>
|
||
|
|
||
3 years ago
|
<v-card dark class="elevation-10">
|
||
|
<p class="title text-center pt-2">List of Databases</p>
|
||
3 years ago
|
<v-simple-table v-if="rowsCount" style="width: 100%">
|
||
3 years ago
|
<tr v-for="(_, i) in new Array(rowsCount)" :key="i">
|
||
|
<td v-for="db in databaseList.slice(i * 5, (i + 1) * 5)" :key="db" class="py-2 px-3">
|
||
4 years ago
|
<div class="d-flex">
|
||
3 years ago
|
<v-icon :color="db in data ? 'green' : 'orange'" x-small class="mr-2"> mdi-moon-full </v-icon>
|
||
4 years ago
|
<span class="caption">{{ db }}</span>
|
||
3 years ago
|
<v-spacer />
|
||
4 years ago
|
</div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</v-simple-table>
|
||
|
</v-card>
|
||
|
</v-container>
|
||
|
</v-card>
|
||
|
</div>
|
||
|
</v-overlay>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
3 years ago
|
name: 'ApiOverlay',
|
||
|
props: {
|
||
3 years ago
|
projectCreated: Boolean,
|
||
3 years ago
|
},
|
||
4 years ago
|
data: () => ({
|
||
|
client: null,
|
||
|
data: {},
|
||
|
databaseList: null,
|
||
|
upCount: 0,
|
||
|
tablesCount: 0,
|
||
|
apisCount: 0,
|
||
|
timeTaken: 0,
|
||
|
completed: false,
|
||
|
perHourCost: 35,
|
||
|
apisPerHour: 2,
|
||
3 years ago
|
apis: 0,
|
||
4 years ago
|
}),
|
||
|
computed: {
|
||
3 years ago
|
rowsCount() {
|
||
3 years ago
|
return this.databaseList ? Math.ceil(this.databaseList.length / 5) : 0;
|
||
4 years ago
|
},
|
||
3 years ago
|
databaseCount() {
|
||
3 years ago
|
return this.databaseList ? this.databaseList.length : 0;
|
||
4 years ago
|
},
|
||
3 years ago
|
cost() {
|
||
3 years ago
|
if (!this.apis) {
|
||
|
return 0;
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
const cost = Math.round(this.perHourCost * (this.apis / this.apisPerHour));
|
||
4 years ago
|
|
||
3 years ago
|
return (cost + '').replace(/\d(?=(?:\d{3})+$)/g, '$&,');
|
||
4 years ago
|
},
|
||
3 years ago
|
hoursSaved() {
|
||
3 years ago
|
if (!this.apis) {
|
||
|
return 0;
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
const hours = Math.round(this.apis / this.apisPerHour);
|
||
4 years ago
|
|
||
3 years ago
|
return (hours + '').replace(/\d(?=(?:\d{3})+$)/g, '$&,');
|
||
|
},
|
||
3 years ago
|
},
|
||
3 years ago
|
created() {
|
||
3 years ago
|
this.initSocketClient();
|
||
3 years ago
|
},
|
||
3 years ago
|
beforeDestroy() {
|
||
3 years ago
|
if (this.client) {
|
||
3 years ago
|
this.client.disconnect();
|
||
4 years ago
|
}
|
||
|
},
|
||
|
methods: {
|
||
3 years ago
|
initSocketClient() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
this.client = require('socket.io-client')(`ws://${window.location.hostname}:8083`);
|
||
|
const self = this;
|
||
|
let toast;
|
||
|
this.client.on('server-to-client', data => {
|
||
4 years ago
|
// console.log('=========== server-to-client ========', data);
|
||
|
|
||
3 years ago
|
self.$set(self.data, data.data.info.databaseName, data.data.info);
|
||
4 years ago
|
|
||
3 years ago
|
self.upCount = data.data.startedBuildersCount;
|
||
4 years ago
|
|
||
3 years ago
|
self.tablesCount = (data.data.aggregatedInfo[1] + '').replace(/\d(?=(?:\d{3})+$)/g, '$&,');
|
||
|
self.apis = data.data.aggregatedInfo[4];
|
||
|
self.apisCount = (data.data.aggregatedInfo[4] + '').replace(/\d(?=(?:\d{3})+$)/g, '$&,');
|
||
4 years ago
|
|
||
3 years ago
|
self.timeTaken = data.data.aggregatedInfo[5];
|
||
4 years ago
|
|
||
|
if ((!self.databaseList || !self.databaseList.length) && data.databaseList) {
|
||
3 years ago
|
self.databaseList = data.databaseList;
|
||
4 years ago
|
}
|
||
|
|
||
|
if (!toast) {
|
||
|
toast = self.$toast.info('', {
|
||
3 years ago
|
position: 'bottom-center',
|
||
|
});
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
toast.text(`APIs created for ${data.data.info.databaseName}`);
|
||
4 years ago
|
|
||
3 years ago
|
this.completed = self.databaseList.length === data.data.startedBuildersCount;
|
||
|
});
|
||
|
} catch (e) {
|
||
|
console.log('demo-error');
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/deep/ .v-overlay__content {
|
||
|
height: 100%;
|
||
|
width: 100%;
|
||
|
padding: 10px;
|
||
|
}
|
||
|
|
||
|
/deep/ .v-overlay__content > div {
|
||
|
overflow: auto;
|
||
|
height: 100%;
|
||
|
}
|
||
|
|
||
|
/deep/ .v-overlay__content table tr,
|
||
|
/deep/ .v-overlay__content table td {
|
||
|
border: 1px solid #7f828b33;
|
||
|
}
|
||
|
|
||
|
/deep/ .v-overlay__content table {
|
||
|
border-collapse: collapse;
|
||
|
}
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|