|
82 | 82 |
|
83 | 83 | let latestOnly = $state(false); |
84 | 84 | let shareTab = $state("share"); |
| 85 | + let copyFeedback = $state(null); |
| 86 | + let copyFeedbackTimer = null; |
85 | 87 |
|
86 | 88 | function toggleLatestOnly() { |
87 | 89 | latestOnly = !latestOnly; |
|
143 | 145 | const params = new URLSearchParams(); |
144 | 146 | params.set("project", selectedProject); |
145 | 147 | if (metricFilter?.trim()) { |
146 | | - params.set("metrics", metricFilter.trim()); |
| 148 | + params.set("metric_filter", metricFilter.trim()); |
147 | 149 | } |
148 | 150 | const runNames = selectedRunNamesFromIds(selectedRuns, runs); |
149 | 151 | if (runNames.length) { |
|
164 | 166 | return `<iframe src="${shareUrl}" style="width:1600px; height:500px; border:0;"></iframe>`; |
165 | 167 | }); |
166 | 168 |
|
167 | | - async function copyText(value) { |
| 169 | + async function copyText(value, feedbackKey) { |
168 | 170 | if (!value) return; |
169 | 171 | try { |
170 | 172 | await navigator.clipboard.writeText(value); |
|
179 | 181 | document.execCommand("copy"); |
180 | 182 | document.body.removeChild(textarea); |
181 | 183 | } |
| 184 | + copyFeedback = feedbackKey; |
| 185 | + if (copyFeedbackTimer) { |
| 186 | + clearTimeout(copyFeedbackTimer); |
| 187 | + } |
| 188 | + copyFeedbackTimer = setTimeout(() => { |
| 189 | + copyFeedback = null; |
| 190 | + copyFeedbackTimer = null; |
| 191 | + }, 2000); |
182 | 192 | } |
183 | 193 | </script> |
184 | 194 |
|
|
221 | 231 | </div> |
222 | 232 |
|
223 | 233 | {#if variant === "full"} |
224 | | - <div class="section"> |
225 | | - <div class="share-tabs"> |
226 | | - <button |
227 | | - class="share-tab-btn" |
228 | | - class:active={shareTab === "share"} |
229 | | - onclick={() => { shareTab = "share"; }} |
230 | | - > |
231 | | - Share |
232 | | - </button> |
233 | | - <button |
234 | | - class="share-tab-btn" |
235 | | - class:active={shareTab === "embed"} |
236 | | - onclick={() => { shareTab = "embed"; }} |
237 | | - > |
238 | | - Embed |
239 | | - </button> |
240 | | - </div> |
241 | | - {#if shareTab === "share"} |
242 | | - <div class="share-field"> |
243 | | - <span class="section-label">Share this view</span> |
244 | | - {#if shareUrl} |
245 | | - <div class="share-input-row"> |
246 | | - <input type="text" value={shareUrl} readonly /> |
247 | | - <button class="copy-btn" onclick={() => copyText(shareUrl)}> |
248 | | - Copy |
249 | | - </button> |
250 | | - </div> |
251 | | - {:else} |
252 | | - <p class="share-hint">Select a project to generate a share link.</p> |
253 | | - {/if} |
254 | | - </div> |
255 | | - {:else} |
256 | | - <div class="share-field"> |
257 | | - <span class="section-label">Embed this view</span> |
258 | | - {#if embedCode} |
259 | | - <div class="share-input-row"> |
260 | | - <textarea readonly rows="2" value={embedCode}></textarea> |
261 | | - <button class="copy-btn" onclick={() => copyText(embedCode)}> |
262 | | - Copy |
263 | | - </button> |
264 | | - </div> |
265 | | - {:else} |
266 | | - <p class="share-hint">Select a project to generate embed HTML.</p> |
267 | | - {/if} |
| 234 | + {#if currentPage === "metrics"} |
| 235 | + <div class="section"> |
| 236 | + <div class="share-tabs"> |
| 237 | + <button |
| 238 | + class="share-tab-btn" |
| 239 | + class:active={shareTab === "share"} |
| 240 | + onclick={() => { shareTab = "share"; }} |
| 241 | + > |
| 242 | + Share |
| 243 | + </button> |
| 244 | + <button |
| 245 | + class="share-tab-btn" |
| 246 | + class:active={shareTab === "embed"} |
| 247 | + onclick={() => { shareTab = "embed"; }} |
| 248 | + > |
| 249 | + Embed |
| 250 | + </button> |
268 | 251 | </div> |
269 | | - {/if} |
270 | | - </div> |
| 252 | + {#if shareTab === "share"} |
| 253 | + <div class="share-field"> |
| 254 | + <span class="section-label">Share this view</span> |
| 255 | + {#if shareUrl} |
| 256 | + <div class="share-input-row"> |
| 257 | + <input type="text" value={shareUrl} readonly /> |
| 258 | + <button class="copy-btn" onclick={() => copyText(shareUrl, "share")}> |
| 259 | + {copyFeedback === "share" ? "Copied" : "Copy"} |
| 260 | + </button> |
| 261 | + </div> |
| 262 | + {:else} |
| 263 | + <p class="share-hint">Select a project to generate a share link.</p> |
| 264 | + {/if} |
| 265 | + </div> |
| 266 | + {:else} |
| 267 | + <div class="share-field"> |
| 268 | + <span class="section-label">Embed this view</span> |
| 269 | + {#if embedCode} |
| 270 | + <div class="share-input-row"> |
| 271 | + <textarea readonly rows="2" value={embedCode}></textarea> |
| 272 | + <button class="copy-btn" onclick={() => copyText(embedCode, "embed")}> |
| 273 | + {copyFeedback === "embed" ? "Copied" : "Copy"} |
| 274 | + </button> |
| 275 | + </div> |
| 276 | + {:else} |
| 277 | + <p class="share-hint">Select a project to generate embed HTML.</p> |
| 278 | + {/if} |
| 279 | + </div> |
| 280 | + {/if} |
| 281 | + </div> |
| 282 | + {/if} |
271 | 283 |
|
272 | 284 | <div class="section"> |
273 | 285 | <div class="runs-header"> |
|
0 commit comments