Skip to content

Commit 7448528

Browse files
committed
Working linkable partition metric.
1 parent 49a9c7f commit 7448528

File tree

11 files changed

+649
-60
lines changed

11 files changed

+649
-60
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "saintsystems/nova-linkable-metrics",
3-
"version":"2.0.0",
3+
"version":"4.0.0",
44
"description": "Linkable metrics for Laravel Nova 4.x.",
55
"keywords": [
66
"laravel",

dist/js/card.js

Lines changed: 578 additions & 25 deletions
Large diffs are not rendered by default.

dist/mix-manifest.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
{
2-
"/js/card.js": "/js/card.js",
3-
"/css/card.css": "/css/card.css"
4-
}
1+
{}

resources/js/card.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import upperFirst from 'lodash/upperFirst'
33

44
import BaseLinkableValueMetric from './components/Base/BaseValueMetric'
55
import BaseLinkableTrendMetric from './components/Base/BaseTrendMetric'
6+
import BaseLinkablePartitionMetric from './components/Base/BasePartitionMetric'
67

78
import LinkableValueMetric from './components/LinkableValueMetric'
89
import LinkableTrendMetric from './components/LinkableTrendMetric'
9-
// import LinkablePartitionMetric from './components/LinkablePartitionMetric'
10+
import LinkablePartitionMetric from './components/LinkablePartitionMetric'
1011

1112
Nova.booting((app, store) => {
1213
// const requireComponent = require.context(
@@ -32,7 +33,8 @@ Nova.booting((app, store) => {
3233

3334
app.component('BaseLinkableValueMetric', BaseLinkableValueMetric)
3435
app.component('BaseLinkableTrendMetric', BaseLinkableTrendMetric)
36+
app.component('BaseLinkablePartitionMetric', BaseLinkablePartitionMetric)
3537
app.component('linkable-value-metric', LinkableValueMetric)
3638
app.component('linkable-trend-metric', LinkableTrendMetric)
37-
// app.component('linkable-partition-metric', LinkablePartitionMetric)
39+
app.component('linkable-partition-metric', LinkablePartitionMetric)
3840
})

resources/js/components/Base/BasePartitionMetric.vue

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<template>
22
<LoadingCard :loading="loading" class="px-6 py-4">
33
<h3 class="h-6 flex mb-3 text-sm font-bold">
4-
{{ title }}
4+
<Link :href="this.url" :title="title" class="link-default font-normal">
5+
{{ title }}
56

6-
<span class="ml-auto font-semibold text-gray-400 text-xs"
7-
>({{ formattedTotal }} {{ __('total') }})</span
8-
>
7+
<span class="ml-auto font-semibold text-gray-400 text-xs"
8+
>({{ formattedTotal }} {{ __('total') }})</span
9+
>
10+
</Link>
911
</h3>
1012

1113
<HelpTextTooltip :text="helpText" :width="helpWidth" />
@@ -18,12 +20,19 @@
1820
:key="item.color"
1921
class="text-xs leading-normal"
2022
>
21-
<span
22-
class="inline-block rounded-full w-2 h-2 mr-2"
23-
:style="{
24-
backgroundColor: item.color,
25-
}"
26-
/>{{ item.label }} ({{ item.value }} - {{ item.percentage }}%)
23+
<component
24+
:is="item.label in partitionLinks ? 'a' : 'span'"
25+
target="_blank"
26+
:href="`${item.label in partitionLinks ? partitionLinks[item.label] : '#'}`"
27+
class='link-default font-normal no-underline'
28+
>
29+
<span
30+
class="inline-block rounded-full w-2 h-2 mr-2"
31+
:style="{
32+
backgroundColor: item.color,
33+
}"
34+
/>{{ item.label }} ({{ item.value }} - {{ item.percentage }}%)
35+
</component>
2736
</li>
2837
</ul>
2938
</div>
@@ -68,6 +77,8 @@ export default {
6877
helpText: {},
6978
helpWidth: {},
7079
chartData: Array,
80+
partitionLinks: Array,
81+
url: '',
7182
},
7283
7384
data: () => ({

resources/js/components/Base/BaseTrendMetric.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</div>
1818

1919
<p class="flex items-center text-4xl mb-4">
20-
<Link :href="this.url" :title="title" class="link-default font-normal">
20+
<Link :href="this.url" :title="title" class="link-defaultd">
2121
{{ formattedValue }}
2222
</Link>
2323
<span v-if="suffix" class="ml-2 text-sm font-bold">{{
@@ -37,7 +37,7 @@
3737
import debounce from 'lodash/debounce'
3838
import Chartist from 'chartist'
3939
import 'chartist/dist/chartist.min.css'
40-
import { singularOrPlural } from '@/mixins'//'laravel-nova'
40+
import { singularOrPlural } from '@/mixins'
4141
import ChartistTooltip from 'chartist-plugin-tooltips-updated'
4242
import 'chartist-plugin-tooltips-updated/dist/chartist-plugin-tooltip.css'
4343

resources/js/components/Base/BaseValueMetric.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
class="flex items-center text-4xl"
3232
:rounded="false"
3333
>
34-
<Link :href="this.url" :title="title" class="link-default font-normal">
34+
<Link :href="this.url" :title="title" class="link-default">
3535
<span v-tooltip="`${tooltipFormattedValue}`">
3636
{{ formattedValue }}
3737
</span>
@@ -107,8 +107,8 @@
107107
</template>
108108

109109
<script>
110-
import { increaseOrDecrease, singularOrPlural } from 'laravel-nova'
111-
import { CopiesToClipboard } from 'laravel-nova'
110+
import { increaseOrDecrease, singularOrPlural } from '@/util'
111+
import { CopiesToClipboard } from '@/mixins'
112112
113113
export default {
114114
name: 'BaseLinkableValueMetric',

resources/js/components/LinkablePartitionMetric.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
<template>
2-
<BasePartitionMetric
2+
<component :is="this.card.url ? 'BaseLinkablePartitionMetric' : 'BasePartitionMetric'"
33
:title="card.name"
44
:help-text="card.helpText"
55
:help-width="card.helpWidth"
66
:chart-data="chartData"
7+
:partition-links="partitionLinks"
78
:loading="loading"
9+
:url="this.card.url"
810
/>
911
</template>
1012

1113
<script>
12-
import { MetricBehavior } from 'laravel-nova'
13-
import { minimum } from '../util'
14+
import { MetricBehavior } from '@/mixins'
15+
import { minimum } from '@/util'
1416
1517
export default {
18+
name: 'LinkablePartitionMetric',
19+
1620
mixins: [MetricBehavior],
1721
1822
props: {
@@ -40,6 +44,7 @@
4044
data: () => ({
4145
loading: true,
4246
chartData: [],
47+
partitionLinks: [],
4348
}),
4449
4550
watch: {
@@ -71,10 +76,11 @@
7176
minimum(Nova.request().get(this.metricEndpoint, this.metricPayload)).then(
7277
({
7378
data: {
74-
value: { value },
79+
value: { value, partitionLinks },
7580
},
7681
}) => {
7782
this.chartData = value
83+
this.partitionLinks = partitionLinks
7884
this.loading = false
7985
}
8086
)

resources/js/components/LinkableTrendMetric.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
<script>
2121
import map from 'lodash/map'
22-
import { InteractsWithDates, MetricBehavior } from 'laravel-nova' //'@/mixins'
23-
import { minimum } from '../util'
22+
import { InteractsWithDates, MetricBehavior } from '@/mixins'
23+
import { minimum } from '@/util'
2424
2525
export default {
2626
name: 'LinkableTrendMetric',

resources/js/components/LinkableValueMetric.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,12 @@
2323

2424
<script>
2525
import { minimum } from '@/util'
26-
import { InteractsWithDates, MetricBehavior } from '@/mixins' //'laravel-nova'
27-
// import BaseLinkableValueMetric from './Base/BaseValueMetric'
28-
// import { BaseValueMetric } from 'laravel-nova'
26+
import { InteractsWithDates, MetricBehavior } from '@/mixins'
27+
2928
export default {
3029
3130
name: 'LinkableValueMetric',
3231
33-
// components: [
34-
// BaseLinkableValueMetric
35-
// ],
36-
3732
// mixins: [InteractsWithDates, MetricBehavior],
3833
3934
props: {

0 commit comments

Comments
 (0)