|
| 1 | +<script setup lang="ts"> |
| 2 | +import {getJson} from "../../utils/requests"; |
| 3 | +import {STATUS_DATA_NEW_URL} from "../../urls"; |
| 4 | +import {withLoading} from "../../utils/loading"; |
| 5 | +import {ref, Ref} from "vue"; |
| 6 | +import {StatusResponseNew} from "./data"; |
| 7 | +import {useExpandedStore} from "./expansion"; |
| 8 | +
|
| 9 | +async function loadStatusNew(loading: Ref<boolean>) { |
| 10 | + dataNew.value = await withLoading(loading, () => |
| 11 | + getJson<StatusResponse>(STATUS_DATA_NEW_URL) |
| 12 | + ); |
| 13 | +} |
| 14 | +
|
| 15 | +const loading = ref(true); |
| 16 | +const dataNew: Ref<StatusResponse | null> = ref(null); |
| 17 | +
|
| 18 | +function statusLabel(c) { |
| 19 | + if (!c.is_active) return "Inactive"; |
| 20 | + return this.isStale(c) ? "Stale" : "Active"; |
| 21 | +} |
| 22 | +
|
| 23 | +function statusClass(c) { |
| 24 | + return c.is_active ? "active" : "inactive"; |
| 25 | +} |
| 26 | +
|
| 27 | +loadStatusNew(loading); |
| 28 | +</script> |
| 29 | + |
| 30 | +<template> |
| 31 | + <div v-if="dataNew !== null"> |
| 32 | + <span> |
| 33 | + <h2>JSON from the database</h2> |
| 34 | + <code style="white-space: break-spaces"> |
| 35 | + {{ JSON.stringify(dataNew, null, 2) }} |
| 36 | + </code> |
| 37 | + </span> |
| 38 | + <div id="app" class="container"> |
| 39 | + <h1>Collectors</h1> |
| 40 | + |
| 41 | + <div class="grid"> |
| 42 | + <div |
| 43 | + v-for="c in dataNew.collector_configs" |
| 44 | + :key="c.name + c.target" |
| 45 | + class="card" |
| 46 | + > |
| 47 | + <div> |
| 48 | + <div class="header"> |
| 49 | + <div class="name">{{ c.name }}:</div> |
| 50 | + <div class="status" :class="statusClass(c)"> |
| 51 | + {{ c.is_active ? "Active" : "Inactive" }} |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + <div class="meta"> |
| 55 | + <div><strong>Target:</strong> {{ c.target }}</div> |
| 56 | + <div><strong>Benchmark Set:</strong> #{{ c.benchmark_set }}</div> |
| 57 | + <div> |
| 58 | + <strong>Last Heartbeat:</strong> |
| 59 | + {{ c.last_heartbeat_at }} |
| 60 | + </div> |
| 61 | + <div> |
| 62 | + <strong>Date Added:</strong> |
| 63 | + {{ c.date_added }} |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + </div> |
| 71 | +</template> |
| 72 | + |
| 73 | +<style scoped lang="scss"> |
| 74 | +.timeline { |
| 75 | + max-width: 100%; |
| 76 | + width: fit-content; |
| 77 | +
|
| 78 | + table { |
| 79 | + border-collapse: collapse; |
| 80 | + font-size: 1.1em; |
| 81 | +
|
| 82 | + th, |
| 83 | + td { |
| 84 | + padding: 0.2em; |
| 85 | + } |
| 86 | +
|
| 87 | + th { |
| 88 | + text-align: center; |
| 89 | + } |
| 90 | + td { |
| 91 | + text-align: left; |
| 92 | + padding: 0 0.5em; |
| 93 | +
|
| 94 | + &.centered { |
| 95 | + text-align: center; |
| 96 | + } |
| 97 | + &.right-align { |
| 98 | + text-align: right; |
| 99 | + } |
| 100 | + } |
| 101 | + tr.active { |
| 102 | + font-weight: bold; |
| 103 | + } |
| 104 | + } |
| 105 | +
|
| 106 | + @media screen and (min-width: 1440px) { |
| 107 | + width: 100%; |
| 108 | + } |
| 109 | +} |
| 110 | +
|
| 111 | +.header { |
| 112 | + display: flex; |
| 113 | + align-items: center; |
| 114 | +} |
| 115 | +
|
| 116 | +.status { |
| 117 | + padding: 2px 8px; |
| 118 | + border-radius: 20px; |
| 119 | + font-size: 0.75rem; |
| 120 | + width: 50px; |
| 121 | + font-weight: bold; |
| 122 | +} |
| 123 | +
|
| 124 | +.status.active { |
| 125 | + color: green; |
| 126 | +} |
| 127 | +.status.inactive { |
| 128 | + color: red; |
| 129 | +} |
| 130 | +
|
| 131 | +.wrapper { |
| 132 | + display: grid; |
| 133 | + column-gap: 100px; |
| 134 | + grid-template-columns: 1fr; |
| 135 | +
|
| 136 | + @media screen and (min-width: 1440px) { |
| 137 | + grid-template-columns: 4fr 6fr; |
| 138 | + } |
| 139 | +} |
| 140 | +.current { |
| 141 | + max-width: 100%; |
| 142 | + width: fit-content; |
| 143 | +
|
| 144 | + .benchmark { |
| 145 | + margin-bottom: 10px; |
| 146 | + font-size: 1.2em; |
| 147 | + } |
| 148 | +} |
| 149 | +.column-centered { |
| 150 | + display: flex; |
| 151 | + flex-direction: column; |
| 152 | + align-items: center; |
| 153 | +} |
| 154 | +.current-table { |
| 155 | + border-collapse: collapse; |
| 156 | + font-size: 1.1em; |
| 157 | +
|
| 158 | + td, |
| 159 | + th { |
| 160 | + padding: 0 10px; |
| 161 | + } |
| 162 | + tbody > tr { |
| 163 | + td { |
| 164 | + padding-top: 5px; |
| 165 | + text-align: center; |
| 166 | + } |
| 167 | + } |
| 168 | +} |
| 169 | +.aligned { |
| 170 | + text-align: right; |
| 171 | +} |
| 172 | +.error { |
| 173 | + padding: 10px; |
| 174 | + background-color: #f7f7f7; |
| 175 | + max-width: 100%; |
| 176 | + white-space: pre-wrap; |
| 177 | + word-break: break-word; |
| 178 | +} |
| 179 | +.grid { |
| 180 | + display: grid; |
| 181 | + grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); |
| 182 | + gap: 20px; |
| 183 | +} |
| 184 | +.card { |
| 185 | + border-radius: 12px; |
| 186 | + padding: 16px; |
| 187 | + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); |
| 188 | + display: flex; |
| 189 | + flex-direction: column; |
| 190 | + justify-content: space-between; |
| 191 | + transition: transform 0.2s ease; |
| 192 | +} |
| 193 | +</style> |
0 commit comments