refactor: product analytics

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
This commit is contained in:
Raju Udava
2022-04-20 18:08:35 +05:30
parent 19d5f0114b
commit 891e22dc80
44 changed files with 7852 additions and 6095 deletions

View File

@@ -10,13 +10,11 @@
hide-details
class="my-2 mx-auto search-field"
placeholder="Search models"
style="max-width:300px"
style="max-width: 300px"
outlined
>
<template #prepend-inner>
<v-icon small>
search
</v-icon>
<v-icon small> search </v-icon>
</template>
</v-text-field>
<v-spacer />
@@ -43,7 +41,7 @@
@click="save()"
>
<!-- Save -->
{{ $t('general.save') }}
{{ $t("general.save") }}
</x-btn>
</v-toolbar>
@@ -53,67 +51,92 @@
<tr>
<th class="caption" width="100px">
<!--TableName-->
{{ $t('labels.tableName') }}
{{ $t("labels.tableName") }}
</th>
<th class="caption" width="150px">
<!--ViewName-->
{{ $t('labels.viewName') }}
{{ $t("labels.viewName") }}
</th>
<th v-for="role in roles" :key="role" class="caption" width="100px">
<th
v-for="role in roles"
:key="role"
class="caption"
width="100px"
>
{{ role.charAt(0).toUpperCase() + role.slice(1) }}
</th>
</tr>
</thead>
<tbody>
<template
v-for="table in tables"
>
<template v-for="table in tables">
<tr
v-if="table.title.toLowerCase().indexOf(filter.toLowerCase()) > -1"
v-if="
table.title.toLowerCase().indexOf(filter.toLowerCase()) > -1
"
:key="table.table_name"
:class="`nc-acl-table-row nc-acl-table-row-${table.title}`"
>
<td>
<v-tooltip bottom>
<template #activator="{on}">
<span
class="caption ml-2"
v-on="on"
>{{ table.ptype === 'table' ? table._ptn : table.ptype === 'view' ? table._ptn : table._ptn }}</span>
<template #activator="{ on }">
<span class="caption ml-2" v-on="on">{{
table.ptype === "table"
? table._ptn
: table.ptype === "view"
? table._ptn
: table._ptn
}}</span>
</template>
<span class="caption">{{ table.ptn || table._ptn }}</span>
</v-tooltip>
</td>
<td>
<v-icon small :color="viewIcons[table.type].color" v-on="on">
<v-icon
small
:color="viewIcons[table.type].color"
v-on="on"
>
{{ viewIcons[table.type].icon }}
</v-icon>
<span v-if="table.ptn" class="caption">{{ table.title }}</span>
<span v-else class="caption">{{ $t('general.default') }}</span>
<span v-if="table.ptn" class="caption">{{
table.title
}}</span>
<span v-else class="caption">{{
$t("general.default")
}}</span>
<!-- {{ table.show_as || table.type }}-->
</td>
<td v-for="role in roles" :key="`${table.table_name}-${role}`">
<td
v-for="role in roles"
:key="`${table.table_name}-${role}`"
>
<v-tooltip bottom>
<template #activator="{on}">
<div
v-on="on"
>
<template #activator="{ on }">
<div v-on="on">
<v-checkbox
v-model="table.disabled[role]"
:class="`pt-0 mt-0 nc-acl-${table.title.toLowerCase().replace('_','')}-${role}-chkbox`"
:class="`pt-0 mt-0 nc-acl-${table.title
.toLowerCase()
.replace('_', '')}-${role}-chkbox`"
dense
hide-details
:true-value="false"
:false-value="true"
@change="$set(table,'edited',true)"
@change="$set(table, 'edited', true)"
/>
</div>
</template>
<span v-if="table.disabled[role]">Click to make '{{ table.table_name }}' visible for Role:{{
role
}} in UI dashboard</span>
<span v-else>Click to hide '{{ table.table_name }}' for Role:{{ role }} in UI dashboard</span>
<span v-if="table.disabled[role]"
>Click to make '{{ table.table_name }}' visible for
Role:{{ role }} in UI dashboard</span
>
<span v-else
>Click to hide '{{ table.table_name }}' for Role:{{
role
}}
in UI dashboard</span
>
</v-tooltip>
</td>
</tr>
@@ -128,30 +151,32 @@
</template>
<script>
import { mapGetters } from 'vuex'
import viewIcons from '~/helpers/viewIcons'
import { mapGetters } from "vuex";
import viewIcons from "~/helpers/viewIcons";
export default {
name: 'ToggleTableUiAcl',
name: "ToggleTableUiAcl",
components: {},
props: ['nodes', 'db'],
props: ["nodes", "db"],
data: () => ({
viewIcons,
models: null,
updating: false,
dbsTab: 0,
filter: '',
tables: null
filter: "",
tables: null,
}),
async mounted() {
await this.loadTableList()
await this.loadTableList();
},
methods: {
async loadTableList() {
this.tables = (await this.$api.project.modelVisibilityList(
this.db.project_id, {
includeM2M: this.$store.state.windows.includeM2M || ''
}))
this.tables = await this.$api.project.modelVisibilityList(
this.db.project_id,
{
includeM2M: this.$store.state.windows.includeM2M || "",
}
);
// this.tables = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
// dbAlias: this.db.meta.dbAlias,
// env: this.$store.getters['project/GtrEnv']
@@ -161,27 +186,34 @@ export default {
},
async save() {
try {
await this.$api.project.modelVisibilitySet(this.db.project_id, this.tables.filter(t => t.edited))
this.$toast.success('Updated UI ACL for tables successfully').goAway(3000)
await this.$api.project.modelVisibilitySet(
this.db.project_id,
this.tables.filter((t) => t.edited)
);
this.$toast
.success("Updated UI ACL for tables successfully")
.goAway(3000);
} catch (e) {
this.$toast.error(e.message).goAway(3000)
this.$toast.error(e.message).goAway(3000);
}
this.$tele.emit('proj-meta:ui-acl:update')
}
this.$e("a:proj-meta:ui-acl");
},
},
computed: {
...mapGetters({
dbAliasList: 'project/GtrDbAliasList'
dbAliasList: "project/GtrDbAliasList",
}),
edited() {
return this.tables && this.tables.length && this.tables.some(t => t.edited)
return (
this.tables && this.tables.length && this.tables.some((t) => t.edited)
);
},
roles() {
return ['editor', 'commenter', 'viewer']// this.tables && this.tables.length ? Object.keys(this.tables[0].disabled) : []
}
}
}
return ["editor", "commenter", "viewer"]; // this.tables && this.tables.length ? Object.keys(this.tables[0].disabled) : []
},
},
};
</script>
<style scoped lang="scss">
@@ -194,11 +226,11 @@ export default {
border-right: 1px solid #7f828b33;
}
.search-field.v-text-field > .v-input__control, .search-field.v-text-field > .v-input__control > .v-input__slot {
.search-field.v-text-field > .v-input__control,
.search-field.v-text-field > .v-input__control > .v-input__slot {
min-height: auto;
}
}
</style>
<!--
/**