Пересобрать объект
This commit is contained in:
1 parent
3089ecc289
commit
5d4ff98f8a
2 files changed
+60
-48
No files matched your search
@@ -1,8 +1,18 @@
|
||||
<template>
|
||||
<v-card class="h-100 d-flex flex-column pa-1" >
|
||||
<my-helper :pretext="activusers"/>
|
||||
<!-- <my-helper :pretext="activusers"/> -->
|
||||
<v-row no-gutters class="overflow-auto h-0">
|
||||
<v-col class="d-flex flex-column">
|
||||
<v-chip
|
||||
color="light-blue-darken-4"
|
||||
label
|
||||
class="text-center rounded-0 text-subtitle-1 font-weight-medium"
|
||||
>
|
||||
<v-icon start icon="mdi-account-circle-outline"></v-icon>
|
||||
Самые активные пользователи
|
||||
</v-chip>
|
||||
|
||||
<v-divider/>
|
||||
<v-data-table
|
||||
v-model:expanded="expanded"
|
||||
:headers="dessertHeaders"
|
||||
@@ -12,18 +22,14 @@
|
||||
items-per-page-text=""
|
||||
:items-per-page-options=perpage
|
||||
show-current-page
|
||||
:sort-by="[{ key: 'info.count', order: 'desc' }]"
|
||||
density="compact"
|
||||
>
|
||||
<template v-slot:top>
|
||||
<v-toolbar flat>
|
||||
<v-toolbar-title>Самые активные пользователи</v-toolbar-title>
|
||||
</v-toolbar>
|
||||
</template>
|
||||
|
||||
|
||||
<template v-slot:expanded-row="{ columns, item }">
|
||||
<tr>
|
||||
<td :colspan="columns.length">
|
||||
<!-- :sort-by="[{ key: 'tooltip.count', order: 'desc' }]" -->
|
||||
<v-card class="my-2 elevation-5" >
|
||||
<v-chip
|
||||
prepend-icon="mdi-script"
|
||||
size="small"
|
||||
@@ -32,6 +38,7 @@
|
||||
variant="text"
|
||||
color="grey"
|
||||
/>
|
||||
<v-divider/>
|
||||
<v-data-table
|
||||
:headers="subtable"
|
||||
:items="item.tooltip"
|
||||
@@ -46,23 +53,9 @@
|
||||
</v-chip>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
|
||||
|
||||
<!-- <v-data-table
|
||||
:headers="subtable"
|
||||
:items="item.tooltip"
|
||||
|
||||
items-per-page=-1
|
||||
class="subtable"
|
||||
|
||||
density="compact"
|
||||
> -->
|
||||
|
||||
<!-- <template v-slot:item.count="{ value }">
|
||||
<v-chip :color="getColor(value)" density="compact">
|
||||
{{ value }}
|
||||
</v-chip>
|
||||
</template> -->
|
||||
<!-- </v-data-table> -->
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -107,9 +100,9 @@ export default {
|
||||
key: 'user.fio',
|
||||
},
|
||||
|
||||
{ title: 'Просмотры', align: 'end', key: 'info.count' },
|
||||
{ title: 'Сессии', align: 'end', key: 'info.session' },
|
||||
{ title: 'Страницы', align: 'end', key: 'info.pages' },
|
||||
{ title: 'Просмотры', align: 'start', key: 'info.count' },
|
||||
{ title: 'Сессии', align: 'start', key: 'info.session' },
|
||||
{ title: 'Страницы', align: 'start', key: 'info.pages' },
|
||||
|
||||
|
||||
]
|
||||
@@ -121,8 +114,8 @@ export default {
|
||||
sortable: false,
|
||||
key: 'namepages',
|
||||
},
|
||||
{ title: 'Всего', align: 'end', key: 'count' },
|
||||
{ title: 'Уникальных', align: 'center', key: 'unic' },
|
||||
{ title: 'Всего', align: 'start', key: 'count' },
|
||||
{ title: 'Уникальных', align: 'start', key: 'unic' },
|
||||
|
||||
|
||||
]
|
||||
|
||||
@@ -279,6 +279,7 @@ setup(){
|
||||
let activusers = {}
|
||||
let top_user = {}
|
||||
let top_users = []
|
||||
let minitooltip = {}
|
||||
// let portal_traffic = {
|
||||
// now: {
|
||||
// title: '',
|
||||
@@ -313,11 +314,16 @@ setup(){
|
||||
checking_for_entry(lineCharts[item.visitdate]['unic'], splitname(item.author))
|
||||
|
||||
// ------------------------------
|
||||
|
||||
if (!activusers[splitname(item.author)])
|
||||
{
|
||||
activusers[splitname(item.author)] = {session: {} }
|
||||
}
|
||||
|
||||
if (!minitooltip[splitname(item.author)])
|
||||
{
|
||||
minitooltip[splitname(item.author)] = {tooltip: {} }
|
||||
}
|
||||
|
||||
if (!activusers[splitname(item.author)].session[item.visitdate]) {
|
||||
activusers[splitname(item.author)].session[item.visitdate] = {pages: {}}
|
||||
}
|
||||
@@ -329,7 +335,7 @@ setup(){
|
||||
|
||||
// ------------------------------
|
||||
if (!top_user[splitname(item.author)]) {
|
||||
top_user[splitname(item.author)] = { user: {}, info: {count: 0}, tooltip: {namepages: {}}}
|
||||
top_user[splitname(item.author)] = { user: {}, info: {count: 0}, tooltip: []}
|
||||
}
|
||||
|
||||
top_user[splitname(item.author)].user.login = item.author.login
|
||||
@@ -382,6 +388,7 @@ setup(){
|
||||
}
|
||||
|
||||
const tooltipinfo = () => {
|
||||
|
||||
Object.entries(dataActivusers.value).reduce((acc, item) => {
|
||||
dataTopUser.value[item[0]].info.session = Object.keys(item[1].session).length
|
||||
|
||||
@@ -392,34 +399,46 @@ setup(){
|
||||
acc_data[item[0]] += Object.keys(data[1].pages).length
|
||||
|
||||
Object.entries(data[1].pages).map(e => {
|
||||
if (!dataTopUser.value[item[0]].tooltip.namepages[e[0]])
|
||||
if (!minitooltip[e[0]])
|
||||
{
|
||||
dataTopUser.value[item[0]].tooltip.namepages[e[0]] = {count: 0, unic: 0 }
|
||||
minitooltip[e[0]] = {count: 0, unic: 0, namepages: '' }
|
||||
}
|
||||
dataTopUser.value[item[0]].tooltip.namepages[e[0]].count += data[1].pages[e[0]].count
|
||||
dataTopUser.value[item[0]].tooltip.namepages[e[0]].unic +=1
|
||||
minitooltip[e[0]].count += data[1].pages[e[0]].count
|
||||
minitooltip[e[0]].unic +=1
|
||||
minitooltip[e[0]].namepages = e[0]
|
||||
|
||||
|
||||
// if (!dataTopUser.value[item[0]].tooltip[e[0]])
|
||||
// {
|
||||
// dataTopUser.value[item[0]].tooltip[e[0]] = {count: 0, unic: 0, namepages: '' }
|
||||
// }
|
||||
// dataTopUser.value[item[0]].tooltip[e[0]].count += data[1].pages[e[0]].count
|
||||
// dataTopUser.value[item[0]].tooltip[e[0]].unic +=1
|
||||
// dataTopUser.value[item[0]].tooltip[e[0]].namepages = e[0]
|
||||
}
|
||||
|
||||
|
||||
)
|
||||
console.log(minitooltip);
|
||||
// Object.entries(minitooltip).map(e => {
|
||||
// dataTopUser.value[item[0]].tooltip.push(e[1])
|
||||
|
||||
|
||||
// })
|
||||
|
||||
dataTopUser.value[item[0]].info.pages = acc_data[item[0]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// dataTopUser.value = sorted
|
||||
return acc_data
|
||||
}, {})
|
||||
|
||||
// dataTopUser.value = sorted
|
||||
// arrfortable()
|
||||
// const arrfortable = () => {
|
||||
// console.log(dataTopUser.value, '----')
|
||||
// }
|
||||
return acc
|
||||
}, {})
|
||||
// dataTopUser.value = Object.values(dataTopUser.value)
|
||||
// .sort((a,b) => (b.info.count - a.info.count || b.info.session - a.info.session ))
|
||||
// console.log(sorted, '111111111111111111111111111111')
|
||||
console.log(dataTopUser.value)
|
||||
|
||||
|
||||
console.log(dataTopUser.value, '----')
|
||||
|
||||
}
|
||||
|
||||
const sortcount = () => {
|
||||
|
||||
Reference in new issue
Block a user