Sha256: a5136b9aacb497dd083c99b724c21104ab6f3cf0d01aae3536cd69e2bc5a3c55

Contents?: true

Size: 941 Bytes

Versions: 2

Compression:

Stored size: 941 Bytes

Contents

var RobotCommandsCtrl = function RobotCommandsCtrl($scope, $http) {
  $scope.command = "";
  $scope.types = [ 'string', 'boolean', 'number' ];

  $scope.isDisabled = function() {
    return ($scope.command === "")
  };

  $scope.addParam = function(last) {
    if (!last) { return; }
    $scope.robot.params.push({ name: '', value: '', type: 'string' });
  };

  $scope.removeParam = function(index) {
    if ($scope.robot.params.length === 1) { return; }
    $scope.robot.params.splice(index, 1);
  };

  $scope.submit = function() {
    var robot = $scope.robot.name,
        command = $scope.command,
        params = parseParams($scope.robot.params);

    var url ='/api/robots/' + robot + "/commands/" + command;

    $http.post(url, params).success(function(data) {
      if (data.result) {
        if ($scope.robot.results.length > 4) { $scope.robot.results.pop(); }
        $scope.robot.results.unshift(data);
      }
    });
  };
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
robeaux-0.3.0 js/controllers/robot_commands_ctrl.js
robeaux-0.2.0 js/controllers/robot_commands_ctrl.js