Merged in dashboards2 (pull request #1955)

Dashboard refactorization and upgrades
This commit is contained in:
Julio Cesar Laura Avendaño
2015-04-20 11:46:47 -04:00
20 changed files with 2280 additions and 2022 deletions

View File

@@ -109,6 +109,7 @@ BarChart.prototype.drawBars = function(data, canvas, param) {
var currObj = this;
if (data == null || data.length == 0) {
console.log(graphDim);
canvas.append("text")
.attr('class','pm-charts-no-draw')
.attr("y", graphDim.height/2)
@@ -1385,6 +1386,7 @@ PieChart.prototype.drawPie2D = function (dataset, canvas, param) {
.enter()
.append("text")
.attr("x", width + 30)
.attr("class", "legend")
.text(function (d, i) {
return (d.datalabel + "-" + getPercent(d.value))
})

View File

@@ -337,6 +337,36 @@ class indicatorsCalculator
return $retval;
}
public function ueiCostHistoric($employeeId, $initDate, $endDate, $periodicity)
{
if (!is_a($initDate, 'DateTime')) throw new InvalidArgumentException ('initDate parameter must be a DateTime object.', 0);
if (!is_a($endDate, 'DateTime')) throw new InvalidArgumentException ('endDate parameter must be a DateTime object.', 0);
$periodicitySelectFields = $this->periodicityFieldsForSelect($periodicity);
$periodicityGroup = $this->periodicityFieldsForGrouping($periodicity);
$initYear = $initDate->format("Y");
$initMonth = $initDate->format("m");
$initDay = $endDay = 1;
$endYear = $endDate->format("Y");
$endMonth = $endDate->format("m");
//$params[":initYear"] = $initYear;
//$params[":initMonth"] = $initMonth;
$params[":endYear"] = $endYear;
$params[":endMonth"] = $endMonth;
$sqlString = "SELECT $periodicitySelectFields " . $this->ueiCostFormula . " as EEC
FROM USR_REPORTING
WHERE
IF(`YEAR` = :endYear, `MONTH`, `YEAR`) <= IF (`YEAR` = :endYear, :endMonth, :endYear)"
. $periodicityGroup;
$retval = $this->pdoExecutor($sqlString, $params);
//$retval = $this->propelExecutor($sqlString);
return $retval;
}
public function generalIndicatorData($indicatorId, $initDate, $endDate, $periodicity) {
if (!is_a($initDate, 'DateTime')) throw new InvalidArgumentException ('initDate parameter must be a DateTime object.', 0);
if (!is_a($endDate, 'DateTime')) throw new InvalidArgumentException ('endDate parameter must be a DateTime object.', 0);
@@ -443,14 +473,16 @@ class indicatorsCalculator
$sqlString = " select
i.TAS_UID as uid,
t.CON_VALUE as name,
i.efficienceIndex,
i.efficiencyIndex,
i.inefficiencyCost,
i.averageTime,
i.deviationTime,
i.configuredTime
FROM
( select
TAS_UID,
$this->peiFormula as efficienceIndex,
$this->peiFormula as efficiencyIndex,
$this->peiCostFormula as inefficiencyCost,
AVG(AVG_TIME) as averageTime,
AVG(SDV_TIME) as deviationTime,
CONFIGURED_TASK_TIME as configuredTime
@@ -468,6 +500,95 @@ class indicatorsCalculator
return $retval;
}
public function statusIndicatorGeneral ($usrUid)
{
$params[':usrUid'] = $usrUid;
$sqlString = "SELECT
COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS OVERDUE,
COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) > 0 ) , 0 ) AS ONTIME,
COALESCE( SUM( DATEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 ) , 0 ) AS ATRISK
FROM LIST_INBOX
WHERE USR_UID = :usrUid
AND APP_STATUS = 'TO_DO'
AND DEL_DUE_DATE IS NOT NULL ";
return $this->pdoExecutor($sqlString, $params);
}
public function statusIndicatorDetail ($usrUid)
{
$params[':usrUid'] = $usrUid;
$sqlString = "SELECT
TAS_UID as tasUid,
PRO_UID as proUid,
APP_TAS_TITLE AS taskTitle,
APP_PRO_TITLE AS proTitle,
COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) < 0 ) , 0 ) AS overdue,
COALESCE( SUM( DATEDIFF( DEL_DUE_DATE , NOW( ) ) > 0 ) , 0 ) AS onTime,
COALESCE( SUM( DATEDIFF( DEL_RISK_DATE , NOW( ) ) < 0 ) , 0 ) AS atRisk
FROM LIST_INBOX
WHERE USR_UID = :usrUid
AND APP_STATUS = 'TO_DO'
AND DEL_DUE_DATE IS NOT NULL
GROUP BY TAS_UID";
return $this->pdoExecutor($sqlString, $params);
}
public function statusIndicator($usrUid)
{
$response = array();
$result = $this->statusIndicatorGeneral($usrUid);
$response['overdue'] = 0;
$response['atRisk'] = 0;
$response['onTime'] = 0;
$response['percentageOverdue'] = 0;
$response['percentageAtRisk'] = 0;
$response['percentageOnTime'] = 0;
$response['dataList'] = array();
if (is_array($result) && isset($result[0])) {
$response['overdue'] = $result[0]['OVERDUE'];
$response['atRisk'] = $result[0]['ONTIME'];
$response['onTime'] = $result[0]['ATRISK'];
$total = $response['overdue'] + $response['atRisk'] + $response['onTime'];
if ($total != 0) {
$response['percentageOverdue'] = ($response['overdue']*100)/$total;
$response['percentageAtRisk'] = ($response['atRisk']*100)/$total;
$response['percentageOnTime'] = ($response['onTime']*100)/$total;
}
}
$result = $this->statusIndicatorDetail($usrUid);
foreach ($result as $key => $value) {
$result[$key]['overdue'] = $value['overdue'];
$result[$key]['atRisk'] = $value['atRisk'];
$result[$key]['onTime'] = $value['onTime'];
$result[$key]['percentageOverdue'] = 0;
$result[$key]['percentageAtRisk'] = 0;
$result[$key]['percentageOnTime'] = 0;
$result[$key]['percentageTotalOverdue'] = 0;
$result[$key]['percentageTotalAtRisk'] = 0;
$result[$key]['percentageTotalOnTime'] = 0;
$total = $value['overdue'] + $value['onTime'] + $value['atRisk'];
if ($total != 0) {
$result[$key]['percentageOverdue'] = ($value['overdue']*100)/$total;
$result[$key]['percentageAtRisk'] = ($value['atRisk']*100)/$total;
$result[$key]['percentageOnTime'] = ($value['onTime']*100)/$total;
$result[$key]['percentageTotalOverdue'] = $response['overdue'] != 0 ? ($value['overdue']*100)/$response['overdue']: 0;
$result[$key]['percentageTotalAtRisk'] = $response['atRisk'] != 0 ? ($value['atRisk']*100)/$response['atRisk'] : 0;
$result[$key]['percentageTotalOnTime'] = $response['onTime'] != 0 ? ($value['onTime']*100)/$response['onTime']: 0;
}
}
$response['dataList'] = $result;
return $response;
}
private function periodicityFieldsForSelect($periodicity) {
$periodicityFields = $this->periodicityFieldsString($periodicity);

View File

@@ -70,6 +70,28 @@ class DashboardIndicator extends BaseDashboardIndicator
$oldValue = current(reset($calculator->ueiHistoric($uid, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE)));
$row['DAS_IND_VARIATION'] = $value - $oldValue;
break;
case '1050':
$value = $calculator->statusIndicatorGeneral($userUid);
$row['OVERDUE'] = 0;
$row['ON_TIME'] = 0;
$row['AT_RISK'] = 0;
$row['PERCENTAGE_OVERDUE'] = 0;
$row['PERCENTAGE_AT_RISK'] = 0;
$row['PERCENTAGE_ON_TIME'] = 0;
if (is_array($value) && isset($value[0])) {
$row['OVERDUE'] = $value[0]['OVERDUE'];
$row['ON_TIME'] = $value[0]['ONTIME'];
$row['AT_RISK'] = $value[0]['ATRISK'];
$total = $row['OVERDUE'] + $row['AT_RISK'] + $row['ON_TIME'];
if ($total != 0) {
$row['PERCENTAGE_OVERDUE'] = ($row['OVERDUE']*100)/$total;
$row['PERCENTAGE_AT_RISK'] = ($row['AT_RISK']*100)/$total;
$row['PERCENTAGE_ON_TIME'] = ($row['ON_TIME']*100)/$total;
}
}
break;
default:
$arrResult = $calculator->generalIndicatorData($row['DAS_IND_UID'], $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE);
$value = $arrResult[0]['value'];

4
workflow/engine/data/mysql/insert.sql Executable file → Normal file
View File

@@ -59976,11 +59976,7 @@ INSERT INTO CATALOG (CAT_UID, CAT_LABEL_ID, CAT_TYPE, CAT_FLAG, CAT_OBSERVATION,
('400','ID_YEAR','PERIODICITY','','','2015-03-04','2015-03-04'),
('1010','ID_PROCESS_EFFICIENCE','INDICATOR','','','2015-03-04','2015-03-04'),
('1030','ID_EMPLYEE_EFFICIENCIE','INDICATOR','','','2015-03-04','2015-03-04'),
('1040','ID_USER_INEFFICIENCE','INDICATOR','','','2015-03-04','2015-03-04'),
('1050','ID_OVER_DUE','INDICATOR','%','Unit for displaying','2015-03-04','2015-03-04'),
('1060','ID_NEW_CASES','INDICATOR','','','2015-03-04','2015-03-04'),
('1070','ID_COMPLETED_CASES','INDICATOR','','','2015-03-04','2015-03-04'),
('1080','ID_WORKING_CASES','INDICATOR','','','2015-03-04','2015-03-04');
INSERT INTO ADDONS_MANAGER (ADDON_DESCRIPTION,ADDON_ID,ADDON_NAME,ADDON_NICK,ADDON_PUBLISHER,ADDON_RELEASE_TYPE,ADDON_STATUS,STORE_ID,ADDON_TYPE,ADDON_DOWNLOAD_URL,ADDON_VERSION,ADDON_DOWNLOAD_PROGRESS) VALUES
('Enables de Actions By Email feature.','actionsByEmail','actionsByEmail','actionsByEmail','Colosa','localRegistry','ready','00000000000000000000000000010004','features','','','0'),

View File

@@ -2789,7 +2789,7 @@ CREATE TABLE `DASHBOARD_DAS_IND`
(
`DAS_UID` VARCHAR(32) default '' NOT NULL,
`OWNER_UID` VARCHAR(32) default '' NOT NULL,
`OWNER_TYPE` VARCHAR(15) default '' NOT NULL
`OWNER_TYPE` VARCHAR(15) default '' NOT NULL,
PRIMARY KEY (`DAS_UID`),
CONSTRAINT `fk_dashboard_indicator_dashboard_das_ind`
FOREIGN KEY (`DAS_UID`)

File diff suppressed because it is too large Load Diff

View File

@@ -1,500 +0,0 @@
var getKeyValue =
function getKeyValue(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];
}
};
var setKeyValue =
function setKeyValue(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;
}
};
var merge =
function merge(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 = getKeyValue(objFrom, fromKey);
if (transform) {
value = transform(value, objFrom, objTo);
}
if (typeof value !== 'undefined') {
setKeyValue(objTo, key, value);
}
else if (typeof def !== 'undefined') {
setKeyValue(objTo, key, def);
}
}
}
}
return objTo;
};
var DashboardProxy = function (oauthToken, server, workspace) {
this.server = server;
this.workspace = workspace;
this.baseUrl = "/api/1.0/" + workspace + "/";
this.oauthToken = oauthToken;
};
DashboardProxy.prototype.userDashboards = function(userId, callBack) {
this.getJson('dashboard/ownerData/' + userId,
function (r) {
var returnList = [];
$.each(r, function(index, originalObject) {
var map = {
"DAS_TITLE" : "dashName",
"DAS_UID" : "dashUid",
"DAS_FAVORITE" : "favorite",
};
var newObject = merge(originalObject, {}, map);
returnList.push(newObject);
});
callBack(returnList);
});
};
DashboardProxy.prototype.dashboardIndicators = function(dashboardId, initDate, endDate, callBack) {
this.getJson('dashboard/' + dashboardId + '/indicator?dateIni=' + initDate + '&dateFin=' + endDate,
function (r) {
var returnList = [];
$.each(r, function(index, originalObject) {
var map = {
"DAS_IND_UID" : "indUid",
"DAS_IND_TITLE" : "indName",
"DAS_IND_TYPE" : "id",
"DAS_IND_VARIATION" : "comparative",
"DAS_IND_DIRECTION" : "direction",
"DAS_IND_VALUE" : "index",
"DAS_IND_X" : "x",
"DAS_IND_Y" : "y",
"DAS_IND_WIDTH" : "width",
"DAS_IND_HEIGHT" : "height",
"DAS_UID_PROCESS" : "process"
};
var newObject = merge(originalObject, {}, map);
//TODO do not burn this value. Data must come from the endpoint
newObject.favorite = ((returnList.length == 1) ? 1 : 0);
returnList.push(newObject);
});
callBack(returnList);
});
};
DashboardProxy.prototype.peiData = function(indicatorId, measureDate, compareDate, callBack) {
var endPoint = "ReportingIndicators/process-efficiency-data?" +
"indicator_uid=" + indicatorId +
"&measure_date=" + measureDate +
"&compare_date=" + compareDate +
"&language=en";
this.getJson(endPoint,
function (r) {
var graphData = [];
$.each(r.data, function(index, originalObject) {
var map = {
"name" : "datalabel",
"inefficiencyCost" : "value"
};
var newObject = merge(originalObject, {}, map);
var shortLabel = (newObject.datalabel == null)
? ""
: newObject.datalabel.substring(0,15);
newObject.datalabel = shortLabel;
graphData.push(newObject);
});
r.dataToDraw = graphData.splice(0,7);
callBack(r);
});
}
DashboardProxy.prototype.processTasksData = function(process, initDate, endDate, callBack) {
var endPoint = "ReportingIndicators/process-tasks?" +
"process_list=" + process +
"&init_date=" + initDate +
"&end_date=" + endDate +
"&language=en";
this.getJson(endPoint,
function (r) {
var graphData = [];
$.each(r, function(index, originalObject) {
var map = {
"name" : "datalabel",
"averageTime" : "value",
"deviationTime" : "dispersion"
};
var newObject = merge(originalObject, {}, map);
newObject.datalabel = newObject.datalabel.substring(0, 7);
graphData.push(newObject);
});
var retval = {};
retval.dataToDraw = graphData.splice(0,7);
retval.tasksData = r;
callBack(retval);
});
}
DashboardProxy.prototype.ueiData = function(indicatorId, measureDate, compareDate, callBack) {
var endPoint = "ReportingIndicators/employee-efficiency-data?" +
"indicator_uid=" + indicatorId +
"&measure_date=" + measureDate +
"&compare_date=" + compareDate +
"&language=en";
this.getJson(endPoint,
function (r) {
var graphData = [];
$.each(r.data, function(index, originalObject) {
var map = {
"name" : "datalabel",
"averageTime" : "value",
"deviationTime" : "dispersion"
};
var newObject = merge(originalObject, {}, map);
var shortLabel = (newObject.datalabel == null)
? ""
: newObject.datalabel.substring(0,7);
newObject.datalabel = shortLabel;
graphData.push(newObject);
});
r.dataToDraw = graphData.splice(0,7);
callBack(r);
});
/*var retval = {
"efficiencyIndex":1.23,
"efficiencyVariation":0.23,
"inefficiencyCost":"$ 20112.23",
"employeeGroupsDataToDraw":
[
{"value":"96", "datalabel":"User 1"},
{"value":"84", "datalabel":"User 2"},
{"value":"72", "datalabel":"User 3"},
{"value":"18", "datalabel":"User 4"},
{"value":"85", "datalabel":"User 5"}
],
"employeeGroupsData": [
{"name": "User 1", "efficiencyIndex":"0.45", "innefficiencyCost":"$ 3404"},
{"name": "User 2", "efficiencyIndex":"1.45", "innefficiencyCost":"$ 1404"},
{"name": "User 3", "efficiencyIndex":"0.25", "innefficiencyCost":"$ 3304"},
{"name": "User 4", "efficiencyIndex":"1.95", "innefficiencyCost":"$ 404"},
{"name": "User 5", "efficiencyIndex":"1.25", "innefficiencyCost":"$ 13404"},
{"name": "User 6", "efficiencyIndex":"0.75", "innefficiencyCost":"$ 4"}
]
}
return retval;*/
}
DashboardProxy.prototype.userGroupData = function(groupId, initDate, endDate, callBack) {
var endPoint = "ReportingIndicators/group-employee-data?" +
"group_uid=" + groupId +
"&init_date=" + initDate +
"&end_date=" + endDate +
"&language=en";
this.getJson(endPoint,
function (r) {
var graphData = [];
$.each(r, function(index, originalObject) {
var map = {
"name" : "datalabel",
"averageTime" : "value",
"deviationTime" : "dispersion"
};
var newObject = merge(originalObject, {}, map);
newObject.datalabel = newObject.datalabel.substring(0, 7);
graphData.push(newObject);
});
var retval = {};
retval.dataToDraw = graphData.splice(0,7);
retval.tasksData = r;
callBack(retval);
});
}
DashboardProxy.prototype.generalIndicatorData = function(indicatorId, initDate, endDate, callBack) {
var method = "";
var endPoint = "ReportingIndicators/general-indicator-data?" +
"indicator_uid=" + indicatorId +
"&init_date=" + initDate +
"&end_date=" + endDate +
"&language=en";
this.getJson(endPoint,
function (r) {
$.each(r.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(r.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;
});
callBack(r);
});
/*var retval = {
"index" : "23",
"graph1Data": [
{"value":"96", "datalabel":"User 1"},
{"value":"84", "datalabel":"User 2"},
{"value":"72", "datalabel":"User 3"},
{"value":"18", "datalabel":"User 4"},
{"value":"85", "datalabel":"User 5"}
],
"graph2Data": [
{"value":"196", "datalabel":"User 1"},
{"value":"184", "datalabel":"User 2"},
{"value":"172", "datalabel":"User 3"},
{"value":"118", "datalabel":"User 4"},
{"value":"185", "datalabel":"User 5"}
]
}
return retval;*/
}
DashboardProxy.prototype.userTasksData = function(processId, monthCompare, yearCompare) {
var retval = {
"tasksDataToDraw": [
{"value":"96", "datalabel":"Task 1"},
{"value":"84", "datalabel":"Task 2"},
{"value":"72", "datalabel":"Task 3"},
{"value":"18", "datalabel":"Task 4"},
{"value":"85", "datalabel":"Task 5"}
],
"tasksData": [
{"Name": "Task 1", "efficiencyIndex":"0.45", "deviationTime":"0.45", "averageTime":"34 days"},
{"Name": "Task 2", "efficiencyIndex":"1.45", "deviationTime":"1.45", "averageTime":"14 days"},
{"Name": "Task 3", "efficiencyIndex":"0.25", "deviationTime":"0.25", "averageTime":"3 days"},
{"Name": "Task 4", "efficiencyIndex":"1.95", "deviationTime":"1.95", "averageTime":"4 days"},
{"Name": "Task 5", "efficiencyIndex":"1.25", "deviationTime":"1.25", "averageTime":"14 days"},
{"Name": "Task 6", "efficiencyIndex":"0.75", "deviationTime":"0.75", "averageTime":"4 days"}
]
}
return retval;
}
DashboardProxy.prototype.getPositionIndicator = function(callBack) {
this.getJson('dashboard/config', 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);
});
};
DashboardProxy.prototype.setPositionIndicator = function(data, callBack) {
var that = this;
this.getPositionIndicator(
function(response){
if (response.length != 0) {
that.putJson('dashboard/config', data, function (r) {
});
} else {
that.postJson('dashboard/config', data, function (r) {
});
}
}
);
};
DashboardProxy.prototype.getJson = function (endPoint, callBack) {
var that = this;
var callUrl = this.baseUrl + endPoint
//For Debug: console.log('Llamando:');
//For Debug: console.log(callUrl)
$.ajax({
url: callUrl,
type: 'GET',
datatype: 'json',
success: function(response) { callBack(response); },
error: function(jqXHR, textStatus, errorThrown) {
throw new Error(textStatus);
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken);
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
}
});
}
DashboardProxy.prototype.postJson = function (endPoint, data, callBack) {
var that = this;
$.ajax({
url : this.baseUrl + endPoint,
type : 'POST',
datatype : 'json',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
success: function(response) {
callBack(response);
},
error: function(jqXHR, textStatus, errorThrown) {
throw new Error(textStatus);
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken);
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
}
}).fail(function () {
throw new Error('Fail server');
});
};
DashboardProxy.prototype.putJson = function (endPoint, data, callBack) {
var that = this;
$.ajax({
url : this.baseUrl + endPoint,
type : 'PUT',
datatype : 'json',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
success: function(response) {
callBack(response);
},
error: function(jqXHR, textStatus, errorThrown) {
throw new Error(textStatus);
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + that.oauthToken);
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
}
}).fail(function () {
throw new Error('Fail server');
});
};

