show robot errors

This commit is contained in:
Michael Zanetti 2021-04-11 22:45:49 +02:00
parent baa26f85f9
commit bfa2d4fba3

View File

@ -38,9 +38,11 @@ import "../customviews"
ThingPageBase { ThingPageBase {
id: root id: root
showBrowserButton: false
readonly property State robotState: thing.stateByName("robotState") readonly property State robotState: thing.stateByName("robotState")
showBrowserButton: false readonly property State errorMessageState: thing.stateByName("errorMessage")
GridLayout { GridLayout {
anchors.fill: parent anchors.fill: parent
@ -48,7 +50,7 @@ ThingPageBase {
Item { Item {
Layout.preferredWidth: app.landscape ? Layout.preferredWidth: app.landscape ?
Math.min(parent.width, parent.height) Math.min(parent.width - controlsContainer.minimumWidth, parent.height)
: Math.min(Math.min(500, parent.width), parent.height) : Math.min(Math.min(500, parent.width), parent.height)
Layout.preferredHeight: width Layout.preferredHeight: width
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
@ -80,7 +82,11 @@ ThingPageBase {
name: "../images/cleaning-robot.svg" name: "../images/cleaning-robot.svg"
x: robotArea.robotX - (width / 2) x: robotArea.robotX - (width / 2)
y: robotArea.robotY - (height / 2) y: robotArea.robotY - (height / 2)
color: root.robotState.value == "cleaning" ? Style.accentColor : Style.iconColor color: root.robotState.value == "cleaning"
? Style.accentColor
: root.robotState.value === "error"
? Style.red
: Style.iconColor
property int pixelsPerSecond: 30 property int pixelsPerSecond: 30
@ -220,63 +226,75 @@ ThingPageBase {
} }
ColumnLayout {
RowLayout {
id: controlsContainer
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.margins: app.margins * 2
property int minimumWidth: Style.iconSize * 2.7 * 3
property int minimumHeight: Style.iconSize * 4.5
Item { Label {
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: Style.margins
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
visible: root.errorMessageState != null && root.robotState.value === "error"
text: root.errorMessageState ? root.errorMessageState.value : ""
} }
ProgressButton { RowLayout {
longpressEnabled: false id: controlsContainer
mode: root.robotState.value === "cleaning" ? "normal" : "highlight" Layout.margins: app.margins * 2
size: Style.bigIconSize property int minimumWidth: Style.iconSize * 2.7 * 3
imageSource: root.robotState.value === "cleaning" ? "../images/media-playback-pause.svg" : "../images/media-playback-start.svg" property int minimumHeight: Style.iconSize * 4.5
onClicked: {
if (root.robotState.value === "cleaning" || root.robotState.value === "paused") { Item {
engine.thingManager.executeAction(root.thing.id, root.thing.thingClass.actionTypes.findByName("pauseCleaning").id) Layout.fillWidth: true
} else { }
engine.thingManager.executeAction(root.thing.id, root.thing.thingClass.actionTypes.findByName("startCleaning").id)
ProgressButton {
longpressEnabled: false
mode: root.robotState.value === "cleaning" ? "normal" : "highlight"
size: Style.bigIconSize
imageSource: root.robotState.value === "cleaning" ? "../images/media-playback-pause.svg" : "../images/media-playback-start.svg"
onClicked: {
if (root.robotState.value === "cleaning" || root.robotState.value === "paused") {
engine.thingManager.executeAction(root.thing.id, root.thing.thingClass.actionTypes.findByName("pauseCleaning").id)
} else {
engine.thingManager.executeAction(root.thing.id, root.thing.thingClass.actionTypes.findByName("startCleaning").id)
}
} }
} }
} Item {
Item { Layout.fillWidth: true
Layout.fillWidth: true }
}
ProgressButton { ProgressButton {
longpressEnabled: false longpressEnabled: false
imageSource: "../images/media-playback-stop.svg" imageSource: "../images/media-playback-stop.svg"
size: Style.bigIconSize size: Style.bigIconSize
mode: "destructive" mode: "destructive"
onClicked: { onClicked: {
engine.thingManager.executeAction(root.thing.id, root.thing.thingClass.actionTypes.findByName("returnToBase").id) engine.thingManager.executeAction(root.thing.id, root.thing.thingClass.actionTypes.findByName("returnToBase").id)
}
} }
} Item {
Item { Layout.fillWidth: true
Layout.fillWidth: true }
} ProgressButton {
ProgressButton { longpressEnabled: false
longpressEnabled: false imageSource: "../images/view-grid-symbolic.svg"
imageSource: "../images/view-grid-symbolic.svg" mode: "normal"
mode: "normal" size: Style.bigIconSize
size: Style.bigIconSize visible: root.thing.thingClass.browsable
visible: root.thing.thingClass.browsable onClicked: {
onClicked: { pageStack.push(mapPageComponent)
pageStack.push(mapPageComponent) }
}
Item {
Layout.fillWidth: true
visible: root.thing.thingClass.browsable
} }
}
Item {
Layout.fillWidth: true
visible: root.thing.thingClass.browsable
} }
} }
} }
Component { Component {
@ -429,15 +447,7 @@ ThingPageBase {
y: center.y - height / 2 y: center.y - height / 2
onClicked: { onClicked: {
var params = [] engine.thingManager.executeBrowserItem(root.thing.id, boundary.id)
var zoneParam = {}
var actionType = root.thing.thingClass.actionTypes.findByName("startCleaning")
var paramType = actionType.paramTypes.findByName("zone");
print("boundary:", boundary, actionType, paramType)
zoneParam["paramTypeId"] = paramType.id
zoneParam["value"] = boundary.id
params.push(zoneParam)
engine.thingManager.executeAction(root.thing.id, root.thing.thingClass.actionTypes.findByName("startCleaning").id, params)
} }
} }
} }