1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
<script>
import { GlTable, GlLink, GlPagination, GlTooltipDirective } from '@gitlab/ui';
import { __ } from '~/locale';
import { getParameterValues, setUrlParams } from '~/lib/utils/url_utility';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import IncubationAlert from './incubation_alert.vue';
export default {
name: 'MlExperiment',
components: {
GlTable,
GlLink,
TimeAgo,
IncubationAlert,
GlPagination,
},
directives: {
GlTooltip: GlTooltipDirective,
},
inject: ['candidates', 'metricNames', 'paramNames', 'pagination'],
data() {
return {
page: parseInt(getParameterValues('page')[0], 10) || 1,
};
},
computed: {
fields() {
return [
{ key: 'name', label: this.$options.i18n.nameLabel },
{ key: 'created_at', label: this.$options.i18n.createdAtLabel },
{ key: 'user', label: this.$options.i18n.userLabel },
...this.paramNames,
...this.metricNames,
{ key: 'details', label: '' },
{ key: 'artifact', label: '' },
];
},
displayPagination() {
return this.candidates.length > 0;
},
prevPage() {
return this.pagination.page > 1 ? this.pagination.page - 1 : null;
},
nextPage() {
return !this.pagination.isLastPage ? this.pagination.page + 1 : null;
},
},
methods: {
generateLink(page) {
return setUrlParams({ page });
},
},
i18n: {
titleLabel: __('Experiment candidates'),
emptyStateLabel: __('This experiment has no logged candidates'),
artifactsLabel: __('Artifacts'),
detailsLabel: __('Details'),
userLabel: __('User'),
createdAtLabel: __('Created at'),
nameLabel: __('Name'),
noDataContent: __('-'),
},
};
</script>
<template>
<div>
<incubation-alert />
<h3>
{{ $options.i18n.titleLabel }}
</h3>
<gl-table
:fields="fields"
:items="candidates"
:empty-text="$options.i18n.emptyStateLabel"
show-empty
small
class="gl-mt-0! ml-candidate-table"
>
<template #cell()="data">
<div v-gl-tooltip.hover :title="data.value">{{ data.value }}</div>
</template>
<template #cell(artifact)="data">
<gl-link
v-if="data.value"
v-gl-tooltip.hover
:href="data.value"
target="_blank"
:title="$options.i18n.artifactsLabel"
>{{ $options.i18n.artifactsLabel }}</gl-link
>
<div v-else v-gl-tooltip.hover :title="$options.i18n.artifactsLabel">
{{ $options.i18n.noDataContent }}
</div>
</template>
<template #cell(details)="data">
<gl-link v-gl-tooltip.hover :href="data.value" :title="$options.i18n.detailsLabel">{{
$options.i18n.detailsLabel
}}</gl-link>
</template>
<template #cell(created_at)="data">
<time-ago v-gl-tooltip.hover :time="data.value" :title="data.value" />
</template>
<template #cell(user)="data">
<gl-link
v-if="data.value"
v-gl-tooltip.hover
:href="data.value.path"
:title="data.value.username"
>@{{ data.value.username }}</gl-link
>
<div v-else>{{ $options.i18n.noDataContent }}</div>
</template>
</gl-table>
<gl-pagination
v-if="displayPagination"
v-model="pagination.page"
:prev-page="prevPage"
:next-page="nextPage"
:total-items="pagination.totalItems"
:per-page="pagination.perPage"
:link-gen="generateLink"
align="center"
class="w-100"
/>
</div>
</template>
|