View File

@@ -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;
};

View File

@@ -0,0 +1,194 @@
var ViewDashboardModel = function (oauthToken, server, workspace) {
this.server = server;
this.workspace = workspace;
this.baseUrl = "/api/1.0/" + workspace + "/";
//this.baseUrl = "http://127.0.0.1:8080/api/1.0/workflow/";
this.oauthToken = oauthToken;
this.helper = new ViewDashboardHelper();
this.cache = [];
this.forceRemote=false; //if true, the next call will go to the remote server
};
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, compareDate, measureDate) {
var endPoint = "ReportingIndicators/process-efficiency-data?" +
"indicator_uid=" + indicatorId +
"&compare_date=" + compareDate +
"&measure_date=" + measureDate +
"&language=en";
return this.getJson(endPoint);
}
ViewDashboardModel.prototype.statusData = function() {
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, compareDate, measureDate ) {
var endPoint = "ReportingIndicators/employee-efficiency-data?" +
"indicator_uid=" + indicatorId +
"&compare_date=" + compareDate +
"&measure_date=" + measureDate +
"&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
var requestFinished = $.Deferred();
var itemInCache = that.getCacheItem(endPoint);
if (itemInCache != null && !this.forceRemote) {
that.forceRemote = false;
requestFinished.resolve(itemInCache);
return requestFinished.promise();
}
else {
return $.ajax({
url: callUrl,
type: 'GET',
datatype: 'json',
success: function (data) {
that.forceRemote = false;
requestFinished.resolve(data);
that.putInCache(endPoint, data);
// return requestFinished.promise();
},
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');
});
};
ViewDashboardModel.prototype.getCacheItem = function (endPoint) {
var retval = null;
$.each(this.cache, function(index, objectItem) {
if (objectItem.key == endPoint) {
retval = objectItem.value;
}
});
return retval;
}
ViewDashboardModel.prototype.putInCache = function (endPoint, data) {
var cacheItem = this.getCacheItem(endPoint);
if (cacheItem == null) {
this.cache.push ({ key: endPoint, value:data });
}
else {
cacheItem.value = data;
}
}

View File

@@ -0,0 +1,381 @@
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();
that.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",
"inefficiencyCost" : "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 = {};
retval = data;
graphData.sort(function(a,b) {
var retval = 0;
retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1);
return retval;
})
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",
"inefficiencyCost" : "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 = {};
retval = data;
graphData.sort(function(a,b) {
var retval = 0;
retval = ((a.value*1.0 <= b.value*1.0) ? 1 : -1);
return retval;
})
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();
//if modelData is passed (because it was cached on the view) no call is made to the server.
//and just a order is applied to the list
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 == 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;
};
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*/
ViewDashboardPresenter.prototype.orderDataList = function(listData, orderDirection, orderFunction) {
//orderDirection is passed in case no order FUnction is passed (to use in the default ordering)
var orderToUse = orderFunction;
if (orderFunction == undefined) {
orderToUse = function (a ,b) {
var retval = 0;
if (orderDirection == "down") {
retval = ((a.inefficiencyCost*1.0 <= b.inefficiencyCost*1.0) ? 1 : -1);
}
else {
//the 1,-1 are flipped
retval = ((a.inefficiencyCost*1.0 <= b.inefficiencyCost*1.0) ? -1 : 1);
}
return retval;
}
}
return listData.sort(orderToUse);
}

