Persisted copied steps to backend; Require login to view dashboard SPA
parent
f16cec0602
commit
35a9f1b332
4
Gemfile
4
Gemfile
|
@ -1,5 +1,5 @@
|
||||||
source 'http://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
source 'http://rails-assets.org'
|
source 'https://rails-assets.org'
|
||||||
|
|
||||||
ruby '2.2.0'
|
ruby '2.2.0'
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ GIT
|
||||||
sprockets-rails (~> 2.0)
|
sprockets-rails (~> 2.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
remote: http://rails-assets.org/
|
remote: https://rails-assets.org/
|
||||||
specs:
|
specs:
|
||||||
actionmailer (4.1.0)
|
actionmailer (4.1.0)
|
||||||
actionpack (= 4.1.0)
|
actionpack (= 4.1.0)
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
controller = ($scope, Data) ->
|
controller = ($scope, Data) ->
|
||||||
#TODO: We really really need an error handler / reporter at this point.
|
#TODO: We really really need an error handler / reporter at this point.
|
||||||
|
nope = (e) ->
|
||||||
|
alert 'Doh!'
|
||||||
|
console.error e
|
||||||
#TODO: We need a way of creating a "new" sequence. If you load a sequence,
|
#TODO: We need a way of creating a "new" sequence. If you load a sequence,
|
||||||
# there is no way to clear out of it.
|
# there is no way to clear out of it.
|
||||||
Data
|
Data
|
||||||
.findAll('sequence', {})
|
.findAll('sequence', {})
|
||||||
.catch (error) -> console.error error
|
.catch(nope)
|
||||||
|
|
||||||
$scope.dragControlListeners =
|
$scope.dragControlListeners =
|
||||||
accept: (sourceItemHandleScope, destSortableScope) -> true
|
accept: (sourceItemHandleScope, destSortableScope) -> true
|
||||||
itemMoved: (event) -> debugger
|
itemMoved: (event) -> debugger
|
||||||
|
@ -23,7 +27,7 @@ controller = ($scope, Data) ->
|
||||||
message_type: message_type
|
message_type: message_type
|
||||||
sequence_id: $scope.sequence._id
|
sequence_id: $scope.sequence._id
|
||||||
).then((step) -> $scope.sequence.steps.push(step))
|
).then((step) -> $scope.sequence.steps.push(step))
|
||||||
.catch((e) -> console.error e)
|
.catch(nope)
|
||||||
$scope.load = (seq) ->
|
$scope.load = (seq) ->
|
||||||
Data.loadRelations('sequence', seq._id, ['step'])
|
Data.loadRelations('sequence', seq._id, ['step'])
|
||||||
$scope.sequence = seq
|
$scope.sequence = seq
|
||||||
|
@ -32,22 +36,28 @@ controller = ($scope, Data) ->
|
||||||
Data
|
Data
|
||||||
.create('sequence', params)
|
.create('sequence', params)
|
||||||
.then((seq) -> $scope.load(seq)) # Load child resources of the new seqnce
|
.then((seq) -> $scope.load(seq)) # Load child resources of the new seqnce
|
||||||
.catch((e) -> console.error(e))
|
.catch(nope)
|
||||||
$scope.deleteSequence = (seq) ->
|
$scope.deleteSequence = (seq) ->
|
||||||
return unless hasSequence()
|
return unless hasSequence()
|
||||||
Data
|
Data
|
||||||
.destroy('sequence', seq._id)
|
.destroy('sequence', seq._id)
|
||||||
.then(() -> $scope.sequence = null)
|
.then(() -> $scope.sequence = null)
|
||||||
.catch((e) -> console.error(e))
|
.catch(nope)
|
||||||
$scope.saveSequence = (seq) ->
|
$scope.saveSequence = (seq) ->
|
||||||
Data
|
Data
|
||||||
.save('sequence', seq._id)
|
.save('sequence', seq._id)
|
||||||
.then((s) -> console.log(s))
|
.then((s) -> console.log(s))
|
||||||
.catch((e) -> console.error(e))
|
.catch(nope)
|
||||||
$scope.copy = (obj, index) ->
|
$scope.copy = (obj, index) ->
|
||||||
# Let's try:
|
return unless hasSequence()
|
||||||
# Data.create('step', the_step_to_copy)
|
yep = (step) -> $scope.sequence.steps.splice((index + 1), 0, step)
|
||||||
$scope.sequence.steps.splice((index + 1), 0, angular.copy(obj))
|
Data
|
||||||
|
.create('step',
|
||||||
|
sequence_id: $scope.sequence._id
|
||||||
|
message_type: obj.message_type
|
||||||
|
command: obj.command || {}
|
||||||
|
).then(yep)
|
||||||
|
.catch(nope)
|
||||||
$scope.remove = (index) ->
|
$scope.remove = (index) ->
|
||||||
step = $scope.sequence.steps[index]
|
step = $scope.sequence.steps[index]
|
||||||
Data.destroy('step', step._id).catch((e) -> console.error e)
|
Data.destroy('step', step._id).catch((e) -> console.error e)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# A non-resourceful controller for the 'glue' that holds this SPA together.
|
# A non-resourceful controller for the 'glue' that holds this SPA together.
|
||||||
# Let's try not to overwhelm this control and write as much API as possible.
|
# Let's try not to overwhelm this control and write as much API as possible.
|
||||||
class DashboardController < ApplicationController
|
class DashboardController < ApplicationController
|
||||||
|
before_action :authenticate_user!
|
||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -145,10 +145,10 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="row" as-sortable="dragControlListeners" ng-model="sequenceList">
|
<div class="row" as-sortable="dragControlListeners" ng-model="sequenceList">
|
||||||
<div ng-repeat='seq in sequence.steps track by $id(seq)' as-sortable-item>
|
<div ng-repeat='step in sequence.steps track by $id(step)' as-sortable-item>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<ng-include src="'sequence-builder/' + seq.message_type" >
|
<ng-include src="'sequence-builder/' + step.message_type" >
|
||||||
</ng-include>
|
</ng-include>
|
||||||
</div><div>
|
</div><div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 columns">
|
<div class="small-12 columns">
|
||||||
<div ng-repeat="seq in storedSequences track by $id(seq)">
|
<div ng-repeat="step in storedSequences track by $id(step)">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="icon-group">
|
<div class="icon-group">
|
||||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="icon-group">
|
<div class="icon-group">
|
||||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="icon-group">
|
<div class="icon-group">
|
||||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="icon-group">
|
<div class="icon-group">
|
||||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="icon-group">
|
<div class="icon-group">
|
||||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="icon-group">
|
<div class="icon-group">
|
||||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
Loading…
Reference in New Issue