implement additional actions (reason was logout functionality)

This commit is contained in:
Dennis Eichhorn 2019-12-21 10:34:59 +01:00
parent 4514673727
commit bf803f6919
5 changed files with 30 additions and 5 deletions

View File

@ -103,7 +103,7 @@ export class EventManager {
{
if (this.callbacks.hasOwnProperty(group)) {
return this.triggerSingleEvent(group, id, data);
}p
}
const allGroups = Object.keys(this.callbacks),
regex = new RegExp(group),

View File

@ -0,0 +1,19 @@
/**
* Reload dom.
*
* @param {Object} action Action data
* @param {function} callback Callback
* @param {string} id Action element
*
* @since 1.0.0
*/
export function reloadButtonAction (action, callback, id)
{
"use strict";
setTimeout(function () {
document.location.reload(true);
}, parseInt(action.delay));
callback();
};

View File

@ -11,6 +11,8 @@ export function preventEvent (action, callback, id)
{
"use strict";
console.log('prevented');
jsOMS.preventAll(action.data);
callback();

View File

@ -1,3 +1,6 @@
import { Request } from '../../../Message/Request/Request.js';
/**
* Set message.
*
@ -11,7 +14,7 @@ export function requestAction (action, callback)
"use strict";
/** global: jsOMS */
const request = new jsOMS.Message.Request.Request(action.uri, action.method, action.request_type);
const request = new Request(action.uri, action.method, action.request_type);
request.setSuccess(function(xhr) {
console.log(xhr.responseText);

View File

@ -18,6 +18,7 @@ export class ActionManager {
*/
constructor(app)
{
this.logger = Logger.getInstance();
this.app = app;
this.actions = {};
};
@ -55,7 +56,7 @@ export class ActionManager {
bindElement (e)
{
if (!jsOMS.isValidJson(e.getAttribute('data-action'))) {
jsOMS.Log.Logger.instance.error('Invalid json string: \'' + e.getAttribute('data-action') + '\'');
this.logger.error('Invalid json string: \'' + e.getAttribute('data-action') + '\'');
return;
}
@ -122,7 +123,7 @@ export class ActionManager {
for (let j = 1; j < actionLength; ++j) {
if (typeof id === 'undefined' || typeof listener.key === 'undefined') {
jsOMS.Log.Logger.instance.error('Invalid element id/key: ' + id + '/' + listener.key);
this.logger.error('Invalid element id/key: ' + id + '/' + listener.key);
return;
}
@ -162,7 +163,7 @@ export class ActionManager {
const self = this;
if (!this.actions.hasOwnProperty(action.type)) {
jsOMS.Log.Logger.instance.warning('Undefined action ' + action.type);
this.logger.warning('Undefined action ' + action.type);
return;
}