View File

@@ -0,0 +1,904 @@
/**************************************************************/
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 ('<li><b>'+indicatorPrincipalData.title+'</b></li>')
$retval.find(".sind-index-selector").text(G_STRING.ID_EFFICIENCY_INDEX);
$retval.find(".sind-cost-selector").text(G_STRING.ID_INEFFICIENCY_COST);
this.setColorForInefficiency($retval.find(".sind-cost-number-selector"), indicatorData);
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_INEFFICIENCY_COST);
this.setColorForInefficiency($retval.find(".detail-cost-number-selector"), oneItemDetail);
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 ('<li><b>'+indicatorPrincipalData.title+'</b></li>')
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 ('<li><a class="bread-back-selector" href="#"><i class="fa fa-chevron-left fa-fw"></i>' + window.currentIndicator.title + '</a></li>');
$retval.find('.breadcrumb').append ('<li><b>' + window.currentEntityData.name + '</b></li>');
this.setColorForInefficiency($retval.find(".sind-cost-number-selector"), window.currentEntityData);
return $retval;
};
WidgetBuilder.prototype.buildSpecialIndicatorSecondViewDetail = function (oneItemDetail) {
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.specialIndicatorSencondViewDetail").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_INEFFICIENCY_COST);
this.setColorForInefficiency($retval.find(".detail-cost-number-selector"), oneItemDetail);
return $retval;
}
WidgetBuilder.prototype.getIndicatorLoadedById = function (searchedIndicatorId) {
var retval = null;
for (key in window.loadedIndicators) {
var indicator = window.loadedIndicators[key];
if (indicator.id == searchedIndicatorId) {
retval = indicator;
}
}
if (retval == null) { throw new Error(searchedIndicatorId + " was not found in the loaded indicators.");}
return retval;
}
WidgetBuilder.prototype.buildGeneralIndicatorFirstView = function (indicatorData) {
_.templateSettings.variable = "indicator";
var template = _.template ($("script.generalIndicatorMainPanel").html());
var $retval = $(template(indicatorData));
$retval.find(".ind-title-selector").text(window.currentIndicator.title);
return $retval;
}
WidgetBuilder.prototype.setColorForInefficiency = function ($widget, indicatorData) {
//turn red/gree the font according if is positive or negative: var $widget = $retval.find(".sind-cost-number-selector");
$widget.removeClass("red");
$widget.removeClass("green");
if (indicatorData.inefficiencyCost >= 0) {
$widget.addClass("green");
}
else {
$widget.addClass("red");
}
}
/**********************************************************************/
helper = new ViewDashboardHelper();
var ws = urlProxy.split('/');
model = new ViewDashboardModel(token, urlProxy, ws[3]);
presenter = new ViewDashboardPresenter(model);
window.loadedIndicators = []; //updated in das-title-selector.click->fillIndicatorWidgets, ready->fillIndicatorWidgets
window.currentEntityData = null;
window.currentIndicator = null;//updated in ind-button-selector.click ->loadIndicator, ready->loadIndicator
window.currentDashboardId = null;
window.currentDetailFunction = null;
window.currentDetailList = null;
$(document).ready(function() {
$('#indicatorsGridStack').gridstack();
$('#indicatorsDataGridStack').gridstack();
$('#relatedDetailGridStack').gridstack();
$('#sortListButton').click(function() {
var btn = $(this);
if (btn.hasClass('fa-chevron-up')) {
btn.removeClass('fa-chevron-up');
btn.addClass('fa-chevron-down');
}
else {
btn.removeClass('fa-chevron-down');
btn.addClass('fa-chevron-up');
}
window.currentDetailFunction (presenter.orderDataList (
window.currentDetailList,
selectedOrderOfDetailList()));
//send scroll +1 and -1 to activate the show/hide event.
//both scrolls are sent cause if the scroll at the end
//scroll +1 has no effect but -1 yes
$(window).scrollTop($(window).scrollTop() + 1);
$(window).scrollTop($(window).scrollTop() - 1);
return false;
});
/* Show on scroll functionality */
$(window).scroll( function() {
/* Check the location of each desired element */
$('.hideme').each( function(i){
var bottom_of_object = $(this).offset().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* If the object is completely visible in the window, fade it in */
if (bottom_of_window + 100 > bottom_of_object) {
$(this).animate({'opacity':'1'}, 500);
$(this).removeClass('hideme');
}
});
hideScrollIfAllDivsAreVisible();
});
var isHover = false;
$('#scrollImg').mouseover(function() {
isHover = true;
var interval = window.setInterval(function () {
var newPos = $(window).scrollTop() + 100;
$(window).scrollTop(newPos);
if (isHover == false) {
window.clearInterval(interval);
}
}, 200);
});
$('#scrollImg').mouseleave(function() {
isHover = false;
});
//When some item is moved
$('.grid-stack').on('change', function (e, items) {
var widgets = [];
_.map($('.grid-stack .grid-stack-item:visible'), function (el) {
el = $(el);
var item = el.data('_gridstack_node');
var idWidGet = el.data("indicator-id");
/*if(favorite == actualDashId){
favoriteData = 1;
} else {
favoriteData = 0;
}*/
if (typeof idWidGet != "undefined") {
var widgetsObj = {
'indicatorId': idWidGet,
'x': item.x,
'y': item.y,
'width': item.width,
'height': item.height <= 1 ? 2 : item.height
}
widgets.push(widgetsObj);
}
});
var favoriteDasbhoardId = $('.das-icon-selector.selected').parent().data('dashboard-id');
if (favoriteDasbhoardId == null || favoriteDasbhoardId == 'undefined') {throw new Error ('No favorite dashboard detected');}
if (widgets.length != 0) {
var dashboard = {
'dashId': window.currentDashboardId,
'dashFavorite': ((window.currentDashboardId == favoriteDasbhoardId) ? 1 : 0),
'dashData': widgets
}
model.setPositionIndicator(dashboard);
}
});
$('body').on('click', '.das-icon-selector', function() {
var dashboardId = $(this).parent().data('dashboard-id');
$('.das-icon-selector').removeClass("selected");
$(this).addClass('selected');
var dashboard = {
'dashId': dashboardId,
'dashFavorite': 1,
'dashData': ''
}
model.setPositionIndicator(dashboard);
});
/*-------------------------------clicks----------------------------*/
$('body').on('click','.btn-compare', function() {
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
.done(function(indicatorsVM) {
fillIndicatorWidgets(indicatorsVM);
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
});
});
$('#dashboardsList').on('click','.das-title-selector', function() {
var dashboardId = $(this).parent().data('dashboard-id');
window.currentDashboardId = dashboardId;
presenter.getDashboardIndicators(dashboardId, defaultInitDate(), defaultEndDate())
.done(function(indicatorsVM) {
fillIndicatorWidgets(indicatorsVM);
//TODO use real data
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
});
});
$('#indicatorsGridStack').on('click','.ind-button-selector', function() {
var indicatorId = $(this).data('indicator-id');
//TODO use real data
loadIndicator(indicatorId, defaultInitDate(), defaultEndDate());
});
$('body').on('click','.bread-back-selector', function() {
var indicatorId = window.currentIndicator.id;
//TODO use real data
loadIndicator(indicatorId, defaultInitDate(), defaultEndDate());
return false;
});
$('#relatedDetailGridStack').on('click','.detail-button-selector', function() {
var detailId = $(this).data('detail-id');
window.currentEntityData = {"entityId":$(this).data('detail-id'),
"indicatorId":$(this).data('indicator-id'),
"efficiencyIndexToShow":$(this).data('detail-index'),
"inefficiencyCostToShow":$(this).data('detail-cost-to-show'),
"inefficiencyCost":$(this).data('detail-cost'),
"name":$(this).data('detail-name')
};
//TODO PASS REAL VALUES
presenter.getSpecialIndicatorSecondLevel(detailId, window.currentIndicator.type, defaultInitDate(), defaultEndDate())
.done(function (viewModel) {
fillSpecialIndicatorSecondView(viewModel);
});
});
initialDraw();
});
var hideScrollIfAllDivsAreVisible = function(){
if ($('.hideme').length <= 0) {
$('#scrollImg').hide();
}
else {
$('#scrollImg').show();
}
}
var selectedOrderOfDetailList = function () {
return ($('#sortListButton').hasClass('fa-chevron-up') ? "up" : "down");
}
var initialDraw = function () {
presenter.getUserDashboards(pageUserId)
.then(function(dashboardsVM) {
fillDashboardsList(dashboardsVM);
/**** window initialization with favorite dashboard*****/
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
.done(function(indicatorsVM) {
fillIndicatorWidgets(indicatorsVM);
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
});
});
}
var loadIndicator = function (indicatorId, initDate, endDate) {
var builder = new WidgetBuilder();
window.currentIndicator = builder.getIndicatorLoadedById(indicatorId);
presenter.getIndicatorData(indicatorId, window.currentIndicator.type, initDate, endDate)
.done(function (viewModel) {
switch (window.currentIndicator.type) {
case "1010":
case "1030":
fillSpecialIndicatorFirstView(viewModel);
break;
case "1050":
fillStatusIndicatorFirstView(viewModel);
break;
default:
fillGeneralIndicatorFirstView(viewModel);
break;
}
});
}
var setIndicatorActiveMarker = function () {
$('.panel-footer').each (function () {
$(this).removeClass('panel-active');
var indicatorId = $(this).parents('.ind-button-selector').data('indicator-id');
if (window.currentIndicator.id == indicatorId) {
$(this).addClass('panel-active');
}
});
}
var getFavoriteIndicator = function() {
var retval = (window.loadedIndicators.length > 0)
? window.loadedIndicators[0]
: null;
for (key in window.loadedIndicators) {
var indicator = window.loadedIndicators[key];
if (indicator.favorite == 1) {
retval = indicator;
}
}
if (retval==null) {throw new Error ('No favorites found.');}
return retval;
}
var defaultInitDate = function() {
var date = new Date();
var dateMonth = date.getMonth();
var dateYear = date.getFullYear();
var initDate = $('#year').val() + '-' + $('#month').val() + '-' + '01';
return initDate;
}
var defaultEndDate = function () {
var date = new Date();
var dateMonth = date.getMonth();
var dateYear = date.getFullYear();
return dateYear + "-" + (dateMonth + 1) + "-30";
}
var fillDashboardsList = function (presenterData) {
if (presenterData == null || presenterData.length == 0) {
$('#dashboardsList').append(G_STRING['ID_NO_DATA_TO_DISPLAY']);
}
_.templateSettings.variable = "dashboard";
var template = _.template ($("script.dashboardButtonTemplate").html())
for (key in presenterData) {
var dashboard = presenterData[key];
$('#dashboardsList').append(template(dashboard));
if (dashboard.isFavorite == 1) {
window.currentDashboardId = dashboard.id;
$('#dashboardButton-' + dashboard.id)
.find('.das-icon-selector')
.addClass('selected');
}
}
};
var fillIndicatorWidgets = function (presenterData) {
var widgetBuilder = new WidgetBuilder();
var grid = $('#indicatorsGridStack').data('gridstack');
grid.remove_all();
window.loadedIndicators = presenterData;
$.each(presenterData, function(key, indicator) {
var $widget = widgetBuilder.getIndicatorWidget(indicator);
grid.add_widget($widget, indicator.toDrawX, indicator.toDrawY, indicator.toDrawWidth, indicator.toDrawHeight, true);
//TODO will exist animation?
/*if (indicator.category == "normal") {
animateProgress(indicator, $widget);
}*/
var $title = $widget.find('.ind-title-selector');
if (indicator.favorite == "1") {
$title.addClass("panel-active");
}
});
}
var fillStatusIndicatorFirstView = function (presenterData) {
var widgetBuilder = new WidgetBuilder();
var panel = $('#indicatorsDataGridStack').data('gridstack');
panel.remove_all();
$('#relatedDetailGridStack').data('gridstack').remove_all();
var $widget = widgetBuilder.buildStatusIndicatorFirstView(presenterData);
panel.add_widget($widget, 0, 15, 20, 4.7, true);
var graphParams1 = {
canvas : {
containerId:'graph1',
width:300,
height:300,
stretch:true
},
graph: {
allowDrillDown:false,
allowTransition:true,
showTip: true,
allowZoom: false,
gapWidth:0.2,
useShadows: true,
thickness: 30,
showLabels: true,
colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a']
}
};
var graph1 = new PieChart(presenterData.graph1Data, graphParams1, null, null);
graph1.drawChart();
var graphParams2 = graphParams1;
graphParams2.canvas.containerId = "graph2";
var graph2 = new PieChart(presenterData.graph2Data, graphParams2, null, null);
graph2.drawChart();
var graphParams3 = graphParams1;
graphParams3.canvas.containerId = "graph3";
var graph3 = new PieChart(presenterData.graph3Data, graphParams3, null, null);
graph3.drawChart();
var indicatorPrincipalData = widgetBuilder.getIndicatorLoadedById(presenterData.id)
setIndicatorActiveMarker();
}
var fillStatusIndicatorFirstViewDetail = function(presenterData) {
var widgetBuilder = new WidgetBuilder();
var gridDetail = $('#relatedDetailGridStack').data('gridstack');
//gridDetail.remove_all();
$.each(presenterData.dataList, function(index, dataItem) {
var $widget = widgetBuilder.buildStatusIndicatorFirstViewDetail(dataItem);
var x = (index % 2 == 0) ? 6 : 0;
gridDetail.add_widget($widget, x, 15, 6, 2, true);
});
if (window.currentIndicator.type == "1010") {
$('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_PROCESS']);
}
if (window.currentIndicator.type == "1030") {
$('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_GROUPS']);
}
if (window.currentIndicator.type == "1050") {
$('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_PROCESS']);
}
}
var fillSpecialIndicatorFirstView = function(presenterData) {
var widgetBuilder = new WidgetBuilder();
var panel = $('#indicatorsDataGridStack').data('gridstack');
panel.remove_all();
$('#relatedDetailGridStack').data('gridstack').remove_all();
var $widget = widgetBuilder.buildSpecialIndicatorFirstView(presenterData);
panel.add_widget($widget, 0, 15, 20, 4.7, true);
var peiParams = {
canvas : {
containerId:'specialIndicatorGraph',
width:300,
height:300,
stretch:true
},
graph: {
allowDrillDown:false,
allowTransition:true,
showTip: true,
allowZoom: false,
gapWidth:0.3,
useShadows: true,
thickness: 30,
showLabels: true,
colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a']
}
};
var ueiParams = {
canvas : {
containerId:'specialIndicatorGraph',
width:500,
height:300,
stretch:true
},
graph: {
allowDrillDown:false,
allowTransition:true,
axisX:{ showAxis: true, label: G_STRING.ID_YEAR },
axisY:{ showAxis: true, label: "Q" },
gridLinesX:false,
gridLinesY:true,
showTip: true,
allowZoom: false,
useShadows: true,
paddingTop: 50,
colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a','#74a9a9']
}
};
var indicatorPrincipalData = widgetBuilder.getIndicatorLoadedById(presenterData.id)
if (indicatorPrincipalData.type == "1010") {
var graph = new Pie3DChart(presenterData.dataToDraw, peiParams, null, null);
graph.drawChart();
//the pie chart goes to much upwards,so a margin is added:
$('#specialIndicatorGraph').css('margin-top','60px');
}
if (indicatorPrincipalData.type == "1030") {
var graph = new BarChart(presenterData.dataToDraw, ueiParams, null, null);
graph.drawChart();
}
this.fillSpecialIndicatorFirstViewDetail(presenter.orderDataList(presenterData.data, selectedOrderOfDetailList()));
setIndicatorActiveMarker();
}
var fillSpecialIndicatorFirstViewDetail = function (list) {
//presenterData = { id: "indId", efficiencyIndex: "0.11764706", efficiencyVariation: -0.08235294,
// inefficiencyCost: "-127.5000", inefficiencyCostToShow: -127, efficiencyIndexToShow: 0.12
// data: {indicatorId, uid, name, averateTime...}, dataToDraw: [{datalabe, value}] }
var widgetBuilder = new WidgetBuilder();
var gridDetail = $('#relatedDetailGridStack').data('gridstack');
gridDetail.remove_all();
window.currentDetailList = list;
window.currentDetailFunction = fillSpecialIndicatorFirstViewDetail;
$.each(list, function(index, dataItem) {
var $widget = widgetBuilder.buildSpecialIndicatorFirstViewDetail(dataItem);
var x = (index % 2 == 0) ? 6 : 0;
//the first 2 elements are not hidden
if (index < 2) {
$widget.removeClass("hideme");
}
gridDetail.add_widget($widget, x, 15, 6, 2, true);
});
if (window.currentIndicator.type == "1010") {
$('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_PROCESS']);
}
if (window.currentIndicator.type == "1030") {
$('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_GROUPS']);
}
hideScrollIfAllDivsAreVisible();
}
var fillSpecialIndicatorSecondView = function(presenterData) {
//presenterData= object {dataToDraw[], entityData[] //user/tasks data}
var widgetBuilder = new WidgetBuilder();
var panel = $('#indicatorsDataGridStack').data('gridstack');
panel.remove_all();
var $widget = widgetBuilder.buildSpecialIndicatorSecondView(presenterData);
panel.add_widget($widget, 0, 15, 20, 4.7, true);
var detailParams = {
canvas : {
containerId:'specialIndicatorGraph',
width:300,
height:300,
stretch:true
},
graph: {
allowTransition: false,
allowDrillDown: true,
showTip: true,
allowZoom: false,
useShadows: false,
gridLinesX: true,
gridLinesY: true,
area: {visible: false, css:"area"},
axisX:{ showAxis: true, label: G_STRING.ID_USERS },
axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS },
showErrorBars: true
}
};
var indicatorPrincipalData = widgetBuilder.getIndicatorLoadedById(window.currentEntityData.indicatorId);
if (window.currentIndicator.type == "1010") {
var graph = new BarChart(presenterData.dataToDraw, detailParams, null, null);
graph.drawChart();
}
if (window.currentIndicator.type == "1030") {
var graph = new BarChart(presenterData.dataToDraw, detailParams, null, null);
graph.drawChart();
}
this.fillSpecialIndicatorSecondViewDetail(presenter.orderDataList(presenterData.entityData, selectedOrderOfDetailList()));
}
var fillSpecialIndicatorSecondViewDetail = function (list) {
//presenterData = { entityData: Array[{name,uid,inefficiencyCost,
// inefficiencyIndex, deviationTime,
// averageTime}],
// dataToDraw: Array[{datalabel, value}] }
var widgetBuilder = new WidgetBuilder();
var gridDetail = $('#relatedDetailGridStack').data('gridstack');
gridDetail.remove_all();
window.currentDetailList = list;
window.currentDetailFunction = fillSpecialIndicatorSecondViewDetail;
$.each(list, function(index, dataItem) {
var $widget = widgetBuilder.buildSpecialIndicatorSecondViewDetail(dataItem);
var x = (index % 2 == 0) ? 6 : 0;
//the first 2 elements are not hidden
if (index < 2) {
$widget.removeClass("hideme");
}
gridDetail.add_widget($widget, x, 15, 6, 2, true);
});
if (window.currentIndicator.type == "1010") {
$('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_TASKS']);
}
if (window.currentIndicator.type == "1030") {
$('#relatedLabel').find('h3').text(G_STRING['ID_RELATED_USERS']);
}
hideScrollIfAllDivsAreVisible();
}
var fillGeneralIndicatorFirstView = function (presenterData) {
var widgetBuilder = new WidgetBuilder();
var panel = $('#indicatorsDataGridStack').data('gridstack');
panel.remove_all();
$('#relatedDetailGridStack').data('gridstack').remove_all();
var $widget = widgetBuilder.buildGeneralIndicatorFirstView(presenterData);
panel.add_widget($widget, 0, 15, 20, 4.7, true);
$('#relatedLabel').find('h3').text('');
var generalLineParams1 = {
canvas : {
containerId:'generalGraph1',
width:300,
height:300,
stretch:true
},
graph: {
allowTransition: false,
allowDrillDown: true,
showTip: true,
allowZoom: false,
useShadows: false,
gridLinesX: true,
gridLinesY: true,
area: {visible: false, css:"area"},
axisX:{ showAxis: true, label: G_STRING.ID_PROCESS_TASKS },
axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS },
showErrorBars: false
}
};
var generalLineParams2 = {
canvas : {
containerId:'generalGraph2',
width:300,
height:300,
stretch:true
},
graph: {
allowTransition: false,
allowDrillDown: true,
showTip: true,
allowZoom: false,
useShadows: false,
gridLinesX: true,
gridLinesY: true,
area: {visible: false, css:"area"},
axisX:{ showAxis: true, label: G_STRING.ID_PROCESS_TASKS },
axisY:{ showAxis: true, label: G_STRING.ID_TIME_HOURS },
showErrorBars: false
}
};
var generalBarParams1 = {
canvas : {
containerId:'generalGraph1',
width:300,
height:300,
stretch:true
},
graph: {
allowDrillDown:false,
allowTransition:true,
axisX:{ showAxis: true, label: G_STRING.ID_YEAR },
axisY:{ showAxis: true, label: "Q" },
gridLinesX:false,
gridLinesY:true,
showTip: true,
allowZoom: false,
useShadows: true,
paddingTop: 50,
colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a','#74a9a9']
}
};
var generalBarParams2 = {
canvas : {
containerId:'generalGraph2',
width:300,
height:300,
stretch:true
},
graph: {
allowDrillDown:false,
allowTransition:true,
axisX:{ showAxis: true, label: G_STRING.ID_YEAR },
axisY:{ showAxis: true, label: "Q" },
gridLinesX:false,
gridLinesY:true,
showTip: true,
allowZoom: false,
useShadows: true,
paddingTop: 50,
colorPalette: ['#5486bf','#bf8d54','#acb30c','#7a0c0c','#bc0000','#906090','#007efb','#62284a','#0c7a7a','#74a9a9']
}
};
var graph1 = null;
if (presenterData.graph1Type == '10') {
generalBarParams1.graph.axisX.label = presenterData.graph1XLabel;
generalBarParams1.graph.axisY.label = presenterData.graph1YLabel;
graph1 = new BarChart(presenterData.graph1Data, generalBarParams1, null, null);
} else {
generalLineParams1.graph.axisX.label = presenterData.graph1XLabel;
generalLineParams1.graph.axisY.label = presenterData.graph1YLabel;
graph1 = new LineChart(presenterData.graph1Data, generalLineParams1, null, null);
}
graph1.drawChart();
var graph2 = null;
if (presenterData.graph2Type == '10') {
generalBarParams2.graph.axisX.label = presenterData.graph2XLabel;
generalBarParams2.graph.axisY.label = presenterData.graph2YLabel;
graph2 = new BarChart(presenterData.graph2Data, generalBarParams2, null, null);
} else {
generalLineParams2.graph.axisX.label = presenterData.graph2XLabel;
generalLineParams2.graph.axisY.label = presenterData.graph2YLabel;
graph2 = new LineChart(presenterData.graph2Data, generalLineParams2, null, null);
}
graph2.drawChart();
setIndicatorActiveMarker();
}
var animateProgress = function (indicatorItem, widget){
var getRequestAnimationFrame = function () {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function ( callback ){
window.setTimeout(enroute, 1 / 60 * 1000);
};
};
var fpAnimationFrame = getRequestAnimationFrame();
var i = 0;
var j = 0;
var indicator = indicatorItem;
var animacion = function () {
var intComparative = parseInt(indicator.comparative);
var divId = "#indicatorButton" + indicator.id;
var $valueLabel = widget
.find('.ind-value-selector');
var $progressBar = widget
.find('.ind-progress-selector');
if (!($valueLabel.length > 0)) {throw new Error ('"No ind-value-selector found for " + divId');}
this.helper.assert($progressBar.length > 0, "No ind-progress-selector found for " + divId);
$progressBar.attr('aria-valuemax', intComparative);
var indexToPaint = Math.min(indicator.value * 100 / intComparative, 100);
if (i <= indexToPaint) {
$progressBar.css('width', i+'%').attr('aria-valuenow', i);
i++;
fpAnimationFrame(animacion);
}
if(j <= indicator.value){
$valueLabel.text(j + "%");
j++;
fpAnimationFrame(animacion);
}
}
fpAnimationFrame(animacion);
};
/*var dashboardButtonTemplate = ' <div class="btn-group pull-left"> \
<button id="favorite" type="button" class="btn btn-success"><i class="fa fa-star fa-1x"></i></button> \
<button id="dasB" type="button" class="btn btn-success">'+ G_STRING.ID_MANAGERS_DASHBOARDS +'</button> \
</div>';*/

