2025-02-28 18:17:43 +03:00
import QtQuick
import QtQuick . Controls
import QtQuick . Layouts
import QtQuick . Dialogs
import QtCore
import SortFilterProxyModel 0.2
import PageEnum 1.0
import Style 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
ListViewType {
id: listView
anchors.fill: parent
2026-04-30 14:53:03 +08:00
anchors.topMargin: 20 + PageController . safeAreaTopMargin
2025-02-28 18:17:43 +03:00
anchors.bottomMargin: 24
model: ApiDevicesModel
header: ColumnLayout {
width: listView . width
BackButtonType {
id: backButton
}
2025-05-02 23:54:36 -07:00
BaseHeaderType {
2025-02-28 18:17:43 +03:00
id: header
Layout.fillWidth: true
Layout.rightMargin: 16
Layout.leftMargin: 16
2025-03-05 06:11:31 +03:00
headerText: qsTr ( "Active Devices" )
2025-03-04 13:33:35 +07:00
descriptionText: qsTr ( "Manage currently connected devices" )
2025-02-28 18:17:43 +03:00
}
WarningType {
Layout.topMargin: 16
Layout.rightMargin: 16
Layout.leftMargin: 16
Layout.fillWidth: true
textString: qsTr ( "You can find the identifier on the Support tab or, for older versions of the app, "
+ "by tapping '+' and then the three dots at the top of the page." )
iconPath: "qrc:/images/controls/alert-circle.svg"
}
}
delegate: ColumnLayout {
width: listView . width
LabelWithButtonType {
Layout.fillWidth: true
Layout.topMargin: 6
text: osVersion + ( isCurrentDevice ? qsTr ( " (current device)" ) : "" )
descriptionText: qsTr ( "Support tag: " ) + "\n" + supportTag + "\n" + qsTr ( "Last updated: " ) + lastUpdate
rightImageSource: "qrc:/images/controls/trash.svg"
clickedFunction: function ( ) {
2026-04-30 14:53:03 +08:00
if ( isCurrentDevice && ServersUiController . isDefaultServerCurrentlyProcessed ( ) && ConnectionController . isConnected ) {
2025-03-04 13:33:35 +07:00
PageController . showNotificationMessage ( qsTr ( "Cannot unlink device during active connection" ) )
return
}
var headerText = qsTr ( "Are you sure you want to unlink this device?" )
2025-05-12 10:31:41 +03:00
var descriptionText = qsTr ( "This will unlink the device from your subscription. You can reconnect it anytime by pressing \"Reload API config\" in subscription settings on device." )
2025-02-28 18:17:43 +03:00
var yesButtonText = qsTr ( "Continue" )
var noButtonText = qsTr ( "Cancel" )
var yesButtonFunction = function ( ) {
2026-05-28 10:57:08 +08:00
var serverId = ServersUiController . processedServerId
2026-05-15 12:33:36 +08:00
Qt . callLater ( deactivateExternalDevice , serverId , supportTag , countryCode )
2025-02-28 18:17:43 +03:00
}
var noButtonFunction = function ( ) {
}
showQuestionDrawer ( headerText , descriptionText , yesButtonText , noButtonText , yesButtonFunction , noButtonFunction )
}
}
DividerType { }
}
}
2026-05-15 12:33:36 +08:00
function deactivateExternalDevice ( serverId , supportTag , countryCode ) {
2025-02-28 18:17:43 +03:00
PageController . showBusyIndicator ( true )
2026-05-15 12:33:36 +08:00
if ( SubscriptionUiController . deactivateExternalDevice ( serverId , supportTag , countryCode ) ) {
SubscriptionUiController . getAccountInfo ( serverId , true )
2025-02-28 18:17:43 +03:00
}
PageController . showBusyIndicator ( false )
}
}