-
Notifications
You must be signed in to change notification settings - Fork 199
/
Dashboard.qml
418 lines (357 loc) · 11.8 KB
/
Dashboard.qml
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
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.1
import QtGraphicalEffects 1.0
import QtWebEngine 1.10
import "../Components"
import "../Constants"
import App 1.0
import "../Dashboard"
import "../Portfolio"
import "../Wallet"
import "../Exchange"
import "../Settings"
import "../Support"
import "../Sidebar"
import "../Fiat"
import "../Settings" as SettingsPage
Item {
id: dashboard
property alias webEngineView: webEngineView
readonly property int idx_dashboard_portfolio: 0
readonly property int idx_dashboard_wallet: 1
readonly property int idx_dashboard_exchange: 2
readonly property int idx_dashboard_addressbook: 3
readonly property int idx_dashboard_news: 4
readonly property int idx_dashboard_dapps: 5
readonly property int idx_dashboard_settings: 6
readonly property int idx_dashboard_support: 7
readonly property int idx_dashboard_light_ui: 8
readonly property int idx_dashboard_privacy_mode: 9
readonly property int idx_dashboard_fiat_ramp: 10
//readonly property int idx_exchange_trade: 3
readonly property int idx_exchange_trade: 0
readonly property int idx_exchange_orders: 1
readonly property int idx_exchange_history: 2
property var current_ticker
Layout.fillWidth: true
function openLogsFolder() {
Qt.openUrlExternally(General.os_file_prefix + API.app.settings_pg.get_log_folder())
}
readonly property
var api_wallet_page: API.app.wallet_pg
readonly property
var current_ticker_infos: api_wallet_page.ticker_infos
readonly property bool can_change_ticker: !api_wallet_page.tx_fetching_busy
readonly property alias loader: loader
readonly property alias current_component: loader.item
property int current_page: idx_dashboard_portfolio
onCurrent_pageChanged: {
app.deepPage = current_page * 10
}
readonly property bool is_dex_banned: !API.app.ip_checker.ip_authorized
function inCurrentPage() {
return app.current_page === idx_dashboard
}
function switchPage(page)
{
if (loader.status === Loader.Ready)
current_page = page
else
console.warn("Tried to switch to page %1 when loader is not ready yet.".arg(page))
}
property
var notifications_list: ([])
readonly property
var portfolio_mdl: API.app.portfolio_pg.portfolio_mdl
property
var portfolio_coins: portfolio_mdl.portfolio_proxy_mdl
function resetCoinFilter() {
portfolio_coins.setFilterFixedString("")
}
function openTradeViewWithTicker() {
dashboard.loader.onLoadComplete = () => {
dashboard.current_component.openTradeView(api_wallet_page.ticker)
}
}
// Al settings depends this modal
SettingsPage.SettingModal {
id: setting_modal
}
// Force restart modal: opened when the user has more coins enabled than specified in its configuration
ForceRestartModal {
reasonMsg: qsTr("The current number of enabled coins does not match your configuration specification. Your assets configuration will be reset.")
Component.onCompleted: {
if (API.app.portfolio_pg.portfolio_mdl.length > atomic_settings2.value("MaximumNbCoinsEnabled")) {
open()
onTimerEnded = () => {
API.app.settings_pg.reset_coin_cfg()
}
}
}
}
// Right side
AnimatedRectangle {
color: DexTheme.backgroundColorDeep
width: parent.width - sidebar.width
height: parent.height
x: sidebar.width
border.color: 'transparent'
// Modals
ModalLoader {
id: enable_coin_modal
sourceComponent: EnableCoinModal {
anchors.centerIn: Overlay.overlay
}
}
Component {
id: portfolio
Portfolio {}
}
Component {
id: wallet
Wallet {}
}
Component {
id: exchange
Exchange {}
}
Component {
id: addressbook
AddressBook {}
}
Component {
id: news
Item {
Layout.fillWidth: true
Layout.fillHeight: true
DefaultText {
anchors.centerIn: parent
text_value: qsTr("Content for this section will be added later. Stay tuned!")
}
}
}
Component {
id: dapps
Item {
Layout.fillWidth: true
Layout.fillHeight: true
DefaultText {
anchors.centerIn: parent
text_value: qsTr("Content for this section will be added later. Stay tuned!")
}
}
}
Component {
id: settings
Settings {
Layout.alignment: Qt.AlignCenter
}
}
Component {
id: support
Support {
Layout.alignment: Qt.AlignCenter
}
}
Component {
id: fiat_ramp
FiatRamp {
}
}
WebEngineView
{
id: webEngineView
backgroundColor: "transparent"
}
DefaultLoader {
id: loader
anchors.fill: parent
transformOrigin: Item.Center
asynchronous: true
sourceComponent: {
switch (current_page) {
case idx_dashboard_portfolio:
return portfolio
case idx_dashboard_wallet:
return wallet
case idx_dashboard_exchange:
return exchange
case idx_dashboard_addressbook:
return addressbook
case idx_dashboard_news:
return news
case idx_dashboard_dapps:
return dapps
case idx_dashboard_settings:
return settings
case idx_dashboard_support:
return support
case idx_dashboard_fiat_ramp:
return fiat_ramp
default:
return undefined
}
}
}
Item {
visible: !loader.visible
anchors.fill: parent
DexBusyIndicator {
anchors.centerIn: parent
running: !loader.visible
}
}
}
// Sidebar, left side
Sidebar {
id: sidebar
y: -30
}
DropShadow {
anchors.fill: sidebar
source: sidebar
cached: false
horizontalOffset: 0
verticalOffset: 0
radius: DexTheme.sidebarShadowRadius
samples: 32
spread: 0
color: DexTheme.colorSidebarDropShadow
smooth: true
}
ModalLoader {
id: add_custom_coin_modal
sourceComponent: AddCustomCoinModal {}
}
// CEX Rates info
ModalLoader {
id: cex_rates_modal
sourceComponent: CexInfoModal {}
}
ModalLoader {
id: min_trade_modal
sourceComponent: MinTradeModal {}
}
ModalLoader {
id: restart_modal
sourceComponent: RestartModal {}
}
function getStatusColor(status) {
switch (status) {
case "matching":
return Style.colorYellow
case "matched":
case "ongoing":
case "refunding":
return Style.colorOrange
case "successful":
return DexTheme.greenColor
case "failed":
default:
return DexTheme.redColor
}
}
function isSwapDone(status) {
switch (status) {
case "matching":
case "matched":
case "ongoing":
return false
case "successful":
case "refunding":
case "failed":
default:
return true
}
}
function getStatusStep(status) {
switch (status) {
case "matching":
return "0/3"
case "matched":
return "1/3"
case "ongoing":
return "2/3"
case "successful":
return Style.successCharacter
case "refunding":
return Style.warningCharacter
case "failed":
return Style.failureCharacter
default:
return "?"
}
}
function getStatusText(status, short_text=false) {
switch(status) {
case "matching":
return short_text ? qsTr("Matching") : qsTr("Order Matching")
case "matched":
return short_text ? qsTr("Matched") : qsTr("Order Matched")
case "ongoing":
return short_text ? qsTr("Ongoing") : qsTr("Swap Ongoing")
case "successful":
return short_text ? qsTr("Successful") : qsTr("Swap Successful")
case "refunding":
return short_text ? qsTr("Refunding") : qsTr("Refunding")
case "failed":
return short_text ? qsTr("Failed") : qsTr("Swap Failed")
default:
return short_text ? qsTr("Unknown") : qsTr("Unknown State")
}
}
function getStatusTextWithPrefix(status, short_text = false) {
return getStatusStep(status) + " " + getStatusText(status, short_text)
}
function getEventText(event_name) {
switch (event_name) {
case "Started":
return qsTr("Started")
case "Negotiated":
return qsTr("Negotiated")
case "TakerFeeSent":
return qsTr("Taker fee sent")
case "MakerPaymentReceived":
return qsTr("Maker payment received")
case "MakerPaymentWaitConfirmStarted":
return qsTr("Maker payment wait confirm started")
case "MakerPaymentValidatedAndConfirmed":
return qsTr("Maker payment validated and confirmed")
case "TakerPaymentSent":
return qsTr("Taker payment sent")
case "TakerPaymentSpent":
return qsTr("Taker payment spent")
case "MakerPaymentSpent":
return qsTr("Maker payment spent")
case "Finished":
return qsTr("Finished")
case "StartFailed":
return qsTr("Start failed")
case "NegotiateFailed":
return qsTr("Negotiate failed")
case "TakerFeeValidateFailed":
return qsTr("Taker fee validate failed")
case "MakerPaymentTransactionFailed":
return qsTr("Maker payment transaction failed")
case "MakerPaymentDataSendFailed":
return qsTr("Maker payment Data send failed")
case "MakerPaymentWaitConfirmFailed":
return qsTr("Maker payment wait confirm failed")
case "TakerPaymentValidateFailed":
return qsTr("Taker payment validate failed")
case "TakerPaymentWaitConfirmFailed":
return qsTr("Taker payment wait confirm failed")
case "TakerPaymentSpendFailed":
return qsTr("Taker payment spend failed")
case "MakerPaymentWaitRefundStarted":
return qsTr("Maker payment wait refund started")
case "MakerPaymentRefunded":
return qsTr("Maker payment refunded")
case "MakerPaymentRefundFailed":
return qsTr("Maker payment refund failed")
default:
return qsTr(event_name)
}
}
}