-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPanel.qml
More file actions
924 lines (819 loc) · 31.4 KB
/
Copy pathPanel.qml
File metadata and controls
924 lines (819 loc) · 31.4 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
import QtQuick
import QtQuick.Effects
import Quickshell
import Quickshell.Io
import qs.Commons
import qs.Ui
import "Model.js" as Model
// QuickNode detail popup: credit usage for the current billing period, a
// filterable endpoint list with per-chain usage and copyable RPC/WSS
// addresses, and inline Admin API key management.
Panel {
id: root
moduleName: "io.github.quicknode.quicknode"
ipcTarget: "io.github.quicknode.quicknode"
manageIpc: false
property var anchorItem: null
property bool openedFromHotkey: false
// The bar tracks the widget mounted in its slot — BarWidget.qml — not this
// nested panel, so everything the bar identifies a panel by has to be that
// widget (popout coordinator, switchPanelFrom).
property var hostWidget: null
readonly property var barIdentity: hostWidget || root
function open() {
openedFromHotkey = false
setCenterHoverRevealSuppressed(false)
root.controller.show()
root.refresh()
}
function openFromHotkey() {
openedFromHotkey = true
root.controller.show()
root.refresh()
// Set after showing: showing hands the popout coordinator over, which
// closes whichever panel was open, and that close clears the shared flag.
Qt.callLater(function() {
if (root.opened) setCenterHoverRevealSuppressed(true)
})
}
function close() {
setCenterHoverRevealSuppressed(false)
if (root.editingKey) root.cancelEditingKey()
root.controller.hide()
}
function toggle() {
if (root.opened) root.close()
else root.openFromHotkey()
}
function switchPanel(direction) {
if (root.bar && typeof root.bar.switchPanelFrom === "function")
return root.bar.switchPanelFrom(root.barIdentity, direction)
return false
}
function setCenterHoverRevealSuppressed(value) {
if (root.bar && "centerHoverRevealSuppressed" in root.bar)
root.bar.centerHoverRevealSuppressed = value
}
// ---- Data. Last-good reports are kept on failure so stale numbers stay
// visible instead of blanking while the network is down.
property var usage: null
property var endpoints: []
property var chainUsage: ({})
property string errorMessage: ""
property int usageRetries: 0
property int endpointsRetries: 0
property int chainUsageRetries: 0
readonly property string apiKey: String(setting("apiKey", ""))
readonly property bool hasKey: apiKey !== ""
readonly property int refreshMinutes: Math.max(1, parseInt(setting("refreshMinutes", 15), 10) || 15)
readonly property var percent: Model.usagePercent(usage)
readonly property bool overLimit: !!usage && ((usage.overages !== null && usage.overages > 0) || (percent !== null && percent >= 100))
readonly property bool nearLimit: percent !== null && percent >= 90
readonly property color foreground: root.bar ? root.bar.foreground : Color.foreground
readonly property string fontFamily: root.bar ? root.bar.fontFamily : Style.font.family
readonly property color mutedText: Qt.darker(foreground, 1.5)
// Click-to-edit state for the API key.
property bool editingKey: false
// Endpoint list filter and the transient "copied" flash on a copy button
// (keyed by endpoint id + kind so only the pressed button reacts).
property string filterText: ""
property string copiedKey: ""
readonly property var visibleEndpoints: Model.filterEndpoints(endpoints, filterText)
function refresh() {
if (!root.hasKey) return
usageRetries = 0
endpointsRetries = 0
chainUsageRetries = 0
if (!usageProc.running) usageProc.running = true
if (!endpointsProc.running) endpointsProc.running = true
if (!chainUsageProc.running) chainUsageProc.running = true
}
function startEditingKey() {
editingKey = true
Qt.callLater(function() {
keyField.text = root.apiKey
keyField.selectAll()
keyField.forceActiveFocus()
})
}
function cancelEditingKey() {
editingKey = false
Qt.callLater(function() { if (keyCatcher) keyCatcher.forceActiveFocus() })
}
// Persist the key inline on this widget's shell.json entry (the same
// mechanism the clock uses to store a cycled format). An empty commit is
// treated as a cancel so the stored key can't be lost by accident.
function commitKey() {
var key = String(keyField.text || "").trim()
if (key === "" || key === root.apiKey) {
cancelEditingKey()
return
}
var entry = { id: root.moduleName }
for (var k in root.settings) if (k !== "id") entry[k] = root.settings[k]
entry.apiKey = key
// Applied locally first so the panel reacts on the commit itself; the
// shell.json write comes back through the bar as the same value.
root.settings = entry
if (root.bar && root.bar.shell && typeof root.bar.shell.updateEntryInline === "function")
root.bar.shell.updateEntryInline(root.moduleName, entry)
usage = null
endpoints = []
chainUsage = {}
errorMessage = ""
cancelEditingKey()
Qt.callLater(root.refresh)
}
function focusFilter() {
filterField.forceActiveFocus()
}
function blurFilter() {
if (keyCatcher) keyCatcher.forceActiveFocus()
}
function copyText(key, text) {
if (!text) return
copyProc.payload = text
copyProc.running = true
copiedKey = key
copiedTimer.restart()
}
function scheduleUsageRetry() {
if (usageRetries >= 3) return
usageRetries++
usageRetryTimer.restart()
}
function scheduleEndpointsRetry() {
if (endpointsRetries >= 3) return
endpointsRetries++
endpointsRetryTimer.restart()
}
function scheduleChainUsageRetry() {
if (chainUsageRetries >= 3) return
chainUsageRetries++
chainUsageRetryTimer.restart()
}
// The Admin API key travels via the child environment, not argv, so it
// never shows up in the process list.
Process {
id: usageProc
environment: ({ QN_ADMIN_KEY: root.apiKey })
command: ["sh", "-c", "exec curl -sS --max-time 10 -H \"x-api-key: $QN_ADMIN_KEY\" -H 'accept: application/json' 'https://api.quicknode.com/v0/usage/rpc'"]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: {
var parsed = Model.parseUsage(text)
if (!parsed) {
root.errorMessage = "Could not reach the QuickNode API"
root.scheduleUsageRetry()
return
}
if (parsed.error) {
root.errorMessage = parsed.error
return
}
root.usage = parsed
root.errorMessage = ""
root.usageRetries = 0
}
}
}
Timer {
id: usageRetryTimer
interval: 3000
onTriggered: if (!usageProc.running) usageProc.running = true
}
Process {
id: endpointsProc
environment: ({ QN_ADMIN_KEY: root.apiKey })
command: ["sh", "-c", "exec curl -sS --max-time 10 -H \"x-api-key: $QN_ADMIN_KEY\" -H 'accept: application/json' 'https://api.quicknode.com/v0/endpoints?limit=50&offset=0'"]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: {
var parsed = Model.parseEndpoints(text)
if (!parsed) {
root.scheduleEndpointsRetry()
return
}
if (parsed.error) return
root.endpoints = parsed
root.endpointsRetries = 0
}
}
}
Timer {
id: endpointsRetryTimer
interval: 3000
onTriggered: if (!endpointsProc.running) endpointsProc.running = true
}
Process {
id: chainUsageProc
environment: ({ QN_ADMIN_KEY: root.apiKey })
command: ["sh", "-c", "exec curl -sS --max-time 10 -H \"x-api-key: $QN_ADMIN_KEY\" -H 'accept: application/json' 'https://api.quicknode.com/v0/usage/rpc/by-chain'"]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: {
var parsed = Model.parseChainUsage(text)
if (!parsed) {
root.scheduleChainUsageRetry()
return
}
if (parsed.error) return
root.chainUsage = parsed
root.chainUsageRetries = 0
}
}
}
Timer {
id: chainUsageRetryTimer
interval: 3000
onTriggered: if (!chainUsageProc.running) chainUsageProc.running = true
}
// Endpoint URLs embed the auth token, so they go to wl-copy over a pipe
// rather than as an argument.
Process {
id: copyProc
property string payload: ""
environment: ({ COPY_TEXT: copyProc.payload })
command: ["sh", "-c", "printf %s \"$COPY_TEXT\" | wl-copy"]
}
Timer {
id: copiedTimer
interval: 1500
onTriggered: root.copiedKey = ""
}
// hasKey gates the timer, so the first fetch fires the moment a key is
// configured and nothing runs while there is none.
Timer {
interval: root.refreshMinutes * 60 * 1000
running: root.hasKey
repeat: true
triggeredOnStart: true
onTriggered: root.refresh()
}
IpcHandler {
target: root.ipcTarget
function open(): void { root.openFromHotkey() }
function close(): void { root.close() }
function show(): void { root.openFromHotkey() }
function hide(): void { root.close() }
function toggle(): void { root.toggle() }
function edit(): void { root.openFromHotkey(); root.startEditingKey() }
function refresh(): void { root.refresh() }
}
KeyboardPanel {
id: panel
anchorItem: root.anchorItem
owner: root.barIdentity
bar: root.bar
open: root.opened
focusTarget: keyCatcher
contentWidth: panel.fittedContentWidth(Style.space(460))
contentHeight: panel.fittedContentHeight(contentColumn.implicitHeight)
PanelKeyCatcher {
id: keyCatcher
anchors.fill: parent
blocked: root.editingKey || filterField.activeFocus
onReturnRequested: root.startEditingKey()
onCloseRequested: root.close()
onTabRequested: function(direction) { root.switchPanel(direction) }
onTextKey: function(t) { if (t === "/") root.focusFilter() }
Flickable {
id: contentScroll
anchors.fill: parent
contentWidth: width
contentHeight: contentColumn.implicitHeight
clip: true
boundsBehavior: Flickable.StopAtBounds
interactive: contentHeight > height
Column {
id: contentColumn
width: contentScroll.width
spacing: Style.space(14)
// ---- Hero row: QuickNode symbol left, stats stacked right.
Item {
visible: root.hasKey
width: parent.width
height: Math.max(heroLeft.height, heroRight.height)
Row {
id: heroLeft
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(18)
// QuickNode symbol, painted in the panel foreground. Sized to
// match the hero percentage's cap height.
Item {
anchors.verticalCenter: parent.verticalCenter
width: Style.space(32)
height: Style.space(32)
Image {
id: heroLogo
anchors.fill: parent
source: Qt.resolvedUrl("assets/quicknode.svg")
sourceSize.width: Style.space(32) * 2
sourceSize.height: Style.space(32) * 2
fillMode: Image.PreserveAspectFit
smooth: true
visible: false
layer.enabled: true
}
MultiEffect {
anchors.fill: heroLogo
source: heroLogo
colorization: 1.0
colorizationColor: root.foreground
}
}
}
Row {
id: heroRight
anchors.right: parent.right
anchors.rightMargin: Style.space(20)
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(28)
Column {
spacing: Style.space(5)
Text {
text: "USED"
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
font.letterSpacing: 1
}
Text {
text: root.usage ? Model.formatCredits(root.usage.creditsUsed) : "—"
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.title
}
}
Column {
spacing: Style.space(5)
Text {
text: "LIMIT"
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
font.letterSpacing: 1
}
Text {
text: root.usage ? Model.formatCredits(root.usage.limit) : "—"
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.title
}
}
Column {
spacing: Style.space(5)
Text {
text: "RESETS"
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
font.letterSpacing: 1
}
Text {
text: root.usage ? Model.resetShort(root.usage.startTime, Date.now()) : "—"
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.title
}
}
}
}
// ---- Usage progress bar for the billing period. Track and fill
// are siblings: a child fill would inherit the track's
// washed-out opacity.
Item {
visible: root.hasKey && root.percent !== null
width: parent.width
height: Style.space(6)
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: Style.space(16)
anchors.rightMargin: Style.space(16)
height: parent.height
radius: height / 2
color: root.foreground
opacity: 0.12
}
Rectangle {
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
width: (parent.width - Style.space(32)) * Math.min(root.percent === null ? 0 : root.percent, 100) / 100
height: parent.height
radius: height / 2
color: root.overLimit || root.nearLimit ? Color.urgent : Color.accent
}
}
Text {
visible: root.hasKey && root.overLimit && !!root.usage && root.usage.overages !== null && root.usage.overages > 0
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
text: Model.formatCredits(root.usage ? root.usage.overages : null) + " credits over the plan limit"
color: Color.urgent
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
}
Text {
visible: root.hasKey && !root.usage && root.errorMessage === ""
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
text: "Fetching usage…"
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
font.italic: true
}
Text {
visible: root.errorMessage !== ""
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
width: parent.width - Style.space(32)
text: root.errorMessage
wrapMode: Text.WordWrap
color: Color.urgent
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
}
// ---- API key: prompt when unset, masked click-to-edit row when set.
Column {
visible: !root.hasKey && !root.editingKey
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
spacing: Style.space(6)
Text {
text: "QUICKNODE"
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.title
font.letterSpacing: 1
}
Text {
width: contentColumn.width - Style.space(32)
wrapMode: Text.WordWrap
text: "Paste an Admin API key to see credit usage and endpoints."
color: Qt.darker(root.foreground, 1.4)
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
}
Row {
spacing: Style.space(6)
TapHandler {
onTapped: root.startEditingKey()
}
HoverHandler {
cursorShape: Qt.PointingHandCursor
}
Text {
text: ""
color: Color.accent
font.family: root.fontFamily
font.pixelSize: Style.font.body
}
Text {
text: "Set API key"
color: Color.accent
font.family: root.fontFamily
font.pixelSize: Style.font.body
}
}
}
Row {
visible: root.editingKey
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
spacing: Style.space(6)
TextField {
id: keyField
width: Style.space(300)
password: true
placeholderText: "QuickNode Admin API key"
foreground: root.foreground
font.family: root.fontFamily
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
root.cancelEditingKey()
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
root.commitKey()
event.accepted = true
}
}
}
Rectangle {
width: Style.space(18)
height: Style.space(18)
anchors.verticalCenter: parent.verticalCenter
radius: Math.min(4, Style.cornerRadius)
color: cancelKeyArea.containsMouse ? Style.hoverFillFor(root.foreground, Color.accent) : "transparent"
Text {
anchors.centerIn: parent
text: "✕"
font.family: root.fontFamily
color: Qt.darker(root.foreground, 1.4)
font.pixelSize: Style.font.bodySmall
}
MouseArea {
id: cancelKeyArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.cancelEditingKey()
}
}
}
// ---- Endpoints: header with filter, then one row per endpoint.
Rectangle {
visible: root.hasKey && root.endpoints.length > 0
width: parent.width
height: Style.spacing.hairline
color: root.foreground
opacity: 0.12
}
Item {
visible: root.hasKey && root.endpoints.length > 0
width: parent.width
height: filterField.implicitHeight
Row {
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(8)
Text {
anchors.verticalCenter: parent.verticalCenter
text: "ENDPOINTS"
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
font.letterSpacing: 1
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: root.visibleEndpoints.length === root.endpoints.length
? String(root.endpoints.length)
: root.visibleEndpoints.length + "/" + root.endpoints.length
color: Qt.darker(root.foreground, 2)
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
}
}
TextField {
id: filterField
anchors.right: parent.right
anchors.rightMargin: Style.space(16)
anchors.verticalCenter: parent.verticalCenter
width: Style.space(190)
verticalPadding: Style.space(3)
placeholderText: "Filter chain or name /"
foreground: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
onTextChanged: root.filterText = text
// Escape clears a non-empty filter first; a second press hands
// focus back so the panel's own Escape (close) works again.
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
if (text !== "") text = ""
else root.blurFilter()
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
root.blurFilter()
event.accepted = true
}
}
}
}
Text {
visible: root.hasKey && root.endpoints.length > 0 && root.visibleEndpoints.length === 0
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
text: "No endpoints match “" + root.filterText + "”"
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
font.italic: true
}
Column {
visible: root.hasKey && root.visibleEndpoints.length > 0
width: parent.width
spacing: Style.space(4)
Repeater {
model: root.visibleEndpoints
Rectangle {
id: endpointRow
required property var modelData
readonly property var badge: Model.chainBadge(modelData.chain)
readonly property string iconPath: Model.chainIcon(modelData.chain)
readonly property var credits: Model.chainCredits(root.chainUsage, modelData.chain)
width: parent.width
height: rowLeft.implicitHeight + Style.space(16)
radius: Style.cornerRadius
color: rowHover.hovered ? Style.hoverFillFor(root.foreground, Color.accent) : "transparent"
HoverHandler {
id: rowHover
}
Row {
id: rowLeft
anchors.left: parent.left
anchors.leftMargin: Style.space(12)
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(10)
// Chain logo from icons/ when bundled; otherwise a
// brand-colored badge with the chain's glyph or initial.
// Paused endpoints are dimmed either way.
Item {
anchors.verticalCenter: parent.verticalCenter
width: Style.space(28)
height: Style.space(28)
opacity: endpointRow.modelData.active ? 1 : 0.45
Image {
id: chainLogo
anchors.fill: parent
source: endpointRow.iconPath ? Qt.resolvedUrl(endpointRow.iconPath) : ""
// Rasterize the SVG above display size so it stays
// crisp on HiDPI outputs.
sourceSize.width: Style.space(28) * 2
sourceSize.height: Style.space(28) * 2
fillMode: Image.PreserveAspectFit
smooth: true
visible: status === Image.Ready
}
Rectangle {
anchors.fill: parent
visible: chainLogo.status !== Image.Ready
radius: Style.space(7)
color: endpointRow.badge.color
Text {
anchors.centerIn: parent
text: endpointRow.badge.symbol
color: "#ffffff"
font.family: root.fontFamily
font.pixelSize: endpointRow.badge.symbol.length > 1 ? Style.font.caption : Style.font.body
font.bold: true
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(2)
Text {
text: endpointRow.modelData.label
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.body
elide: Text.ElideRight
width: Math.min(implicitWidth, Style.space(220))
}
Row {
spacing: Style.space(6)
Text {
text: Model.endpointLocation(endpointRow.modelData)
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
}
Text {
visible: !endpointRow.modelData.active
text: "paused"
color: Color.urgent
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.letterSpacing: 1
anchors.verticalCenter: parent.verticalCenter
}
}
}
}
Column {
anchors.right: parent.right
anchors.rightMargin: Style.space(16)
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(4)
// Per-chain credits this billing period; shared by every
// endpoint on that chain.
Row {
anchors.right: parent.right
spacing: Style.space(4)
visible: endpointRow.credits !== null
Text {
id: creditsValue
text: Model.formatCredits(endpointRow.credits)
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.body
}
Text {
text: "credits"
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.caption
anchors.baseline: creditsValue.baseline
}
}
// Copy-to-clipboard chips for the RPC / WSS addresses.
Row {
anchors.right: parent.right
spacing: Style.space(4)
Repeater {
model: [
{ label: "RPC", key: endpointRow.modelData.id + ":http", payload: endpointRow.modelData.httpUrl },
{ label: "WSS", key: endpointRow.modelData.id + ":wss", payload: endpointRow.modelData.wssUrl }
]
Rectangle {
id: chip
required property var modelData
readonly property bool copied: root.copiedKey === modelData.key
visible: modelData.payload !== ""
width: chipText.implicitWidth + Style.space(12)
height: chipText.implicitHeight + Style.space(6)
radius: Math.min(4, Style.cornerRadius)
color: chipArea.containsMouse ? Style.hoverFillFor(root.foreground, Color.accent) : "transparent"
border.width: 1
border.color: chip.copied ? Color.accent : Qt.darker(root.foreground, 2.2)
Text {
id: chipText
anchors.centerIn: parent
text: chip.copied ? " copied" : chip.modelData.label
color: chip.copied ? Color.accent : root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.letterSpacing: 1
}
MouseArea {
id: chipArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.copyText(chip.modelData.key, chip.modelData.payload)
}
}
}
}
}
}
}
}
// ---- Footer: masked key + dashboard link.
Item {
visible: root.hasKey
width: parent.width
height: footerLeft.implicitHeight + Style.space(4)
Row {
id: footerLeft
anchors.left: parent.left
anchors.leftMargin: Style.space(16)
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(6)
visible: !root.editingKey
TapHandler {
onTapped: root.startEditingKey()
}
HoverHandler {
cursorShape: Qt.PointingHandCursor
}
Text {
text: ""
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
}
Text {
text: Model.maskedKey(root.apiKey)
color: root.mutedText
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
}
}
Row {
anchors.right: parent.right
anchors.rightMargin: Style.space(20)
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(6)
TapHandler {
onTapped: if (root.bar) root.bar.run("xdg-open https://dashboard.quicknode.com")
}
HoverHandler {
cursorShape: Qt.PointingHandCursor
}
Text {
text: "DASHBOARD"
color: Qt.darker(root.foreground, 1.4)
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
font.letterSpacing: 1
}
Text {
text: ""
color: Qt.darker(root.foreground, 1.4)
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
}
}
}
}
}
}
}
}