mirror of
https://github.com/Hopiu/webapi-eca.git
synced 2026-03-16 22:10:31 +00:00
Time to sleep, see ya tomorrow
This commit is contained in:
parent
ca2f6e06ff
commit
1ba352987e
13 changed files with 466 additions and 400 deletions
|
|
@ -454,21 +454,22 @@ commandFunctions =
|
|||
if answ.code isnt 200
|
||||
callback answ
|
||||
else
|
||||
db.getUserWebhookIDs user.username, ( err, hooks ) =>
|
||||
if hooks.indexOf( oBody.hookname ) > -1
|
||||
answ.code = 409
|
||||
answ.message = 'Webhook already existing: ' + oBody.hookname
|
||||
callback answ
|
||||
db.getAllUserWebhookNames user.username, ( err, arrHooks ) =>
|
||||
hookExists = false
|
||||
hookExists = true for hookid, hookname of arrHooks when hookname is oBody.hookname
|
||||
if hookExists
|
||||
callback
|
||||
code: 409
|
||||
message: 'Webhook already existing: ' + oBody.hookname
|
||||
else
|
||||
db.getAllWebhookIDs ( arrHooks ) ->
|
||||
db.getAllWebhookIDs ( err, arrHooks ) ->
|
||||
genHookID = ( arrHooks ) ->
|
||||
hookid = ''
|
||||
for i in [0..1]
|
||||
for i in [ 0..1 ]
|
||||
hookid += Math.random().toString( 36 ).substring 2
|
||||
if arrHooks and arrHooks.indexOf( hookid ) > -1
|
||||
genHookID arrHooks
|
||||
else
|
||||
hookid
|
||||
hookid = genHookID arrHooks
|
||||
hookid
|
||||
hookid = genHookID arrHooks
|
||||
db.createWebhook user.username, hookid, oBody.hookname
|
||||
rh.activateWebhook user.username, hookid, oBody.hookname
|
||||
|
|
@ -479,13 +480,13 @@ commandFunctions =
|
|||
hookname: oBody.hookname
|
||||
|
||||
get_all_webhooks: ( user, oBody, callback ) ->
|
||||
db.getAllUserWebhooks user.username, ( err, data ) ->
|
||||
db.getAllUserWebhookNames user.username, ( err, data ) ->
|
||||
if err
|
||||
callback
|
||||
code: 400
|
||||
message: "We didn't like your request!"
|
||||
else
|
||||
data = JSON.stringify data || ''
|
||||
data = JSON.stringify( data ) || null
|
||||
callback
|
||||
code: 200
|
||||
message: data
|
||||
|
|
|
|||
|
|
@ -838,10 +838,10 @@ exports.getUserWebhookIDs = ( username, cb ) =>
|
|||
###
|
||||
Gets all the user's webhooks with names.
|
||||
|
||||
@public getAllUserWebhooks( *username* )
|
||||
@public getAllUserWebhookNames( *username* )
|
||||
@param {String} username
|
||||
###
|
||||
exports.getAllUserWebhooks = ( username, cb ) =>
|
||||
exports.getAllUserWebhookNames = ( username, cb ) =>
|
||||
getSetRecords "user:#{ username }:webhooks", exports.getWebhookName, cb
|
||||
|
||||
###
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ exports = module.exports = ( args ) =>
|
|||
@allowedHooks = {}
|
||||
db.getAllWebhooks ( err, oHooks ) =>
|
||||
if oHooks
|
||||
console
|
||||
@log.info "RH | Initializing #{ Object.keys( oHooks ).length } Webhooks"
|
||||
@allowedHooks = oHooks
|
||||
module.exports
|
||||
|
|
@ -416,6 +415,7 @@ exports.activateWebhook = ( user, hookid, name ) =>
|
|||
hookname: name
|
||||
username: user
|
||||
|
||||
|
||||
# Deactivate a webhook
|
||||
exports.deactivateWebhook = ( hookid ) =>
|
||||
@log.info "HL | Webhook '#{ hookid }' deactivated"
|
||||
|
|
|
|||
|
|
@ -570,26 +570,34 @@ Components Manager
|
|||
if (answ.code !== 200) {
|
||||
return callback(answ);
|
||||
} else {
|
||||
return db.getUserWebhookIDs(user.username, (function(_this) {
|
||||
return function(err, hooks) {
|
||||
if (hooks.indexOf(oBody.hookname) > -1) {
|
||||
answ.code = 409;
|
||||
answ.message = 'Webhook already existing: ' + oBody.hookname;
|
||||
return callback(answ);
|
||||
return db.getAllUserWebhookNames(user.username, (function(_this) {
|
||||
return function(err, arrHooks) {
|
||||
var hookExists, hookid, hookname;
|
||||
hookExists = false;
|
||||
for (hookid in arrHooks) {
|
||||
hookname = arrHooks[hookid];
|
||||
if (hookname === oBody.hookname) {
|
||||
hookExists = true;
|
||||
}
|
||||
}
|
||||
if (hookExists) {
|
||||
return callback({
|
||||
code: 409,
|
||||
message: 'Webhook already existing: ' + oBody.hookname
|
||||
});
|
||||
} else {
|
||||
return db.getAllWebhookIDs(function(arrHooks) {
|
||||
var genHookID, hookid;
|
||||
return db.getAllWebhookIDs(function(err, arrHooks) {
|
||||
var genHookID;
|
||||
genHookID = function(arrHooks) {
|
||||
var hookid, i, _i;
|
||||
var i, _i;
|
||||
hookid = '';
|
||||
for (i = _i = 0; _i <= 1; i = ++_i) {
|
||||
hookid += Math.random().toString(36).substring(2);
|
||||
}
|
||||
if (arrHooks && arrHooks.indexOf(hookid) > -1) {
|
||||
return genHookID(arrHooks);
|
||||
} else {
|
||||
return hookid;
|
||||
hookid = genHookID(arrHooks);
|
||||
}
|
||||
return hookid;
|
||||
};
|
||||
hookid = genHookID(arrHooks);
|
||||
db.createWebhook(user.username, hookid, oBody.hookname);
|
||||
|
|
@ -608,14 +616,14 @@ Components Manager
|
|||
}
|
||||
},
|
||||
get_all_webhooks: function(user, oBody, callback) {
|
||||
return db.getAllUserWebhooks(user.username, function(err, data) {
|
||||
return db.getAllUserWebhookNames(user.username, function(err, data) {
|
||||
if (err) {
|
||||
return callback({
|
||||
code: 400,
|
||||
message: "We didn't like your request!"
|
||||
});
|
||||
} else {
|
||||
data = JSON.stringify(data || '');
|
||||
data = JSON.stringify(data) || null;
|
||||
return callback({
|
||||
code: 200,
|
||||
message: data
|
||||
|
|
|
|||
|
|
@ -1097,11 +1097,11 @@ Persistence
|
|||
/*
|
||||
Gets all the user's webhooks with names.
|
||||
|
||||
@public getAllUserWebhooks( *username* )
|
||||
@public getAllUserWebhookNames( *username* )
|
||||
@param {String} username
|
||||
*/
|
||||
|
||||
exports.getAllUserWebhooks = (function(_this) {
|
||||
exports.getAllUserWebhookNames = (function(_this) {
|
||||
return function(username, cb) {
|
||||
return getSetRecords("user:" + username + ":webhooks", exports.getWebhookName, cb);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ Request Handler
|
|||
_this.allowedHooks = {};
|
||||
db.getAllWebhooks(function(err, oHooks) {
|
||||
if (oHooks) {
|
||||
console;
|
||||
_this.log.info("RH | Initializing " + (Object.keys(oHooks).length) + " Webhooks");
|
||||
return _this.allowedHooks = oHooks;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,43 @@ for param in arrParams
|
|||
if oParams.id
|
||||
oParams.id = decodeURIComponent oParams.id
|
||||
|
||||
# Webpage elements. Registered here for easier access
|
||||
domInputEventName = $( '<div>' )
|
||||
el = $( '<input>' ).attr( 'type', 'text' )
|
||||
.attr( 'style', 'font-size:1em' )
|
||||
.attr( 'id', 'input_eventname' )
|
||||
domInputEventName.append $( '<h4>' ).text( 'Event Name : ' ).append el
|
||||
|
||||
domSelectWebhook = $( '<div>' )
|
||||
el = $( '<select>' ).attr( 'type', 'text' )
|
||||
.attr( 'style', 'font-size:1em' )
|
||||
.attr( 'id', 'select_eventhook' )
|
||||
domSelectWebhook.append $( '<h4>' ).text( 'Webhook Name : ' ).append el
|
||||
|
||||
domSelectEventPoller = $( '<div>' )
|
||||
el = $( '<select>' ).attr( 'type', 'text' )
|
||||
.attr( 'style', 'font-size:1em' )
|
||||
.attr( 'id', 'select_eventpoller' )
|
||||
el.change () -> fFetchEventParams $( this ).val()
|
||||
domSelectEventPoller.append $( '<h4>' ).text( 'Event Poller Name : ' ).append el
|
||||
|
||||
domInputStartTime = $( '<div>' ).attr( 'class', 'indent20' ).html "Start Time :
|
||||
<input id=\"input_start\" type=\"text\" /> <b>\"hh:mm\"</b>, default = 12:00"
|
||||
|
||||
domInputInterval = $( '<div>' ).attr( 'class', 'indent20' ).html "Interval :
|
||||
<input id=\"input_interval\" type=\"text\" /> <b>\"days hours:minutes\"</b>, default = 10 minutes"
|
||||
|
||||
domEventPollerParameters = $( '<div>' ).attr 'id', 'event_poller_params'
|
||||
|
||||
domTableSelectedActions = $( '<table> ' ).attr( 'id', 'selected_actions' )
|
||||
domDivActionUserParams = $( '<div>' ).attr( 'id', 'action_invoker_params' )
|
||||
$( '#action_parameters' ).append $( '<div>' ).html "<b>Selected Actions:</b>"
|
||||
$( '#action_parameters' ).append domTableSelectedActions
|
||||
$( '#action_parameters' ).append $( '<div>' ).html "<br><br><b>Required Parameters:</b><br><br>"
|
||||
$( '#action_parameters' ).append domDivActionUserParams
|
||||
$( '#action_parameters' ).append $( '<div>' ).html "<br><br>"
|
||||
|
||||
|
||||
fDisplayError = ( msg ) ->
|
||||
window.scrollTo 0, 0
|
||||
$( '#info' ).text "Error: #{ msg }"
|
||||
|
|
@ -28,7 +65,7 @@ fFailedRequest = ( msg ) ->
|
|||
|
||||
fIssueRequest = ( args ) ->
|
||||
$( '#info' ).text ''
|
||||
$.post( '/usercommand', args.body )
|
||||
$.post( '/usercommand', args.data )
|
||||
.done args.done
|
||||
.fail args.fail
|
||||
|
||||
|
|
@ -104,42 +141,32 @@ fConvertDayHourToMinutes = ( strDayHour ) ->
|
|||
# EVENT Related Helper Functions
|
||||
#
|
||||
|
||||
# fPlaceAndPaintInterval = () ->
|
||||
# $( '#event_start' ).html 'Start Time:
|
||||
# <input id="input_start" type="text" />
|
||||
# <b>"hh:mm"</b>, default = 12:00'
|
||||
# $( '#event_interval' ).html 'Interval:
|
||||
# <input id="input_interval" type="text" />
|
||||
# <b>"days hours:minutes"</b>, default = 10 minutes'
|
||||
|
||||
# Prepare the event section when a different event type is selected
|
||||
fPrepareEventType = ( eventtype ) ->
|
||||
$( '#select_event_type' ).val eventtype
|
||||
$( '#event_parameters *' ).remove()
|
||||
$( '#event_parameters > div' ).detach()
|
||||
switch eventtype
|
||||
|
||||
# The user wants to react to custom event
|
||||
when 'Custom Event'
|
||||
inpEvt = $( '<input>' ).attr( 'type', 'text' )
|
||||
.attr( 'style', 'font-size:1em' ).attr 'id', 'input_eventname'
|
||||
$( '#event_parameters' ).append $( '<h4>' ).text( 'Event Name : ' ).append inpEvt
|
||||
$( '#event_parameters' ).append domInputEventName
|
||||
|
||||
# The user wants a webhook as event producer
|
||||
when 'Webhook'
|
||||
fIssueRequest
|
||||
body: command: 'get_all_webhooks'
|
||||
data: command: 'get_all_webhooks'
|
||||
done: ( data ) ->
|
||||
try
|
||||
oHooks = JSON.parse data.message
|
||||
selHook = $( '<select>' ).attr( 'type', 'text' )
|
||||
.attr( 'style', 'font-size:1em' ).attr 'id', 'select_eventhook'
|
||||
selHook = $( 'select', domSelectWebhook )
|
||||
selHook.children().remove()
|
||||
i = 0
|
||||
for hookid, hookname of oHooks
|
||||
i++
|
||||
selHook.append $( '<option>' ).text hookname
|
||||
|
||||
if i > 0
|
||||
$( '#event_parameters' ).append $( '<h4>' ).text( 'Webhook Name : ' ).append selHook
|
||||
$( '#event_parameters' ).append domSelectWebhook
|
||||
|
||||
else
|
||||
fDisplayError 'No webhooks found! Choose another Event Type or create a Webhook.'
|
||||
|
|
@ -151,59 +178,57 @@ fPrepareEventType = ( eventtype ) ->
|
|||
fail: fFailedRequest 'Unable to get webhooks!'
|
||||
|
||||
when 'Event Poller'
|
||||
selPoller = $( '<select>' ).attr( 'type', 'text' )
|
||||
.attr( 'style', 'font-size:1em' ).attr 'id', 'select_eventpoller'
|
||||
$( '#event_parameters' ).append $( '<h4>' ).text( 'Event Poller Name : ' ).append selPoller
|
||||
fIssueRequest
|
||||
body: command: 'get_event_pollers'
|
||||
data: command: 'get_event_pollers'
|
||||
done: ( data ) ->
|
||||
try
|
||||
|
||||
oEps = JSON.parse data.message
|
||||
fAppendEvents = ( id, events ) ->
|
||||
fAppendEvent = ( evt ) ->
|
||||
$( '#select_eventpoller' ).append $( '<option>' ).text id + ' -> ' + evt
|
||||
fAppendEvent evt for evt in events
|
||||
fAppendEvents id, events for id, events of oEps
|
||||
fFetchEventParams $( '#select_eventpoller option:selected' ).text()
|
||||
if JSON.stringify( oEps ) is '{}'
|
||||
fDisplayError 'No Event Pollers found! Create one first!'
|
||||
$( '#select_event_type' ).val ''
|
||||
|
||||
else
|
||||
$( '#event_parameters' ).append domSelectEventPoller
|
||||
$( '#event_parameters' ).append domInputStartTime
|
||||
$( '#event_parameters' ).append domInputInterval
|
||||
|
||||
$( '#select_eventpoller option' ).remove()
|
||||
for id, events of oEps
|
||||
for evt in events
|
||||
$( '#select_eventpoller' ).append $( '<option>' ).text id + ' -> ' + evt
|
||||
|
||||
fFetchEventParams $( 'option:selected', domSelectEventPoller ).text()
|
||||
|
||||
catch err
|
||||
console.error 'ERROR: non-object received for event poller from server: ' + data.message
|
||||
|
||||
fail: fFailedRequest 'Error fetching Event Poller'
|
||||
|
||||
$( '#select_eventpoller' ).change () ->
|
||||
evtFunc = $( this ).val()
|
||||
if evtFunc is ''
|
||||
$( '#event_start' ).html ''
|
||||
$( '#event_interval' ).html ''
|
||||
else
|
||||
fPlaceAndPaintInterval()
|
||||
$( '#input_event' ).val evtFunc
|
||||
fFetchEventParams evtFunc
|
||||
|
||||
# Fetch the required Event Poller parameters
|
||||
fFetchEventParams = ( name ) ->
|
||||
console.log 'fetching event params'
|
||||
console.log name
|
||||
$( '#event_poller_params *' ).remove()
|
||||
if name
|
||||
$( '#event_parameters' ).append domEventPollerParameters
|
||||
arr = name.split ' -> '
|
||||
fIssueRequest
|
||||
body:
|
||||
data:
|
||||
command: 'get_event_poller_params'
|
||||
body: JSON.stringify
|
||||
id: arr[ 0 ]
|
||||
done: fAddEventParams arr[ 0 ]
|
||||
done: fDisplayEventParams arr[ 0 ]
|
||||
fail: fFailedRequest 'Error fetching Event Poller params'
|
||||
fFetchEventFunctionArgs arr
|
||||
|
||||
fAddEventParams = ( id ) ->
|
||||
fDisplayEventParams = ( id ) ->
|
||||
( data ) ->
|
||||
console.log 'displaying event parameters'
|
||||
if data.message
|
||||
oParams = JSON.parse data.message
|
||||
table = $ '<table>'
|
||||
i = 0
|
||||
fAppendParam = ( name, shielded ) ->
|
||||
for name, shielded of oParams
|
||||
i++
|
||||
tr = $( '<tr>' )
|
||||
tr.append $( '<td>' ).css 'width', '20px'
|
||||
|
|
@ -213,23 +238,20 @@ fAddEventParams = ( id ) ->
|
|||
inp.attr( 'type', 'password' )
|
||||
tr.append $( '<td>' ).text( ' : ' ).append inp
|
||||
table.append tr
|
||||
fAppendParam name, shielded for name, shielded of oParams
|
||||
if i > 0
|
||||
$( '#event_poller_params' ).html '<b>Required Global Parameters:</b>'
|
||||
$( '#event_poller_params' ).append table
|
||||
|
||||
fDelayed = () ->
|
||||
fFillEventParams id
|
||||
setTimeout fDelayed, 200
|
||||
|
||||
fFillEventParams = ( moduleId ) ->
|
||||
obj =
|
||||
command: 'get_event_poller_user_params'
|
||||
body: JSON.stringify
|
||||
id: moduleId
|
||||
fIssueRequest
|
||||
body: obj
|
||||
data:
|
||||
command: 'get_event_poller_user_params'
|
||||
body: JSON.stringify
|
||||
id: moduleId
|
||||
done: ( data ) ->
|
||||
console.log 'filling event params: '
|
||||
console.log data
|
||||
oParams = JSON.parse data.message
|
||||
for param, oParam of oParams
|
||||
par = $( "#event_poller_params tr" ).filter () ->
|
||||
|
|
@ -239,23 +261,15 @@ fFillEventParams = ( moduleId ) ->
|
|||
$( 'input', par ).change () ->
|
||||
$( this ).attr 'unchanged', 'false'
|
||||
|
||||
obj.command = 'get_event_poller_user_arguments'
|
||||
obj.body = JSON.stringify
|
||||
ruleId: $( '#input_id' ).val()
|
||||
moduleId: moduleId
|
||||
fIssueRequest
|
||||
body: obj
|
||||
done: fAddEventUserArgs moduleId # FIXME this is wrong here
|
||||
|
||||
# Fetch function arguments required for an event polling function
|
||||
fFetchEventFunctionArgs = ( arrName ) ->
|
||||
# FIXME this data gets not populated sometimes!
|
||||
fIssueRequest
|
||||
body:
|
||||
data:
|
||||
command: 'get_event_poller_function_arguments'
|
||||
body: JSON.stringify
|
||||
id: arrName[ 0 ]
|
||||
done: ( data ) ->
|
||||
console.log 'fetching event function arguments: '
|
||||
if data.message
|
||||
oParams = JSON.parse data.message
|
||||
if oParams[ arrName[ 1 ] ]
|
||||
|
|
@ -272,10 +286,21 @@ fFetchEventFunctionArgs = ( arrName ) ->
|
|||
td = $( '<td>' ).appendTo tr
|
||||
td.append $( '<input>' ).attr 'type', 'text'
|
||||
tr.append td
|
||||
fail: fFailedRequest 'Error fetching action invoker function params'
|
||||
|
||||
fIssueRequest
|
||||
data:
|
||||
command: 'get_event_poller_user_arguments'
|
||||
body: JSON.stringify
|
||||
ruleId: $( '#input_id' ).val()
|
||||
moduleId: moduleId
|
||||
done: fAddEventUserArgs moduleId
|
||||
|
||||
fail: fFailedRequest 'Error fetching event poller function arguments'
|
||||
|
||||
fAddEventUserArgs = ( name ) ->
|
||||
( data ) ->
|
||||
console.log 'filling event funcction arguments: '
|
||||
console.log data
|
||||
for key, arrFuncs of data.message
|
||||
par = $ "#event_poller_params"
|
||||
for oFunc in JSON.parse arrFuncs
|
||||
|
|
@ -291,7 +316,7 @@ fAddEventUserArgs = ( name ) ->
|
|||
|
||||
fAddSelectedAction = ( name ) ->
|
||||
arrName = name.split ' -> '
|
||||
arrEls = $( "#action_params div.modName" ).map( () ->
|
||||
arrEls = $( "#action_invoker_params div.modName" ).map( () ->
|
||||
$( this ).text()
|
||||
).get()
|
||||
table = $( '#selected_actions' )
|
||||
|
|
@ -302,7 +327,7 @@ fAddSelectedAction = ( name ) ->
|
|||
td = $( '<td>' ).attr( 'class', 'funcMappings').appendTo tr
|
||||
fFetchActionFunctionArgs td, arrName
|
||||
if arrName[ 0 ] not in arrEls
|
||||
div = $( '<div>' ).appendTo $( '#action_params' )
|
||||
div = $( '<div>' ).appendTo $( '#action_invoker_params' )
|
||||
subdiv = $( '<div> ').appendTo div
|
||||
subdiv.append $( '<div>' )
|
||||
.attr( 'class', 'modName underlined' ).text arrName[ 0 ]
|
||||
|
|
@ -315,12 +340,11 @@ fAddSelectedAction = ( name ) ->
|
|||
setTimeout fDelayed, 300
|
||||
|
||||
fFetchActionParams = ( div, modName ) ->
|
||||
obj =
|
||||
command: 'get_action_invoker_params'
|
||||
body: JSON.stringify
|
||||
id: modName
|
||||
fIssueRequest
|
||||
body: obj
|
||||
data:
|
||||
command: 'get_action_invoker_params'
|
||||
body: JSON.stringify
|
||||
id: modName
|
||||
done: ( data ) ->
|
||||
if data.message
|
||||
oParams = JSON.parse data.message
|
||||
|
|
@ -342,7 +366,7 @@ fFetchActionParams = ( div, modName ) ->
|
|||
|
||||
fFetchActionFunctionArgs = ( tag, arrName ) ->
|
||||
fIssueRequest
|
||||
body:
|
||||
data:
|
||||
command: 'get_action_invoker_function_arguments'
|
||||
body: JSON.stringify
|
||||
id: arrName[ 0 ]
|
||||
|
|
@ -363,14 +387,14 @@ fFetchActionFunctionArgs = ( tag, arrName ) ->
|
|||
|
||||
fFillActionFunction = ( name ) ->
|
||||
fIssueRequest
|
||||
body:
|
||||
data:
|
||||
command: 'get_action_invoker_user_params'
|
||||
body: JSON.stringify
|
||||
id: name
|
||||
done: fAddActionUserParams name
|
||||
|
||||
fIssueRequest
|
||||
body:
|
||||
data:
|
||||
command: 'get_action_invoker_user_arguments'
|
||||
body: JSON.stringify
|
||||
ruleId: $( '#input_id' ).val()
|
||||
|
|
@ -380,7 +404,7 @@ fFillActionFunction = ( name ) ->
|
|||
fAddActionUserParams = ( name ) ->
|
||||
( data ) ->
|
||||
oParams = JSON.parse data.message
|
||||
domMod = $( "#action_params div" ).filter () ->
|
||||
domMod = $( "#action_invoker_params div" ).filter () ->
|
||||
$( 'div.modName', this ).text() is name
|
||||
for param, oParam of oParams
|
||||
par = $( "tr", domMod ).filter () ->
|
||||
|
|
@ -409,7 +433,7 @@ fAddActionUserArgs = ( name ) ->
|
|||
fOnLoad = () ->
|
||||
# Fetch the public key from the engine
|
||||
fIssueRequest
|
||||
body: command: 'get_public_key'
|
||||
data: command: 'get_public_key'
|
||||
done: ( data ) ->
|
||||
strPublicKey = data.message
|
||||
fail: ( err ) ->
|
||||
|
|
@ -448,35 +472,17 @@ fOnLoad = () ->
|
|||
when 'webhook'
|
||||
$( '#input_id' ).val "My '#{ oParams.hookname }' Rule"
|
||||
fPrepareEventType 'Webhook'
|
||||
$( 'select_eventhook' ).val oParams.hookname
|
||||
domSelectWebhook.val oParams.hookname
|
||||
|
||||
when 'poller'
|
||||
$( '#input_id' ).val "My '#{ oParams.eventpoller }' Rule"
|
||||
fPrepareEventType 'Event Poller'
|
||||
|
||||
$( '#input_event' ).change () ->
|
||||
$( '#select_event' ).val ''
|
||||
$( '#select_event' ).val $( this ).val()
|
||||
fFetchEventParams $( '#select_event' ).val()
|
||||
if $( '#select_event' ).val() is ''
|
||||
$( '#event_start' ).html ''
|
||||
$( '#event_interval' ).html ''
|
||||
else
|
||||
fPlaceAndPaintInterval()
|
||||
|
||||
|
||||
# ACTIONS
|
||||
|
||||
# <b>Selected Actions:</b>
|
||||
# <table id="selected_actions"></table>
|
||||
# <br><br>
|
||||
# <b>Required Parameters:</b>
|
||||
# <br><br>
|
||||
# <div id="action_params"></div>
|
||||
# <br><br>
|
||||
|
||||
fIssueRequest
|
||||
body:
|
||||
data:
|
||||
command: 'get_action_invokers'
|
||||
done: ( data ) ->
|
||||
try
|
||||
|
|
@ -484,32 +490,42 @@ fOnLoad = () ->
|
|||
catch err
|
||||
console.error 'ERROR: non-object received from server: ' + data.message
|
||||
return
|
||||
fAppendActions = ( module, actions ) ->
|
||||
i = 0
|
||||
for module, actions of oAis
|
||||
for act in actions
|
||||
arrEls = $( "#action_params div" ).filter () ->
|
||||
i++
|
||||
arrEls = $( "#action_invoker_params div" ).filter () ->
|
||||
$( this ).text() is "#{ module } -> #{ act }"
|
||||
# It could have been loaded async before through the rules ito the action params
|
||||
# It could have been loaded async before through the rules into the action params
|
||||
if arrEls.length is 0
|
||||
$( '#select_actions' ).append $( '<option>' ).text module + ' -> ' + act
|
||||
fAppendActions module, actions for module, actions of oAis
|
||||
fail: fFailedRequest 'Error fetching Event Poller'
|
||||
fail: fFailedRequest 'Error fetching Action Invokers'
|
||||
|
||||
|
||||
$( '#select_actions' ).on 'change', () ->
|
||||
$( '#action_parameters' ).append domTableSelectedActions
|
||||
opt = $ 'option:selected', this
|
||||
fAddSelectedAction opt.text()
|
||||
|
||||
$( '#selected_actions' ).on 'click', 'img', () ->
|
||||
console.log 'click'
|
||||
act = $( this ).closest( 'td' ).siblings( '.title' ).text()
|
||||
arrName = act.split ' -> '
|
||||
|
||||
i = 0
|
||||
nMods = 0
|
||||
# Check whether we're the only function left that was selected from this module
|
||||
$( "#selected_actions td.title" ).each () ->
|
||||
i++
|
||||
arrNm = $( this ).text().split ' -> '
|
||||
nMods++ if arrNm[ 0 ] is arrName[ 0 ]
|
||||
|
||||
# If we are the last selected action we detach the whole action parameter section
|
||||
if i is 1
|
||||
$( '#action_parameters > *' ).detach()
|
||||
|
||||
if nMods is 1
|
||||
$('#action_params > div').each () ->
|
||||
$('#action_invoker_params > div').each () ->
|
||||
if $( this ).children( 'div.modName' ).text() is arrName[ 0 ]
|
||||
$( this ).remove()
|
||||
|
||||
|
|
@ -574,7 +590,7 @@ fOnLoad = () ->
|
|||
|
||||
# Store all selected action invokers
|
||||
ap = {}
|
||||
$( '> div', $( '#action_params' ) ).each () ->
|
||||
$( '> div', $( '#action_invoker_params' ) ).each () ->
|
||||
modName = $( '.modName', this ).text()
|
||||
params = {}
|
||||
$( 'tr', this ).each () ->
|
||||
|
|
@ -630,7 +646,7 @@ fOnLoad = () ->
|
|||
payl.overwrite = true
|
||||
obj.body = JSON.stringify payl
|
||||
fIssueRequest
|
||||
body: obj
|
||||
data: obj
|
||||
done: ( data ) ->
|
||||
$( '#info' ).text data.message
|
||||
$( '#info' ).attr 'class', 'success'
|
||||
|
|
@ -638,29 +654,26 @@ fOnLoad = () ->
|
|||
else
|
||||
fFailedRequest( "#{ obj.id } not stored!" ) err
|
||||
|
||||
start = fConvertTimeToDate
|
||||
mins = fConvertDayHourToMinutes
|
||||
if $( '#select_event' ).val() is ''
|
||||
start = null
|
||||
mins = null
|
||||
else
|
||||
start = start.toISOString()
|
||||
if $( '#select_event_type' ) is 'Event Poller'
|
||||
start = fConvertTimeToDate $( '#input_start' ).val().toISOString()
|
||||
mins = fConvertDayHourToMinutes $( '#input_interval' ).val()
|
||||
|
||||
obj =
|
||||
command: 'forge_rule'
|
||||
body: JSON.stringify
|
||||
id: $( '#input_id' ).val()
|
||||
eventname: eventId
|
||||
eventparams: ep
|
||||
eventstart: start
|
||||
eventinterval: mins
|
||||
eventfunctions: evtFuncs
|
||||
conditions: conds
|
||||
actions: acts
|
||||
actionparams: ap
|
||||
actionfunctions: actFuncs
|
||||
console.log obj
|
||||
fIssueRequest
|
||||
body: obj
|
||||
data:
|
||||
command: 'forge_rule'
|
||||
body: JSON.stringify
|
||||
id: $( '#input_id' ).val()
|
||||
eventname: eventId
|
||||
eventparams: ep
|
||||
eventstart: start
|
||||
eventinterval: mins
|
||||
eventfunctions: evtFuncs
|
||||
conditions: conds
|
||||
actions: acts
|
||||
actionparams: ap
|
||||
actionfunctions: actFuncs
|
||||
done: ( data ) ->
|
||||
$( '#info' ).text data.message
|
||||
$( '#info' ).attr 'class', 'success'
|
||||
|
|
@ -675,10 +688,10 @@ fOnLoad = () ->
|
|||
if oParams.id
|
||||
obj =
|
||||
command: 'get_rule'
|
||||
body: JSON.stringify
|
||||
data: JSON.stringify
|
||||
id: oParams.id
|
||||
fIssueRequest
|
||||
body: obj
|
||||
data: obj
|
||||
done: ( data ) ->
|
||||
oRule = JSON.parse data.message
|
||||
if oRule
|
||||
|
|
|
|||
|
|
@ -32,36 +32,58 @@ fFailedRequest = ( msg ) ->
|
|||
fDisplayError msg
|
||||
|
||||
|
||||
fUpdateWebhookList = () ->
|
||||
fUpdateWebhookList = ( cb ) ->
|
||||
fIssueRequest
|
||||
body:
|
||||
command: 'get_all_webhooks'
|
||||
done: fProcessWebhookList
|
||||
done: fProcessWebhookList cb
|
||||
fail: fFailedRequest 'Unable to get Webhook list'
|
||||
|
||||
fProcessWebhookList = ( cb ) ->
|
||||
( data ) ->
|
||||
$( '#table_webhooks *' ).remove()
|
||||
if data.message
|
||||
oHooks = JSON.parse data.message
|
||||
$( '#table_webhooks' ).append $( '<h3>' ).text 'Your existing Webhooks:'
|
||||
for hookid, hookname of oHooks
|
||||
tr = $( '<tr>' )
|
||||
tdName = $( '<div>' ).text hookname
|
||||
tdUrl = $( '<input>' ).attr( 'style', 'width:600px' ).val "#{ hostUrl }/webhooks/#{ hookid }"
|
||||
img = $( '<img>' ).attr( 'class', 'del' )
|
||||
.attr( 'title', 'Delete Module' ).attr 'src', 'red_cross_small.png'
|
||||
tr.append( $( '<td>' ).append img )
|
||||
tr.append( $( '<td>' ).attr( 'style', 'padding-left:10px' ).append tdName )
|
||||
tr.append( $( '<td>' ).attr( 'style', 'padding-left:10px' ).append tdUrl )
|
||||
$( '#table_webhooks' ).append tr
|
||||
else
|
||||
fShowWebhookUsage null
|
||||
cb? hookid, hookname
|
||||
|
||||
fProcessWebhookList = ( data ) ->
|
||||
$( '#table_webhooks *' ).remove()
|
||||
if data.message
|
||||
oHooks = JSON.parse data.message
|
||||
$( '#table_webhooks' ).append $( '<h3>' ).text 'Your existing Webhooks:'
|
||||
for hookid, hookname of oHooks
|
||||
tr = $( '<tr>' )
|
||||
tdName = $( '<div>' ).text hookname
|
||||
tdUrl = $( '<input>' ).attr( 'style', 'width:600px' ).val "#{ hostUrl }/webhooks/#{ hookid }"
|
||||
img = $( '<img>' ).attr( 'class', 'del' )
|
||||
.attr( 'title', 'Delete Module' ).attr 'src', 'red_cross_small.png'
|
||||
tr.append( $( '<td>' ).append img )
|
||||
tr.append( $( '<td>' ).attr( 'style', 'padding-left:10px' ).append tdName )
|
||||
tr.append( $( '<td>' ).attr( 'style', 'padding-left:10px' ).append tdUrl )
|
||||
$( '#table_webhooks' ).append tr
|
||||
fShowWebhookUsage = ( hookid, hookname ) ->
|
||||
$( '#display_hookurl *' ).remove()
|
||||
if hookid
|
||||
b = $( '<b>' ).text "This is the Webhook Url you can use for your Events '#{ hookname }' : "
|
||||
$( '#display_hookurl' ).append b
|
||||
$( '#display_hookurl' ).append $('<br>')
|
||||
inp = $('<input>').attr( 'type', 'text' ).attr( 'style', 'width:600px' )
|
||||
.val "#{ hostUrl }/webhooks/#{ hookid }"
|
||||
$( '#display_hookurl' ).append inp
|
||||
$( '#display_hookurl' ).append $('<br>')
|
||||
|
||||
div = $( '<div>' )
|
||||
div.append $( '<br>' )
|
||||
div.append $( '<div>' ).html "1. Try it out and push your location to your new webhook
|
||||
via <a target=\"_blank\" href=\"#{ hostUrl }/mobile.html?hookid=#{ hookid }\">this page</a>."
|
||||
div.append $( '<br>' )
|
||||
div.append $( '<div>' ).html "2. Then you should setup <a target=\"_blank\"
|
||||
href=\"forge?page=forge_rule&eventtype=webhook&hookname=#{ hookname }\">a Rule for the '#{ hookname }' Event!</a>"
|
||||
$( '#display_hookurl' ).append div
|
||||
|
||||
fOnLoad = () ->
|
||||
|
||||
document.title = 'Create Webhooks!'
|
||||
# Load existing Webhooks
|
||||
fUpdateWebhookList()
|
||||
fUpdateWebhookList fShowWebhookUsage
|
||||
|
||||
# Register button action
|
||||
$( '#but_submit' ).click ->
|
||||
|
|
@ -80,29 +102,15 @@ fOnLoad = () ->
|
|||
hookname: hookname
|
||||
done: ( data ) ->
|
||||
oAnsw = JSON.parse data.message
|
||||
b = $( '<b>' ).text "This is the Webhook Url you can use for your Event '#{ oAnsw.hookname }' : "
|
||||
$( '#display_hookurl' ).append b
|
||||
$( '#display_hookurl' ).append $('<br>')
|
||||
inp = $('<input>').attr( 'type', 'text' ).attr( 'style', 'width:600px' )
|
||||
.val "#{ hostUrl }/webhooks/#{ oAnsw.hookid }"
|
||||
$( '#display_hookurl' ).append inp
|
||||
$( '#display_hookurl' ).append $('<br>')
|
||||
|
||||
div = $( '<div>' )
|
||||
div.append $( '<br>' )
|
||||
div.append $( '<div>' ).html "1. Try it out and push your location to your new webhook
|
||||
via <a target=\"_blank\" href=\"#{ hostUrl }/mobile.html?hookid=#{ oAnsw.hookid }\">this page</a>."
|
||||
div.append $( '<br>' )
|
||||
div.append $( '<div>' ).html "2. Then you should setup <a target=\"_blank\"
|
||||
href=\"forge?page=forge_rule&eventtype=webhook&hookname=#{ hookname }\">a Rule for this Event!</a>"
|
||||
$( '#display_hookurl' ).append div
|
||||
fUpdateWebhookList()
|
||||
fShowWebhookUsage oAnsw.hookid, oAnsw.hookname
|
||||
fUpdateWebhookList ( data ) ->
|
||||
$( '#info' ).text "New Webhook successfully created!"
|
||||
$( '#info' ).attr 'class', 'success'
|
||||
fail: ( err ) ->
|
||||
if err.status is 409
|
||||
fFailedRequest( 'Webhook Event Name already existing!' ) err
|
||||
else
|
||||
fFailedRequest( 'Unable to create Webhook! ' + err.message ) err
|
||||
fUpdateWebhookList()
|
||||
|
||||
$( '#table_webhooks' ).on 'click', 'img', () ->
|
||||
if confirm "Do you really want to delete this webhook?"
|
||||
|
|
@ -113,12 +121,13 @@ fOnLoad = () ->
|
|||
command: 'delete_webhook'
|
||||
body: JSON.stringify
|
||||
hookid: arrUrl[ arrUrl.length - 1 ]
|
||||
|
||||
done: ( data ) ->
|
||||
$( '#info' ).text data.message
|
||||
$( '#info' ).attr 'class', 'success'
|
||||
fUpdateWebhookList()
|
||||
fUpdateWebhookList ( data ) ->
|
||||
$( '#info' ).text 'Webhook deleted!'
|
||||
$( '#info' ).attr 'class', 'success'
|
||||
|
||||
fail: ( err ) ->
|
||||
fFailedRequest( 'Unable to delete Webhook!' ) err
|
||||
fUpdateWebhookList()
|
||||
|
||||
window.addEventListener 'load', fOnLoad, true
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var arrKV, arrParams, fAddActionUserArgs, fAddActionUserParams, fAddEventParams, fAddEventUserArgs, fAddSelectedAction, fConvertDayHourToMinutes, fConvertTimeToDate, fDisplayError, fFailedRequest, fFetchActionFunctionArgs, fFetchActionParams, fFetchEventFunctionArgs, fFetchEventParams, fFillActionFunction, fFillEventParams, fIssueRequest, fOnLoad, fPrepareEventType, oParams, param, strPublicKey, _i, _len,
|
||||
var arrKV, arrParams, domDivActionUserParams, domEventPollerParameters, domInputEventName, domInputInterval, domInputStartTime, domSelectEventPoller, domSelectWebhook, domTableSelectedActions, el, fAddActionUserArgs, fAddActionUserParams, fAddEventUserArgs, fAddSelectedAction, fConvertDayHourToMinutes, fConvertTimeToDate, fDisplayError, fDisplayEventParams, fFailedRequest, fFetchActionFunctionArgs, fFetchActionParams, fFetchEventFunctionArgs, fFetchEventParams, fFillActionFunction, fFillEventParams, fIssueRequest, fOnLoad, fPrepareEventType, oParams, param, strPublicKey, _i, _len,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
strPublicKey = '';
|
||||
|
|
@ -19,6 +19,48 @@
|
|||
oParams.id = decodeURIComponent(oParams.id);
|
||||
}
|
||||
|
||||
domInputEventName = $('<div>');
|
||||
|
||||
el = $('<input>').attr('type', 'text').attr('style', 'font-size:1em').attr('id', 'input_eventname');
|
||||
|
||||
domInputEventName.append($('<h4>').text('Event Name : ').append(el));
|
||||
|
||||
domSelectWebhook = $('<div>');
|
||||
|
||||
el = $('<select>').attr('type', 'text').attr('style', 'font-size:1em').attr('id', 'select_eventhook');
|
||||
|
||||
domSelectWebhook.append($('<h4>').text('Webhook Name : ').append(el));
|
||||
|
||||
domSelectEventPoller = $('<div>');
|
||||
|
||||
el = $('<select>').attr('type', 'text').attr('style', 'font-size:1em').attr('id', 'select_eventpoller');
|
||||
|
||||
el.change(function() {
|
||||
return fFetchEventParams($(this).val());
|
||||
});
|
||||
|
||||
domSelectEventPoller.append($('<h4>').text('Event Poller Name : ').append(el));
|
||||
|
||||
domInputStartTime = $('<div>').attr('class', 'indent20').html("Start Time : <input id=\"input_start\" type=\"text\" /> <b>\"hh:mm\"</b>, default = 12:00");
|
||||
|
||||
domInputInterval = $('<div>').attr('class', 'indent20').html("Interval : <input id=\"input_interval\" type=\"text\" /> <b>\"days hours:minutes\"</b>, default = 10 minutes");
|
||||
|
||||
domEventPollerParameters = $('<div>').attr('id', 'event_poller_params');
|
||||
|
||||
domTableSelectedActions = $('<table> ').attr('id', 'selected_actions');
|
||||
|
||||
domDivActionUserParams = $('<div>').attr('id', 'action_invoker_params');
|
||||
|
||||
$('#action_parameters').append($('<div>').html("<b>Selected Actions:</b>"));
|
||||
|
||||
$('#action_parameters').append(domTableSelectedActions);
|
||||
|
||||
$('#action_parameters').append($('<div>').html("<br><br><b>Required Parameters:</b><br><br>"));
|
||||
|
||||
$('#action_parameters').append(domDivActionUserParams);
|
||||
|
||||
$('#action_parameters').append($('<div>').html("<br><br>"));
|
||||
|
||||
fDisplayError = function(msg) {
|
||||
window.scrollTo(0, 0);
|
||||
$('#info').text("Error: " + msg);
|
||||
|
|
@ -37,7 +79,7 @@
|
|||
|
||||
fIssueRequest = function(args) {
|
||||
$('#info').text('');
|
||||
return $.post('/usercommand', args.body).done(args.done).fail(args.fail);
|
||||
return $.post('/usercommand', args.data).done(args.done).fail(args.fail);
|
||||
};
|
||||
|
||||
fConvertTimeToDate = function(str) {
|
||||
|
|
@ -111,23 +153,22 @@
|
|||
};
|
||||
|
||||
fPrepareEventType = function(eventtype) {
|
||||
var inpEvt, selPoller;
|
||||
$('#select_event_type').val(eventtype);
|
||||
$('#event_parameters *').remove();
|
||||
$('#event_parameters > div').detach();
|
||||
switch (eventtype) {
|
||||
case 'Custom Event':
|
||||
inpEvt = $('<input>').attr('type', 'text').attr('style', 'font-size:1em').attr('id', 'input_eventname');
|
||||
return $('#event_parameters').append($('<h4>').text('Event Name : ').append(inpEvt));
|
||||
return $('#event_parameters').append(domInputEventName);
|
||||
case 'Webhook':
|
||||
return fIssueRequest({
|
||||
body: {
|
||||
data: {
|
||||
command: 'get_all_webhooks'
|
||||
},
|
||||
done: function(data) {
|
||||
var err, hookid, hookname, i, oHooks, selHook;
|
||||
try {
|
||||
oHooks = JSON.parse(data.message);
|
||||
selHook = $('<select>').attr('type', 'text').attr('style', 'font-size:1em').attr('id', 'select_eventhook');
|
||||
selHook = $('select', domSelectWebhook);
|
||||
selHook.children().remove();
|
||||
i = 0;
|
||||
for (hookid in oHooks) {
|
||||
hookname = oHooks[hookid];
|
||||
|
|
@ -135,7 +176,7 @@
|
|||
selHook.append($('<option>').text(hookname));
|
||||
}
|
||||
if (i > 0) {
|
||||
return $('#event_parameters').append($('<h4>').text('Webhook Name : ').append(selHook));
|
||||
return $('#event_parameters').append(domSelectWebhook);
|
||||
} else {
|
||||
fDisplayError('No webhooks found! Choose another Event Type or create a Webhook.');
|
||||
return $('#select_event_type').val('');
|
||||
|
|
@ -148,33 +189,31 @@
|
|||
fail: fFailedRequest('Unable to get webhooks!')
|
||||
});
|
||||
case 'Event Poller':
|
||||
selPoller = $('<select>').attr('type', 'text').attr('style', 'font-size:1em').attr('id', 'select_eventpoller');
|
||||
$('#event_parameters').append($('<h4>').text('Event Poller Name : ').append(selPoller));
|
||||
fIssueRequest({
|
||||
body: {
|
||||
return fIssueRequest({
|
||||
data: {
|
||||
command: 'get_event_pollers'
|
||||
},
|
||||
done: function(data) {
|
||||
var err, events, fAppendEvents, id, oEps;
|
||||
var err, events, evt, id, oEps, _j, _len1;
|
||||
try {
|
||||
oEps = JSON.parse(data.message);
|
||||
fAppendEvents = function(id, events) {
|
||||
var evt, fAppendEvent, _j, _len1, _results;
|
||||
fAppendEvent = function(evt) {
|
||||
return $('#select_eventpoller').append($('<option>').text(id + ' -> ' + evt));
|
||||
};
|
||||
_results = [];
|
||||
for (_j = 0, _len1 = events.length; _j < _len1; _j++) {
|
||||
evt = events[_j];
|
||||
_results.push(fAppendEvent(evt));
|
||||
if (JSON.stringify(oEps) === '{}') {
|
||||
fDisplayError('No Event Pollers found! Create one first!');
|
||||
return $('#select_event_type').val('');
|
||||
} else {
|
||||
$('#event_parameters').append(domSelectEventPoller);
|
||||
$('#event_parameters').append(domInputStartTime);
|
||||
$('#event_parameters').append(domInputInterval);
|
||||
$('#select_eventpoller option').remove();
|
||||
for (id in oEps) {
|
||||
events = oEps[id];
|
||||
for (_j = 0, _len1 = events.length; _j < _len1; _j++) {
|
||||
evt = events[_j];
|
||||
$('#select_eventpoller').append($('<option>').text(id + ' -> ' + evt));
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
for (id in oEps) {
|
||||
events = oEps[id];
|
||||
fAppendEvents(id, events);
|
||||
return fFetchEventParams($('option:selected', domSelectEventPoller).text());
|
||||
}
|
||||
return fFetchEventParams($('#select_eventpoller option:selected').text());
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
return console.error('ERROR: non-object received for event poller from server: ' + data.message);
|
||||
|
|
@ -182,18 +221,6 @@
|
|||
},
|
||||
fail: fFailedRequest('Error fetching Event Poller')
|
||||
});
|
||||
return $('#select_eventpoller').change(function() {
|
||||
var evtFunc;
|
||||
evtFunc = $(this).val();
|
||||
if (evtFunc === '') {
|
||||
$('#event_start').html('');
|
||||
$('#event_interval').html('');
|
||||
} else {
|
||||
fPlaceAndPaintInterval();
|
||||
}
|
||||
$('#input_event').val(evtFunc);
|
||||
return fFetchEventParams(evtFunc);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -203,30 +230,32 @@
|
|||
console.log(name);
|
||||
$('#event_poller_params *').remove();
|
||||
if (name) {
|
||||
$('#event_parameters').append(domEventPollerParameters);
|
||||
arr = name.split(' -> ');
|
||||
fIssueRequest({
|
||||
body: {
|
||||
data: {
|
||||
command: 'get_event_poller_params',
|
||||
body: JSON.stringify({
|
||||
id: arr[0]
|
||||
})
|
||||
},
|
||||
done: fAddEventParams(arr[0]),
|
||||
done: fDisplayEventParams(arr[0]),
|
||||
fail: fFailedRequest('Error fetching Event Poller params')
|
||||
});
|
||||
return fFetchEventFunctionArgs(arr);
|
||||
}
|
||||
};
|
||||
|
||||
fAddEventParams = function(id) {
|
||||
fDisplayEventParams = function(id) {
|
||||
return function(data) {
|
||||
var fAppendParam, fDelayed, i, name, shielded, table;
|
||||
var i, inp, name, shielded, table, tr;
|
||||
console.log('displaying event parameters');
|
||||
if (data.message) {
|
||||
oParams = JSON.parse(data.message);
|
||||
table = $('<table>');
|
||||
i = 0;
|
||||
fAppendParam = function(name, shielded) {
|
||||
var inp, tr;
|
||||
for (name in oParams) {
|
||||
shielded = oParams[name];
|
||||
i++;
|
||||
tr = $('<tr>');
|
||||
tr.append($('<td>').css('width', '20px'));
|
||||
|
|
@ -236,36 +265,29 @@
|
|||
inp.attr('type', 'password');
|
||||
}
|
||||
tr.append($('<td>').text(' : ').append(inp));
|
||||
return table.append(tr);
|
||||
};
|
||||
for (name in oParams) {
|
||||
shielded = oParams[name];
|
||||
fAppendParam(name, shielded);
|
||||
table.append(tr);
|
||||
}
|
||||
if (i > 0) {
|
||||
$('#event_poller_params').html('<b>Required Global Parameters:</b>');
|
||||
$('#event_poller_params').append(table);
|
||||
}
|
||||
fDelayed = function() {
|
||||
return fFillEventParams(id);
|
||||
};
|
||||
return setTimeout(fDelayed, 200);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
fFillEventParams = function(moduleId) {
|
||||
var obj;
|
||||
obj = {
|
||||
command: 'get_event_poller_user_params',
|
||||
body: JSON.stringify({
|
||||
id: moduleId
|
||||
})
|
||||
};
|
||||
fIssueRequest({
|
||||
body: obj,
|
||||
return fIssueRequest({
|
||||
data: {
|
||||
command: 'get_event_poller_user_params',
|
||||
body: JSON.stringify({
|
||||
id: moduleId
|
||||
})
|
||||
},
|
||||
done: function(data) {
|
||||
var oParam, par, _results;
|
||||
console.log('filling event params: ');
|
||||
console.log(data);
|
||||
oParams = JSON.parse(data.message);
|
||||
_results = [];
|
||||
for (param in oParams) {
|
||||
|
|
@ -282,27 +304,19 @@
|
|||
return _results;
|
||||
}
|
||||
});
|
||||
obj.command = 'get_event_poller_user_arguments';
|
||||
obj.body = JSON.stringify({
|
||||
ruleId: $('#input_id').val(),
|
||||
moduleId: moduleId
|
||||
});
|
||||
return fIssueRequest({
|
||||
body: obj,
|
||||
done: fAddEventUserArgs(moduleId)
|
||||
});
|
||||
};
|
||||
|
||||
fFetchEventFunctionArgs = function(arrName) {
|
||||
return fIssueRequest({
|
||||
body: {
|
||||
data: {
|
||||
command: 'get_event_poller_function_arguments',
|
||||
body: JSON.stringify({
|
||||
id: arrName[0]
|
||||
})
|
||||
},
|
||||
done: function(data) {
|
||||
var functionArgument, table, td, tr, _j, _len1, _ref, _results;
|
||||
var functionArgument, table, td, tr, _j, _len1, _ref;
|
||||
console.log('fetching event function arguments: ');
|
||||
if (data.message) {
|
||||
oParams = JSON.parse(data.message);
|
||||
if (oParams[arrName[1]]) {
|
||||
|
|
@ -311,7 +325,6 @@
|
|||
}
|
||||
table = $('<table>').appendTo($('#event_poller_params'));
|
||||
_ref = oParams[arrName[1]];
|
||||
_results = [];
|
||||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
|
||||
functionArgument = _ref[_j];
|
||||
tr = $('<tr>').attr('class', 'funcMappings').appendTo(table);
|
||||
|
|
@ -322,19 +335,30 @@
|
|||
tr.append($('<td>').text(' : '));
|
||||
td = $('<td>').appendTo(tr);
|
||||
td.append($('<input>').attr('type', 'text'));
|
||||
_results.push(tr.append(td));
|
||||
tr.append(td);
|
||||
}
|
||||
return _results;
|
||||
return fIssueRequest({
|
||||
data: {
|
||||
command: 'get_event_poller_user_arguments',
|
||||
body: JSON.stringify({
|
||||
ruleId: $('#input_id').val(),
|
||||
moduleId: moduleId
|
||||
})
|
||||
},
|
||||
done: fAddEventUserArgs(moduleId)
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: fFailedRequest('Error fetching action invoker function params')
|
||||
fail: fFailedRequest('Error fetching event poller function arguments')
|
||||
});
|
||||
};
|
||||
|
||||
fAddEventUserArgs = function(name) {
|
||||
return function(data) {
|
||||
var arrFuncs, key, oFunc, par, tr, _ref, _results;
|
||||
console.log('filling event funcction arguments: ');
|
||||
console.log(data);
|
||||
_ref = data.message;
|
||||
_results = [];
|
||||
for (key in _ref) {
|
||||
|
|
@ -361,7 +385,7 @@
|
|||
fAddSelectedAction = function(name) {
|
||||
var arrEls, arrName, div, fDelayed, img, subdiv, table, td, tr, _ref;
|
||||
arrName = name.split(' -> ');
|
||||
arrEls = $("#action_params div.modName").map(function() {
|
||||
arrEls = $("#action_invoker_params div.modName").map(function() {
|
||||
return $(this).text();
|
||||
}).get();
|
||||
table = $('#selected_actions');
|
||||
|
|
@ -372,7 +396,7 @@
|
|||
td = $('<td>').attr('class', 'funcMappings').appendTo(tr);
|
||||
fFetchActionFunctionArgs(td, arrName);
|
||||
if (_ref = arrName[0], __indexOf.call(arrEls, _ref) < 0) {
|
||||
div = $('<div>').appendTo($('#action_params'));
|
||||
div = $('<div>').appendTo($('#action_invoker_params'));
|
||||
subdiv = $('<div> ').appendTo(div);
|
||||
subdiv.append($('<div>')).attr('class', 'modName underlined').text(arrName[0]);
|
||||
fFetchActionParams(div, arrName[0]);
|
||||
|
|
@ -389,15 +413,13 @@
|
|||
};
|
||||
|
||||
fFetchActionParams = function(div, modName) {
|
||||
var obj;
|
||||
obj = {
|
||||
command: 'get_action_invoker_params',
|
||||
body: JSON.stringify({
|
||||
id: modName
|
||||
})
|
||||
};
|
||||
return fIssueRequest({
|
||||
body: obj,
|
||||
data: {
|
||||
command: 'get_action_invoker_params',
|
||||
body: JSON.stringify({
|
||||
id: modName
|
||||
})
|
||||
},
|
||||
done: function(data) {
|
||||
var fAppendActionParam, name, sh, table, _results;
|
||||
if (data.message) {
|
||||
|
|
@ -432,7 +454,7 @@
|
|||
|
||||
fFetchActionFunctionArgs = function(tag, arrName) {
|
||||
return fIssueRequest({
|
||||
body: {
|
||||
data: {
|
||||
command: 'get_action_invoker_function_arguments',
|
||||
body: JSON.stringify({
|
||||
id: arrName[0]
|
||||
|
|
@ -466,7 +488,7 @@
|
|||
|
||||
fFillActionFunction = function(name) {
|
||||
fIssueRequest({
|
||||
body: {
|
||||
data: {
|
||||
command: 'get_action_invoker_user_params',
|
||||
body: JSON.stringify({
|
||||
id: name
|
||||
|
|
@ -475,7 +497,7 @@
|
|||
done: fAddActionUserParams(name)
|
||||
});
|
||||
return fIssueRequest({
|
||||
body: {
|
||||
data: {
|
||||
command: 'get_action_invoker_user_arguments',
|
||||
body: JSON.stringify({
|
||||
ruleId: $('#input_id').val(),
|
||||
|
|
@ -490,7 +512,7 @@
|
|||
return function(data) {
|
||||
var domMod, oParam, par, _results;
|
||||
oParams = JSON.parse(data.message);
|
||||
domMod = $("#action_params div").filter(function() {
|
||||
domMod = $("#action_invoker_params div").filter(function() {
|
||||
return $('div.modName', this).text() === name;
|
||||
});
|
||||
_results = [];
|
||||
|
|
@ -540,7 +562,7 @@
|
|||
fOnLoad = function() {
|
||||
var editor, obj;
|
||||
fIssueRequest({
|
||||
body: {
|
||||
data: {
|
||||
command: 'get_public_key'
|
||||
},
|
||||
done: function(data) {
|
||||
|
|
@ -575,29 +597,18 @@
|
|||
case 'webhook':
|
||||
$('#input_id').val("My '" + oParams.hookname + "' Rule");
|
||||
fPrepareEventType('Webhook');
|
||||
$('select_eventhook').val(oParams.hookname);
|
||||
domSelectWebhook.val(oParams.hookname);
|
||||
break;
|
||||
case 'poller':
|
||||
$('#input_id').val("My '" + oParams.eventpoller + "' Rule");
|
||||
fPrepareEventType('Event Poller');
|
||||
}
|
||||
$('#input_event').change(function() {
|
||||
$('#select_event').val('');
|
||||
$('#select_event').val($(this).val());
|
||||
fFetchEventParams($('#select_event').val());
|
||||
if ($('#select_event').val() === '') {
|
||||
$('#event_start').html('');
|
||||
return $('#event_interval').html('');
|
||||
} else {
|
||||
return fPlaceAndPaintInterval();
|
||||
}
|
||||
});
|
||||
fIssueRequest({
|
||||
body: {
|
||||
data: {
|
||||
command: 'get_action_invokers'
|
||||
},
|
||||
done: function(data) {
|
||||
var actions, err, fAppendActions, module, oAis, _results;
|
||||
var act, actions, arrEls, err, i, module, oAis, _results;
|
||||
try {
|
||||
oAis = JSON.parse(data.message);
|
||||
} catch (_error) {
|
||||
|
|
@ -605,50 +616,58 @@
|
|||
console.error('ERROR: non-object received from server: ' + data.message);
|
||||
return;
|
||||
}
|
||||
fAppendActions = function(module, actions) {
|
||||
var act, arrEls, _j, _len1, _results;
|
||||
_results = [];
|
||||
for (_j = 0, _len1 = actions.length; _j < _len1; _j++) {
|
||||
act = actions[_j];
|
||||
arrEls = $("#action_params div").filter(function() {
|
||||
return $(this).text() === ("" + module + " -> " + act);
|
||||
});
|
||||
if (arrEls.length === 0) {
|
||||
_results.push($('#select_actions').append($('<option>').text(module + ' -> ' + act)));
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
i = 0;
|
||||
_results = [];
|
||||
for (module in oAis) {
|
||||
actions = oAis[module];
|
||||
_results.push(fAppendActions(module, actions));
|
||||
_results.push((function() {
|
||||
var _j, _len1, _results1;
|
||||
_results1 = [];
|
||||
for (_j = 0, _len1 = actions.length; _j < _len1; _j++) {
|
||||
act = actions[_j];
|
||||
i++;
|
||||
arrEls = $("#action_invoker_params div").filter(function() {
|
||||
return $(this).text() === ("" + module + " -> " + act);
|
||||
});
|
||||
if (arrEls.length === 0) {
|
||||
_results1.push($('#select_actions').append($('<option>').text(module + ' -> ' + act)));
|
||||
} else {
|
||||
_results1.push(void 0);
|
||||
}
|
||||
}
|
||||
return _results1;
|
||||
})());
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
fail: fFailedRequest('Error fetching Event Poller')
|
||||
fail: fFailedRequest('Error fetching Action Invokers')
|
||||
});
|
||||
$('#select_actions').on('change', function() {
|
||||
var opt;
|
||||
$('#action_parameters').append(domTableSelectedActions);
|
||||
opt = $('option:selected', this);
|
||||
return fAddSelectedAction(opt.text());
|
||||
});
|
||||
$('#selected_actions').on('click', 'img', function() {
|
||||
var act, arrName, nMods, opt;
|
||||
var act, arrName, i, nMods, opt;
|
||||
console.log('click');
|
||||
act = $(this).closest('td').siblings('.title').text();
|
||||
arrName = act.split(' -> ');
|
||||
i = 0;
|
||||
nMods = 0;
|
||||
$("#selected_actions td.title").each(function() {
|
||||
var arrNm;
|
||||
i++;
|
||||
arrNm = $(this).text().split(' -> ');
|
||||
if (arrNm[0] === arrName[0]) {
|
||||
return nMods++;
|
||||
}
|
||||
});
|
||||
if (i === 1) {
|
||||
$('#action_parameters > *').detach();
|
||||
}
|
||||
if (nMods === 1) {
|
||||
$('#action_params > div').each(function() {
|
||||
$('#action_invoker_params > div').each(function() {
|
||||
if ($(this).children('div.modName').text() === arrName[0]) {
|
||||
return $(this).remove();
|
||||
}
|
||||
|
|
@ -659,7 +678,7 @@
|
|||
return $(this).closest('tr').remove();
|
||||
});
|
||||
$('#but_submit').click(function() {
|
||||
var actFuncs, acts, ap, conds, el, ep, err, eventname, eventtype, evtFuncs, fCheckOverwrite, mins, obj, start;
|
||||
var actFuncs, acts, ap, conds, ep, err, eventname, eventtype, evtFuncs, fCheckOverwrite, mins, obj, start;
|
||||
window.scrollTo(0, 0);
|
||||
$('#info').text('');
|
||||
try {
|
||||
|
|
@ -718,7 +737,7 @@
|
|||
throw new Error('Please select at least one action or create one!');
|
||||
}
|
||||
ap = {};
|
||||
$('> div', $('#action_params')).each(function() {
|
||||
$('> div', $('#action_invoker_params')).each(function() {
|
||||
var modName, params;
|
||||
modName = $('.modName', this).text();
|
||||
params = {};
|
||||
|
|
@ -776,7 +795,7 @@
|
|||
payl.overwrite = true;
|
||||
obj.body = JSON.stringify(payl);
|
||||
return fIssueRequest({
|
||||
body: obj,
|
||||
data: obj,
|
||||
done: function(data) {
|
||||
$('#info').text(data.message);
|
||||
return $('#info').attr('class', 'success');
|
||||
|
|
@ -789,32 +808,27 @@
|
|||
}
|
||||
};
|
||||
};
|
||||
start = fConvertTimeToDate;
|
||||
mins = fConvertDayHourToMinutes;
|
||||
if ($('#select_event').val() === '') {
|
||||
start = null;
|
||||
mins = null;
|
||||
} else {
|
||||
start = start.toISOString();
|
||||
if ($('#select_event_type') === 'Event Poller') {
|
||||
start = fConvertTimeToDate($('#input_start').val().toISOString());
|
||||
mins = fConvertDayHourToMinutes($('#input_interval').val());
|
||||
}
|
||||
obj = {
|
||||
command: 'forge_rule',
|
||||
body: JSON.stringify({
|
||||
id: $('#input_id').val(),
|
||||
eventname: eventId,
|
||||
eventparams: ep,
|
||||
eventstart: start,
|
||||
eventinterval: mins,
|
||||
eventfunctions: evtFuncs,
|
||||
conditions: conds,
|
||||
actions: acts,
|
||||
actionparams: ap,
|
||||
actionfunctions: actFuncs
|
||||
})
|
||||
};
|
||||
console.log(obj);
|
||||
obj = console.log(obj);
|
||||
return fIssueRequest({
|
||||
body: obj,
|
||||
data: {
|
||||
command: 'forge_rule',
|
||||
body: JSON.stringify({
|
||||
id: $('#input_id').val(),
|
||||
eventname: eventId,
|
||||
eventparams: ep,
|
||||
eventstart: start,
|
||||
eventinterval: mins,
|
||||
eventfunctions: evtFuncs,
|
||||
conditions: conds,
|
||||
actions: acts,
|
||||
actionparams: ap,
|
||||
actionfunctions: actFuncs
|
||||
})
|
||||
},
|
||||
done: function(data) {
|
||||
$('#info').text(data.message);
|
||||
return $('#info').attr('class', 'success');
|
||||
|
|
@ -831,12 +845,12 @@
|
|||
if (oParams.id) {
|
||||
obj = {
|
||||
command: 'get_rule',
|
||||
body: JSON.stringify({
|
||||
data: JSON.stringify({
|
||||
id: oParams.id
|
||||
})
|
||||
};
|
||||
return fIssueRequest({
|
||||
body: obj,
|
||||
data: obj,
|
||||
done: function(data) {
|
||||
var action, arrName, d, mins, oRule, _j, _len1, _ref, _results;
|
||||
oRule = JSON.parse(data.message);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Generated by CoffeeScript 1.7.1
|
||||
(function() {
|
||||
var arrKV, arrParams, fDisplayError, fFailedRequest, fIssueRequest, fOnLoad, fProcessWebhookList, fUpdateWebhookList, hostUrl, oParams, param, _i, _len;
|
||||
var arrKV, arrParams, fDisplayError, fFailedRequest, fIssueRequest, fOnLoad, fProcessWebhookList, fShowWebhookUsage, fUpdateWebhookList, hostUrl, oParams, param, _i, _len;
|
||||
|
||||
arrParams = window.location.search.substring(1).split('&');
|
||||
|
||||
|
|
@ -39,41 +39,63 @@
|
|||
};
|
||||
};
|
||||
|
||||
fUpdateWebhookList = function() {
|
||||
fUpdateWebhookList = function(cb) {
|
||||
return fIssueRequest({
|
||||
body: {
|
||||
command: 'get_all_webhooks'
|
||||
},
|
||||
done: fProcessWebhookList,
|
||||
done: fProcessWebhookList(cb),
|
||||
fail: fFailedRequest('Unable to get Webhook list')
|
||||
});
|
||||
};
|
||||
|
||||
fProcessWebhookList = function(data) {
|
||||
var hookid, hookname, img, oHooks, tdName, tdUrl, tr, _results;
|
||||
$('#table_webhooks *').remove();
|
||||
if (data.message) {
|
||||
oHooks = JSON.parse(data.message);
|
||||
$('#table_webhooks').append($('<h3>').text('Your existing Webhooks:'));
|
||||
_results = [];
|
||||
for (hookid in oHooks) {
|
||||
hookname = oHooks[hookid];
|
||||
tr = $('<tr>');
|
||||
tdName = $('<div>').text(hookname);
|
||||
tdUrl = $('<input>').attr('style', 'width:600px').val("" + hostUrl + "/webhooks/" + hookid);
|
||||
img = $('<img>').attr('class', 'del').attr('title', 'Delete Module').attr('src', 'red_cross_small.png');
|
||||
tr.append($('<td>').append(img));
|
||||
tr.append($('<td>').attr('style', 'padding-left:10px').append(tdName));
|
||||
tr.append($('<td>').attr('style', 'padding-left:10px').append(tdUrl));
|
||||
_results.push($('#table_webhooks').append(tr));
|
||||
fProcessWebhookList = function(cb) {
|
||||
return function(data) {
|
||||
var hookid, hookname, img, oHooks, tdName, tdUrl, tr;
|
||||
$('#table_webhooks *').remove();
|
||||
if (data.message) {
|
||||
oHooks = JSON.parse(data.message);
|
||||
$('#table_webhooks').append($('<h3>').text('Your existing Webhooks:'));
|
||||
for (hookid in oHooks) {
|
||||
hookname = oHooks[hookid];
|
||||
tr = $('<tr>');
|
||||
tdName = $('<div>').text(hookname);
|
||||
tdUrl = $('<input>').attr('style', 'width:600px').val("" + hostUrl + "/webhooks/" + hookid);
|
||||
img = $('<img>').attr('class', 'del').attr('title', 'Delete Module').attr('src', 'red_cross_small.png');
|
||||
tr.append($('<td>').append(img));
|
||||
tr.append($('<td>').attr('style', 'padding-left:10px').append(tdName));
|
||||
tr.append($('<td>').attr('style', 'padding-left:10px').append(tdUrl));
|
||||
$('#table_webhooks').append(tr);
|
||||
}
|
||||
} else {
|
||||
fShowWebhookUsage(null);
|
||||
}
|
||||
return _results;
|
||||
return typeof cb === "function" ? cb(hookid, hookname) : void 0;
|
||||
};
|
||||
};
|
||||
|
||||
fShowWebhookUsage = function(hookid, hookname) {
|
||||
var b, div, inp;
|
||||
$('#display_hookurl *').remove();
|
||||
if (hookid) {
|
||||
b = $('<b>').text("This is the Webhook Url you can use for your Events '" + hookname + "' : ");
|
||||
$('#display_hookurl').append(b);
|
||||
$('#display_hookurl').append($('<br>'));
|
||||
inp = $('<input>').attr('type', 'text').attr('style', 'width:600px').val("" + hostUrl + "/webhooks/" + hookid);
|
||||
$('#display_hookurl').append(inp);
|
||||
$('#display_hookurl').append($('<br>'));
|
||||
div = $('<div>');
|
||||
div.append($('<br>'));
|
||||
div.append($('<div>').html("1. Try it out and push your location to your new webhook via <a target=\"_blank\" href=\"" + hostUrl + "/mobile.html?hookid=" + hookid + "\">this page</a>."));
|
||||
div.append($('<br>'));
|
||||
div.append($('<div>').html("2. Then you should setup <a target=\"_blank\" href=\"forge?page=forge_rule&eventtype=webhook&hookname=" + hookname + "\">a Rule for the '" + hookname + "' Event!</a>"));
|
||||
return $('#display_hookurl').append(div);
|
||||
}
|
||||
};
|
||||
|
||||
fOnLoad = function() {
|
||||
document.title = 'Create Webhooks!';
|
||||
fUpdateWebhookList();
|
||||
fUpdateWebhookList(fShowWebhookUsage);
|
||||
$('#but_submit').click(function() {
|
||||
var hookname;
|
||||
$('#info').text('');
|
||||
|
|
@ -89,29 +111,20 @@
|
|||
})
|
||||
},
|
||||
done: function(data) {
|
||||
var b, div, inp, oAnsw;
|
||||
var oAnsw;
|
||||
oAnsw = JSON.parse(data.message);
|
||||
b = $('<b>').text("This is the Webhook Url you can use for your Event '" + oAnsw.hookname + "' : ");
|
||||
$('#display_hookurl').append(b);
|
||||
$('#display_hookurl').append($('<br>'));
|
||||
inp = $('<input>').attr('type', 'text').attr('style', 'width:600px').val("" + hostUrl + "/webhooks/" + oAnsw.hookid);
|
||||
$('#display_hookurl').append(inp);
|
||||
$('#display_hookurl').append($('<br>'));
|
||||
div = $('<div>');
|
||||
div.append($('<br>'));
|
||||
div.append($('<div>').html("1. Try it out and push your location to your new webhook via <a target=\"_blank\" href=\"" + hostUrl + "/mobile.html?hookid=" + oAnsw.hookid + "\">this page</a>."));
|
||||
div.append($('<br>'));
|
||||
div.append($('<div>').html("2. Then you should setup <a target=\"_blank\" href=\"forge?page=forge_rule&eventtype=webhook&hookname=" + hookname + "\">a Rule for this Event!</a>"));
|
||||
$('#display_hookurl').append(div);
|
||||
return fUpdateWebhookList();
|
||||
fShowWebhookUsage(oAnsw.hookid, oAnsw.hookname);
|
||||
return fUpdateWebhookList(function(data) {
|
||||
$('#info').text("New Webhook successfully created!");
|
||||
return $('#info').attr('class', 'success');
|
||||
});
|
||||
},
|
||||
fail: function(err) {
|
||||
if (err.status === 409) {
|
||||
fFailedRequest('Webhook Event Name already existing!')(err);
|
||||
return fFailedRequest('Webhook Event Name already existing!')(err);
|
||||
} else {
|
||||
fFailedRequest('Unable to create Webhook! ' + err.message)(err);
|
||||
return fFailedRequest('Unable to create Webhook! ' + err.message)(err);
|
||||
}
|
||||
return fUpdateWebhookList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -129,13 +142,13 @@
|
|||
})
|
||||
},
|
||||
done: function(data) {
|
||||
$('#info').text(data.message);
|
||||
$('#info').attr('class', 'success');
|
||||
return fUpdateWebhookList();
|
||||
return fUpdateWebhookList(function(data) {
|
||||
$('#info').text('Webhook deleted!');
|
||||
return $('#info').attr('class', 'success');
|
||||
});
|
||||
},
|
||||
fail: function(err) {
|
||||
fFailedRequest('Unable to delete Webhook!')(err);
|
||||
return fUpdateWebhookList();
|
||||
return fFailedRequest('Unable to delete Webhook!')(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<h2>Create your own Webhooks</h2>
|
||||
<h3>Choose a name for the Events that are pushed to the new Webhook :
|
||||
<h3>Label the Events received over the new Webhook with :
|
||||
<input type="text" id="inp_hookname" style="font-size:1em;width:300px" /></h3>
|
||||
<button type="button" id="but_submit">Create Webhook!</button>
|
||||
<br><br>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@
|
|||
}
|
||||
|
||||
function displayError(positionError) {
|
||||
$('#info').text('Error: ' + positionError);
|
||||
console.log(positionError);
|
||||
$('#info').text('Error: ' + positionError.message);
|
||||
}
|
||||
|
||||
var gl = navigator.geolocation;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ input[type=password]:focus {
|
|||
border: 1px solid rgba(81, 203, 238, 1);
|
||||
}
|
||||
|
||||
.indent20 {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
#mobile {
|
||||
margin: 10px 20px 10px 20px;
|
||||
}
|
||||
|
|
@ -101,6 +105,10 @@ input[type=password]:focus {
|
|||
margin-left: 20px;
|
||||
}
|
||||
|
||||
#event_poller_params {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
#input_id {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue