6import QGroundControl.Controls
10 pageComponent: pageComponent
11 pageDescription: qsTr("Onboard Logs allows you to download binary log files from your vehicle. Click Refresh to get list of available logs.")
13 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
14 readonly property bool _vehicleArmed: _activeVehicle ? _activeVehicle.armed : false
15 readonly property bool _actionsAllowed: !_vehicleArmed && !OnboardLogController.requestingList && !OnboardLogController.downloadingLogs
17 QGCPalette { id: qgcPal; colorGroupEnabled: true }
19 function _updateNavigationBlocked() {
20 if (OnboardLogController.downloadingLogs) {
21 globals.navigationBlockedReason = qsTr("Wait for the log download to complete or cancel it first")
23 globals.navigationBlockedReason = ""
28 target: OnboardLogController
29 function onDownloadingLogsChanged() { onboardLogPage._updateNavigationBlocked() }
32 Component.onCompleted: _updateNavigationBlocked()
33 Component.onDestruction: globals.navigationBlockedReason = ""
40 height: availableHeight
42 Component.onCompleted: {
43 if (!onboardLogPage._vehicleArmed) {
44 OnboardLogController.refresh()
49 Layout.fillWidth: true
50 Layout.fillHeight: true
51 contentWidth: gridLayout.width
52 contentHeight: gridLayout.height
56 rows: OnboardLogController.model.count + 1
58 flow: GridLayout.TopToBottom
59 columnSpacing: ScreenTools.defaultFontPixelWidth
62 Item { } // First column is for checkboxes, so add empty item to align headers with log entries
65 model: OnboardLogController.model
68 objectName: "onboardLogCheckbox_" + index
70 Binding on checkState {
71 value: object.selected ? Qt.Checked : Qt.Unchecked
74 onClicked: object.selected = checked
78 QGCLabel { text: qsTr("Id") }
81 model: OnboardLogController.model
83 QGCLabel { text: object.id }
86 QGCLabel { text: qsTr("Date") }
89 model: OnboardLogController.model
92 objectName: "onboardLogDate_" + index
95 if (!object.received) {
99 // getUTCFullYear() is NaN for an invalid date
100 const year = object.time.getUTCFullYear()
101 if (Number.isNaN(year) || year < 2010) {
102 return qsTr("Date Unknown")
105 return object.time.toLocaleString(undefined)
110 QGCLabel { text: qsTr("Size") }
113 model: OnboardLogController.model
115 QGCLabel { text: object.sizeStr }
118 QGCLabel { text: qsTr("Status") }
121 model: OnboardLogController.model
124 objectName: "onboardLogStatus_" + index
132 spacing: ScreenTools.defaultFontPixelWidth
133 Layout.alignment: Qt.AlignTop
134 Layout.fillWidth: false
137 objectName: "onboardLog_armedWarning"
138 Layout.fillWidth: true
139 // Zero preferred width stops the label widening the column; it wraps to the button width
140 Layout.preferredWidth: 0
141 visible: onboardLogPage._vehicleArmed
142 text: qsTr("Disabled while the vehicle is armed")
143 color: qgcPal.warningText
144 wrapMode: Text.WordWrap
148 objectName: "onboardLog_refreshButton"
149 Layout.fillWidth: true
150 enabled: onboardLogPage._actionsAllowed
151 text: qsTr("Refresh")
154 if (!QGroundControl.multiVehicleManager.activeVehicle || QGroundControl.multiVehicleManager.activeVehicle.isOfflineEditingVehicle) {
155 QGroundControl.showMessageDialog(onboardLogPage, qsTr("Onboard Log Refresh"), qsTr("You must be connected to a vehicle in order to download onboard logs."))
159 OnboardLogController.refresh()
164 objectName: "onboardLog_selectAllButton"
165 Layout.fillWidth: true
166 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.model.count > 0)
167 text: OnboardLogController.allLogsSelected ? qsTr("Deselect All") : qsTr("Select All")
168 onClicked: OnboardLogController.selectAll(!OnboardLogController.allLogsSelected)
172 objectName: "onboardLog_downloadButton"
173 Layout.fillWidth: true
174 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.selectedCount > 0)
175 text: qsTr("Download")
178 if (ScreenTools.isMobile) {
179 OnboardLogController.download()
183 fileDialog.title = qsTr("Select save directory")
184 fileDialog.folder = QGroundControl.settingsManager.appSettings.logSavePath
185 fileDialog.selectFolder = true
186 fileDialog.openForLoad()
191 onAcceptedForLoad: (file) => {
192 OnboardLogController.download(file)
199 objectName: "onboardLog_sortButton"
200 Layout.fillWidth: true
201 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.model.count > 1)
202 text: OnboardLogController.sortAscending ? qsTr("Sort Descending") : qsTr("Sort Ascending")
203 onClicked: OnboardLogController.toggleSortByDate()
207 objectName: "onboardLog_eraseSelectedButton"
208 Layout.fillWidth: true
209 visible: OnboardLogController.transport === "ftp"
210 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.selectedCount > 0)
211 text: qsTr("Erase Selected")
212 onClicked: QGroundControl.showMessageDialog(
214 qsTr("Delete Selected Onboard Log Files"),
215 qsTr("The selected onboard log files will be erased permanently. Is this really what you want?"),
216 Dialog.Yes | Dialog.No,
217 function() { OnboardLogController.eraseSelected() }
222 objectName: "onboardLog_eraseAllButton"
223 Layout.fillWidth: true
224 enabled: onboardLogPage._actionsAllowed && (OnboardLogController.model.count > 0)
225 text: qsTr("Erase All")
226 onClicked: QGroundControl.showMessageDialog(
228 qsTr("Delete All Onboard Log Files"),
229 qsTr("All onboard log files will be erased permanently. Is this really what you want?"),
230 Dialog.Yes | Dialog.No,
231 function() { OnboardLogController.eraseAll() }
236 objectName: "onboardLog_cancelButton"
237 Layout.fillWidth: true
239 enabled: OnboardLogController.requestingList || OnboardLogController.downloadingLogs
240 onClicked: OnboardLogController.cancel()