pulling things out into factories
parent
daef15642e
commit
a6f8b65565
|
@ -1,89 +1,14 @@
|
|||
# The overview controller provides an indepth view of a device as well as fine-
|
||||
# grained controll options. Needs a better name.
|
||||
# TODO: Network status indicator
|
||||
# TODO: Device selection
|
||||
# Run this in the command line for diagnostics.
|
||||
# ======
|
||||
# curl -X GET http://skynet.im/subscribe/713c69b1-e36a-11e3-93f8-f3e7e8d1cce9?token=0waw1l97lbwc23xrh0oem7d8rbai3sor --header "skynet_auth_uuid: 4bb4a961-e8e6-11e3-93f8-f3e7e8d1cce9" --header "skynet_auth_token: jce90gf7szxxyldihii1m3xv5d9jatt9"
|
||||
|
||||
# The Overview controller is in need of a better name. It should be called
|
||||
# 'controlController' or something. The name 'overview' is somewhat of an
|
||||
# artifact.
|
||||
angular.module('FarmBot').controller "OverviewController", [
|
||||
'$scope'
|
||||
'Restangular'
|
||||
($scope, Restangular, Skynet) ->
|
||||
|
||||
$scope.x = 0
|
||||
$scope.y = 0
|
||||
$scope.z = 0
|
||||
|
||||
$scope.upx = ->
|
||||
$scope.x = $scope.x + 5
|
||||
$scope.upy = ->
|
||||
$scope.y = $scope.y + 5
|
||||
$scope.upz = ->
|
||||
$scope.z = $scope.z + 5
|
||||
|
||||
$scope.downx = ->
|
||||
$scope.x = $scope.x - 5
|
||||
$scope.downy = ->
|
||||
$scope.y = $scope.y - 5
|
||||
$scope.downz = ->
|
||||
$scope.z = $scope.z - 5
|
||||
|
||||
'DeviceFactory'
|
||||
($scope, Restangular, DeviceFactory) ->
|
||||
Restangular.all('devices').getList().then (data) ->
|
||||
$scope.devices = data
|
||||
$scope.device = data[0]
|
||||
$scope.connectToSkyNet()
|
||||
|
||||
$scope.goHome = ->
|
||||
$scope.socket.emit "message",
|
||||
devices: $scope.device.uuid
|
||||
payload:
|
||||
message_type: 'single_command'
|
||||
time_stamp: new Date()
|
||||
command:
|
||||
action: 'MOVE ABSOLUTE'
|
||||
x: 0
|
||||
y: 0
|
||||
z: 0
|
||||
speed: 100 # Not sure about this one.
|
||||
amount: 0 # Is this for "DOSE WATER"?
|
||||
delay: 0
|
||||
, (data) ->
|
||||
console.log data
|
||||
return true
|
||||
|
||||
$scope.goAbs = ->
|
||||
$scope.socket.emit "message",
|
||||
devices: $scope.device.uuid
|
||||
payload:
|
||||
message_type: 'single_command'
|
||||
time_stamp: new Date()
|
||||
command:
|
||||
action: 'MOVE ABSOLUTE'
|
||||
x: $scope.x
|
||||
y: $scope.y
|
||||
z: $scope.z
|
||||
speed: 100 # Not sure about this one.
|
||||
amount: 0 # Is this for "DOSE WATER"?
|
||||
delay: 0
|
||||
, (data) ->
|
||||
console.log data
|
||||
return true
|
||||
|
||||
$scope.connectToSkyNet = ->
|
||||
config =
|
||||
type: "farmbotdss"
|
||||
uuid: "901ba251-ed7a-11e3-995a-b7667747c514"
|
||||
token: "32pwbkzd7qp06bt9zznee5xjhc7kfbt9"
|
||||
protocol: "websocket"
|
||||
skynet config, (e, socket) ->
|
||||
throw e if e
|
||||
$scope.socket = socket
|
||||
$scope.socket.on "message", (message) ->
|
||||
console.log "message received", message
|
||||
|
||||
$scope.debug = ->
|
||||
$scope.socket.emit "message", JSON.parse($scope.message), (data) ->
|
||||
console.log data
|
||||
$scope.device.connectToSkyNet()
|
||||
|
||||
]
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
Device = (Restangular) ->
|
||||
class Device
|
||||
constructor: () ->
|
||||
@all = @fetchAll
|
||||
fetchAll: ->
|
||||
Restangular.all("devices").getList().$object
|
||||
|
||||
angular.module('FarmBot').service 'Device',[
|
||||
'Restangular'
|
||||
Device
|
||||
]
|
||||
|
|
@ -1 +0,0 @@
|
|||
# TODO: This.
|
|
@ -18,8 +18,6 @@
|
|||
%section.top-bar-section
|
||||
%ul.left
|
||||
-if current_user
|
||||
%li{class: ("active" if current_page? page_path('dashboard'))}
|
||||
= link_to 'STUB', page_path('dashboard')
|
||||
%li{class: ("active" if current_page? page_path('#/settings'))}
|
||||
= link_to 'Control', '/dashboard#/overview'
|
||||
// TODO: Add CSS rul based on hash fragment.
|
||||
|
|
Loading…
Reference in New Issue