-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ベンチマーク関連ページの実装 #26
Open
cp-20
wants to merge
8
commits into
main
Choose a base branch
from
client/benchmark-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ベンチマーク関連ページの実装 #26
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8a5ce33
ベンチマーク一覧の view
cp-20 d654265
ベンチマークの詳細画面
cp-20 1e8c40d
ベンチマークの実行の様子を mock するように
cp-20 58f8ded
ログを継続的に更新するように
cp-20 87a3d87
fix: スコアが0でも表示されるように
cp-20 377edd3
fix: waiting のときも継続的に更新するように
cp-20 1a51feb
スコアが実行中に増えるように
cp-20 dda7c2b
スコアをカンマで区切るように
cp-20 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<script setup lang="ts"> | ||
import BenchmarkStatusChip from '@/components/BenchmarkStatusChip.vue' | ||
import ErrorMessage from '@/components/ErrorMessage.vue' | ||
import { formatDate } from '@/lib/formatDate' | ||
import { useTeamBench, useTeamInstances, useUsers } from '@/lib/useServerData' | ||
import { computed, watch } from 'vue' | ||
|
||
const { teamId, benchId } = defineProps<{ | ||
teamId: string | ||
benchId: string | ||
}>() | ||
|
||
const { data: bench, error: benchError, refetch } = useTeamBench(teamId, benchId) | ||
const { data: instances } = useTeamInstances(teamId) | ||
const { data: users } = useUsers() | ||
|
||
const instance = computed(() => instances.value?.find((i) => i.id === bench.value?.instanceId)) | ||
const user = computed(() => users.value?.find((u) => u.id === bench.value?.userId)) | ||
|
||
watch( | ||
bench, | ||
() => { | ||
if (bench.value?.status === 'running' || bench.value?.status === 'waiting') { | ||
const interval = setInterval(() => { | ||
refetch() | ||
}, 1000) | ||
return () => clearInterval(interval) | ||
} | ||
}, | ||
{ immediate: true }, | ||
) | ||
</script> | ||
|
||
<template> | ||
<ErrorMessage v-if="benchError"></ErrorMessage> | ||
<div v-if="bench" class="bench-detail-container"> | ||
<div class="bench-score-container"> | ||
<div class="bench-score-label">スコア</div> | ||
<div v-if="bench.score !== undefined" class="bench-score-content">{{ bench.score }}</div> | ||
<div v-else class="bench-score-content-dimmed">未計測</div> | ||
</div> | ||
<div class="bench-detail-element-container"> | ||
<div class="bench-detail-element"> | ||
<div class="bench-detail-label">ステータス</div> | ||
<BenchmarkStatusChip :status="bench.status" /> | ||
</div> | ||
<div class="bench-detail-element"> | ||
<div class="bench-detail-label">実行ユーザー</div> | ||
<div class="bench-detail-content">@{{ user?.name }}</div> | ||
</div> | ||
<div class="bench-detail-element"> | ||
<div class="bench-detail-label">対象サーバー</div> | ||
<div class="bench-detail-content">サーバー{{ instance?.serverId }}</div> | ||
</div> | ||
<div class="bench-detail-element"> | ||
<div class="bench-detail-label">リクエスト時刻</div> | ||
<div class="bench-detail-content"> | ||
{{ formatDate(bench.createdAt, 'YYYY/MM/DD hh:mm:ss') }} | ||
</div> | ||
</div> | ||
<div class="bench-detail-element"> | ||
<div class="bench-detail-label">開始時刻</div> | ||
<div class="bench-detail-content" v-if="bench.startedAt"> | ||
{{ formatDate(bench.startedAt, 'YYYY/MM/DD hh:mm:ss') }} | ||
</div> | ||
<div class="bench-detail-content-dimmed" v-else>まだ開始していません</div> | ||
</div> | ||
<div class="bench-detail-element"> | ||
<div class="bench-detail-label">終了時刻</div> | ||
<div class="bench-detail-content" v-if="bench.finishedAt"> | ||
{{ formatDate(bench.finishedAt, 'YYYY/MM/DD hh:mm:ss') }} | ||
</div> | ||
<div class="bench-detail-content-dimmed" v-else>まだ終了していません</div> | ||
</div> | ||
</div> | ||
<div class="bench-log-container"> | ||
<pre><code>{{ bench.log }}</code></pre> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.bench-detail-container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
} | ||
|
||
.bench-score-container { | ||
display: flex; | ||
flex-direction: column; | ||
border: 1px solid var(--ct-slate-300); | ||
border-radius: 2px; | ||
padding: 0.5rem; | ||
} | ||
.bench-score-label { | ||
font-weight: 700; | ||
font-size: 0.9rem; | ||
} | ||
.bench-score-content { | ||
font-size: 1.5rem; | ||
font-weight: 700; | ||
} | ||
.bench-score-content-dimmed { | ||
font-size: 1.5rem; | ||
color: var(--ct-slate-500); | ||
} | ||
|
||
.bench-detail-element-container { | ||
display: grid; | ||
grid-template-columns: repeat(3, 1fr); | ||
gap: 0.5rem; | ||
} | ||
.bench-detail-element { | ||
display: flex; | ||
flex-direction: column; | ||
border: 1px solid var(--ct-slate-300); | ||
border-radius: 2px; | ||
padding: 0.5rem; | ||
} | ||
.bench-detail-label { | ||
font-weight: 700; | ||
font-size: 0.8rem; | ||
} | ||
.bench-detail-content { | ||
font-size: 0.9rem; | ||
} | ||
.bench-detail-content-dimmed { | ||
font-size: 0.9rem; | ||
color: var(--ct-slate-500); | ||
} | ||
|
||
.bench-log-container { | ||
border-radius: 2px; | ||
background-color: var(--ct-slate-800); | ||
color: var(--ct-slate-200); | ||
font-size: 0.8rem; | ||
padding: 1rem; | ||
overflow-x: auto; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<script setup lang="ts"> | ||
import { useTeamBenches, useTeamInstances, useUsers } from '@/lib/useServerData' | ||
import { computed } from 'vue' | ||
import { RouterLink } from 'vue-router' | ||
import { formatDate } from '@/lib/formatDate' | ||
import { Icon } from '@iconify/vue' | ||
import ErrorMessage from '@/components/ErrorMessage.vue' | ||
import BenchmarkStatusChip from '@/components/BenchmarkStatusChip.vue' | ||
|
||
const { teamId } = defineProps<{ teamId: string }>() | ||
|
||
const { data: benches, error: benchesError } = useTeamBenches(teamId) | ||
const sortedBenches = computed(() => | ||
[...(benches.value ?? [])].sort( | ||
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), | ||
), | ||
) | ||
const { data: instances } = useTeamInstances(teamId) | ||
const { data: users } = useUsers() | ||
</script> | ||
|
||
<template> | ||
<div class="bench-list"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. スコアで並び替えたり実行ユーザーとかステータスで絞り込めたらうれしいかも There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ちょっとめんどくさいので、後からやることにします |
||
<div class="list-label"> | ||
<Icon icon="mdi:score" width="24" height="24" /> | ||
<span>スコア</span> | ||
</div> | ||
<div class="list-label"> | ||
<Icon icon="mdi:calendar-clock" width="24" height="24" /> | ||
<span>日時</span> | ||
</div> | ||
<div class="list-label"> | ||
<Icon icon="mdi:server-network" width="24" height="24" /> | ||
<span>対象サーバー</span> | ||
</div> | ||
<div class="list-label"> | ||
<Icon icon="mdi:account" width="24" height="24" /> | ||
<span>実行ユーザー</span> | ||
</div> | ||
<div class="list-label"> | ||
<Icon icon="mdi:progress-clock" width="24" height="24" /> | ||
<span>ステータス</span> | ||
</div> | ||
<div class="list-label"></div> | ||
<template v-for="bench in sortedBenches" :key="bench.id"> | ||
<div v-if="bench.score !== undefined" class="bench-score"> | ||
{{ bench.score }} | ||
</div> | ||
<div v-else class="bench-score-loading">計測中</div> | ||
<div> | ||
{{ formatDate(bench.createdAt, 'YYYY/MM/DD hh:mm:ss.SSS') }} | ||
</div> | ||
<div class="bench-server"> | ||
サーバー{{ instances?.find((i) => i.id === bench.instanceId)?.serverId ?? '?' }} | ||
</div> | ||
<div class="bench-user"> | ||
<img | ||
:src="`https://q.trap.jp/api/v3/public/icon/${users?.find((u) => u.id === bench.userId)?.name}`" | ||
alt="" | ||
width="24" | ||
height="24" | ||
/> | ||
<span>@{{ users?.find((u) => u.id === bench.userId)?.name }}</span> | ||
</div> | ||
<div> | ||
<BenchmarkStatusChip :status="bench.status" /> | ||
</div> | ||
<div> | ||
<RouterLink :to="`/benches/${bench.id}`" class="bench-link"> | ||
<span>詳細を見る</span> | ||
<Icon icon="mdi:chevron-right" width="24" height="24" /> | ||
</RouterLink> | ||
</div> | ||
</template> | ||
</div> | ||
<ErrorMessage v-if="benchesError" /> | ||
</template> | ||
|
||
<style scoped> | ||
.bench-list { | ||
width: 100%; | ||
display: grid; | ||
grid-template-columns: 1fr 1fr 1fr 1fr 1fr auto; | ||
} | ||
|
||
.bench-skeleton { | ||
height: 2rem; | ||
border-bottom: 1px solid var(--ct-slate-300); | ||
padding: 0.5rem 1rem; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.bench-list > div { | ||
border-bottom: 1px solid var(--ct-slate-300); | ||
padding: 0.5rem 1rem; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.list-label { | ||
font-weight: 700; | ||
gap: 0.25rem; | ||
} | ||
|
||
.bench-score { | ||
font-weight: 700; | ||
} | ||
.bench-score-loading { | ||
color: var(--ct-slate-500); | ||
font-size: 0.8rem; | ||
} | ||
|
||
.bench-user { | ||
font-weight: 600; | ||
font-size: 0.9rem; | ||
gap: 0.25rem; | ||
} | ||
|
||
.bench-link { | ||
display: flex; | ||
width: fit-content; | ||
align-items: center; | ||
gap: 0rem; | ||
text-decoration: none; | ||
color: var(--color-primary); | ||
font-weight: 700; | ||
} | ||
|
||
.bench-link svg { | ||
margin-top: 0.15rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script setup lang="ts"> | ||
import type { components } from '@/api/openapi' | ||
type Status = components['schemas']['BenchmarkStatus'] | ||
const { status } = defineProps<{ status: Status }>() | ||
|
||
const labels: Record<Status, string> = { | ||
waiting: 'WAITING', | ||
running: 'RUNNING', | ||
finished: 'FINISHED', | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="status-chip" :class="status"> | ||
{{ labels[status] }} | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.status-chip { | ||
line-height: 2; | ||
border-radius: 2px; | ||
width: 72px; | ||
color: white; | ||
font-weight: 600; | ||
font-size: 0.7rem; | ||
text-align: center; | ||
} | ||
.status-chip.waiting { | ||
background-color: #f0ad4e33; | ||
color: #f0ad4e; | ||
} | ||
.status-chip.running { | ||
background-color: #5bc0de33; | ||
color: #5bc0de; | ||
} | ||
.status-chip.finished { | ||
background-color: #5cb85c33; | ||
color: #5cb85c; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup lang="ts"> | ||
import { Icon } from '@iconify/vue' | ||
</script> | ||
|
||
<template> | ||
<div class="error-message"> | ||
<Icon icon="mdi:alert-octagon" width="48" height="48" /> | ||
<span>エラーが発生しました</span> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.error-message { | ||
padding: 1rem; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 0.5rem; | ||
font-size: 1.2rem; | ||
color: var(--ct-red-500); | ||
font-weight: 700; | ||
text-align: center; | ||
} | ||
</style> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
スコアをコンマ区切り(123,456)で書きたいかも