Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
fe460c02
Commit
fe460c02
authored
2 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
feat(client): add instances doughnuts charts for dashboard
parent
d7c6e2e6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/client/src/pages/admin/overview.pie.vue
+102
-0
102 additions, 0 deletions
packages/client/src/pages/admin/overview.pie.vue
packages/client/src/pages/admin/overview.vue
+53
-5
53 additions, 5 deletions
packages/client/src/pages/admin/overview.vue
with
155 additions
and
5 deletions
packages/client/src/pages/admin/overview.pie.vue
0 → 100644
+
102
−
0
View file @
fe460c02
<
template
>
<canvas
ref=
"chartEl"
></canvas>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
onMounted
,
onUnmounted
,
ref
}
from
'
vue
'
;
import
{
Chart
,
ArcElement
,
LineElement
,
BarElement
,
PointElement
,
BarController
,
LineController
,
CategoryScale
,
LinearScale
,
TimeScale
,
Legend
,
Title
,
Tooltip
,
SubTitle
,
Filler
,
DoughnutController
,
}
from
'
chart.js
'
;
import
number
from
'
@/filters/number
'
;
import
{
defaultStore
}
from
'
@/store
'
;
import
{
useChartTooltip
}
from
'
@/scripts/use-chart-tooltip
'
;
Chart
.
register
(
ArcElement
,
LineElement
,
BarElement
,
PointElement
,
BarController
,
LineController
,
DoughnutController
,
CategoryScale
,
LinearScale
,
TimeScale
,
Legend
,
Title
,
Tooltip
,
SubTitle
,
Filler
,
);
const
props
=
defineProps
<
{
data
:
{
name
:
string
;
value
:
number
;
color
:
string
;
}[];
}
>
();
const
chartEl
=
ref
<
HTMLCanvasElement
>
(
null
);
// フォントカラー
Chart
.
defaults
.
color
=
getComputedStyle
(
document
.
documentElement
).
getPropertyValue
(
'
--fg
'
);
const
{
handler
:
externalTooltipHandler
}
=
useChartTooltip
();
let
chartInstance
:
Chart
;
onMounted
(()
=>
{
chartInstance
=
new
Chart
(
chartEl
.
value
,
{
type
:
'
doughnut
'
,
data
:
{
labels
:
props
.
data
.
map
(
x
=>
x
.
name
),
datasets
:
[{
backgroundColor
:
props
.
data
.
map
(
x
=>
x
.
color
),
data
:
props
.
data
.
map
(
x
=>
x
.
value
),
}],
},
options
:
{
layout
:
{
padding
:
{
left
:
8
,
right
:
8
,
top
:
8
,
bottom
:
8
,
},
},
interaction
:
{
intersect
:
false
,
},
plugins
:
{
legend
:
{
display
:
false
,
},
tooltip
:
{
enabled
:
false
,
mode
:
'
index
'
,
animation
:
{
duration
:
0
,
},
external
:
externalTooltipHandler
,
},
},
},
});
});
</
script
>
<
style
lang=
"scss"
scoped
>
</
style
>
This diff is collapsed.
Click to expand it.
packages/client/src/pages/admin/overview.vue
+
53
−
5
View file @
fe460c02
...
...
@@ -43,7 +43,12 @@
</div>
</div>
<!--<XMetrics/>-->
<div
class=
"container files"
>
<div
class=
"title"
>
Recent files
</div>
<div
class=
"body"
>
<MkFileListForAdmin
:pagination=
"filesPagination"
view-mode=
"grid"
/>
</div>
</div>
<div
class=
"container env"
>
<div
class=
"title"
>
Enviroment
</div>
...
...
@@ -103,10 +108,18 @@
</div>
</div>
</div>
<div
class=
"container files"
>
<div
class=
"title"
>
Recent files
</div>
<div
v-if=
"fedStats"
class=
"container federationPies"
>
<div
class=
"body"
>
<MkFileListForAdmin
:pagination=
"filesPagination"
view-mode=
"grid"
/>
<div
class=
"chart deliver"
>
<div
class=
"title"
>
Sub
</div>
<XPie
:data=
"fedStats.topSubInstances.map(x => ({ name: x.host, value: x.followersCount }))"
/>
<div
class=
"subTitle"
>
Top 10
</div>
</div>
<div
class=
"chart inbox"
>
<div
class=
"title"
>
Pub
</div>
<XPie
:data=
"fedStats.topPubInstances.map(x => ({ name: x.host, value: x.followingCount }))"
/>
<div
class=
"subTitle"
>
Top 10
</div>
</div>
</div>
</div>
</div>
...
...
@@ -140,6 +153,7 @@ import XMetrics from './metrics.vue';
import
XFederation
from
'
./overview.federation.vue
'
;
import
XQueueChart
from
'
./overview.queue-chart.vue
'
;
import
XUser
from
'
./overview.user.vue
'
;
import
XPie
from
'
./overview.pie.vue
'
;
import
MkInstanceStats
from
'
@/components/instance-stats.vue
'
;
import
MkNumberDiff
from
'
@/components/number-diff.vue
'
;
import
{
version
,
url
}
from
'
@/config
'
;
...
...
@@ -175,6 +189,7 @@ const rootEl = $ref<HTMLElement>();
const
chartEl
=
$ref
<
HTMLCanvasElement
>
(
null
);
let
stats
:
any
=
$ref
(
null
);
let
serverInfo
:
any
=
$ref
(
null
);
let
fedStats
:
any
=
$ref
(
null
);
let
usersComparedToThePrevDay
:
any
=
$ref
(
null
);
let
notesComparedToThePrevDay
:
any
=
$ref
(
null
);
let
federationPubActive
=
$ref
<
number
|
null
>
(
null
);
...
...
@@ -257,7 +272,7 @@ async function renderChart() {
layout
:
{
padding
:
{
left
:
0
,
right
:
8
,
right
:
0
,
top
:
0
,
bottom
:
0
,
},
...
...
@@ -380,6 +395,10 @@ onMounted(async () => {
federationSubActiveDiff
=
chart
.
subActive
[
0
]
-
chart
.
subActive
[
1
];
});
os
.
apiGet
(
'
federation/stats
'
).
then
(
res
=>
{
fedStats
=
res
;
});
os
.
api
(
'
admin/server-info
'
).
then
(
serverInfoResponse
=>
{
serverInfo
=
serverInfoResponse
;
});
...
...
@@ -529,6 +548,35 @@ definePageMetadata({
}
}
}
&
.federationPies
{
>
.body
{
display
:
grid
;
grid-gap
:
16px
;
grid-template-columns
:
repeat
(
auto-fill
,
minmax
(
180px
,
1fr
));
>
.chart
{
position
:
relative
;
padding
:
20px
;
background
:
var
(
--
panel
);
border-radius
:
var
(
--
radius
);
>
.title
{
position
:
absolute
;
top
:
20px
;
left
:
20px
;
font-size
:
90%
;
}
>
.subTitle
{
position
:
absolute
;
bottom
:
20px
;
right
:
20px
;
font-size
:
85%
;
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment