' ).text ruleName
+ img = $( '
![]()
' ).attr( 'class', 'del' )
+ .attr( 'title', 'Delete Rule' ).attr 'src', 'red_cross_small.png'
tr.append( $( '
' ).append img )
- tr.append( $( ' | ' ).append imgTwo )
+ img = $( ' ' ).attr( 'class', 'edit' )
+ .attr( 'title', 'Edit Rule' ).attr 'src', 'edit.png'
+ tr.append( $( ' | ' ).append img )
+ img = $( ' ' ).attr( 'class', 'log' )
+ .attr( 'title', 'Show Rule Log' ).attr 'src', 'logicon.png'
+ tr.append( $( ' | ' ).append img )
+ inp = $( '' ).text ruleName
tr.append( $( ' ' ).append inp )
$( '#tableRules' ).append tr
@@ -52,6 +69,10 @@ fOnLoad = () ->
.done fFetchRules
.fail fErrHandler 'Could not delete rule! '
+ $( '#tableRules' ).on 'click', 'img.edit', () ->
+ ruleName = $( 'div', $( this ).closest( 'tr' )).text()
+ window.location.href = 'forge?page=forge_rule&id=' + encodeURIComponent ruleName
+
$( '#tableRules' ).on 'click', 'img.log', () ->
ruleName = $( 'div', $( this ).closest( 'tr' )).text()
data =
@@ -65,4 +86,38 @@ fOnLoad = () ->
$( '#log_col' ).html "#{ ruleName } Log:#{ log }"
.fail fErrHandler 'Could not get rule log! '
+ # Add parameter list functionality
+ fChangeInputVisibility = () ->
+ $( '#tableParams tr' ).each ( id ) ->
+ if $( this ).is ':last-child' or $( this ).is ':only-child'
+ $( 'img', this ).hide()
+ $( 'input[type=checkbox]', this ).hide()
+ else
+ $( 'img', this ).show()
+ $( 'input[type=checkbox]', this ).show()
+
+ $( '#tableParams' ).on 'click', 'img', () ->
+ par = $( this ).closest 'tr'
+ if not par.is ':last-child'
+ par.remove()
+ fChangeInputVisibility()
+
+ $( '#tableParams' ).on 'keyup', 'input', ( e ) ->
+ code = e.keyCode or e.which
+ if code isnt 9
+ par = $( this ).closest 'tr'
+ if par.is ':last-child'
+ tr = $ ' | '
+ img = $( ' ' ).attr( 'title', 'Remove?').attr 'src', 'red_cross_small.png'
+ cb = $( '' ).attr( 'type', 'checkbox' ).attr 'title', 'Password shielded input?'
+ inp = $( '' ).attr( 'type', 'text' ).attr 'class', 'textinput'
+ tr.append $( '' ).append img
+ tr.append $( ' | ' ).append cb
+ tr.append $( ' | ' ).append inp
+ par.parent().append tr
+ fChangeInputVisibility()
+ else if $( this ).val() is '' and not par.is ':only-child'
+ par.remove()
+
+ fChangeInputVisibility()
window.addEventListener 'load', fOnLoad, true
diff --git a/webpages/handlers/coffee/forge_action_invoker.coffee b/webpages/handlers/coffee/forge_action_invoker.coffee
index a357139..80e9f8b 100644
--- a/webpages/handlers/coffee/forge_action_invoker.coffee
+++ b/webpages/handlers/coffee/forge_action_invoker.coffee
@@ -17,44 +17,52 @@ fOnLoad = () ->
editor.getSession().setMode "ace/mode/javascript"
# Add parameter list functionality
- fChangeCrosses = () ->
- $( '#tableParams img' ).each ( id ) ->
- par = $( this ).closest 'tr'
- if par.is ':last-child' or par.is ':only-child'
- $( this ).hide()
+ fChangeInputVisibility = () ->
+ $( '#tableParams tr' ).each ( id ) ->
+ if $( this ).is ':last-child' or $( this ).is ':only-child'
+ $( 'img', this ).hide()
+ $( 'input[type=checkbox]', this ).hide()
else
- $( this ).show()
+ $( 'img', this ).show()
+ $( 'input[type=checkbox]', this ).show()
$( '#tableParams' ).on 'click', 'img', () ->
par = $( this ).closest 'tr'
if not par.is ':last-child'
par.remove()
- fChangeCrosses()
+ fChangeInputVisibility()
- $( '#tableParams' ).on 'keyup', 'input', () ->
- par = $( this ).closest( 'tr' )
- if par.is ':last-child'
- tr = $ ' | '
- img = $( ' ' ).attr 'src', 'red_cross_small.png'
- inp = $( '' ).attr 'type', 'text'
- tr.append( $( '' ).append img )
- tr.append( $( ' | ' ).append inp )
- par.parent().append tr
- fChangeCrosses()
- else if $( this ).val() is '' and not par.is ':only-child'
- par.remove()
- fChangeCrosses()
+ $( '#tableParams' ).on 'keyup', 'input', ( e ) ->
+ code = e.keyCode or e.which
+ if code isnt 9
+ par = $( this ).closest( 'tr' )
+ if par.is ':last-child'
+ tr = $ ' | '
+ img = $( ' ' ).attr( 'title', 'Remove?').attr 'src', 'red_cross_small.png'
+ cb = $( '' ).attr( 'type', 'checkbox' ).attr 'title', 'Password shielded input?'
+ inp = $( '' ).attr( 'type', 'text' ).attr 'class', 'textinput'
+ tr.append( $( '' ).append img )
+ tr.append( $( ' | ' ).append cb )
+ tr.append( $( ' | ' ).append inp )
+ par.parent().append tr
+ fChangeInputVisibility()
+ else if $( this ).val() is '' and not par.is ':only-child'
+ par.remove()
+
+ fChangeInputVisibility()
# Add submit button logic
$( '#but_submit' ).click () ->
if $( '#input_id' ).val() is ''
alert 'Please enter an action invoker name!'
else
- listParams = []
- $( '#tableParams input' ).each () ->
- val = $( this ).val()
+ listParams = {}
+ $( '#tableParams tr' ).each () ->
+ val = $( 'input.textinput', this ).val()
+ shld = $( 'input[type=checkbox]', this ).is ':checked'
if val isnt ""
- listParams.push val
+ listParams[val] = shld
+ true
obj =
command: 'forge_action_invoker'
payload:
diff --git a/webpages/handlers/coffee/forge_event_poller.coffee b/webpages/handlers/coffee/forge_event_poller.coffee
index ecda36c..026f211 100644
--- a/webpages/handlers/coffee/forge_event_poller.coffee
+++ b/webpages/handlers/coffee/forge_event_poller.coffee
@@ -16,44 +16,53 @@ fOnLoad = () ->
editor.getSession().setMode "ace/mode/javascript"
# Add parameter list functionality
- fChangeCrosses = () ->
- $( '#tableParams img' ).each ( id ) ->
- par = $( this ).closest 'tr'
- if par.is ':last-child' or par.is ':only-child'
- $( this ).hide()
+ fChangeInputVisibility = () ->
+ $( '#tableParams tr' ).each ( id ) ->
+ if $( this ).is ':last-child' or $( this ).is ':only-child'
+ $( 'img', this ).hide()
+ $( 'input[type=checkbox]', this ).hide()
else
- $( this ).show()
+ $( 'img', this ).show()
+ $( 'input[type=checkbox]', this ).show()
$( '#tableParams' ).on 'click', 'img', () ->
par = $( this ).closest 'tr'
if not par.is ':last-child'
par.remove()
- fChangeCrosses()
+ fChangeInputVisibility()
- $( '#tableParams' ).on 'keyup', 'input', () ->
- par = $( this ).closest( 'tr' )
- if par.is ':last-child'
- tr = $ ' | '
- img = $( ' ' ).attr 'src', 'red_cross_small.png'
- inp = $( '' ).attr 'type', 'text'
- tr.append( $( '' ).append img )
- tr.append( $( ' | ' ).append inp )
- par.parent().append tr
- fChangeCrosses()
- else if $( this ).val() is '' and not par.is ':only-child'
- par.remove()
- fChangeCrosses()
+ $( '#tableParams' ).on 'keyup', 'input', ( e ) ->
+ code = e.keyCode or e.which
+ if code isnt 9
+ par = $( this ).closest( 'tr' )
+ if par.is ':last-child'
+ tr = $ ' | '
+ img = $( ' ' ).attr( 'title', 'Remove?').attr 'src', 'red_cross_small.png'
+ cb = $( '' ).attr( 'type', 'checkbox' ).attr 'title', 'Password shielded input?'
+ inp = $( '' ).attr( 'type', 'text' ).attr 'class', 'textinput'
+ tr.append( $( '' ).append img )
+ tr.append( $( ' | ' ).append cb )
+ tr.append( $( ' | ' ).append inp )
+ tr.append $( ' | ' )
+ par.parent().append tr
+ fChangeInputVisibility()
+ else if $( this ).val() is '' and not par.is ':only-child'
+ par.remove()
+
+ fChangeInputVisibility()
# Add submit button logic
$( '#but_submit' ).click () ->
if $( '#input_id' ).val() is ''
alert 'Please enter an event poller name!'
else
- listParams = []
- $( '#tableParams input' ).each () ->
- val = $( this ).val()
+ listParams = {}
+ $( '#tableParams tr' ).each () ->
+ val = $( 'input.textinput', this ).val()
+ shld = $( 'input[type=checkbox]', this ).is ':checked'
if val isnt ""
- listParams.push val
+ listParams[val] = shld
+ true
obj =
command: 'forge_event_poller'
payload:
diff --git a/webpages/handlers/coffee/forge_rule.coffee b/webpages/handlers/coffee/forge_rule.coffee
index f950330..19b3e6b 100644
--- a/webpages/handlers/coffee/forge_rule.coffee
+++ b/webpages/handlers/coffee/forge_rule.coffee
@@ -1,4 +1,13 @@
strPublicKey = ''
+
+fFailedRequest = ( msg ) ->
+ ( err ) ->
+ if err.status is 401
+ window.location.href = 'forge?page=forge_rule'
+ else
+ $( '#info' ).text msg
+ $( '#info' ).attr 'class', 'error'
+
$.post( '/usercommand', command: 'get_public_key' )
.done ( data ) ->
strPublicKey = data.message
@@ -6,11 +15,12 @@ $.post( '/usercommand', command: 'get_public_key' )
if err.status is 401
window.location.href = 'forge?page=forge_rule'
else
- console.log err
- $( '#info' ).text 'Error fetching public key, unable to send user-specific parameters securely'
+ $( '#info' ).text 'Error fetching public key, unable to send user specific parameters securely'
$( '#info' ).attr 'class', 'error'
fOnLoad = () ->
+ document.title = 'Rule Forge!'
+ $( '#pagetitle' ).text '{{{user.username}}}, forge your ECA Rule!'
editor = ace.edit "editor_conditions"
editor.setTheme "ace/theme/monokai"
@@ -18,9 +28,6 @@ fOnLoad = () ->
editor.setShowPrintMargin false
# editor.session.setUseSoftTabs false
- document.title = 'Rule Forge!'
- $( '#pagetitle' ).text '{{{user.username}}}, forge your ECA Rule!'
-
# Fetch Event Poller user-specific parameters
fFetchEventParams = ( name ) ->
if name
@@ -33,39 +40,24 @@ fOnLoad = () ->
$.post( '/usercommand', obj )
.done ( data ) ->
if data.message
- arrParams = JSON.parse data.message
+ oParams = JSON.parse data.message
$( '#event_poller_params table' ).remove()
- if arrParams.length > 0
- table = $ ''
- $( '#event_poller_params' ).append table
- fAppendParam = ( name ) ->
- tr = $( '' )
- tr.append $( '| ' ).css 'width', '20px'
- tr.append $( ' | ' ).attr( 'class', 'key' ).text name
- inp = $( '' ).attr( 'type', 'password' ).attr 'id', "#{ name }"
- tr.append $( ' | ' ).text( ' :' ).append inp
- table.append tr
- fAppendParam name for name in arrParams
- .fail ( err ) ->
- if err.status is 401
- window.location.href = 'forge?page=forge_rule'
- else
- fDelayed = () ->
- console.log err
- $( '#info' ).text 'Error fetching event poller params'
- $( '#info' ).attr 'class', 'error'
- setTimeout fDelayed, 500
-
-
-#FIXME Add possibility for custom event via text input
-#FIXME Add conditions
-#FIXME Only send user parameters encrypted! RSA required! Crypto-js doesn't provide it
-
+ table = $ ''
+ $( '#event_poller_params' ).append table
+ fAppendParam = ( name, shielded ) ->
+ tr = $( '' )
+ tr.append $( '| ' ).css 'width', '20px'
+ tr.append $( ' | ' ).attr( 'class', 'key' ).text name
+ inp = $( '' ).attr 'id', "#{ name }"
+ if shielded
+ inp.attr( 'type', 'password' )
+ tr.append $( ' | ' ).text( ' : ' ).append inp
+ table.append tr
+ fAppendParam name, shielded for name, shielded of oParams
+ .fail fFailedRequest 'Error fetching event poller params'
# Init Event Pollers
- obj =
- command: 'get_event_pollers'
- $.post( '/usercommand', obj )
+ $.post( '/usercommand', command: 'get_event_pollers' )
.done ( data ) ->
try
oEps = JSON.parse data.message
@@ -79,110 +71,119 @@ fOnLoad = () ->
fAppendEvent evt for evt in events
fAppendEvents id, events for id, events of oEps
fFetchEventParams $( '#select_event option:selected' ).text()
- .fail ( err ) ->
- if err.status is 401
- window.location.href = 'forge?page=forge_rule'
- else
- fDelayed = () ->
- console.log err
- $( '#info' ).text 'Error fetching event poller'
- $( '#info' ).attr 'class', 'error'
- setTimeout fDelayed, 500
+ .fail fFailedRequest 'Error fetching event poller'
$( '#select_event' ).change () ->
fFetchEventParams $( this ).val()
# Init Action Invoker
- arrActionInvoker = []
obj =
command: 'get_action_invokers'
$.post( '/usercommand', obj )
+
.done ( data ) ->
try
oAis = JSON.parse data.message
catch err
console.error 'ERROR: non-object received from server: ' + data.message
return
- i = 0
- fAppendActions = ( id, actions ) ->
- fAppendAction = ( act ) ->
- $( '#select_actions' ).append $( ' | | | |