/**
*
* Copyright (C) 2021 Akorbi Digital RMP
*
* This file is part of RunMyProcess SDK-JS.
*
* RunMyProcess SDK-JS is free software: you can redistribute it and/or modify
* it under the terms of the Apache License Version 2.0 (the "License");
*
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
Create a new instance of LogLog
@constructor
@property {Object} log - the objects log
@property {Array} links - Contains the array of links
@see ProjectApp
@see Resource
@example Load Log
var l = new LogLog();
l.load({
onSuccess:function(){
alert(JSON.stringify(l.log));
}
});
*/
function LogLog(){
this.log = {};
this.links = [];
};
/**
@borrows
Inherits Resource
*/
LogLog.prototype = new Resource();
/**
Overrides Resource's loadPreset method.
@method
@see Resource#loadPreset
*/
LogLog.prototype.loadPreset = function () {
/**
Overrides Resource's generateUrl method to return the request url
@method
@see Resource#generateUrl
*/
this.generateUrl = function () {
return "logs/log/"+context.customer_id+"/";//HARDCODED
};
};
/**
Override Resource load method.
@method
@param {object} options - options to be used during the call<br/>
@param {string} options.period - the period to load
@param {Resource~onSuccess} options.onSuccess - a callback function called in case of a success
@param {Resource~onFailure} [options.onFailure] - a callback function called in case of a failure
@param {String} [options.baseUrl] - base URL. If not set the current base URL will be used
@see Resource#load
*/
LogLog.prototype.load = function(options){
var loadOptions = {};
var father = this;
father.pagination = {};//remove current pagination
father.filters = [];//remove current filters
father.orderBy = [];//remove current orderBy
father.mode = '';
father.parameters = [];
if(options.removeDefaultFilters) father.defaultFilters = [];
father.loadPreset();
if(!jQuery.isEmptyObject(options.pagination))father.pagination = options.pagination;
if(options.mode)father.mode = options.mode;
if(options.parameters)father.parameters = options.parameters;
if(options.filters)father.filters = options.filters;
if(options.orderBy)father.orderBy = options.orderBy;
this.period = options.period;
loadOptions.onSuccess = function(rObject){
father.log = rObject.log;
father.links = rObject.links;
options.onSuccess(rObject);
};
loadOptions.onFailure = function(e){
options.eObject=e;
father.errorManager(options);
};
loadOptions.baseUrl = options.baseUrl || RMPApplication.getBaseUrl();
father.straightLoad(loadOptions);
};