WIP inversion button directive

pull/207/head
Rick Carlino 2015-08-11 11:51:08 -05:00
parent e4cf26abb9
commit c9cdd09b07
4 changed files with 66 additions and 14 deletions

View File

@ -8,11 +8,12 @@ ctrl = [
'Info'
($scope, Data, Devices, Info) ->
nope = (e) -> alert 'Doh!'; console.error e
$scope.logs = Info.logs
$scope.form = Devices
$scope.logs = Info.logs
$scope.device = Devices
Devices.socket.on 'ready',->
Devices.fetchLogs (d) -> Info.logs.push(data) for data in (d.data || [])
$scope.createDevice = -> Devices.save().error(nope)
$scope.debug = -> debugger
]
controller =

View File

@ -0,0 +1,17 @@
# A button used to set integers
ctrl = [
'$scope',
'Devices',
($scope, Devices) ->
$scope.toggle = -> debugger
]
directive =
restrict: 'AEC'
template: '<button class="red button-like" type="button">{{ 2 + 2}}</button>'
scope:
toggle_val: '@'
link: ($scope, el, attr) ->
el.on 'click', => $scope.toggle()
controller: ctrl
angular.module("FarmBot").directive 'calibrationbutton', [() -> directive]

View File

@ -36,6 +36,7 @@ private
if auth.success?
@current_device = auth.result
else
binding.pry
sorry("""You failed to authenticate with the API. Ensure that you have
provided a `bot_token` and `bot_uuid` header in the HTTP request.
""".squish, 401)

View File

@ -40,19 +40,19 @@
.row
.large-12.columns
%label FarmBot Name *
%input{id: 'botname', placeholder: "Brocolli Overlord", type: "text", ng_model: 'form.name', required: true}/
%input{id: 'botname', placeholder: "Brocolli Overlord", type: "text", ng_model: 'device.name', required: true}/
.row
.large-6.columns
%label UUID *
%input{placeholder: "ad698900-2546-11e3-87fb-c560cb0ca47b", type: "text", ng_model: 'form.uuid', required: true}/
%input{placeholder: "ad698900-2546-11e3-87fb-c560cb0ca47b", type: "text", ng_model: 'device.uuid', required: true}/
.large-6.columns
%label Security Token *
%input{placeholder: "4bbd2jm242dl5wmimbwz4rvlu77m0a4i", type: "text", ng_model: 'form.token', required: true}/
%input{placeholder: "4bbd2jm242dl5wmimbwz4rvlu77m0a4i", type: "text", ng_model: 'device.token', required: true}/
.row
.large-12.columns
%button.green.button-like
{{ !!form._id ? "Update" : "Add" }} FarmBot
%button.gray.button-like{ng_if: '!!form._id', ng_click: 'refreshLogs()', type: 'button'}
{{ !!device._id ? "Update" : "Add" }} FarmBot
%button.gray.button-like{ng_if: '!!device._id', ng_click: 'refreshLogs()', type: 'button'}
Fetch Logs
/ sorry
%br
@ -69,11 +69,9 @@
%thead
%tr
%th.row-axis Axis
%th.row-length Length
%th.row-input Max Speed
%th.row-input Accelerate For
%th.row-input Timeout After
%th.row-input Steps Per mm
%th.row-invert
Invert
%br
@ -86,24 +84,59 @@
%tbody
%tr
%td X
%td 1.23 m
%td
%input
%input{ng_model: "device.MOVEMENT_MAX_SPD_X"}
%br
mm/s
%td
%input
%input{ng_model: "device.MOVEMENT_STEPS_ACC_DEC_X"}
%br
steps
%td
%input
%input{ng_model: "device.MOVEMENT_TIMEOUT_X"}
%br
seconds
%td{ng_click: "debug()"}
%calibrationbutton{toggle_val: "'MOVEMENT_TIMEOUT_X'"}
%td
%input
%button.xx-small.green YES
%td
%button.xx-small.red NO
%tr
%td Y
%td
%input{ng_model: "device.MOVEMENT_MAX_SPD_Y"}
%br
mm/s
%td
%input{ng_model: "device.MOVEMENT_STEPS_ACC_DEC_Y"}
%br
steps
%td
%input{ng_model: "device.MOVEMENT_TIMEOUT_Y"}
%br
seconds
%td{ng_click: "debug()"}
%button.xx-small.green YES
%td
%button.xx-small.green YES
%td
%button.xx-small.red NO
%tr
%td Z
%td
%input{ng_model: "device.MOVEMENT_MAX_SPD_Z"}
%br
mm/s
%td
%input{ng_model: "device.MOVEMENT_STEPS_ACC_DEC_Z"}
%br
steps
%td
%input{ng_model: "device.MOVEMENT_TIMEOUT_Z"}
%br
seconds
%td{ng_click: "debug()"}
%button.xx-small.green YES
%td
%button.xx-small.green YES