denniss17/pimatic-angular-material-frontend

View on GitHub
app/controllers/devices/timer.js

Summary

Maintainability
C
1 day
Test Coverage
angular.module('pimaticApp.devices').controller('TimerController', [
    '$scope',
    'store',
    'events',
    function ($scope, store, events) {
        $scope.start = function () {
            var action = 'startTimer';
            store.adapter.deviceAction($scope.device.id, action).then(function () {
                events.onDeviceActionDone($scope.device, action);
            }, function () {
                events.onDeviceActionFail($scope.device, action);
            });
        };

        $scope.stop = function () {
            var action = 'stopTimer';
            store.adapter.deviceAction($scope.device.id, action).then(function () {
                events.onDeviceActionDone($scope.device, action);
            }, function () {
                events.onDeviceActionFail($scope.device, action);
            });
        };

        $scope.reset = function () {
            var action = 'resetTimer';
            store.adapter.deviceAction($scope.device.id, action).then(function () {
                events.onDeviceActionDone($scope.device, action);
            }, function () {
                events.onDeviceActionFail($scope.device, action);
            });
        };
    }
]);