This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-app/mea/ui/devicepages/InputTriggerDevicePage.qml
2018-05-26 21:14:10 +02:00

35 lines
1.3 KiB
QML

import QtQuick 2.5
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.1
import Mea 1.0
import "../components"
import "../customviews"
GenericDevicePage {
id: root
GenericTypeLogView {
anchors.fill: parent
text: qsTr("This event has appeared %1 times in the last 24 hours.")
device: root.device
onAddRuleClicked: {
var rule = Engine.ruleManager.createNewRule();
var eventDescriptor = rule.eventDescriptors.createNewEventDescriptor();
eventDescriptor.deviceId = device.id;
var eventType = root.deviceClass.eventTypes.findByName("triggered");
eventDescriptor.eventTypeId = eventType.id;
rule.name = root.device.name + " - " + eventType.displayName;
if (eventType.paramTypes.count === 1) {
var paramType = eventType.paramTypes.get(0);
eventDescriptor.paramDescriptors.setParamDescriptor(paramType.id, value, ParamDescriptor.ValueOperatorEquals);
rule.eventDescriptors.addEventDescriptor(eventDescriptor);
rule.name = rule.name + " - " + value
}
var rulePage = pageStack.push(Qt.resolvedUrl("../magic/DeviceRulesPage.qml"), {device: root.device});
rulePage.addRule(rule);
}
}
}