View File

@@ -42,7 +42,7 @@ GROUP BY APPLICATION.PRO_UID;
UPDATE PRO_REPORTING
SET PRO_REPORTING.CONFIGURED_PROCESS_TIME = (
SELECT SUM(if (TASK.TAS_TIMEUNIT = "DAYS", (TASK.TAS_DURATION*8), TASK.TAS_DURATION))
SELECT SUM(if (TASK.TAS_TIMEUNIT = "DAYS", (TASK.TAS_DURATION*24), TASK.TAS_DURATION))
FROM TASK
WHERE PRO_REPORTING.PRO_UID = TASK.PRO_UID
);

View File

@@ -55,7 +55,7 @@ UPDATE USR_REPORTING
INNER JOIN
TASK
ON USR_REPORTING.TAS_UID = TASK.TAS_UID
SET USR_REPORTING.CONFIGURED_TASK_TIME = if (TASK.TAS_TIMEUNIT = "DAYS", (TASK.TAS_DURATION*8), TASK.TAS_DURATION)
SET USR_REPORTING.CONFIGURED_TASK_TIME = if (TASK.TAS_TIMEUNIT = "DAYS", (TASK.TAS_DURATION*24), TASK.TAS_DURATION)

View File

@@ -18,7 +18,7 @@ class ReportingIndicators
*
* return decimal value
*/
public function getPeiCompleteData($indicatorUid, $measureDate, $compareDate, $language)
public function getPeiCompleteData($indicatorUid, $compareDate, $measureDate, $language)
{
G::loadClass('indicatorsCalculator');
$calculator = new \IndicatorsCalculator();
@@ -30,7 +30,10 @@ class ReportingIndicators
$peiCost = current(reset($calculator->peiCostHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$peiCompare = current(reset($calculator->peiHistoric($processesId, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE)));
$retval = array("efficiencyIndex" => $peiValue,
$retval = array(
"id" => $indicatorUid,
"efficiencyIndex" => $peiValue,
"efficiencyIndexCompare" => $peiCompare,
"efficiencyVariation" => ($peiValue-$peiCompare),
"inefficiencyCost" => $peiCost,
"data"=>$processes);
@@ -47,32 +50,22 @@ class ReportingIndicators
*
* return decimal value
*/
public function getUeiCompleteData($indicatorUid, $measureDate, $compareDate, $language)
public function getUeiCompleteData($indicatorUid, $compareDate, $measureDate,$language)
{
G::loadClass('indicatorsCalculator');
$calculator = new \IndicatorsCalculator();
$groups = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language);
$groupIds = array();
foreach($groups as $p) {
array_push($groupIds, $p['uid']);
}
if (sizeof($groupIds) == 0) {
$groupIds = null;
}
//TODO think what if each indicators has a group or user subset assigned. Now are all
$ueiValue = current(reset($calculator->ueiHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$arrCost = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language);
$ueiCost = (sizeof($arrCost) > 0)
? $arrCost[0]['inefficiencyCost']
: null;
$ueiCost = current(reset($calculator->ueiCostHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$ueiCompare = current(reset($calculator->ueiHistoric(null, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE)));
$retval = array("efficiencyIndex" => $ueiValue,
$retval = array(
"id" => $indicatorUid,
"efficiencyIndex" => $ueiValue,
"efficiencyVariation" => ($ueiValue-$ueiCompare),
"inefficiencyCost" => $ueiCost,
"data"=>$groups);
@@ -296,5 +289,27 @@ class ReportingIndicators
);
return $returnValue;
}
/**
* Get list status indicator
*
* @access public
* @param array $options, Data for list
* @return array
*
* @author Marco Antonio Nina <marco.antonio.nina@colosa.com>
* @copyright Colosa - Bolivia
*/
public function getStatusIndicator($options = array())
{
Validator::isArray($options, '$options');
$usrUid = isset( $options["usrUid"] ) ? $options["usrUid"] : "";
G::loadClass('indicatorsCalculator');
$calculator = new \IndicatorsCalculator();
$result = $calculator->statusIndicator($usrUid);
return $result;
}
}

View File

@@ -71,223 +71,6 @@ class ReportingIndicators extends Api
}
}
// /**
// * Returns the aggregate Efficiency of a employee or set of employees
// *
// * @param string $employee_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @return array
// *
// * @url GET /employee-efficiency-index
// */
// public function doGetEmployeeEfficiencyIndex($employee_list, $init_date, $end_date)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($employee_list) > 1)
// ? $listArray = explode(',', $employee_list)
// : null;
// $response = $indicatorsObj->getEmployeeEfficiencyIndex($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date));
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Lists tasks of a employee and it's statistics (efficiency, average times, etc.)
// *
// * @param string $employee_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @param string $language {@from path}
// * @return array
// *
// * @url GET /employee-tasks
// */
// public function doGetEmployeeTasksInfo($employee_list, $init_date, $end_date, $language)
// {
// if ($employee_list == null || strlen($employee_list) <= 1)
// throw new InvalidArgumentException ('employee_list must have at least a value', 0);
//
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = $listArray = explode(',', $employee_list);
// $response = $indicatorsObj->getEmployeeTasksInfoList($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date),
// $language);
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the percent of Cases with Overdue time
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @return array
// *
// * @url GET /percent-overdue-cases
// */
// public function doGetPercentOverdueByProcess($process_list, $init_date, $end_date)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentOverdueCasesByProcess($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date));
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the percent of Cases with Overdue time with the selected periodicity
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @param string $periodicity {@from path}
// * @return array
// *
// * @url GET /percent-overdue-cases-history
// */
// public function doGetPercentOverdueByProcessHistory($process_list, $init_date, $end_date, $periodicity)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentOverdueCasesByProcessHistory($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date),
// $periodicity);
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the total of Cases with New time
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @return array
// *
// * @url GET /total-new-cases
// */
// public function doGetTotalNewByProcess($process_list, $init_date, $end_date)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentNewCasesByProcess($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date));
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the total of Cases with New time with the selected periodicity
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @param string $periodicity {@from path}
// * @return array
// *
// * @url GET /total-new-cases-history
// */
// public function doGetTotalNewByProcessHistory($process_list, $init_date, $end_date, $periodicity)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentNewCasesByProcessHistory($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date),
// $periodicity);
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the total of Cases with Completed time
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @return array
// *
// * @url GET /total-completed-cases
// */
// public function doGetTotalCompletedByProcess($process_list, $init_date, $end_date)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentCompletedCasesByProcess($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date));
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the total of Cases with Completed time with the selected periodicity
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @param string $periodicity {@from path}
// * @return array
// *
// * @url GET /total-completed-cases-history
// */
// public function doGetTotalCompletedByProcessHistory($process_list, $init_date, $end_date, $periodicity)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentCompletedCasesByProcessHistory($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date),
// $periodicity);
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
/**
* Returns the total of Cases with Completed time with the selected periodicity
*
@@ -299,7 +82,7 @@ class ReportingIndicators extends Api
*
* @url GET /process-efficiency-data
*/
public function doGetProcessEficciencyData($indicator_uid, $measure_date, $compare_date, $language)
public function doGetProcessEficciencyData($indicator_uid, $compare_date, $measure_date, $language)
{
try {
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
@@ -324,7 +107,7 @@ class ReportingIndicators extends Api
*
* @url GET /employee-efficiency-data
*/
public function doGetEmployeeEficciencyData($indicator_uid, $measure_date, $compare_date, $language)
public function doGetEmployeeEficciencyData($indicator_uid, $compare_date, $measure_date, $language)
{
try {
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
@@ -390,6 +173,29 @@ class ReportingIndicators extends Api
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get list Status indicator
*
* @return array
*
* @author Marco Antonio Nina <marco.antonio.nina@colosa.com>
* @copyright Colosa - Bolivia
*
* @url GET /status-indicator
*/
public function doGetStatusIndicator() {
try {
$options['usrUid'] = $this->getUserId();
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
$response = $indicatorsObj->getStatusIndicator($options);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}

View File

@@ -504,7 +504,7 @@ Ext.onReady( function() {
enableTabScroll : true,
//anchor : '98%',
width : '100%',
height : 315,
height : 260,
defaults : {
autoScroll :true
},
@@ -574,7 +574,13 @@ Ext.onReady( function() {
if (typeof dataIndicator[id-1]['DAS_IND_DIRECTION'] != 'undefined') {
Ext.getCmp('DAS_IND_DIRECTION_'+id).setValue(idDirection);
}
if (dataIndicator[id-1]['DAS_IND_TYPE'] != '1010' && dataIndicator[id-1]['DAS_IND_TYPE'] != '1030') {
var field = '';
if (dataIndicator[id-1]['DAS_IND_TYPE'] != '1050') {
field = Ext.getCmp('IND_PROCESS_'+id);
field.enable();
field.show();
}
if (dataIndicator[id-1]['DAS_IND_TYPE'] != '1010' && dataIndicator[id-1]['DAS_IND_TYPE'] != '1030' && dataIndicator[id-1]['DAS_IND_TYPE'] != '1050') {
var fields = ['DAS_IND_FIRST_FIGURE_'+id,'DAS_IND_FIRST_FREQUENCY_'+ id,'DAS_IND_SECOND_FIGURE_'+id, 'DAS_IND_SECOND_FREQUENCY_'+ id];
for (var k=0; k<fields.length; k++) {
field = Ext.getCmp(fields[k]);
@@ -730,7 +736,7 @@ var addTab = function (flag) {
width : "100%",
items : [
new Ext.Panel({
height : 275,
height : 230,
width : "100%",
border : true,
bodyStyle : 'padding:10px',
@@ -771,9 +777,19 @@ var addTab = function (flag) {
scope: this,
select: function(combo, record, index) {
var value = combo.getValue();
var field = '';
var index = tabPanel.getActiveTab().id;
var fields = ['DAS_IND_FIRST_FIGURE_'+index,'DAS_IND_FIRST_FREQUENCY_'+index,'DAS_IND_SECOND_FIGURE_'+index, 'DAS_IND_SECOND_FREQUENCY_'+index];
if (value == '1010' || value == '1030') {
if (value == '1050') {
field = Ext.getCmp('IND_PROCESS_'+index);
field.disable();
field.hide();
} else {
field = Ext.getCmp('IND_PROCESS_'+index);
field.enable();
field.show();
}
if (value == '1010' || value == '1030' || value == '1050') {
for (var i=0; i<fields.length; i++) {
field = Ext.getCmp(fields[i]);
field.disable();
@@ -797,6 +813,7 @@ var addTab = function (flag) {
paddingLeft: "30px",
marginLeft : "60px",
layout : 'hbox',
hidden : true,
items : [
new Ext.form.ComboBox({
editable : false,
@@ -828,6 +845,7 @@ var addTab = function (flag) {
anchor : '40%',
maskRe : /([0-9\.]+)$/,
maxLength : 9,
value : 1,
width : 80,
allowBlank : false,
listeners : {
@@ -863,9 +881,11 @@ var addTab = function (flag) {
forceSelection : false,
emptyText : _('ID_EMPTY_PROCESSES'),
selectOnFocus : true,
hidden : true,
typeAhead : true,
autocomplete : true,
triggerAction : 'all',
value : '0',
store : storeProject
}),
new Ext.form.ComboBox({

View File

@@ -27,18 +27,287 @@
<script type="text/javascript" src="/js/pmchart/pmCharts.js"></script>
<script type="text/javascript" >
var urlProxy = '{$urlProxy}';
var usrId = '{$usrId}';
var pageUserId = '{$usrId}';
var token = '{$credentials.access_token}';
var G_STRING = [];
{foreach from=$translation key=index item=option}
G_STRING['{$index}'] = "{$option}";
{/foreach}
</script>
<script type="text/javascript" src="/jscore/strategicDashboard/dashboard.js"></script>
<script type="text/javascript" src="/jscore/strategicDashboard/dashboardProxy.js"></script>
<script type="text/javascript" src="/jscore/strategicDashboard/viewDashboardHelper.js"></script>
<script type="text/javascript" src="/jscore/strategicDashboard/viewDashboardModel.js"></script>
<script type="text/javascript" src="/jscore/strategicDashboard/viewDashboardPresenter.js"></script>
<script type="text/javascript" src="/jscore/strategicDashboard/viewDashboardView.js"></script>
<script type="text/template" class="specialIndicatorButtonTemplate">
<div class="col-lg-3 col-md-6 dashPro ind-button-selector"
id="indicatorButton-<%- indicator.id %>"
data-indicator-id="<%- indicator.id %>"
data-indicator-type="<%- indicator.type %>"
data-gs-min-width="3" data-gs-min-height="2" data-gs-max-height="2">
<div class="ind-container-selector panel panel-green grid-stack-item-content" style="min-width:200px;">
<a data-toggle="collapse" href="#efficiencyindex" aria-expanded="false" aria-controls="efficiencyindex">
<div class="panel-heading" >
<div class="row">
<div class="col-xs-3">
<div class="huge ind-value-selector"><%- indicator.value %></div>
</div>
<div class="col-xs-9 text-right"><i class="ind-symbol-selector fa fa-chevron-up fa-3x"></i>
<div class="small ind-comparative-selector"><%- indicator.comparative %></div>
</div>
</div>
</div>
<div class="panel-footer text-center ind-title-selector">
<%- indicator.title %>
</div>
</a>
</div>
</div>
</script>
<script type="text/template" class="statusIndicatorButtonTemplate">
<div class="col-lg-3 col-md-6 dashPro ind-button-selector"
id="indicatorButton-<%- indicator.id %>"
data-indicator-id="<%- indicator.id %>"
data-indicator-type="<%- indicator.type %>"
data-gs-min-width="3" data-gs-min-height="2" data-gs-max-height="2">
<div class="ind-container-selector panel grid-stack-item-content" style="min-width:200px;">
<a data-toggle="collapse" href="#efficiencyindex" aria-expanded="false" aria-controls="efficiencyindex">
<div class="panel-heading status-indicator-low"
style=" width:<%- indicator.percentageOverdue %>%;
visibility: <%- indicator.overdueVisibility %>" >
<div class="row">
<div class="col-xs-12">
<div class="small ind-comparative-selector"><%- indicator.percentageOverdue %>%</div>
</div>
</div>
</div>
<div class="panel-heading status-indicator-medium"
style=" width:<%- indicator.percentageAtRisk %>%;
visibility: <%- indicator.atRiskVisibility %>;" >
<div class="row">
<div class="col-xs-12">
<div class="small ind-comparative-selector"><%- indicator.percentageAtRisk %>%</div>
</div>
</div>
</div>
<div class="panel-heading status-indicator-high"
style=" width:<%- indicator.percentageOnTime %>%;
visibility: <%- indicator.onTimeVisibility %>;">
<div class="row">
<div class="col-xs-12">
<div class="small ind-comparative-selector"><%- indicator.percentageOnTime %>%</div>
</div>
</div>
</div>
<div class="panel-footer text-center ind-title-selector" style="clear:both;">
<%- indicator.title %>
</div>
</a>
</div>
</div>
</script>
<script type="text/template" class="indicatorButtonTemplate">
<div class="col-lg-3 col-md-6 ind-button-selector" id="generalLowItem"
id="indicatorButton-<%- indicator.id %>"
data-indicator-id="<%- indicator.id %>"
data-indicator-type="<%- indicator.type %>"
data-gs-min-width="3" data-gs-min-height="2" data-gs-max-height="2" >
<div class="panel ie-panel panel-low grid-stack-item-content ind-container-selector" style="min-width: 200px;">
<a data-toggle="collapse" href="#completedcases" aria-expanded="false" aria-controls="completedcases">
<div class="panel-heading"> <div class="row"> <div class="col-xs-3">
<div class="huge ind-value-selector">X</div>
</div>
<div class="col-xs-9 text-right"><i class="fa fa-file-text-o fa-3x"></i>
<div class="small ind-comparative-selector ellipsis"><%- indicator.comparative %></div>
</div>
</div>
</div>
<div class="progress progress-xs progress-dark-base ie-progress-dark-base mar-no">
<div role="progressbar"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"
class="progress-bar progress-bar-light ind-progress-selector"
style="width: 0%">
</div>
</div>
<div class="panel-footer text-center ind-title-selector">
<span>
<%- indicator.title %>
</span>
</div>
</a>
</div>
</div>
</script>
<script type="text/template" class="specialIndicatorMainPanel">
<div class="process-div well" id="specialIndicatorMainPanel"
data-gs-no-resize="true"
style="clear:both;position:relative;height:auto;">
<div class="panel-heading bluebg sind-title-selector"">
<ol class="breadcrumb">
</ol>
</div>
<div class="text-center huge">
<div class="col-xs-3 vcenter">
<div class="green"><%- indicator.efficiencyIndexToShow %></div>
<div class="small grey sind-index-selector ellipsis"></div>
</div>
<div class="col-xs-3 vcenter" style="margin-right:40px">
<div class="red sind-cost-number-selector"><%- indicator.inefficiencyCostToShow %></div>
<div class="small grey sind-cost-selector ellipsis"></div>
</div>
<div class="col-xs-6" id="specialIndicatorGraph" style="width:540px;height:300px;"></div>
</div>
<div class="clearfix"></div>
</div>
</script>
<script type="text/template" class="specialIndicatorDetail">
<div class="process-div well hideme detail-button-selector" data-gs-no-resize="true"
id="detailData-<%- detailData.uid %>"
data-indicator-id="<%- detailData.indicatorId %>"
data-detail-id="<%- detailData.uid %>"
data-detail-index="<%- detailData.efficiencyIndexToShow %>"
data-detail-cost-to-show="<%- detailData.inefficiencyCostToShow %>"
data-detail-cost="<%- detailData.inefficiencyCost%>"
data-detail-name="<%- detailData.name %>"
>
<div class="col-lg-12 vcenter-task">
<a href="#" class="process-button">
<div class="col-xs-5 text-left title-process">
<div class="small grey detail-title-selector"> <%- detailData.name %></div>
</div>
<div class="col-xs-3 text-center ">
<div class="blue"><%- detailData.efficiencyIndexToShow%></div>
<div class="small grey detail-efficiency-selector ellipsis"></div>
</div>
<div class="col-xs-3 text-center ">
<div class="red detail-cost-number-selector"><%- detailData.inefficiencyCostToShow %></div>
<div class="small grey detail-cost-selector ellipsis"></div>
</div>
<div class="col-xs-1 text-right arrow"><i class="fa fa-chevron-right fa-fw"></i></div>
</a>
</div>
<div class="clearfix"></div>
</div>
</script>
<script type="text/template" class="specialIndicatorSencondViewDetail">
<div class="process-div well hideme detail-button-selector" data-gs-no-resize="true"
id="detailData-<%- detailData.uid %>"
data-indicator-id="<%- detailData.indicatorId %>"
data-detail-id="<%- detailData.uid %>">
<div class="panel-heading greenbg">
<div class="col-xs-12 text-center detail-title-selector"><i class="fa fa-tasks fa-fw"></i> <span id="usrName"><%- detailData.name %></span> </div>
<div class="clearfix"></div>
</div>
<div class="text-center huge">
<div class="col-xs-12 vcenter-task">
<div class="col-xs-5 ">
<div class="blue small"><%- detailData.efficiencyIndexToShow%></div>
<div class="smallB grey fontMedium detail-efficiency-selector ellipsis"></div>
</div>
<div class="col-xs-5 ">
<div class="small detail-cost-number-selector"><%- detailData.inefficiencyCostToShow%></div>
<div class="smallB grey detail-cost-selector ellipsis"></div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</script>
<script type="text/template" class="statusDetail">
<div class="process-div well hideme detail-button-selector" data-gs-no-resize="true"
id="detailData-<%- detailData.uid %>"
data-indicator-id="<%- detailData.indicatorId %>"
data-detail-id="<%- detailData.uid %>">
<div class="panel-heading greenbg">
<div class="col-xs-12 text-center detail-title-selector"><i class="fa fa-tasks fa-fw"></i> <span id="usrName"><%- detailData.taskTitle %></span> </div>
<div class="clearfix"></div>
</div>
<div class="text-center huge">
<div class="col-xs-12 vcenter-task">
<div class="col-xs-4 ">
<div class="blue small"><%- detailData.percentageOverdue%> %</div>
<div class="smallB grey fontMedium detail-efficiency-selector">Overdue</div>
</div>
<div class="col-xs-4">
<div class="blue small"><%- detailData.percentageAtRisk%> %</div>
<div class="smallB grey fontMedium detail-efficiency-selector">At Risk</div>
</div>
<div class="col-xs-4 ">
<div class="blue small"><%- detailData.percentageOnTime%> %</div>
<div class="smallB grey fontMedium detail-efficiency-selector">On Time</div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</script>
<script type="text/template" class="dashboardButtonTemplate">
<div id="dashboardButton-<%- dashboard.id %>" class="btn-group pull-left"
data-dashboard-id="<%- dashboard.id %>" >
<button type="button" class="btn btn-success das-icon-selector">
<i class="fa fa-star fa-1x"></i>
</button>
<button type="button" class="btn btn-success das-title-selector" >
<%- dashboard.title %>
</button>
</div>
</script>
<script type="text/template" class="generalIndicatorMainPanel">
<div class="process-div well" data-gs-no-resize="true" style="clear:both;position:relative;height:auto;">
<div class="panel-heading bluebg">
<ol class="breadcrumb">
<li class="ind-title-selector"></li>
</ol>
</div>
<div class="text-center huge">
<div class="col-xs-6" id="generalGraph1" style="width:600px; height:300px;"><img src="../dist/img/graph.png" /></div>
<div class="col-xs-6" id="generalGraph2" style="width:600px; height:300px;margin-left:60px;"><img src="../dist/img/graph.png" /></div>
</div>
<div class="clearfix"></div>
</div>
</script>
<script type="text/template" class="statusIndicatorMainPanel">
<div class="process-div well" data-gs-no-resize="true" style="clear:both;position:relative;height:auto;">
<div class="panel-heading bluebg">
<ol class="breadcrumb">
<li class="ind-title-selector"></li>
</ol>
</div>
<div class="text-center huge" style="margin:0 auto; width:90%;">
<div class="col-xs-4" style="width:auto;">
<div class="status-graph-title-low">Overdue:</div>
<div id="graph1" style="width:450px; height:300px;"></div>
</div>
<div class="col-xs-4" style="width:auto;">
<div class="status-graph-title-medium">At Risk:</div>
<div id="graph2" style="width:450px; height:300px;"></div>
</div>
<div class="col-xs-4" style="width:auto;">
<div class="status-graph-title-high">On Time:</div>
<div id="graph3" style="width:450px; height:300px;"></div>
</div>
</div>
<div class="clearfix"></div>
</div>
</script>
</head>
<body id="page-top" class="index">
<img id="theImg" class="floating" src="/images/scrolldown.gif" width="80" height="80"/>
<img id="scrollImg" class="floating" src="/images/scrolldown.gif" width="80" height="80" style="border-radius:85px;"/>
<div id="wrapper">
<div id="page-wrapper">
<!--Cabezera-->
@@ -75,7 +344,7 @@
{/literal}
</select>
<select id="mounth" class="form-control pull-right ">
<select id="month" class="form-control pull-right ">
<option value="1">{translate label="ID_MONTH_ABB_1"}</option>
<option value="2">{translate label="ID_MONTH_ABB_2"}</option>
<option value="3">{translate label="ID_MONTH_ABB_3"}</option>
@@ -99,7 +368,7 @@
<p class="text-center">{translate label="ID_DASH_CLICK_TO_VIEW"}</p>
<p>
<!-- Split button -->
<div id="dasbuttons">
<div id="dashboardsList">
</div>
</p>
<div class="clearfix"></div>
@@ -123,9 +392,19 @@
<!--Here are added dynamically the Dat by indicator-->
</div>
</div>
<div id="relatedLabel"></div>
<div id="relatedLabel" style="clear:both;">
<div>
<center><h3></h3></center>
</div>
<div>
Sort: &nbsp; &nbsp;<a id="sortListButton" class="fa fa-chevron-down fa-1x" style="color:#000;" href="#"></a>
</div>
</div>
<div class="col-lg-12 col-md-12">
<div id="relatedDataGridStack" class="grid-stack" data-gs-width="12" data-gs-animate="no" >
<div id="relatedDetailGridStack" class="grid-stack" data-gs-width="12"
data-gs-animate="no" style="clear:both;">
</div>
</div>
</div>
@@ -136,4 +415,3 @@
</body>
</html>

View File

@@ -1,4 +1,6 @@
.pm-charts-no-draw {
font-size:16px;
font-family:"Arial";
@@ -11,10 +13,56 @@
color:#e14333;
}
.status-graph-title-low,
.status-graph-title-medium,
.status-graph-title-high {
text-align:center;
font-size:17px;
font-family: 'Chivo', sans-serif;
width:90%;
margin:0 auto;
border:1px solid #eaeaea;
margin-top:10px;
border-radius: 5px;
}
.status-graph-title-low {
background-color: #e14333;
}
.status-graph-title-medium {
background-color:#fada5e;
}
.status-graph-title-high {
background-color:#1fbc99;
}
.status-indicator-low,
.status-indicator-medium,
.status-indicator-high {
padding:0px;
padding-top:30px;
color:#444;
float:left;
}
.section-title {
}
.status-indicator-low {
background-color: #e14333;
}
.status-indicator-medium {
background-color: #fada5e;
}
.status-indicator-high {
background-color: #1fbc99;
}
.hideme {opacity:0;}
.pie-label {font-size:10px;}
.axis-label {font-size:10px;}
.errorBar, .errorBarLowerMark, .errorBarUpperMark{
@@ -29,15 +77,34 @@
font-size:9px;
}
.das-title-selector {
width:160px;
text-overflow: ellipsis;
white-space: nowrap;
overflow:hidden;
}
.ind-title-selector {
text-overflow: ellipsis;
white-space: nowrap;
overflow:hidden;
}
.ellipsis {
text-overflow: ellipsis;
white-space: nowrap;
overflow:hidden;
}
img.floating {
position:fixed;
right:0;
bottom:0;
margin:0;
padding:0;
z-index:1000;
opacity: 0.9;
filter: alpha(opacity=90);
position:fixed;
right:0;
bottom:0;
margin:0;
padding:0;
z-index:1000;
opacity: 0.9;
filter: alpha(opacity=90);
}

View File

@@ -103,7 +103,7 @@
width: auto !important;
left: 0 !important;
top: auto !important;
margin-bottom: 20px;
margin-bottom:20px;
}
.grid-stack {
@@ -127,3 +127,4 @@
-o-transition: left .0s, top .0s, height .0s, width .0s;
transition: left .0s, top .0s, height .0s, width .0s;
}

View File

@@ -348,21 +348,21 @@ table.dataTable thead .sorting:after {
text-decoration: none;
}
.panel-yellow {
.panel-high {
border-color: #ddd;
}
.panel-yellow .panel-heading {
.panel-high .panel-heading {
border-color: #fcb322;
color: #fff;
background-color: #fcb322;
}
.panel-yellow a {
.panel-high a {
color: #606368;
}
.panel-yellow a:hover {
.panel-high a:hover {
color: #fcb322;
text-decoration: none;
}
@@ -520,15 +520,15 @@ table.dataTable thead .sorting:after {
/*title panel ends*/
.panel-primary{
.panel-low{
border-color: #ddd;
}
.panel-primary a{
.panel-low a{
color: #606368;
}
.panel-primary a:hover{
.panel-low a:hover{
color: #3397e1;
text-decoration: none;
}
@@ -549,7 +549,7 @@ table.dataTable thead .sorting:after {
margin-bottom: 20px;
}
.panel-green:hover, .panel-red:hover, .panel-yellow:hover, .panel-primary:hover{
.panel-green:hover, .panel-red:hover, .panel-high:hover, .panel-low:hover{
box-shadow:0px 3px 2px #dfdfdf;
}
@@ -566,7 +566,7 @@ table.dataTable thead .sorting:after {
}
.panel-active{
background-color: #fff;
background-color: #D99058;
position: relative;
}
@@ -583,6 +583,7 @@ table.dataTable thead .sorting:after {
.panel-active:after {
border-color: rgba(136, 183, 213, 0);
background-color: #000;
border-top-color: #fff;
border-width: 20px;
margin-left: -20px;
@@ -614,11 +615,11 @@ table.dataTable thead .sorting:after {
margin-top:10px;
}
.panel-red .panel-heading, .panel-primary .panel-heading{
.panel-red .panel-heading, .panel-low .panel-heading{
color:rgba(0,0,0,0.4) !important;
}
.panel-yellow .progress-bar{
.panel-high .progress-bar{
background: #fcb322;
}
@@ -728,11 +729,18 @@ table.dataTable thead .sorting:after {
font-size: 14px;
}
.process-button .blue{
.process-button .blue,
.process-button .red,
.process-button .green{
font-size: 24px;
}
.process-button:hover .blue, .process-button:hover, .process-button:hover .grey{
.process-button:hover .blue,
.process-button:hover,
.process-button:hover .grey,
.process-button:hover .red,
.process-button:hover .green
{
background: #337AB8;
color:#fff !important;
}