2023-05-27 22:46:41 +08:00
import QtQuick
import QtQuick . Controls
import QtQuick . Layouts
import SortFilterProxyModel 0.2
import PageEnum 1.0
import ProtocolEnum 1.0
import "../Controls2"
import "../Controls2/TextTypes"
2023-06-05 15:49:10 +08:00
import "../Components"
2023-05-27 22:46:41 +08:00
PageType {
id: root
2023-06-21 20:56:00 +09:00
Connections {
target: InstallController
function onScanServerFinished ( isInstalledContainerFound ) {
var message = ""
if ( isInstalledContainerFound ) {
message = qsTr ( "All installed containers have been added to the application" )
} else {
2023-09-01 00:48:58 +05:00
message = qsTr ( "No new installed containers found" )
2023-06-21 20:56:00 +09:00
}
PageController . showErrorMessage ( message )
}
2023-07-31 00:13:08 +09:00
function onRemoveCurrentlyProcessedServerFinished ( finishedMessage ) {
if ( ! ServersModel . getServersCount ( ) ) {
PageController . replaceStartPage ( )
} else {
2023-09-06 13:37:37 +05:00
PageController . goToStartPage ( )
PageController . goToPage ( PageEnum . PageSettingsServersList )
2023-07-31 00:13:08 +09:00
}
PageController . showNotificationMessage ( finishedMessage )
}
function onRemoveAllContainersFinished ( finishedMessage ) {
2023-09-06 13:37:37 +05:00
PageController . closePage ( ) // close deInstalling page
2023-07-31 00:13:08 +09:00
PageController . showNotificationMessage ( finishedMessage )
}
function onRemoveCurrentlyProcessedContainerFinished ( finishedMessage ) {
2023-09-06 13:37:37 +05:00
PageController . closePage ( ) // close deInstalling page
PageController . closePage ( ) // close page with remove button
2023-07-31 00:13:08 +09:00
PageController . showNotificationMessage ( finishedMessage )
}
2023-06-21 20:56:00 +09:00
}
2023-08-16 12:11:34 +05:00
Connections {
target: SettingsController
function onChangeSettingsFinished ( finishedMessage ) {
PageController . showNotificationMessage ( finishedMessage )
}
}
2023-06-23 15:24:40 +09:00
Connections {
target: ServersModel
function onCurrentlyProcessedServerIndexChanged ( ) {
content . isServerWithWriteAccess = ServersModel . isCurrentlyProcessedServerHasWriteAccess ( )
}
}
2023-05-27 22:46:41 +08:00
FlickableType {
id: fl
2023-06-20 10:25:24 +09:00
anchors.top: parent . top
anchors.bottom: parent . bottom
2023-05-27 22:46:41 +08:00
contentHeight: content . height
ColumnLayout {
id: content
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
2023-06-30 13:45:11 +09:00
property bool isServerWithWriteAccess: ServersModel . isCurrentlyProcessedServerHasWriteAccess ( )
2023-06-23 15:24:40 +09:00
2023-05-27 22:46:41 +08:00
LabelWithButtonType {
2023-06-23 15:24:40 +09:00
visible: content . isServerWithWriteAccess
2023-05-27 22:46:41 +08:00
Layout.fillWidth: true
2023-06-21 20:56:00 +09:00
text: qsTr ( "Clear Amnezia cache" )
descriptionText: qsTr ( "May be needed when changing other settings" )
2023-05-27 22:46:41 +08:00
clickedFunction: function ( ) {
2023-06-05 15:49:10 +08:00
questionDrawer . headerText = qsTr ( "Clear cached profiles?" )
2023-08-28 14:18:41 +03:00
questionDrawer . descriptionText = qsTr ( "" )
2023-06-05 15:49:10 +08:00
questionDrawer . yesButtonText = qsTr ( "Continue" )
questionDrawer . noButtonText = qsTr ( "Cancel" )
questionDrawer . yesButtonFunction = function ( ) {
2023-10-21 14:17:45 +01:00
questionDrawer . visible = false
2023-08-28 14:18:41 +03:00
PageController . showBusyIndicator ( true )
SettingsController . clearCachedProfiles ( )
PageController . showBusyIndicator ( false )
2023-06-05 15:49:10 +08:00
}
questionDrawer . noButtonFunction = function ( ) {
2023-10-21 14:17:45 +01:00
questionDrawer . visible = false
2023-06-05 15:49:10 +08:00
}
2023-10-21 14:17:45 +01:00
questionDrawer . visible = true
2023-05-27 22:46:41 +08:00
}
}
2023-06-23 15:24:40 +09:00
DividerType {
visible: content . isServerWithWriteAccess
}
2023-05-27 22:46:41 +08:00
2023-06-21 20:56:00 +09:00
LabelWithButtonType {
2023-06-23 15:24:40 +09:00
visible: content . isServerWithWriteAccess
2023-06-21 20:56:00 +09:00
Layout.fillWidth: true
2023-07-31 12:54:59 +09:00
text: qsTr ( "Check the server for previously installed Amnezia services" )
2023-07-24 16:33:58 +09:00
descriptionText: qsTr ( "Add them to the application if they were not displayed" )
2023-06-21 20:56:00 +09:00
clickedFunction: function ( ) {
2023-07-04 09:58:19 +09:00
PageController . showBusyIndicator ( true )
2023-06-21 20:56:00 +09:00
InstallController . scanServerForInstalledContainers ( )
2023-07-04 09:58:19 +09:00
PageController . showBusyIndicator ( false )
2023-06-21 20:56:00 +09:00
}
}
2023-06-23 15:24:40 +09:00
DividerType {
visible: content . isServerWithWriteAccess
}
2023-06-21 20:56:00 +09:00
2023-05-27 22:46:41 +08:00
LabelWithButtonType {
Layout.fillWidth: true
2023-06-23 15:24:40 +09:00
text: qsTr ( "Remove server from application" )
2023-05-27 22:46:41 +08:00
textColor: "#EB5757"
clickedFunction: function ( ) {
2023-06-05 15:49:10 +08:00
questionDrawer . headerText = qsTr ( "Remove server?" )
questionDrawer . descriptionText = qsTr ( "All installed AmneziaVPN services will still remain on the server." )
questionDrawer . yesButtonText = qsTr ( "Continue" )
questionDrawer . noButtonText = qsTr ( "Cancel" )
questionDrawer . yesButtonFunction = function ( ) {
2023-10-21 14:17:45 +01:00
questionDrawer . visible = false
2023-07-31 00:13:08 +09:00
PageController . showBusyIndicator ( true )
2023-08-02 20:37:43 +09:00
if ( ServersModel . isDefaultServerCurrentlyProcessed ( ) && ConnectionController . isConnected ) {
2023-06-05 15:49:10 +08:00
ConnectionController . closeConnection ( )
}
2023-07-31 00:13:08 +09:00
InstallController . removeCurrentlyProcessedServer ( )
PageController . showBusyIndicator ( false )
2023-06-01 11:25:33 +08:00
}
2023-06-05 15:49:10 +08:00
questionDrawer . noButtonFunction = function ( ) {
2023-10-21 14:17:45 +01:00
questionDrawer . visible = false
2023-06-01 11:25:33 +08:00
}
2023-10-21 14:17:45 +01:00
questionDrawer . visible = true
2023-05-27 22:46:41 +08:00
}
}
DividerType { }
LabelWithButtonType {
2023-06-23 15:24:40 +09:00
visible: content . isServerWithWriteAccess
2023-05-27 22:46:41 +08:00
Layout.fillWidth: true
2023-06-23 15:24:40 +09:00
text: qsTr ( "Clear server from Amnezia software" )
2023-05-27 22:46:41 +08:00
textColor: "#EB5757"
clickedFunction: function ( ) {
2023-06-05 15:49:10 +08:00
questionDrawer . headerText = qsTr ( "Clear server from Amnezia software?" )
2023-08-28 14:18:41 +03:00
questionDrawer . descriptionText = qsTr ( "All containers will be deleted on the server. This means that configuration files, keys and certificates will be deleted." )
2023-06-05 15:49:10 +08:00
questionDrawer . yesButtonText = qsTr ( "Continue" )
questionDrawer . noButtonText = qsTr ( "Cancel" )
questionDrawer . yesButtonFunction = function ( ) {
2023-10-21 14:17:45 +01:00
questionDrawer . visible = false
2023-09-06 13:37:37 +05:00
PageController . goToPage ( PageEnum . PageDeinstalling )
2023-08-02 20:37:43 +09:00
if ( ServersModel . isDefaultServerCurrentlyProcessed ( ) && ConnectionController . isConnected ) {
2023-08-09 18:17:29 +05:00
ConnectionController . closeConnection ( )
2023-06-05 15:49:10 +08:00
}
2023-07-31 00:13:08 +09:00
InstallController . removeAllContainers ( )
2023-06-05 15:49:10 +08:00
}
questionDrawer . noButtonFunction = function ( ) {
2023-10-21 14:17:45 +01:00
questionDrawer . visible = false
2023-06-01 11:25:33 +08:00
}
2023-10-21 14:17:45 +01:00
questionDrawer . visible = true
2023-05-27 22:46:41 +08:00
}
}
2023-06-23 15:24:40 +09:00
DividerType {
visible: content . isServerWithWriteAccess
}
2023-06-05 15:49:10 +08:00
QuestionDrawer {
id: questionDrawer
}
2023-05-27 22:46:41 +08:00
}
}
}