-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
259 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* The script metadata object describes whether or not your extension should be invoked asynchronously, and which events it supports | ||
* @returns {{ async: boolean, events: string[] }} | ||
*/ | ||
function getScriptMetadata() { | ||
return { | ||
async: false, | ||
events: [ | ||
//supported values: | ||
//'RESERVATION_CONFIRMATION', //fired on reservation confirmation. No results expected. | ||
//'TICKET_ASSIGNMENT', //fired on ticket assignment. No results expected. | ||
//'WAITING_QUEUE_SUBSCRIPTION', //fired on waiting queue subscription. No results expected. | ||
'INVOICE_GENERATION' //fired on invoice generation. Returns the invoice model. | ||
] | ||
}; | ||
} | ||
|
||
/** | ||
* Executes the extension. | ||
* @param scriptEvent | ||
* @returns Object | ||
*/ | ||
function executeScript(scriptEvent) { | ||
log.warn('hello from script with event: ' + scriptEvent); | ||
//this sample calls the https://csrng.net/ website and generates a random invoice number | ||
var symbol = restTemplate.getForObject('https://csrng.net/csrng/csrng.php?min=0&max=100', Java.type('java.util.ArrayList').class)[0].random; | ||
return { | ||
invoiceNumber: symbol | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/webapp/resources/js/admin/feature/extension/add-update/extension-add-update.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<div class="container" container-fluid-responsive=""> | ||
|
||
<div class="page-header"> | ||
<h3>{{$ctrl.edit ? 'Update' : 'Add'}} Extension</h3> | ||
</div> | ||
<form role="form" name="script" ng-submit="$ctrl.save($ctrl.extension)" data-error-sensitive novalidate data-oncancel="$ctrl.cancel()"> | ||
<div class="modal-body"> | ||
<div class="form-group" bs-form-error="$ctrl.extension.path"> | ||
<label for="script-path">Path</label> | ||
<input class="form-control" type="text" data-grab-focus id="script-path" name="path" data-ng-model="$ctrl.extension.path" required> | ||
<field-error data-form-obj="script" data-field-obj="$ctrl.extension.path"></field-error> | ||
</div> | ||
|
||
<div class="form-group" bs-form-error="$ctrl.extension.name"> | ||
<label for="script-name">Name</label> | ||
<input class="form-control" type="text" data-grab-focus id="script-name" name="name" data-ng-model="$ctrl.extension.name" required> | ||
<field-error data-form-obj="script" data-field-obj="$ctrl.extension.name"></field-error> | ||
</div> | ||
|
||
<div class="form-group" bs-form-error="$ctrl.extension.enabled"> | ||
<label for="script-enabled">Enabled</label> | ||
<input type="checkbox" data-grab-focus id="script-enabled" name="enabled" data-ng-model="$ctrl.extension.enabled"> | ||
<field-error data-form-obj="script" data-field-obj="$ctrl.extension.enabled"></field-error> | ||
</div> | ||
|
||
<div class="form-group" bs-form-error="$ctrl.extension.script"> | ||
<div ui-ace="{ | ||
mode: 'javascript', | ||
firstLineNumber: 1, | ||
onLoad: $ctrl.initLoadListener() | ||
}"></div> | ||
<field-error data-form-obj="script" data-field-obj="$ctrl.extension.script"></field-error> | ||
</div> | ||
</div> | ||
<control-buttons data-form-obj="script"></control-buttons> | ||
</form> | ||
</div> |
66 changes: 66 additions & 0 deletions
66
src/main/webapp/resources/js/admin/feature/extension/add-update/extension-add-update.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
angular.module('adminApplication').component('extensionAddUpdate', { | ||
controller: ['$http', '$q', '$state', ExtensionAddUpdateCtrl], | ||
templateUrl: '../resources/js/admin/feature/extension/add-update/extension-add-update.html', | ||
bindings: { | ||
dismiss:'&', | ||
close:'&', | ||
toUpdate:'<' | ||
} | ||
}); | ||
|
||
function ExtensionAddUpdateCtrl($http, $q, $state) { | ||
var ctrl = this; | ||
ctrl.extension = null; | ||
ctrl.extensionLoader = null; | ||
|
||
ctrl.$onInit = function() { | ||
ctrl.edit = ctrl.toUpdate; | ||
if(ctrl.toUpdate) { | ||
ctrl.extensionLoader = $http.get('/admin/api/extensions/' + ctrl.toUpdate.name, {params: {path: ctrl.toUpdate.path}}); | ||
} else { | ||
ctrl.extensionLoader = $http.get('/admin/api/extensions/sample'); | ||
} | ||
ctrl.extensionLoader.then(function(res) { | ||
ctrl.extension = res.data; | ||
}); | ||
}; | ||
|
||
|
||
ctrl.save = function(extension) { | ||
$http.post('/admin/api/extensions', { | ||
path: extension.path, | ||
name: extension.name, | ||
enabled: extension.enabled, | ||
script: extension.script | ||
}).then(function() { | ||
$state.go('extension.list'); | ||
}); | ||
}; | ||
|
||
ctrl.initLoadListener = function() { | ||
return function(editor) { | ||
var session = editor.getSession(); | ||
|
||
// Options | ||
session.setUndoManager(new ace.UndoManager()); | ||
|
||
session.on("change", function(event, editor) { | ||
var newVal = editor.getValue(); | ||
var currVal = ctrl.extension.script; | ||
if(newVal !== currVal) { | ||
ctrl.extension.script = newVal; | ||
} | ||
}); | ||
|
||
ctrl.extensionLoader.then(function() { | ||
editor.setValue(ctrl.extension.script, 0); | ||
editor.clearSelection(); | ||
}); | ||
|
||
} | ||
}; | ||
} | ||
})(); |
31 changes: 31 additions & 0 deletions
31
src/main/webapp/resources/js/admin/feature/extension/extension.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<div class="container" container-fluid-responsive=""> | ||
<h1>Extension</h1> | ||
<hr> | ||
<div class="text-right"> | ||
<a class="btn btn-success" ui-sref="extension.new"><i class="fa fa-plus"></i> add new</a> | ||
</div> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>path</th> | ||
<th>name</th> | ||
<th>enabled</th> | ||
<th width="10%"><span class="sr-only">actions</span></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-if="!$ctrl.scripts || $ctrl.scripts.length == 0"> | ||
<td colspan="4">no extensions have been found.</td> | ||
</tr> | ||
<tr ng-repeat="ext in $ctrl.scripts"> | ||
<td>{{ext.path}}</td> | ||
<td>{{ext.name}}</td> | ||
<td>{{ext.enabled}}</td> | ||
<td class="text-center"> | ||
<a class="btn btn-sm btn-default" ui-sref="extension.edit({path: ext.path, name: ext.name})"><i class="fa fa-edit"></i><span class="sr-only">edit</span></a> | ||
<button class="btn btn-sm btn-danger" ng-click="$ctrl.deleteExtension(ext)"><i class="fa fa-trash"></i><span class="sr-only">delete</span></button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> |
34 changes: 34 additions & 0 deletions
34
src/main/webapp/resources/js/admin/feature/extension/extension.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
angular.module('adminApplication').component('extension', { | ||
controller: ['$http', ExtensionCtrl], | ||
templateUrl: '../resources/js/admin/feature/extension/extension.html' | ||
}); | ||
|
||
function ExtensionCtrl($http) { | ||
var ctrl = this; | ||
|
||
this.$onInit = function() { | ||
load(); | ||
}; | ||
|
||
this.deleteExtension = deleteExtension; | ||
|
||
|
||
function load() { | ||
$http.get('/admin/api/extensions').then(function(res) { | ||
ctrl.scripts = res.data; | ||
}) | ||
} | ||
|
||
function deleteExtension(extension) { | ||
if(window.confirm('Delete ' + extension.name+'?')) { | ||
$http.delete('/admin/api/extensions/'+ extension.name, {params: {path: extension.path}}).then(function () { | ||
load(); | ||
}); | ||
} | ||
} | ||
} | ||
|
||
})(); |
Oops, something went wrong.