mirror of
https://github.com/gotson/komga.git
synced 2025-12-09 10:05:10 +01:00
fix(webui): metrics pie charts show library name in tooltip
Closes: #1159
This commit is contained in:
parent
36a35b5308
commit
318a44482f
1 changed files with 9 additions and 6 deletions
|
|
@ -125,6 +125,9 @@ export default Vue.extend({
|
||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getLibraryNameById(id: string): string {
|
||||||
|
return this.$store.getters.getLibraryById(id).name
|
||||||
|
},
|
||||||
async loadData() {
|
async loadData() {
|
||||||
this.$komgaMetrics.getMetric('komga.tasks.execution')
|
this.$komgaMetrics.getMetric('komga.tasks.execution')
|
||||||
.then(m => {
|
.then(m => {
|
||||||
|
|
@ -144,7 +147,7 @@ export default Vue.extend({
|
||||||
this.$komgaMetrics.getMetric('komga.series')
|
this.$komgaMetrics.getMetric('komga.series')
|
||||||
.then(m => {
|
.then(m => {
|
||||||
this.series = m
|
this.series = m
|
||||||
this.getStatisticForEachTagValue(m, 'library')
|
this.getStatisticForEachTagValue(m, 'library', 'VALUE', this.getLibraryNameById)
|
||||||
.then(v => this.seriesAllTags = v)
|
.then(v => this.seriesAllTags = v)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -154,7 +157,7 @@ export default Vue.extend({
|
||||||
this.$komgaMetrics.getMetric('komga.books')
|
this.$komgaMetrics.getMetric('komga.books')
|
||||||
.then(m => {
|
.then(m => {
|
||||||
this.books = m
|
this.books = m
|
||||||
this.getStatisticForEachTagValue(m, 'library')
|
this.getStatisticForEachTagValue(m, 'library', 'VALUE', this.getLibraryNameById)
|
||||||
.then(v => this.booksAllTags = v)
|
.then(v => this.booksAllTags = v)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -164,7 +167,7 @@ export default Vue.extend({
|
||||||
this.$komgaMetrics.getMetric('komga.books.filesize')
|
this.$komgaMetrics.getMetric('komga.books.filesize')
|
||||||
.then(m => {
|
.then(m => {
|
||||||
this.booksFileSize = m
|
this.booksFileSize = m
|
||||||
this.getStatisticForEachTagValue(m, 'library')
|
this.getStatisticForEachTagValue(m, 'library', 'VALUE', this.getLibraryNameById)
|
||||||
.then(v => this.fileSizeAllTags = v)
|
.then(v => this.fileSizeAllTags = v)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -174,7 +177,7 @@ export default Vue.extend({
|
||||||
this.$komgaMetrics.getMetric('komga.sidecars')
|
this.$komgaMetrics.getMetric('komga.sidecars')
|
||||||
.then(m => {
|
.then(m => {
|
||||||
this.sidecars = m
|
this.sidecars = m
|
||||||
this.getStatisticForEachTagValue(m, 'library')
|
this.getStatisticForEachTagValue(m, 'library', 'VALUE', this.getLibraryNameById)
|
||||||
.then(v => this.sidecarsAllTags = v)
|
.then(v => this.sidecarsAllTags = v)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -191,7 +194,7 @@ export default Vue.extend({
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async getStatisticForEachTagValue(metric: MetricDto, tag: string, statistic: string = 'VALUE'): Promise<{
|
async getStatisticForEachTagValue(metric: MetricDto, tag: string, statistic: string = 'VALUE', tagTransform: (t: string) => string = x => x): Promise<{
|
||||||
[key: string]: number | undefined
|
[key: string]: number | undefined
|
||||||
} | undefined> {
|
} | undefined> {
|
||||||
const tagDto = metric.availableTags.find(x => x.tag === tag)
|
const tagDto = metric.availableTags.find(x => x.tag === tag)
|
||||||
|
|
@ -202,7 +205,7 @@ export default Vue.extend({
|
||||||
}, {} as { [key: string]: number | undefined })
|
}, {} as { [key: string]: number | undefined })
|
||||||
|
|
||||||
for (let tagKey in tagToStatistic) {
|
for (let tagKey in tagToStatistic) {
|
||||||
tagToStatistic[tagKey] = (await this.$komgaMetrics.getMetric(metric.name, [{
|
tagToStatistic[tagTransform(tagKey)] = (await this.$komgaMetrics.getMetric(metric.name, [{
|
||||||
key: tag,
|
key: tag,
|
||||||
value: tagKey,
|
value: tagKey,
|
||||||
}])).measurements.find(x => x.statistic === statistic)?.value
|
}])).measurements.find(x => x.statistic === statistic)?.value
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue