diff --git a/workflow/engine/js/strategicDashboard/viewDashboardHelper.js b/workflow/engine/js/strategicDashboard/viewDashboardHelper.js
new file mode 100644
index 000000000..ff4d2a465
--- /dev/null
+++ b/workflow/engine/js/strategicDashboard/viewDashboardHelper.js
@@ -0,0 +1,180 @@
+
+var ViewDashboardHelper = function () {
+
+};
+
+ViewDashboardHelper.prototype.userDashboards = function(userId, callBack) {
+};
+
+ViewDashboardHelper.prototype.stringIfNull = function (val){
+ if(val === null || val == undefined || val == "?"){
+ val = "?";
+ } else {
+ val = (parseFloat(val)).toFixed(2);
+ }
+ return val;
+};
+
+ViewDashboardHelper.prototype.assert = function (condition, message) {
+ if (!condition) {
+ message = message || "Assertion failed";
+ if (typeof Error !== "undefined") {
+ throw new Error(message);
+ }
+ throw message; // Fallback
+ }
+}
+
+ViewDashboardHelper.prototype.truncateString = function (string, len) {
+ this.assert(len != null && len > 0, "Var len not valid. String must by truncated to a positive non zero length.");
+ this.assert(string != null, "var string can't be null.");
+
+ var retval = "";
+ if(string.length > len){
+ retval = string.substring(0, len ) + "...";
+ }
+ else{
+ retval = string;
+ }
+ return retval;
+}
+
+ViewDashboardHelper.prototype.getKeyValue = function (obj, key, undefined) {
+ var reg = /\./gi
+ , subKey
+ , keys
+ , context
+ , x
+ ;
+
+ if (reg.test(key)) {
+ keys = key.split(reg);
+ context = obj;
+
+ for (x = 0; x < keys.length; x++) {
+ subKey = keys[x];
+
+ //the values of all keys except for
+ //the last one should be objects
+ if (x < keys.length -1) {
+ if (!context.hasOwnProperty(subKey)) {
+ return undefined;
+ }
+
+ context = context[subKey];
+ }
+ else {
+ return context[subKey];
+ }
+ }
+ }
+ else {
+ return obj[key];
+ }
+};
+
+ViewDashboardHelper.prototype.setKeyValue = function (obj, key, value) {
+ var reg = /\./gi
+ , subKey
+ , keys
+ , context
+ , x
+ ;
+
+ //check to see if we need to process
+ //multiple levels of objects
+ if (reg.test(key)) {
+ keys = key.split(reg);
+ context = obj;
+
+ for (x = 0; x < keys.length; x++) {
+ subKey = keys[x];
+
+ //the values of all keys except for
+ //the last one should be objects
+ if (x < keys.length -1) {
+ if (!context[subKey]) {
+ context[subKey] = {};
+ }
+
+ context = context[subKey];
+ }
+ else {
+ context[subKey] = value;
+ }
+ }
+ }
+ else {
+ obj[key] = value;
+ }
+};
+
+ViewDashboardHelper.prototype.merge = function (objFrom, objTo, propMap) {
+ var toKey
+ , fromKey
+ , x
+ , value
+ , def
+ , transform
+ , key
+ , keyIsArray
+ ;
+
+ if (!objTo) {
+ objTo = {};
+ }
+
+ for(fromKey in propMap) {
+ if (propMap.hasOwnProperty(fromKey)) {
+ toKey = propMap[fromKey];
+
+ //force toKey to an array of toKeys
+ if (!Array.isArray(toKey)) {
+ toKey = [toKey];
+ }
+
+ for(x = 0; x < toKey.length; x++) {
+ def = null;
+ transform = null;
+ key = toKey[x];
+ keyIsArray = Array.isArray(key);
+
+ if (typeof(key) === "object" && !keyIsArray) {
+ def = key.default || null;
+ transform = key.transform || null;
+ key = key.key;
+ //evaluate if the new key is an array
+ keyIsArray = Array.isArray(key);
+ }
+
+ if (keyIsArray) {
+ //key[toKeyName,transform,default]
+ def = key[2] || null;
+ transform = key[1] || null;
+ key = key[0];
+ }
+
+ if (def && typeof(def) === "function" ) {
+ def = def(objFrom, objTo);
+ }
+
+ value = this.getKeyValue(objFrom, fromKey);
+
+ if (transform) {
+ value = transform(value, objFrom, objTo);
+ }
+
+ if (typeof value !== 'undefined') {
+ this.setKeyValue(objTo, key, value);
+ }
+ else if (typeof def !== 'undefined') {
+ this.setKeyValue(objTo, key, def);
+ }
+ }
+ }
+ }
+
+ return objTo;
+};
+
+
diff --git a/workflow/engine/js/strategicDashboard/viewDashboardModel.js b/workflow/engine/js/strategicDashboard/viewDashboardModel.js
new file mode 100644
index 000000000..a07e4ca9c
--- /dev/null
+++ b/workflow/engine/js/strategicDashboard/viewDashboardModel.js
@@ -0,0 +1,157 @@
+
+var ViewDashboardModel = function (oauthToken, server, workspace) {
+ this.server = server;
+ this.workspace = workspace;
+ this.baseUrl = "/api/1.0/" + workspace + "/";
+ this.oauthToken = oauthToken;
+ this.helper = new ViewDashboardHelper();
+};
+
+ViewDashboardModel.prototype.userDashboards = function(userId) {
+ return this.getJson('dashboard/ownerData/' + userId);
+};
+
+ViewDashboardModel.prototype.dashboardIndicators = function(dashboardId, initDate, endDate) {
+ return this.getJson('dashboard/' + dashboardId + '/indicator?dateIni=' + initDate + '&dateFin=' + endDate);
+};
+
+ViewDashboardModel.prototype.peiData = function(indicatorId, measureDate, compareDate) {
+ var endPoint = "ReportingIndicators/process-efficiency-data?" +
+ "indicator_uid=" + indicatorId +
+ "&measure_date=" + measureDate +
+ "&compare_date=" + compareDate +
+ "&language=en";
+ return this.getJson(endPoint);
+}
+
+ViewDashboardModel.prototype.statusData = function(indicatorId, measureDate, compareDate) {
+ var endPoint = "ReportingIndicators/status-indicator";
+ return this.getJson(endPoint);
+}
+
+ViewDashboardModel.prototype.peiDetailData = function(process, initDate, endDate) {
+ var endPoint = "ReportingIndicators/process-tasks?" +
+ "process_list=" + process +
+ "&init_date=" + initDate +
+ "&end_date=" + endDate +
+ "&language=en";
+ return this.getJson(endPoint);
+}
+
+ViewDashboardModel.prototype.ueiData = function(indicatorId, measureDate, compareDate) {
+ var endPoint = "ReportingIndicators/employee-efficiency-data?" +
+ "indicator_uid=" + indicatorId +
+ "&measure_date=" + measureDate +
+ "&compare_date=" + compareDate +
+ "&language=en";
+ return this.getJson(endPoint);
+}
+
+ViewDashboardModel.prototype.ueiDetailData = function(groupId, initDate, endDate) {
+ var endPoint = "ReportingIndicators/group-employee-data?" +
+ "group_uid=" + groupId +
+ "&init_date=" + initDate +
+ "&end_date=" + endDate +
+ "&language=en";
+ return this.getJson(endPoint);
+}
+
+ViewDashboardModel.prototype.generalIndicatorData = function(indicatorId, initDate, endDate) {
+ var method = "";
+ var endPoint = "ReportingIndicators/general-indicator-data?" +
+ "indicator_uid=" + indicatorId +
+ "&init_date=" + initDate +
+ "&end_date=" + endDate +
+ "&language=en";
+ return this.getJson(endPoint);
+}
+
+ViewDashboardModel.prototype.getPositionIndicator = function(callBack) {
+ this.getJson('dashboard/config').done(function (r) {
+ var graphData = [];
+ $.each(r, function(index, originalObject) {
+ var map = {
+ "widgetId" : originalObject.widgetId,
+ "x" : originalObject.x,
+ "y" : originalObject.y,
+ "width" : originalObject.width,
+ "height" : originalObject.height
+
+ };
+ graphData.push(map);
+ });
+ callBack(graphData);
+ });
+};
+
+ViewDashboardModel.prototype.setPositionIndicator = function(data) {
+ var that = this;
+
+ this.getPositionIndicator(
+ function(response){
+ if (response.length != 0) {
+ that.putJson('dashboard/config', data);
+ } else {
+ that.postJson('dashboard/config', data);
+ }
+ }
+ );
+};
+
+ViewDashboardModel.prototype.getJson = function (endPoint) {
+ var that = this;
+ var callUrl = this.baseUrl + endPoint
+ return $.ajax({
+ url: callUrl,
+ type: 'GET',
+ datatype: 'json',
+ error: function(jqXHR, textStatus, errorThrown) {
+ throw new Error(callUrl + ' -- ' + errorThrown);
+ },
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken);
+ //xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
+ }
+ });
+}
+
+ViewDashboardModel.prototype.postJson = function (endPoint, data) {
+ var that = this;
+ return $.ajax({
+ url : this.baseUrl + endPoint,
+ type : 'POST',
+ datatype : 'json',
+ contentType: "application/json; charset=utf-8",
+ data: JSON.stringify(data),
+ error: function(jqXHR, textStatus, errorThrown) {
+ throw new Error(errorThrown);
+ },
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken);
+ xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
+ }
+ }).fail(function () {
+ throw new Error('Fail server');
+ });
+};
+
+ViewDashboardModel.prototype.putJson = function (endPoint, data) {
+ var that = this;
+ return $.ajax({
+ url : this.baseUrl + endPoint,
+ type : 'PUT',
+ datatype : 'json',
+ contentType: "application/json; charset=utf-8",
+ data: JSON.stringify(data),
+ error: function(jqXHR, textStatus, errorThrown) {
+ throw new Error(errorThrown);
+ },
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken);
+ //xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
+ }
+ }).fail(function () {
+ throw new Error('Fail server');
+ });
+};
+
diff --git a/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js b/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js
new file mode 100644
index 000000000..277a7bec9
--- /dev/null
+++ b/workflow/engine/js/strategicDashboard/viewDashboardPresenter.js
@@ -0,0 +1,359 @@
+
+
+var ViewDashboardPresenter = function (model) {
+ this.helper = new ViewDashboardHelper();
+ this.helper.assert(model != null, "A model must be passed for the presenter work.")
+ this.model = model;
+};
+
+ViewDashboardPresenter.prototype.getUserDashboards = function (userId) {
+ var that = this;
+ var requestFinished = $.Deferred();
+ this.model.userDashboards(userId)
+ .done(function(modelData){
+ var viewModel = that.userDashboardsViewModel(modelData)
+ requestFinished.resolve(viewModel);
+ });
+ return requestFinished.promise();
+};
+
+ViewDashboardPresenter.prototype.userDashboardsViewModel = function(data) {
+ var that = this;
+ //if null data is returned we default to an empty array
+ if (data == null) { data = []; }
+ var returnList = [];
+ $.each(data, function(index, originalObject) {
+ var map = {
+ "DAS_TITLE" : "title",
+ "DAS_UID" : "id",
+ "DAS_FAVORITE" : "isFavorite"
+ };
+ var newObject = that.helper.merge(originalObject, {}, map);
+ returnList.push(newObject);
+ });
+ return returnList;
+};
+
+ViewDashboardPresenter.prototype.getDashboardIndicators = function (dashboardId,initDate, endDate) {
+ if (dashboardId == null) {throw new Error ("getDashboardIndicators -> dashboardId can't be null");};
+ var that = this;
+ var requestFinished = $.Deferred();
+ this.model.dashboardIndicators (dashboardId, initDate, endDate)
+ .done(function (modelData) {
+ var viewModel = that.dashboardIndicatorsViewModel(modelData)
+ requestFinished.resolve(viewModel);
+ });
+ return requestFinished.promise();
+};
+
+ViewDashboardPresenter.prototype.dashboardIndicatorsViewModel = function(data) {
+ var that = this;
+ var returnList = [];
+ var i = 1;
+ $.each(data, function(index, originalObject) {
+ var map = {
+ "DAS_IND_UID" : "id",
+ "DAS_IND_TITLE" : "title",
+ "DAS_IND_TYPE" : "type",
+ "DAS_IND_VARIATION" : "comparative",
+ "DAS_IND_DIRECTION" : "direction",
+ "DAS_IND_VALUE" : "value",
+ "DAS_IND_X" : "x",
+ "DAS_IND_Y" : "y",
+ "DAS_IND_WIDTH" : "width",
+ "DAS_IND_HEIGHT" : "height",
+ "DAS_UID_PROCESS" : "process",
+ "PERCENTAGE_OVERDUE" : "percentageOverdue",
+ "PERCENTAGE_AT_RISK" : "percentageAtRisk",
+ "PERCENTAGE_ON_TIME" : "percentageOnTime"
+ };
+
+ var newObject = that.helper.merge(originalObject, {}, map);
+ newObject.toDrawX = newObject.x;
+ //newObject.toDrawX = (newObject.x == 0) ? 12 - 12/i : newObject.x;
+
+ newObject.toDrawY = (newObject.y == 0) ? 6 : newObject.y;
+ newObject.toDrawHeight = (newObject.y == 0) ? 2 : newObject.height;
+ newObject.toDrawWidth = (newObject.y == 0) ? 12 / data.length : newObject.width;
+ newObject.comparative = ((newObject.comparative > 0)? "+": "") + that.helper.stringIfNull(newObject.comparative);
+ newObject.directionSymbol = (newObject.direction == "1") ? "<" : ">";
+ newObject.isWellDone = (newObject.direction == "1")
+ ? parseFloat(newObject.value) <= parseFloat(newObject.comparative)
+ : parseFloat(newObject.value) >= parseFloat(newObject.comparative);
+
+ newObject.category = (newObject.type == "1010" || newObject.type == "1030")
+ ? "special"
+ : "normal";
+
+ //round goals for normal indicators
+ newObject.comparative = (newObject.category == "normal")
+ ? Math.round(newObject.comparative) + ""
+ : newObject.comparative;
+
+ newObject.value = (newObject.category == "normal")
+ ? Math.round(newObject.value) + ""
+ : Math.round(newObject.value*100)/100 + ""
+
+ newObject.favorite = 0;
+ newObject.percentageOverdue = Math.round(newObject.percentageOverdue);
+ newObject.percentageAtRisk = Math.round(newObject.percentageAtRisk);
+ //to be sure that percentages sum up to 100 (the rounding will lost decimals)%
+ newObject.percentageOnTime = 100 - newObject.percentageOverdue - newObject.percentageAtRisk;
+ newObject.overdueVisibility = (newObject.percentageOverdue > 0)? "visible" : "hidden";
+ newObject.atRiskVisiblity = (newObject.percentageAtRisk > 0)? "visible" : "hidden";
+ newObject.onTimeVisibility = (newObject.percentageOnTime > 0)? "visible" : "hidden";
+ returnList.push(newObject);
+ i++;
+ });
+
+ //sort the array for drawing in toDrawX order
+ returnList.sort(function (a, b) {
+ return ((a.toDrawX <= b.toDrawX) ? -1 : 1);
+ });
+ if (returnList.length > 0) {
+ returnList[0].favorite = 1;
+ }
+ return returnList;
+};
+
+/*++++++++ FIRST LEVEL INDICATOR DATA +++++++++++++*/
+ViewDashboardPresenter.prototype.getIndicatorData = function (indicatorId, indicatorType, initDate, endDate) {
+ var that = this;
+ var requestFinished = $.Deferred();
+ switch (indicatorType) {
+ case "1010":
+ this.model.peiData(indicatorId, initDate, endDate)
+ .done(function(modelData) {
+ var viewModel = that.peiViewModel(modelData)
+ requestFinished.resolve(viewModel);
+ });
+ break;
+ case "1030":
+ this.model.ueiData(indicatorId, initDate, endDate)
+ .done(function(modelData) {
+ var viewModel = that.ueiViewModel(modelData)
+ requestFinished.resolve(viewModel);
+ });
+ break;
+ case "1050":
+ this.model.statusData(indicatorId)
+ .done(function(modelData) {
+ var viewModel = that.statusViewModel(indicatorId, modelData)
+ requestFinished.resolve(viewModel);
+ });
+ break;
+ default:
+ this.model.generalIndicatorData(indicatorId, initDate, endDate)
+ .done(function(modelData) {
+ var viewModel = that.indicatorViewModel(modelData)
+ requestFinished.resolve(viewModel);
+ });
+ break;
+ }
+ return requestFinished.promise();
+};
+
+ViewDashboardPresenter.prototype.peiViewModel = function(data) {
+ var that = this;
+ var graphData = [];
+ $.each(data.data, function(index, originalObject) {
+ var map = {
+ "name" : "datalabel",
+ "efficiencyIndex" : "value"
+ };
+ var newObject = that.helper.merge(originalObject, {}, map);
+ var shortLabel = (newObject.datalabel == null)
+ ? ""
+ : newObject.datalabel.substring(0,15);
+
+ newObject.datalabel = shortLabel;
+ graphData.push(newObject);
+ originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost);
+ originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100;
+ originalObject.indicatorId = data.id;
+ originalObject.json = JSON.stringify(originalObject);
+ });
+
+ var retval = {};
+ //TODO selecte de 7 worst cases no the first 7
+ retval = data;
+ retval.dataToDraw = graphData.splice(0,7);
+ //TODO aumentar el símbolo de moneda $
+ retval.inefficiencyCostToShow = Math.round(retval.inefficiencyCost);
+ retval.efficiencyIndexToShow = Math.round(retval.efficiencyIndex * 100) / 100;
+ return retval;
+};
+
+ViewDashboardPresenter.prototype.ueiViewModel = function(data) {
+ var that = this;
+ var graphData = [];
+ $.each(data.data, function(index, originalObject) {
+ var map = {
+ "name" : "datalabel",
+ "averageTime" : "value",
+ "deviationTime" : "dispersion"
+ };
+ var newObject = that.helper.merge(originalObject, {}, map);
+ var shortLabel = (newObject.datalabel == null)
+ ? ""
+ : newObject.datalabel.substring(0,7);
+
+ newObject.datalabel = shortLabel;
+ graphData.push(newObject);
+ originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost);
+ originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100;
+ originalObject.indicatorId = data.id;
+ originalObject.json = JSON.stringify(originalObject);
+ });
+
+ var retval = {};
+ //TODO selecte de 7 worst cases no the first 7
+ retval = data;
+ retval.dataToDraw = graphData.splice(0,7);
+ //TODO aumentar el símbolo de moneda $
+ retval.inefficiencyCostToShow = Math.round(retval.inefficiencyCost);
+ retval.efficiencyIndexToShow = Math.round(retval.efficiencyIndex * 100) / 100;
+ return retval;
+};
+
+ViewDashboardPresenter.prototype.statusViewModel = function(indicatorId, data) {
+ var that = this;
+ data.id = indicatorId;
+ var graph1Data = [];
+ var graph2Data = [];
+ var graph3Data = [];
+ $.each(data.dataList, function(index, originalObject) {
+ var title = (originalObject.taskTitle == null)
+ ? ""
+ : originalObject.taskTitle.substring(0,15);
+ var newObject1 = {
+ datalabel : title,
+ value : originalObject.percentageTotalOverdue
+ };
+ var newObject2 = {
+ datalabel : title,
+ value : originalObject.percentageTotalAtRisk
+ };
+ var newObject3 = {
+ datalabel : title,
+ value : originalObject.percentageTotalOnTime
+ };
+
+ graph1Data.push(newObject1);
+ graph2Data.push(newObject2);
+ graph3Data.push(newObject3);
+ //we add the indicator id for reference
+ originalObject.indicatorId = indicatorId;
+ });
+
+ var retval = data;
+ //TODO selecte de 7 worst cases no the first 7
+ retval.graph1Data = graph1Data.splice(0,7)
+ retval.graph2Data = graph2Data.splice(0,7)
+ retval.graph3Data = graph3Data.splice(0,7)
+
+ return retval;
+};
+
+ViewDashboardPresenter.prototype.indicatorViewModel = function(data) {
+ var that = this;
+ $.each(data.graph1Data, function(index, originalObject) {
+ var label = (('YEAR' in originalObject) ? originalObject.YEAR : "") ;
+ label += (('MONTH' in originalObject) ? "/" + originalObject.MONTH : "") ;
+ label += (('QUARTER' in originalObject) ? "/" + originalObject.QUARTER : "");
+ label += (('SEMESTER' in originalObject) ? "/" + originalObject.SEMESTER : "");
+ originalObject.datalabel = label;
+ });
+
+ $.each(data.graph2Data, function(index, originalObject) {
+ var label = (('YEAR' in originalObject) ? originalObject.YEAR : "") ;
+ label += (('MONTH' in originalObject) ? "/" + originalObject.MONTH : "") ;
+ label += (('QUARTER' in originalObject) ? "/" + originalObject.QUARTER : "");
+ label += (('SEMESTER' in originalObject) ? "/" + originalObject.SEMESTER : "") ;
+ originalObject.datalabel = label;
+ });
+ return data;
+};
+/*-------FIRST LEVEL INDICATOR DATA */
+
+/*++++++++ SECOND LEVEL INDICATOR DATA +++++++++++++*/
+ViewDashboardPresenter.prototype.getSpecialIndicatorSecondLevel = function (entityId, indicatorType, initDate, endDate) {
+ var that = this;
+ var requestFinished = $.Deferred();
+ //entityid is the process id or group id
+ switch (indicatorType) {
+ case "1010":
+ this.model.peiDetailData(entityId, initDate, endDate)
+ .done(function (modelData) {
+ var viewModel = that.returnIndicatorSecondLevelPei(modelData);
+ requestFinished.resolve(viewModel);
+ });
+ break;
+ case "1030":
+ this.model.ueiDetailData(entityId, initDate, endDate)
+ .done(function (modelData) {
+ var viewModel = that.returnIndicatorSecondLevelUei(modelData);
+ requestFinished.resolve(viewModel);
+ });
+ break;
+ default:
+ throw new Error("Indicator type " + indicatorType + " has not detail data implemented of special indicator kind.");
+ }
+ return requestFinished.promise();
+};
+
+ViewDashboardPresenter.prototype.returnIndicatorSecondLevelPei = function(modelData) {
+ //modelData arrives in format [{users/tasks}]
+ //returns object {dataToDraw[], entityData[] //user/tasks data}
+ var that = this;
+ var graphData = [];
+ $.each(modelData, function(index, originalObject) {
+ var map = {
+ "name" : "datalabel",
+ "averageTime" : "value",
+ "deviationTime" : "dispersion"
+ };
+ var newObject = that.helper.merge(originalObject, {}, map);
+ newObject.datalabel = newObject.datalabel.substring(0, 7);
+ originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost);
+ originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100;
+ graphData.push(newObject);
+ });
+ var retval = {};
+ retval.dataToDraw = graphData.splice(0,7);
+ retval.entityData = modelData;
+ return retval;
+};
+
+ViewDashboardPresenter.prototype.returnIndicatorSecondLevelUei = function(modelData) {
+ //modelData arrives in format [{users/tasks}]
+ //returns object {dataToDraw[], entityData[] //user/tasks data}
+ var that = this;
+ var graphData = [];
+ $.each(modelData, function(index, originalObject) {
+ var map = {
+ "name" : "datalabel",
+ "averageTime" : "value",
+ "deviationTime" : "dispersion"
+ };
+ var newObject = that.helper.merge(originalObject, {}, map);
+ newObject.datalabel = ((newObject.datalabel == null) ? "" : newObject.datalabel.substring(0, 7));
+ originalObject.inefficiencyCostToShow = Math.round(originalObject.inefficiencyCost);
+ originalObject.efficiencyIndexToShow = Math.round(originalObject.efficiencyIndex * 100) / 100;
+ graphData.push(newObject);
+ });
+ var retval = {};
+ retval.dataToDraw = graphData.splice(0,7);
+ retval.entityData = modelData;
+ return retval;
+};
+/*-------SECOND LEVEL INDICATOR DATA*/
+
+
+
+
+
+
+
+
+
diff --git a/workflow/engine/js/strategicDashboard/viewDashboardView.js b/workflow/engine/js/strategicDashboard/viewDashboardView.js
new file mode 100644
index 000000000..cb707c766
--- /dev/null
+++ b/workflow/engine/js/strategicDashboard/viewDashboardView.js
@@ -0,0 +1,836 @@
+/**************************************************************/
+var WidgetBuilder = function () {
+ this.helper = new ViewDashboardHelper();
+}
+
+WidgetBuilder.prototype.getIndicatorWidget = function (indicator) {
+ var retval = null;
+ switch(indicator.type) {
+ case "1010": retval = this.buildSpecialIndicatorButton(indicator); break;
+ case "1030": retval = this.buildSpecialIndicatorButton(indicator); break;
+ case "1050": retval = this.buildStatusIndicatorButton(indicator); break;
+ case "1020":
+ case "1040":
+ case "1060":
+ case "1070":
+ case "1080":
+ retval = this.buildIndicatorButton(indicator); break;
+ }
+ if(retval == null) {throw new Error(indicator.type + " has not associated a widget.");}
+ return retval;
+};
+
+WidgetBuilder.prototype.buildSpecialIndicatorButton = function (indicator) {
+ _.templateSettings.variable = "indicator";
+ var template = _.template ($("script.specialIndicatorButtonTemplate").html());
+ var $retval = $(template(indicator));
+
+ if(indicator.comparative < 0){
+ $retval.find(".ind-container-selector").removeClass("panel-green").addClass("panel-red");
+ $retval.find(".ind-symbol-selector").removeClass("fa-chevron-up").addClass("fa-chevron-down");
+ }
+
+ if(indicator.comparative > 0){
+ $retval.find(".ind-container-selector").removeClass("panel-red").addClass("panel-green");
+ $retval.find(".ind-symbol-selector").removeClass("fa-chevron-down").addClass("fa-chevron-up");
+ }
+
+ if(indicator.comparative == 0){
+ $retval.find(".ind-symbol-selector").removeClass("fa-chevron-up");
+ $retval.find(".ind-symbol-selector").removeClass("fa-chevron-down");
+ $retval.find(".ind-symbol-selector").addClass("fa-circle-o");
+ $retval.find(".ind-container-selector").removeClass("panel-red").addClass("panel-green");
+ }
+ return $retval;
+}
+
+WidgetBuilder.prototype.buildStatusIndicatorButton = function (indicator) {
+ _.templateSettings.variable = "indicator";
+ var template = _.template ($("script.statusIndicatorButtonTemplate").html());
+ var $retval = $(template(indicator));
+ return $retval;
+}
+
+WidgetBuilder.prototype.buildIndicatorButton = function (indicator) {
+ _.templateSettings.variable = "indicator";
+ var template = _.template ($("script.statusIndicatorButtonTemplate").html());
+ var $retval = $(template(indicator));
+ var $comparative = $retval.find('.ind-comparative-selector');
+ var $title = $retval.find('.ind-title-selector');
+ if (indicator.isWellDone) {
+ $comparative.text("(" + indicator.directionSymbol + " " + indicator.comparative + "%)-"+ G_STRING.ID_WELL_DONE);
+ $retval.find(".ind-container-selector").removeClass("panel-low").addClass("panel-high");
+ }
+ else {
+ $comparative.text("Goal: " + indicator.directionSymbol + " " + indicator.comparative + "%");
+ $retval.find(".ind-container-selector").removeClass("panel-high").addClass("panel-low");
+ }
+ return $retval;
+}
+
+WidgetBuilder.prototype.buildSpecialIndicatorFirstView = function (indicatorData) {
+ if (indicatorData == null) { throw new Error ("indicatorData is null."); }
+ if (!indicatorData.hasOwnProperty("id")) { throw new Error ("indicatorData has no id."); }
+
+ _.templateSettings.variable = "indicator";
+ var template = _.template ($("script.specialIndicatorMainPanel").html());
+ var $retval = $(template(indicatorData));
+ var indicatorPrincipalData = this.getIndicatorLoadedById(indicatorData.id)
+ $retval.find('.breadcrumb').find('li').remove()
+ $retval.find('.breadcrumb').append ('
'+indicatorPrincipalData.title+'
')
+ $retval.find(".sind-index-selector").text(G_STRING.ID_EFFICIENCY_INDEX);
+ $retval.find(".sind-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST);
+ return $retval;
+}
+
+WidgetBuilder.prototype.buildSpecialIndicatorFirstViewDetail = function (oneItemDetail) {
+ //detailData = {indicatorId, uid, name, averateTime...}
+ if (oneItemDetail == null){throw new Error("oneItemDetail is null ");}
+ if (!typeof(oneItemDetail) === 'object'){throw new Error( "detailData is not and object ->" + oneItemDetail);}
+ if (!oneItemDetail.hasOwnProperty("name")){throw new Error("buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail);}
+
+ _.templateSettings.variable = "detailData";
+ var template = _.template ($("script.specialIndicatorDetail").html());
+ var $retval = $(template(oneItemDetail));
+ $retval.find(".detail-efficiency-selector").text(G_STRING.ID_EFFICIENCY_INDEX);
+ $retval.find(".detail-cost-selector").text(G_STRING.ID_EFFICIENCY_COST);
+ return $retval;
+}
+
+WidgetBuilder.prototype.buildStatusIndicatorFirstView = function (indicatorData) {
+ if (indicatorData == null) { throw new Error ("indicatorData is null."); }
+ if (!indicatorData.hasOwnProperty("id")) { throw new Error ("indicatorData has no id."); }
+
+ _.templateSettings.variable = "indicator";
+ var template = _.template ($("script.statusIndicatorMainPanel").html());
+ var $retval = $(template(indicatorData));
+ var indicatorPrincipalData = this.getIndicatorLoadedById(indicatorData.id)
+ $retval.find('.breadcrumb').find('li').remove()
+ $retval.find('.breadcrumb').append ('
'+indicatorPrincipalData.title+'
')
+ return $retval;
+}
+
+WidgetBuilder.prototype.buildStatusIndicatorFirstViewDetail = function (oneItemDetail) {
+ //detailData = {indicatorId, uid, name, averateTime...}
+ if (oneItemDetail == null){throw new Error("oneItemDetail is null ");}
+ if (!typeof(oneItemDetail) === 'object'){throw new Error( "detailData is not and object ->" + oneItemDetail);}
+ if (!oneItemDetail.hasOwnProperty("taskTitle")){throw new Error("detailData has not the name param. Has it the correct Type? ->" + oneItemDetail);}
+
+ _.templateSettings.variable = "detailData";
+ var template = _.template ($("script.statusDetail").html());
+ var $retval = $(template(oneItemDetail));
+ return $retval;
+}
+
+WidgetBuilder.prototype.buildSpecialIndicatorSecondView = function (secondViewData) {
+ //presenterData= object {dataToDraw[], entityData[] //user/tasks data}
+ _.templateSettings.variable = "indicator";
+ var template = _.template ($("script.specialIndicatorMainPanel").html());
+ var $retval = $(template(window.currentEntityData));
+ //var indicatorPrincipalData = this.getIndicatorLoadedById(indicatorId);
+ //$retval.find(".sind-title-selector").text(indicatorPrincipalData.title);
+ $retval.find(".sind-index-selector").text(G_STRING.ID_EFFICIENCY_INDEX);
+ $retval.find(".sind-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST);
+
+
+ $retval.find('.breadcrumb').find('li').remove();
+ $retval.find('.breadcrumb').append ('