From: Henrique Date: Sat, 16 May 2020 09:37:22 +0000 (+0200) Subject: BEE Backport bacula/src/qt-console/tray-monitor/TrayUiPage.qml X-Git-Tag: Release-11.3.2~1557 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02e0cd8001583a95e84e4e951bf36fa42f13e318;p=thirdparty%2Fbacula.git BEE Backport bacula/src/qt-console/tray-monitor/TrayUiPage.qml This commit is the result of the squash of the following main commits: Author: Henrique Date: Thu Oct 10 17:28:50 2019 -0300 android: fixed Tray Monitor logs and fixed small glitch with scrollToBottom() function Author: Henrique Date: Tue Oct 1 20:33:27 2019 -0300 android: added code to scroll logs to the bottom in the start Author: Henrique Date: Tue Sep 3 14:20:10 2019 -0300 android: added popup to create / edit tray-monitor resources Author: Henrique Date: Sun Sep 1 21:28:23 2019 -0300 android: added new start screen Author: Henrique Date: Mon Aug 26 16:13:49 2019 -0300 android: ResourceStatusPage: 1) Added BusyIndicator animation when the App is connecting with a resource 2) Refactor (Identation, comments) Author: Henrique Date: Thu Aug 15 21:20:44 2019 -0300 android: tweak comments Author: Henrique Date: Wed Aug 14 13:09:39 2019 -0300 android: added Splash Screen Author: Henrique Date: Tue Aug 13 21:04:53 2019 -0300 android: created enterprise and community versions Author: Henrique Date: Tue Aug 13 16:07:23 2019 -0300 android: moved QR Code feature to FD screen Author: Henrique Date: Sun Jul 7 15:21:17 2019 -0300 android: added GUI to change Log Level (for Tray and FD). Added watcher thread to track FD Process. Removed default DIR and SD. Author: Henrique Date: Fri Jul 5 09:14:09 2019 -0300 android: fixed password generation and restricted log to show only last 1000 lines Author: Henrique Date: Wed Jun 26 22:53:18 2019 -0300 android: refactored paths to traces and call to android permissions Author: Henrique Date: Wed Jun 26 12:03:27 2019 -0300 android: added missing license and a few comments on src files. FD debug level reduced to 50 Author: Henrique Date: Tue Jun 25 11:54:33 2019 -0300 android: removed unused GUI code for FD status. Added default bacula-fd.conf Author: Henrique Date: Mon May 27 16:37:52 2019 -0300 android: fixed showing of bacula-fd.trace Author: Henrique Date: Mon May 27 15:33:03 2019 -0300 android: added GUI for editing bacula-fd.conf Author: Henrique Date: Mon May 27 01:18:31 2019 -0300 android: added file-daemon tab Author: Henrique Date: Tue May 21 13:26:25 2019 -0300 android: Add log screen that shows tray-monitor trace file Author: Henrique Faria Date: Tue Dec 18 10:56:09 2018 +0100 android: Port bacula tray-monitor for Android --- diff --git a/bacula/src/qt-console/tray-monitor/TrayUiPage.qml b/bacula/src/qt-console/tray-monitor/TrayUiPage.qml new file mode 100644 index 0000000000..94781a3dd9 --- /dev/null +++ b/bacula/src/qt-console/tray-monitor/TrayUiPage.qml @@ -0,0 +1,290 @@ +/* + Bacula(R) - The Network Backup Solution + + Copyright (C) 2000-2020 Kern Sibbald + + The original author of Bacula is Kern Sibbald, with contributions + from many others, a complete list can be found in the file AUTHORS. + + You may use this file and others of this release according to the + license defined in the LICENSE file, which includes the Affero General + Public License, v3.0 ("AGPLv3") and some additional permissions and + terms pursuant to its AGPLv3 Section 7. + + This notice must be preserved when any source code is + conveyed and/or propagated. + + Bacula(R) is a registered trademark of Kern Sibbald. +*/ + +import QtQuick 2.10 +import QtQuick.Window 2.10 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.3 +import QtQuick.Controls.Material 2.1 +import QtQuick.Dialogs 1.2 +import io.qt.bmob.traycontroller 1.0 + +Page { + visible: true + width: parent.width + height: parent.height + + property variant tabTitles: [qsTr("Clients"), qsTr("Directors"), qsTr("Storages"), qsTr("Log")] + + // Our C++ component + TrayUiController { + id: controller + + // Events triggered by our c++ code + onClientsChanged: { + clientsPage.model = controller.clients + } + + onDirectorsChanged: { + directorsPage.model = controller.directors + } + + onStoragesChanged: { + storagesPage.model = controller.storages + } + + onInfoDialogTextChanged: { + infoDialog.text = controller.infoDialogText + infoDialog.open() + } + + onFdTraceChanged: { + traymonLogView.text = controller.fetchFile(controller.trayTracePath) + traymonLogView.scrollToBottom() + } + + Component.onCompleted: { + traymonLogView.text = controller.fetchFile(controller.trayTracePath) + traymonLogView.scrollToBottom() + } + } + + onVisibleChanged: { + if(visible) { + controller.fetchClients() + controller.fetchDirectors() + controller.fetchStorages() + } + } + + header: ToolBar { + id: toolbar + height: 48 + + background: Rectangle { + color: "#d32f2f" + } + + RowLayout { + anchors.fill: parent + anchors.leftMargin: 8 + anchors.rightMargin: 8 + + Label { + id: title + text: tabTitles[bar.currentIndex] + color: "white" + font.pixelSize: 18 + anchors.centerIn: parent + } + + ToolButton { + id: newResButton + anchors.right: parent.right + + property int resType: bar.currentIndex + + onClicked: { + if (resType == 0) { + clientsPage.resType = 0 + clientsPage.panelVisible = true + } else if (resType == 1) { + directorsPage.resType = 1 + directorsPage.panelVisible = true + } else if (resType == 2) { + storagesPage.resType = 2 + storagesPage.panelVisible = true + } + } + + contentItem: Text { + text: bar.currentIndex >= 3 ? qsTr("") : qsTr("+") + font.pixelSize: 24 + opacity: enabled ? 1.0 : 0.3 + color: "white" + } + + background: Rectangle { + color: newResButton.down ? "#b71c1c" : "#d32f2f" + } + } + } + } + + StackLayout { + anchors.fill: parent + currentIndex: bar.currentIndex + + ResourceListPage { + id: clientsPage + model: controller.clients + } + + ResourceListPage { + id: directorsPage + model: controller.directors + } + + ResourceListPage { + id: storagesPage + model: controller.storages + } + + Page { + id: trayMonLogPage + height: parent.height + width: parent.width + + Text { + id: labelLogLevel + text: "Log Level:" + color: "black" + anchors.left: parent.left + anchors.leftMargin: 16 + anchors.verticalCenter: monLogLevel.verticalCenter + } + + TextField { + id: monLogLevel + height: 44 + anchors.top: parent.top + anchors.right: parent.right + anchors.left: labelLogLevel.right + placeholderText: qsTr("value") + text: controller.trayLogLevel + inputMethodHints: Qt.ImhDigitsOnly + maximumLength: 3 + onTextChanged: controller.trayLogLevel = text + + background: Rectangle { + implicitHeight: 48 + implicitWidth: 100 + color: "transparent" + border.color: "transparent" + } + } + + Rectangle { + id: divider + width: parent.width + height: 1 + color: "#d32f2f" + anchors.bottom: monLogLevel.bottom + } + + ScrollView { + id: traymonLogView + anchors.top: divider.bottom + anchors.bottom: parent.bottom + width: parent.width + contentWidth: parent.width + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ScrollBar.horizontal.interactive: false + clip: true + + property alias text: traymonLog.text + + Text { + id: traymonLog + width: traymonLogView.width + leftPadding: 12 + rightPadding: 12 + topPadding: 8 + bottomPadding: 12 + wrapMode: Text.WrapAnywhere + } + + onVisibleChanged: { + if(visible) { + traymonLogView.text = controller.fetchFile(controller.trayTracePath); + } + } + + function scrollToBottom() { + if (traymonLog.height > contentItem.height) { + contentItem.contentY = traymonLog.height - contentItem.height + } + } + } + + } + } + + footer: TabBar { + id: bar + width: parent.width + + background: Rectangle { + color: "#d32f2f" + } + + TabButton { + text: tabTitles[0] + + background: Rectangle { + anchors.fill: parent + color: bar.currentIndex === 0 ? "#ffcdd2" : "#d32f2f" + } + } + + TabButton { + text: tabTitles[1] + + background: Rectangle { + anchors.fill: parent + color: bar.currentIndex === 1 ? "#ffcdd2" : "#d32f2f" + } + } + + TabButton { + text: tabTitles[2] + + background: Rectangle { + anchors.fill: parent + color: bar.currentIndex === 2 ? "#ffcdd2" : "#d32f2f" + } + } + + TabButton { + text: tabTitles[3] + + background: Rectangle { + anchors.fill: parent + color: bar.currentIndex === 3 ? "#ffcdd2" : "#d32f2f" + } + } + } + + MessageDialog { + id: confirmDialog + property var res + + modality: Qt.ApplicationModal + standardButtons: StandardButton.No | StandardButton.Yes + onYes: controller.deleteResource(res) + visible: false + } + + MessageDialog { + id: infoDialog + modality: Qt.ApplicationModal + standardButtons: StandardButton.Ok + visible: false + } +}