fix remove device policy question handling
This commit is contained in:
parent
b041db8c81
commit
fe80fc3531
@ -212,5 +212,6 @@
|
|||||||
<file>ui/mainviews/DevicesPageDelegate.qml</file>
|
<file>ui/mainviews/DevicesPageDelegate.qml</file>
|
||||||
<file>ui/components/AutoSizeMenu.qml</file>
|
<file>ui/components/AutoSizeMenu.qml</file>
|
||||||
<file>ui/components/EmptyViewPlaceholder.qml</file>
|
<file>ui/components/EmptyViewPlaceholder.qml</file>
|
||||||
|
<file>ui/components/RemoveDeviceMethodDialog.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@ -17,6 +17,34 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: d
|
||||||
|
property var deviceToRemove: null
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Engine.deviceManager
|
||||||
|
onRemoveDeviceReply: {
|
||||||
|
if (!d.deviceToRemove) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (params.deviceError) {
|
||||||
|
case "DeviceErrorNoError":
|
||||||
|
d.deviceToRemove = null;
|
||||||
|
return;
|
||||||
|
case "DeviceErrorDeviceInRule":
|
||||||
|
var removeMethodComponent = Qt.createComponent(Qt.resolvedUrl("components/RemoveDeviceMethodDialog.qml"))
|
||||||
|
var popup = removeMethodComponent.createObject(root, {device: d.deviceToRemove, rulesList: params["ruleIds"]});
|
||||||
|
popup.open();
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
var popup = errorDialog.createObject(root, {errorCode: params.deviceError})
|
||||||
|
popup.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
model: Engine.deviceManager.devices
|
model: Engine.deviceManager.devices
|
||||||
@ -28,7 +56,8 @@ Page {
|
|||||||
pageStack.push(Qt.resolvedUrl("devicepages/ConfigureThingPage.qml"), {device: Engine.deviceManager.devices.get(index)})
|
pageStack.push(Qt.resolvedUrl("devicepages/ConfigureThingPage.qml"), {device: Engine.deviceManager.devices.get(index)})
|
||||||
}
|
}
|
||||||
onDeleteClicked: {
|
onDeleteClicked: {
|
||||||
Engine.deviceManager.removeDevice(Engine.deviceManager.devices.get(index).id)
|
d.deviceToRemove = Engine.deviceManager.devices.get(index);
|
||||||
|
Engine.deviceManager.removeDevice(d.deviceToRemove.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
68
nymea-app/ui/components/RemoveDeviceMethodDialog.qml
Normal file
68
nymea-app/ui/components/RemoveDeviceMethodDialog.qml
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import Nymea 1.0
|
||||||
|
|
||||||
|
Dialog {
|
||||||
|
id: root
|
||||||
|
width: Math.min(parent.width * .8, contentLabel.implicitWidth + app.margins * 2)
|
||||||
|
x: (parent.width - width) / 2
|
||||||
|
y: (parent.height - height) / 2
|
||||||
|
modal: true
|
||||||
|
|
||||||
|
property var device: null
|
||||||
|
property var rulesList: null
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
width: parent.width
|
||||||
|
Label {
|
||||||
|
id: contentLabel
|
||||||
|
text: qsTr("This thing is currently used in one or more rules:")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
ThinDivider {}
|
||||||
|
ListView {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: app.iconSize * Math.min(count, 5)
|
||||||
|
model: rulesList
|
||||||
|
interactive: contentHeight > height
|
||||||
|
delegate: Label {
|
||||||
|
height: app.iconSize
|
||||||
|
width: parent.width
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: Engine.ruleManager.rules.getRule(modelData).name
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ThinDivider {}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: qsTr("Remove all those rules")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
onClicked: {
|
||||||
|
Engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyCascade)
|
||||||
|
root.close()
|
||||||
|
root.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: qsTr("Update rules, removing this thing")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
onClicked: {
|
||||||
|
Engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyUpdate)
|
||||||
|
root.close()
|
||||||
|
root.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: qsTr("Don't remove this thing")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
onClicked: {
|
||||||
|
root.close()
|
||||||
|
root.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -47,7 +47,7 @@ Page {
|
|||||||
pageStack.pop();
|
pageStack.pop();
|
||||||
return;
|
return;
|
||||||
case "DeviceErrorDeviceInRule":
|
case "DeviceErrorDeviceInRule":
|
||||||
var popup = removeMethodComponent.createObject(root, {rulesList: params["ruleIds"]});
|
var popup = removeMethodComponent.createObject(root, {device: root.device, rulesList: params["ruleIds"]});
|
||||||
popup.open();
|
popup.open();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
@ -117,67 +117,8 @@ Page {
|
|||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: removeMethodComponent
|
id: removeMethodComponent
|
||||||
Dialog {
|
RemoveDeviceMethodDialog {
|
||||||
id: removeMethodDialog
|
|
||||||
width: Math.min(parent.width * .8, contentLabel.implicitWidth + app.margins * 2)
|
|
||||||
x: (parent.width - width) / 2
|
|
||||||
y: (parent.height - height) / 2
|
|
||||||
modal: true
|
|
||||||
|
|
||||||
property var rulesList: null
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
width: parent.width
|
|
||||||
Label {
|
|
||||||
id: contentLabel
|
|
||||||
text: qsTr("This thing is currently used in one or more rules:")
|
|
||||||
Layout.fillWidth: true
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
}
|
|
||||||
|
|
||||||
ThinDivider {}
|
|
||||||
ListView {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.preferredHeight: app.iconSize * Math.min(count, 5)
|
|
||||||
model: rulesList
|
|
||||||
interactive: contentHeight > height
|
|
||||||
delegate: Label {
|
|
||||||
height: app.iconSize
|
|
||||||
width: parent.width
|
|
||||||
elide: Text.ElideRight
|
|
||||||
text: Engine.ruleManager.rules.getRule(modelData).name
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ThinDivider {}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
text: qsTr("Remove all those rules")
|
|
||||||
Layout.fillWidth: true
|
|
||||||
onClicked: {
|
|
||||||
Engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyCascade)
|
|
||||||
removeMethodDialog.close()
|
|
||||||
removeMethodDialog.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: qsTr("Update rules, removing this thing")
|
|
||||||
Layout.fillWidth: true
|
|
||||||
onClicked: {
|
|
||||||
Engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyUpdate)
|
|
||||||
removeMethodDialog.close()
|
|
||||||
removeMethodDialog.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: qsTr("Don't remove this thing")
|
|
||||||
Layout.fillWidth: true
|
|
||||||
onClicked: {
|
|
||||||
removeMethodDialog.close()
|
|
||||||
removeMethodDialog.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user