Integration to TimeSeries Comparison in dashboard view page
This commit is contained in:
@@ -178,42 +178,8 @@ class StrategicDashboard extends Controller
|
|||||||
$this->setVar('usrId', $this->usrId);
|
$this->setVar('usrId', $this->usrId);
|
||||||
$this->setVar('credentials', $this->clientToken);
|
$this->setVar('credentials', $this->clientToken);
|
||||||
$this->setVar('unitCost', $this->usrUnitCost);
|
$this->setVar('unitCost', $this->usrUnitCost);
|
||||||
|
|
||||||
$translation = array();
|
$translation = $this->getTranslations();
|
||||||
$translation['ID_MANAGERS_DASHBOARDS'] = G::LoadTranslation( 'ID_MANAGERS_DASHBOARDS');
|
|
||||||
$translation['ID_PRO_EFFICIENCY_INDEX'] = G::LoadTranslation( 'ID_PRO_EFFICIENCY_INDEX');
|
|
||||||
$translation['ID_EFFICIENCY_USER'] = G::LoadTranslation( 'ID_EFFICIENCY_USER');
|
|
||||||
$translation['ID_COMPLETED_CASES'] = G::LoadTranslation( 'ID_COMPLETED_CASES');
|
|
||||||
$translation['ID_WELL_DONE'] = G::LoadTranslation( 'ID_WELL_DONE');
|
|
||||||
$translation['ID_NUMBER_CASES'] = G::LoadTranslation( 'ID_NUMBER_CASES');
|
|
||||||
$translation['ID_EFFICIENCY_INDEX'] = G::LoadTranslation( 'ID_EFFICIENCY_INDEX');
|
|
||||||
$translation['ID_INEFFICIENCY_COST'] = G::LoadTranslation( 'ID_INEFFICIENCY_COST');
|
|
||||||
$translation['ID_EFFICIENCY_COST'] = G::LoadTranslation( 'ID_EFFICIENCY_COST');
|
|
||||||
$translation['ID_RELATED_PROCESS'] = G::LoadTranslation( 'ID_RELATED_PROCESS');
|
|
||||||
$translation['ID_RELATED_GROUPS'] = G::LoadTranslation( 'ID_RELATED_GROUPS');
|
|
||||||
$translation['ID_RELATED_TASKS'] = G::LoadTranslation( 'ID_RELATED_TASKS');
|
|
||||||
$translation['ID_RELATED_USERS'] = G::LoadTranslation( 'ID_RELATED_USERS');
|
|
||||||
$translation['ID_GRID_PAGE_NO_DASHBOARD_MESSAGE'] = G::LoadTranslation( 'ID_GRID_PAGE_NO_DASHBOARD_MESSAGE');
|
|
||||||
$translation['ID_PROCESS_TASKS'] = G::LoadTranslation( 'ID_PROCESS_TASKS');
|
|
||||||
$translation['ID_TIME_HOURS'] = G::LoadTranslation( 'ID_TIME_HOURS');
|
|
||||||
$translation['ID_GROUPS'] = G::LoadTranslation( 'ID_GROUPS');
|
|
||||||
$translation['ID_COSTS'] = G::LoadTranslation( 'ID_COSTS');
|
|
||||||
$translation['ID_TASK'] = G::LoadTranslation( 'ID_TASK');
|
|
||||||
$translation['ID_USER'] = G::LoadTranslation( 'ID_USER');
|
|
||||||
$translation['ID_YEAR'] = G::LoadTranslation( 'ID_YEAR');
|
|
||||||
$translation['ID_USERS'] = G::LoadTranslation( 'ID_USERS');
|
|
||||||
$translation['ID_USERS'] = G::LoadTranslation( 'ID_USERS');
|
|
||||||
$translation['ID_OVERDUE'] = G::LoadTranslation( 'ID_OVERDUE');
|
|
||||||
$translation['ID_AT_RISK'] = G::LoadTranslation( 'ID_AT_RISK');
|
|
||||||
$translation['ID_ON_TIME'] = G::LoadTranslation( 'ID_ON_TIME');
|
|
||||||
$translation['ID_NO_INEFFICIENT_PROCESSES'] = G::LoadTranslation('ID_NO_INEFFICIENT_PROCESSES');
|
|
||||||
$translation['ID_NO_INEFFICIENT_TASKS'] = G::LoadTranslation('ID_NO_INEFFICIENT_TASKS');
|
|
||||||
$translation['ID_NO_INEFFICIENT_USER_GROUPS'] = G::LoadTranslation('ID_NO_INEFFICIENT_USER_GROUPS');
|
|
||||||
$translation['ID_NO_INEFFICIENT_USERS'] = G::LoadTranslation('ID_NO_INEFFICIENT_USERS');
|
|
||||||
$translation['ID_DISPLAY_EMPTY'] = G::LoadTranslation('ID_DISPLAY_EMPTY');
|
|
||||||
//text for inbox empty in status indicator
|
|
||||||
$translation['ID_INBOX_EMPTY'] = G::LoadTranslation('ID_INBOX_EMPTY');
|
|
||||||
|
|
||||||
$this->setVar('translation', $translation);
|
$this->setVar('translation', $translation);
|
||||||
$this->render();
|
$this->render();
|
||||||
} catch (Exception $error) {
|
} catch (Exception $error) {
|
||||||
@@ -231,39 +197,7 @@ class StrategicDashboard extends Controller
|
|||||||
$this->setVar('credentials', $this->clientToken);
|
$this->setVar('credentials', $this->clientToken);
|
||||||
$this->setVar('unitCost', $this->usrUnitCost);
|
$this->setVar('unitCost', $this->usrUnitCost);
|
||||||
|
|
||||||
$translation = array();
|
$translation = $this->getTranslations();
|
||||||
$translation['ID_MANAGERS_DASHBOARDS'] = G::LoadTranslation( 'ID_MANAGERS_DASHBOARDS');
|
|
||||||
$translation['ID_PRO_EFFICIENCY_INDEX'] = G::LoadTranslation( 'ID_PRO_EFFICIENCY_INDEX');
|
|
||||||
$translation['ID_EFFICIENCY_USER'] = G::LoadTranslation( 'ID_EFFICIENCY_USER');
|
|
||||||
$translation['ID_COMPLETED_CASES'] = G::LoadTranslation( 'ID_COMPLETED_CASES');
|
|
||||||
$translation['ID_WELL_DONE'] = G::LoadTranslation( 'ID_WELL_DONE');
|
|
||||||
$translation['ID_NUMBER_CASES'] = G::LoadTranslation( 'ID_NUMBER_CASES');
|
|
||||||
$translation['ID_EFFICIENCY_INDEX'] = G::LoadTranslation( 'ID_EFFICIENCY_INDEX');
|
|
||||||
$translation['ID_INEFFICIENCY_COST'] = G::LoadTranslation( 'ID_INEFFICIENCY_COST');
|
|
||||||
$translation['ID_EFFICIENCY_COST'] = G::LoadTranslation( 'ID_EFFICIENCY_COST');
|
|
||||||
$translation['ID_RELATED_PROCESS'] = G::LoadTranslation( 'ID_RELATED_PROCESS');
|
|
||||||
$translation['ID_RELATED_GROUPS'] = G::LoadTranslation( 'ID_RELATED_GROUPS');
|
|
||||||
$translation['ID_RELATED_TASKS'] = G::LoadTranslation( 'ID_RELATED_TASKS');
|
|
||||||
$translation['ID_RELATED_USERS'] = G::LoadTranslation( 'ID_RELATED_USERS');
|
|
||||||
$translation['ID_GRID_PAGE_NO_DASHBOARD_MESSAGE'] = G::LoadTranslation( 'ID_GRID_PAGE_NO_DASHBOARD_MESSAGE');
|
|
||||||
$translation['ID_PROCESS_TASKS'] = G::LoadTranslation( 'ID_PROCESS_TASKS');
|
|
||||||
$translation['ID_TIME_HOURS'] = G::LoadTranslation( 'ID_TIME_HOURS');
|
|
||||||
$translation['ID_GROUPS'] = G::LoadTranslation( 'ID_GROUPS');
|
|
||||||
$translation['ID_COSTS'] = G::LoadTranslation( 'ID_COSTS');
|
|
||||||
$translation['ID_TASK'] = G::LoadTranslation( 'ID_TASK');
|
|
||||||
$translation['ID_USER'] = G::LoadTranslation( 'ID_USER');
|
|
||||||
$translation['ID_YEAR'] = G::LoadTranslation( 'ID_YEAR');
|
|
||||||
$translation['ID_USERS'] = G::LoadTranslation( 'ID_USERS');
|
|
||||||
$translation['ID_OVERDUE'] = G::LoadTranslation( 'ID_OVERDUE');
|
|
||||||
$translation['ID_AT_RISK'] = G::LoadTranslation( 'ID_AT_RISK');
|
|
||||||
$translation['ID_ON_TIME'] = G::LoadTranslation( 'ID_ON_TIME');
|
|
||||||
$translation['ID_NO_INEFFICIENT_PROCESSES'] = G::LoadTranslation('ID_NO_INEFFICIENT_PROCESSES');
|
|
||||||
$translation['ID_NO_INEFFICIENT_TASKS'] = G::LoadTranslation('ID_NO_INEFFICIENT_TASKS');
|
|
||||||
$translation['ID_NO_INEFFICIENT_USER_GROUPS'] = G::LoadTranslation('ID_NO_INEFFICIENT_USER_GROUPS');
|
|
||||||
$translation['ID_NO_INEFFICIENT_USERS'] = G::LoadTranslation('ID_NO_INEFFICIENT_USERS');
|
|
||||||
$translation['ID_DISPLAY_EMPTY'] = G::LoadTranslation('ID_DISPLAY_EMPTY');
|
|
||||||
$translation['ID_INBOX_EMPTY'] = G::LoadTranslation('ID_INBOX_EMPTY');
|
|
||||||
|
|
||||||
$this->setVar('translation', $translation);
|
$this->setVar('translation', $translation);
|
||||||
$this->render();
|
$this->render();
|
||||||
} catch (Exception $error) {
|
} catch (Exception $error) {
|
||||||
@@ -272,4 +206,60 @@ class StrategicDashboard extends Controller
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getTranslations() {
|
||||||
|
$translation = array();
|
||||||
|
$translation['ID_MANAGERS_DASHBOARDS'] = G::LoadTranslation( 'ID_MANAGERS_DASHBOARDS');
|
||||||
|
$translation['ID_PRO_EFFICIENCY_INDEX'] = G::LoadTranslation( 'ID_PRO_EFFICIENCY_INDEX');
|
||||||
|
$translation['ID_EFFICIENCY_USER'] = G::LoadTranslation( 'ID_EFFICIENCY_USER');
|
||||||
|
$translation['ID_COMPLETED_CASES'] = G::LoadTranslation( 'ID_COMPLETED_CASES');
|
||||||
|
$translation['ID_WELL_DONE'] = G::LoadTranslation( 'ID_WELL_DONE');
|
||||||
|
$translation['ID_NUMBER_CASES'] = G::LoadTranslation( 'ID_NUMBER_CASES');
|
||||||
|
$translation['ID_EFFICIENCY_INDEX'] = G::LoadTranslation( 'ID_EFFICIENCY_INDEX');
|
||||||
|
$translation['ID_INEFFICIENCY_COST'] = G::LoadTranslation( 'ID_INEFFICIENCY_COST');
|
||||||
|
$translation['ID_EFFICIENCY_COST'] = G::LoadTranslation( 'ID_EFFICIENCY_COST');
|
||||||
|
$translation['ID_RELATED_PROCESS'] = G::LoadTranslation( 'ID_RELATED_PROCESS');
|
||||||
|
$translation['ID_RELATED_GROUPS'] = G::LoadTranslation( 'ID_RELATED_GROUPS');
|
||||||
|
$translation['ID_RELATED_TASKS'] = G::LoadTranslation( 'ID_RELATED_TASKS');
|
||||||
|
$translation['ID_RELATED_USERS'] = G::LoadTranslation( 'ID_RELATED_USERS');
|
||||||
|
$translation['ID_GRID_PAGE_NO_DASHBOARD_MESSAGE'] = G::LoadTranslation( 'ID_GRID_PAGE_NO_DASHBOARD_MESSAGE');
|
||||||
|
$translation['ID_PROCESS_TASKS'] = G::LoadTranslation( 'ID_PROCESS_TASKS');
|
||||||
|
$translation['ID_TIME_HOURS'] = G::LoadTranslation( 'ID_TIME_HOURS');
|
||||||
|
$translation['ID_GROUPS'] = G::LoadTranslation( 'ID_GROUPS');
|
||||||
|
$translation['ID_COSTS'] = G::LoadTranslation( 'ID_COSTS');
|
||||||
|
$translation['ID_TASK'] = G::LoadTranslation( 'ID_TASK');
|
||||||
|
$translation['ID_USER'] = G::LoadTranslation( 'ID_USER');
|
||||||
|
$translation['ID_YEAR'] = G::LoadTranslation( 'ID_YEAR');
|
||||||
|
$translation['ID_USERS'] = G::LoadTranslation( 'ID_USERS');
|
||||||
|
$translation['ID_USERS'] = G::LoadTranslation( 'ID_USERS');
|
||||||
|
$translation['ID_OVERDUE'] = G::LoadTranslation( 'ID_OVERDUE');
|
||||||
|
$translation['ID_AT_RISK'] = G::LoadTranslation( 'ID_AT_RISK');
|
||||||
|
$translation['ID_ON_TIME'] = G::LoadTranslation( 'ID_ON_TIME');
|
||||||
|
$translation['ID_NO_INEFFICIENT_PROCESSES'] = G::LoadTranslation('ID_NO_INEFFICIENT_PROCESSES');
|
||||||
|
$translation['ID_NO_INEFFICIENT_TASKS'] = G::LoadTranslation('ID_NO_INEFFICIENT_TASKS');
|
||||||
|
$translation['ID_NO_INEFFICIENT_USER_GROUPS'] = G::LoadTranslation('ID_NO_INEFFICIENT_USER_GROUPS');
|
||||||
|
$translation['ID_NO_INEFFICIENT_USERS'] = G::LoadTranslation('ID_NO_INEFFICIENT_USERS');
|
||||||
|
$translation['ID_DISPLAY_EMPTY'] = G::LoadTranslation('ID_DISPLAY_EMPTY');
|
||||||
|
$translation['ID_INBOX_EMPTY'] = G::LoadTranslation('ID_INBOX_EMPTY');
|
||||||
|
$translation['ID_INDICATOR'] = G::LoadTranslation('ID_INDICATOR');
|
||||||
|
$translation['ID_PERIODICITY'] = G::LoadTranslation('ID_PERIODICITY');
|
||||||
|
$translation['ID_MONTH'] = G::LoadTranslation('ID_MONTH');
|
||||||
|
$translation['ID_QUARTER'] = G::LoadTranslation('ID_QUARTER');
|
||||||
|
$translation['ID_SEMESTER'] = G::LoadTranslation('ID_SEMESTER');
|
||||||
|
$translation['ID_TO'] = G::LoadTranslation('ID_TO');
|
||||||
|
$translation['ID_FROM'] = G::LoadTranslation('ID_FROM');
|
||||||
|
$translation['ID_MONTH_ABB_1'] = G::LoadTranslation('ID_MONTH_ABB_1');
|
||||||
|
$translation['ID_MONTH_ABB_2'] = G::LoadTranslation('ID_MONTH_ABB_2');
|
||||||
|
$translation['ID_MONTH_ABB_3'] = G::LoadTranslation('ID_MONTH_ABB_3');
|
||||||
|
$translation['ID_MONTH_ABB_4'] = G::LoadTranslation('ID_MONTH_ABB_4');
|
||||||
|
$translation['ID_MONTH_ABB_5'] = G::LoadTranslation('ID_MONTH_ABB_5');
|
||||||
|
$translation['ID_MONTH_ABB_6'] = G::LoadTranslation('ID_MONTH_ABB_6');
|
||||||
|
$translation['ID_MONTH_ABB_7'] = G::LoadTranslation('ID_MONTH_ABB_7');
|
||||||
|
$translation['ID_MONTH_ABB_8'] = G::LoadTranslation('ID_MONTH_ABB_8');
|
||||||
|
$translation['ID_MONTH_ABB_9'] = G::LoadTranslation('ID_MONTH_ABB_9');
|
||||||
|
$translation['ID_MONTH_ABB_10'] = G::LoadTranslation('ID_MONTH_ABB_10');
|
||||||
|
$translation['ID_MONTH_ABB_11'] = G::LoadTranslation('ID_MONTH_ABB_11');
|
||||||
|
$translation['ID_MONTH_ABB_12'] = G::LoadTranslation('ID_MONTH_ABB_12');
|
||||||
|
return $translation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var TimeSeriesModel = function (oauthToken, server, workspace, userId, dashboardId) {
|
var TimeSeriesModel = function (oauthToken, server, workspace, userId, strings) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.workspace = workspace;
|
this.workspace = workspace;
|
||||||
this.baseUrl = "/api/1.0/" + workspace + "/";
|
this.baseUrl = "/api/1.0/" + workspace + "/";
|
||||||
@@ -7,45 +7,44 @@ var TimeSeriesModel = function (oauthToken, server, workspace, userId, dashboard
|
|||||||
this.cache = {};
|
this.cache = {};
|
||||||
this.forceRemote=false; //if true, the next call will go to the remote server
|
this.forceRemote=false; //if true, the next call will go to the remote server
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.dashboardId = dashboardId;
|
this.strings = strings;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TimeSeriesModel.prototype.label = function(id) {
|
||||||
|
return this.strings[id];
|
||||||
|
};
|
||||||
|
|
||||||
TimeSeriesModel.prototype.indicatorList = function(dashboardId,initDate, endDate) {
|
TimeSeriesModel.prototype.indicatorList = function(dashboardId,initDate, endDate) {
|
||||||
var dummyDate = ''
|
var dummyDate = ''
|
||||||
return this.getJson('dashboard/' + dashboardId + '/indicator?dateIni=' + initDate + '&dateFin=' + endDate);
|
return this.helper.getJson('dashboard/' + dashboardId + '/indicator?dateIni=' + initDate + '&dateFin=' + endDate, this.baseUrl, this.oauthToken);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*TimeSeriesModel.prototype.indicatorList = function() {
|
|
||||||
var requestFinished = $.Deferred();
|
|
||||||
var json = [ {"label":"PEI", "value":"1111"},
|
|
||||||
{"label":"EEI", "value":"2222"}
|
|
||||||
];
|
|
||||||
requestFinished.resolve(json);
|
|
||||||
return requestFinished.promise();
|
|
||||||
};*/
|
|
||||||
|
|
||||||
TimeSeriesModel.prototype.periodicityList = function() {
|
TimeSeriesModel.prototype.periodicityList = function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
var json = [{label:"Monthly", value:that.helper.ReportingPeriodicityEnum.MONTH},
|
var json = [{label:that.label('ID_MONTH'), value:that.helper.ReportingPeriodicityEnum.MONTH},
|
||||||
{label:"Quaterly", value:that.helper.ReportingPeriodicityEnum.QUARTER},
|
{label:that.label('ID_QUARTER'), value:that.helper.ReportingPeriodicityEnum.QUARTER},
|
||||||
{label:"Semester", value:that.helper.ReportingPeriodicityEnum.SEMESTER},
|
{label:that.label('ID_SEMESTER'), value:that.helper.ReportingPeriodicityEnum.SEMESTER},
|
||||||
{label:"Yearly", value:that.helper.ReportingPeriodicityEnum.YEAR}
|
{label:that.label('ID_YEAR'), value:that.helper.ReportingPeriodicityEnum.YEAR}
|
||||||
];
|
];
|
||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeSeriesModel.prototype.monthList = function() {
|
TimeSeriesModel.prototype.monthList = function() {
|
||||||
var json = [{label:"Jan", value:"1"},
|
var that = this;
|
||||||
{label:"Feb", value:"2"},
|
var json = [{label:that.label("ID_MONTH_ABB_1"), value:"1"},
|
||||||
{label:"Mar", value:"3"},
|
{label:that.label("ID_MONTH_ABB_2"), value:"2"},
|
||||||
{label:"Apr", value:"4"},
|
{label:that.label("ID_MONTH_ABB_3"), value:"3"},
|
||||||
{label:"May", value:"5"},
|
{label:that.label("ID_MONTH_ABB_4"), value:"4"},
|
||||||
{label:"Jun", value:"6"},
|
{label:that.label("ID_MONTH_ABB_5"), value:"5"},
|
||||||
{label:"Jul", value:"7"}
|
{label:that.label("ID_MONTH_ABB_6"), value:"6"},
|
||||||
];
|
{label:that.label("ID_MONTH_ABB_7"), value:"7"},
|
||||||
|
{label:that.label("ID_MONTH_ABB_8"), value:"8"},
|
||||||
|
{label:that.label("ID_MONTH_ABB_9"), value:"9"},
|
||||||
|
{label:that.label("ID_MONTH_ABB_10"), value:"10"},
|
||||||
|
{label:that.label("ID_MONTH_ABB_11"), value:"11"},
|
||||||
|
{label:that.label("ID_MONTH_ABB_12"), value:"12"}
|
||||||
|
];
|
||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,7 +62,12 @@ TimeSeriesModel.prototype.semesterList = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TimeSeriesModel.prototype.yearList = function() {
|
TimeSeriesModel.prototype.yearList = function() {
|
||||||
var json = [{label:"2015", value:"2015"}, {label:"2014", value:"2014"}];
|
var currentYear = this.defaultEndDate().getFullYear();
|
||||||
|
var json = [];
|
||||||
|
|
||||||
|
for (var i = currentYear; i > currentYear - 10; i--) {
|
||||||
|
json.push ({label:i, value : i});
|
||||||
|
}
|
||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,32 +86,8 @@ TimeSeriesModel.prototype.historicData = function(indicatorId, periodicity, init
|
|||||||
"&end_date=" + this.helper.date2MysqlString(endDate) +
|
"&end_date=" + this.helper.date2MysqlString(endDate) +
|
||||||
"&periodicity=" + periodicity +
|
"&periodicity=" + periodicity +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
return this.getJson(endPoint);
|
return this.helper.getJson(endPoint, this.baseUrl, this.oauthToken);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeSeriesModel.prototype.getJson = function (endPoint) {
|
|
||||||
var that = this;
|
|
||||||
var callUrl = this.baseUrl + endPoint
|
|
||||||
var requestFinished = $.Deferred();
|
|
||||||
|
|
||||||
return $.ajax({
|
|
||||||
url: callUrl,
|
|
||||||
type: 'GET',
|
|
||||||
datatype: 'json',
|
|
||||||
success: function (data) {
|
|
||||||
that.forceRemote = false;
|
|
||||||
requestFinished.resolve(data);
|
|
||||||
},
|
|
||||||
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', '*');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,26 +4,37 @@ var TimeSeriesPresenter = function (model) {
|
|||||||
this.model = model;
|
this.model = model;
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeSeriesPresenter.prototype.initializePresenter = function () {
|
TimeSeriesPresenter.prototype.initializePresenter = function (dashboardId) {
|
||||||
var that = this;
|
var that = this;
|
||||||
var requestFinished = $.Deferred();
|
var requestFinished = $.Deferred();
|
||||||
$.when (this.fillIndicatorList())
|
$.when (this.fillIndicatorList(dashboardId))
|
||||||
.done(function () {
|
.done(function () {
|
||||||
that.periodicityState = {selValue: that.model.periodicityList()[0], list: that.model.periodicityList()}
|
that.periodicityState = {selValue: that.model.periodicityList()[0],
|
||||||
|
list: that.model.periodicityList(),
|
||||||
|
label: that.model.label('ID_PERIODICITY') + ": "
|
||||||
|
};
|
||||||
|
|
||||||
that.initPeriodState = {selValue:that.model.monthList()[0].value,
|
that.initPeriodState = {selValue:that.model.monthList()[0].value,
|
||||||
list:that.model.monthList(),
|
list:that.model.monthList(),
|
||||||
visible:true };
|
visible:true,
|
||||||
|
label: that.model.label('ID_FROM') + ": "
|
||||||
|
};
|
||||||
|
|
||||||
that.initYearState = {selValue : that.model.yearList() [0].value,
|
that.initYearState = {selValue : that.model.yearList() [0].value,
|
||||||
list : that.model.yearList()};
|
list : that.model.yearList(),
|
||||||
|
label: that.model.label('ID_YEAR') + ": "
|
||||||
|
};
|
||||||
|
|
||||||
that.endPeriodState = {selValue : that.model.defaultEndDate().getMonth() + 1,
|
that.endPeriodState = {selValue : that.model.defaultEndDate().getMonth() + 1,
|
||||||
list : that.model.monthList(),
|
list : that.model.monthList(),
|
||||||
visible:true };
|
visible:true,
|
||||||
|
label: that.model.label('ID_TO') + ": "
|
||||||
|
};
|
||||||
|
|
||||||
that.endYearState = { selValue : that.model.yearList() [0].value,
|
that.endYearState = { selValue : that.model.yearList() [0].value,
|
||||||
list : that.model.yearList()};
|
list : that.model.yearList(),
|
||||||
|
label: that.model.label('ID_YEAR') + ": "
|
||||||
|
};
|
||||||
|
|
||||||
that.initDate = that.model.defaultInitDate();
|
that.initDate = that.model.defaultInitDate();
|
||||||
that.endDate = that.model.defaultEndDate();
|
that.endDate = that.model.defaultEndDate();
|
||||||
@@ -33,17 +44,23 @@ TimeSeriesPresenter.prototype.initializePresenter = function () {
|
|||||||
return requestFinished.promise();
|
return requestFinished.promise();
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeSeriesPresenter.prototype.fillIndicatorList = function () {
|
TimeSeriesPresenter.prototype.fillIndicatorList = function (dashboardId) {
|
||||||
var requestFinished = $.Deferred();
|
var requestFinished = $.Deferred();
|
||||||
var that = this;
|
var that = this;
|
||||||
var dummyDate = this.helper.date2MysqlString(new Date());
|
var dummyDate = this.helper.date2MysqlString(new Date());
|
||||||
that.indicatorList(that.model.dashboardId, dummyDate, dummyDate)
|
that.indicatorList(dashboardId, dummyDate, dummyDate)
|
||||||
.done(function(modelData){
|
.done(function(modelData){
|
||||||
if (modelData== null || modelData.length == 0) {
|
if (modelData== null || modelData.length == 0) {
|
||||||
that.indicatorState = {selValue: null, list: []}
|
that.indicatorState = {selValue: null,
|
||||||
|
list: [],
|
||||||
|
label: that.model.label('ID_INDICATOR') + ": "
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
that.indicatorState = {selValue: modelData[0].value, list: modelData}
|
that.indicatorState = {selValue: modelData[0].value,
|
||||||
|
list: modelData,
|
||||||
|
label: that.model.label('ID_INDICATOR') + ": "
|
||||||
|
};
|
||||||
}
|
}
|
||||||
requestFinished.resolve(that.indicatorState);
|
requestFinished.resolve(that.indicatorState);
|
||||||
});
|
});
|
||||||
@@ -74,7 +91,7 @@ TimeSeriesPresenter.prototype.changePeriodicity = function (periodicity) {
|
|||||||
|
|
||||||
switch (periodicity * 1) {
|
switch (periodicity * 1) {
|
||||||
case this.helper.ReportingPeriodicityEnum.MONTH:
|
case this.helper.ReportingPeriodicityEnum.MONTH:
|
||||||
this.changePeriodicityToQuarter(this.model.monthList());
|
this.changePeriodicityToMonth(this.model.monthList());
|
||||||
break;
|
break;
|
||||||
case this.helper.ReportingPeriodicityEnum.QUARTER:
|
case this.helper.ReportingPeriodicityEnum.QUARTER:
|
||||||
this.changePeriodicityToQuarter(this.model.quarterList());
|
this.changePeriodicityToQuarter(this.model.quarterList());
|
||||||
@@ -166,19 +183,15 @@ TimeSeriesPresenter.prototype.periodInitDate = function (periodicity, period, ye
|
|||||||
var retval = null;
|
var retval = null;
|
||||||
switch (periodicity * 1) {
|
switch (periodicity * 1) {
|
||||||
case this.helper.ReportingPeriodicityEnum.MONTH:
|
case this.helper.ReportingPeriodicityEnum.MONTH:
|
||||||
//retval = '01-' + period + '-' + year;
|
|
||||||
retval = new Date(year, period - 1, 1);
|
retval = new Date(year, period - 1, 1);
|
||||||
break;
|
break;
|
||||||
case this.helper.ReportingPeriodicityEnum.QUARTER:
|
case this.helper.ReportingPeriodicityEnum.QUARTER:
|
||||||
//retval = '01-' + (3*(period-1) + 1) + '-' + year;
|
|
||||||
retval = new Date(year, 3 * (period-1), 1);
|
retval = new Date(year, 3 * (period-1), 1);
|
||||||
break;
|
break;
|
||||||
case this.helper.ReportingPeriodicityEnum.SEMESTER:
|
case this.helper.ReportingPeriodicityEnum.SEMESTER:
|
||||||
//retval = '01-' + (6*(period-1) + 1) + '-' + year;
|
|
||||||
retval = new Date(year, 6 * (period-1), 1);
|
retval = new Date(year, 6 * (period-1), 1);
|
||||||
break;
|
break;
|
||||||
case this.helper.ReportingPeriodicityEnum.YEAR:
|
case this.helper.ReportingPeriodicityEnum.YEAR:
|
||||||
//retval = '01-01-' + year;
|
|
||||||
retval = new Date(year, 0, 1);
|
retval = new Date(year, 0, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -189,7 +202,6 @@ TimeSeriesPresenter.prototype.periodInitDate = function (periodicity, period, ye
|
|||||||
}
|
}
|
||||||
|
|
||||||
TimeSeriesPresenter.prototype.periodEndDate = function (periodicity, period, year) {
|
TimeSeriesPresenter.prototype.periodEndDate = function (periodicity, period, year) {
|
||||||
|
|
||||||
var retval = null;
|
var retval = null;
|
||||||
switch (periodicity * 1) {
|
switch (periodicity * 1) {
|
||||||
case this.helper.ReportingPeriodicityEnum.MONTH:
|
case this.helper.ReportingPeriodicityEnum.MONTH:
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
helper = new ViewDashboardHelper();
|
helper = new ViewDashboardHelper();
|
||||||
var ws = urlProxy.split('/');
|
var ws = urlProxy.split('/');
|
||||||
var dashboardId = '3290922985542460a19e7c1021519011';
|
tsModel = new TimeSeriesModel(token, urlProxy, ws[3], pageUserId, G_STRING);
|
||||||
tsModel = new TimeSeriesModel(token, urlProxy, ws[3], pageUserId, dashboardId);
|
|
||||||
tsPresenter = new TimeSeriesPresenter(tsModel);
|
tsPresenter = new TimeSeriesPresenter(tsModel);
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$('#indicatorsView').show();
|
||||||
|
$('#compareDiv').hide();
|
||||||
|
|
||||||
$('#periodicityList').change(function(){
|
$('#periodicityList').change(function(){
|
||||||
var id = $(this).val();
|
var id = $(this).val();
|
||||||
@@ -15,6 +15,10 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#compareButton').click(function(){
|
$('#compareButton').click(function(){
|
||||||
|
$('#comparisonBreadcrumb').find('li').remove()
|
||||||
|
$('#comparisonBreadcrumb')
|
||||||
|
.append ('<li><a class="bread-back-selector2" href="#"><i class="fa fa-chevron-left fa-fw"></i>Return to Indicator View</a>');
|
||||||
|
|
||||||
tsPresenter.historicData(
|
tsPresenter.historicData(
|
||||||
$('#indicatorList').val(),
|
$('#indicatorList').val(),
|
||||||
$('#periodicityList').val(),
|
$('#periodicityList').val(),
|
||||||
@@ -46,20 +50,30 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$('#indicatorsView').hide();
|
||||||
|
$('#compareDiv').show();
|
||||||
var graph1 = new LineChart(data, graphParams1, null, null);
|
var graph1 = new LineChart(data, graphParams1, null, null);
|
||||||
graph1.drawChart();
|
graph1.drawChart();
|
||||||
$('#indicatorsView').hide();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('body').on('click','.bread-back-selector2', function() {
|
||||||
|
$('#indicatorsView').show();
|
||||||
|
$('#compareDiv').hide();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var bindTimeSeriesLists = function (presenter, elementsToConserve) {
|
var bindTimeSeriesLists = function (presenter, elementsToConserve) {
|
||||||
var conserveStates =[];
|
var conserveStates =[];
|
||||||
elementsToConserve =[];
|
|
||||||
|
if (elementsToConserve === null || elementsToConserve === undefined) {
|
||||||
|
elementsToConserve =[];
|
||||||
|
}
|
||||||
|
|
||||||
$.each (elementsToConserve, function (i, elem){
|
$.each (elementsToConserve, function (i, elem){
|
||||||
conserveStates.push({id:elem, selValue: $('#' + elem).val()});
|
conserveStates.push({id:elem, selValue: $('#' + elem).val()});
|
||||||
});
|
});
|
||||||
helper.fillSelectWithOptions ($('#indicatorList'), presenter.indicatorState.list, presenter.indicatorState.selValue);
|
helper.fillSelectWithOptions ($('#indicatorList'), presenter.indicatorState.list, presenter.indicatorState.selValue);
|
||||||
helper.fillSelectWithOptions ($('#periodicityList'), presenter.periodicityState.list, presenter.periodicityState.selValue);
|
helper.fillSelectWithOptions ($('#periodicityList'), presenter.periodicityState.list, presenter.periodicityState.selValue);
|
||||||
helper.fillSelectWithOptions ($('#initPeriodList'), presenter.initPeriodState.list, presenter.initPeriodState.selValue);
|
helper.fillSelectWithOptions ($('#initPeriodList'), presenter.initPeriodState.list, presenter.initPeriodState.selValue);
|
||||||
@@ -67,9 +81,15 @@ var bindTimeSeriesLists = function (presenter, elementsToConserve) {
|
|||||||
helper.fillSelectWithOptions ($('#endPeriodList'), presenter.endPeriodState.list, presenter.endPeriodState.selValue);
|
helper.fillSelectWithOptions ($('#endPeriodList'), presenter.endPeriodState.list, presenter.endPeriodState.selValue);
|
||||||
helper.fillSelectWithOptions ($('#endYearList'), presenter.endYearState.list, presenter.endYearState.selValue);
|
helper.fillSelectWithOptions ($('#endYearList'), presenter.endYearState.list, presenter.endYearState.selValue);
|
||||||
|
|
||||||
|
$('#indicatorLabel').text(presenter.indicatorState.label);
|
||||||
|
$('#periodicityLabel').text(presenter.periodicityState.label);
|
||||||
|
$('#initPeriodLabel').text(presenter.initPeriodState.label);
|
||||||
|
$('#endPeriodLabel').text(presenter.endPeriodState.label);
|
||||||
|
|
||||||
|
|
||||||
$.each (conserveStates, function (i, item){
|
$.each (conserveStates, function (i, item){
|
||||||
$('#' + item.id).val(item.selValue);
|
$('#' + item.id).val(item.selValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
helper.setVisibility ($('#initPeriodList'), presenter.initPeriodState.visible);
|
helper.setVisibility ($('#initPeriodList'), presenter.initPeriodState.visible);
|
||||||
helper.setVisibility ($('#endPeriodList'), presenter.endPeriodState.visible);
|
helper.setVisibility ($('#endPeriodList'), presenter.endPeriodState.visible);
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
var ViewDashboardHelper = function () {
|
var ViewDashboardHelper = function () {
|
||||||
|
this.cache = [];
|
||||||
|
this.forceRemote=false; //if true, the next call will go to the remote server
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardHelper.prototype.ReportingPeriodicityEnum = {
|
ViewDashboardHelper.prototype.ReportingPeriodicityEnum = {
|
||||||
@@ -227,3 +229,96 @@ ViewDashboardHelper.prototype.merge = function (objFrom, objTo, propMap) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ViewDashboardHelper.prototype.getJson = function (endPoint, baseUrl, oauthToken) {
|
||||||
|
var that = this;
|
||||||
|
var callUrl = 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 ' + oauthToken);
|
||||||
|
//xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewDashboardHelper.prototype.postJson = function (endPoint, data, baseUrl, oauthToken) {
|
||||||
|
var that = this;
|
||||||
|
return $.ajax({
|
||||||
|
url : 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 ' + oauthToken);
|
||||||
|
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
|
||||||
|
}
|
||||||
|
}).fail(function () {
|
||||||
|
throw new Error('Fail server');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
ViewDashboardHelper.prototype.putJson = function (endPoint, data, baseUrl, oauthToken) {
|
||||||
|
var that = this;
|
||||||
|
return $.ajax({
|
||||||
|
url : 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 ' + oauthToken);
|
||||||
|
//xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
|
||||||
|
}
|
||||||
|
}).fail(function () {
|
||||||
|
throw new Error('Fail server');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
ViewDashboardHelper.prototype.getCacheItem = function (endPoint) {
|
||||||
|
var retval = null;
|
||||||
|
$.each(this.cache, function(index, objectItem) {
|
||||||
|
if (objectItem.key == endPoint) {
|
||||||
|
retval = objectItem.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewDashboardHelper.prototype.putInCache = function (endPoint, data) {
|
||||||
|
var cacheItem = this.getCacheItem(endPoint);
|
||||||
|
if (cacheItem == null) {
|
||||||
|
this.cache.push ({ key: endPoint, value:data });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cacheItem.value = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,16 +5,14 @@ var ViewDashboardModel = function (oauthToken, server, workspace) {
|
|||||||
//this.baseUrl = "http://127.0.0.1:8080/api/1.0/workflow/";
|
//this.baseUrl = "http://127.0.0.1:8080/api/1.0/workflow/";
|
||||||
this.oauthToken = oauthToken;
|
this.oauthToken = oauthToken;
|
||||||
this.helper = new ViewDashboardHelper();
|
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) {
|
ViewDashboardModel.prototype.userDashboards = function(userId) {
|
||||||
return this.getJson('dashboard/ownerData/' + userId);
|
return this.helper.getJson('dashboard/ownerData/' + userId, this.baseUrl, this.oauthToken);
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardModel.prototype.dashboardIndicators = function(dashboardId, initDate, endDate) {
|
ViewDashboardModel.prototype.dashboardIndicators = function(dashboardId, initDate, endDate) {
|
||||||
return this.getJson('dashboard/' + dashboardId + '/indicator?dateIni=' + initDate + '&dateFin=' + endDate);
|
return this.helper.getJson('dashboard/' + dashboardId + '/indicator?dateIni=' + initDate + '&dateFin=' + endDate, this.baseUrl, this.oauthToken);
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewDashboardModel.prototype.peiData = function(indicatorId, compareDate, measureDate) {
|
ViewDashboardModel.prototype.peiData = function(indicatorId, compareDate, measureDate) {
|
||||||
@@ -23,12 +21,12 @@ ViewDashboardModel.prototype.peiData = function(indicatorId, compareDate, measur
|
|||||||
"&compare_date=" + compareDate +
|
"&compare_date=" + compareDate +
|
||||||
"&measure_date=" + measureDate +
|
"&measure_date=" + measureDate +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
return this.getJson(endPoint);
|
return this.helper.getJson(endPoint, this.baseUrl, this.oauthToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewDashboardModel.prototype.statusData = function() {
|
ViewDashboardModel.prototype.statusData = function() {
|
||||||
var endPoint = "ReportingIndicators/status-indicator";
|
var endPoint = "ReportingIndicators/status-indicator";
|
||||||
return this.getJson(endPoint);
|
return this.helper.getJson(endPoint, this.baseUrl, this.oauthToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewDashboardModel.prototype.peiDetailData = function(process, initDate, endDate) {
|
ViewDashboardModel.prototype.peiDetailData = function(process, initDate, endDate) {
|
||||||
@@ -37,7 +35,7 @@ ViewDashboardModel.prototype.peiDetailData = function(process, initDate, endDate
|
|||||||
"&init_date=" + initDate +
|
"&init_date=" + initDate +
|
||||||
"&end_date=" + endDate +
|
"&end_date=" + endDate +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
return this.getJson(endPoint);
|
return this.helper.getJson(endPoint, this.baseUrl, this.oauthToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewDashboardModel.prototype.ueiData = function(indicatorId, compareDate, measureDate ) {
|
ViewDashboardModel.prototype.ueiData = function(indicatorId, compareDate, measureDate ) {
|
||||||
@@ -46,7 +44,7 @@ ViewDashboardModel.prototype.ueiData = function(indicatorId, compareDate, measur
|
|||||||
"&compare_date=" + compareDate +
|
"&compare_date=" + compareDate +
|
||||||
"&measure_date=" + measureDate +
|
"&measure_date=" + measureDate +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
return this.getJson(endPoint);
|
return this.helper.getJson(endPoint, this.baseUrl, this.oauthToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewDashboardModel.prototype.ueiDetailData = function(groupId, initDate, endDate) {
|
ViewDashboardModel.prototype.ueiDetailData = function(groupId, initDate, endDate) {
|
||||||
@@ -55,7 +53,7 @@ ViewDashboardModel.prototype.ueiDetailData = function(groupId, initDate, endDate
|
|||||||
"&init_date=" + initDate +
|
"&init_date=" + initDate +
|
||||||
"&end_date=" + endDate +
|
"&end_date=" + endDate +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
return this.getJson(endPoint);
|
return this.helper.getJson(endPoint, this.baseUrl, this.oauthToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewDashboardModel.prototype.generalIndicatorData = function(indicatorId, initDate, endDate) {
|
ViewDashboardModel.prototype.generalIndicatorData = function(indicatorId, initDate, endDate) {
|
||||||
@@ -65,11 +63,12 @@ ViewDashboardModel.prototype.generalIndicatorData = function(indicatorId, initDa
|
|||||||
"&init_date=" + initDate +
|
"&init_date=" + initDate +
|
||||||
"&end_date=" + endDate +
|
"&end_date=" + endDate +
|
||||||
"&language=en";
|
"&language=en";
|
||||||
return this.getJson(endPoint);
|
return this.helper.getJson(endPoint, this.baseUrl, this.oauthToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewDashboardModel.prototype.getPositionIndicator = function(callBack) {
|
ViewDashboardModel.prototype.getPositionIndicator = function(callBack) {
|
||||||
this.getJson('dashboard/config').done(function (r) {
|
var that = this;
|
||||||
|
this.helper.getJson('dashboard/config', that.baseUrl, that.oauthToken).done(function (r) {
|
||||||
var graphData = [];
|
var graphData = [];
|
||||||
$.each(r, function(index, originalObject) {
|
$.each(r, function(index, originalObject) {
|
||||||
var map = {
|
var map = {
|
||||||
@@ -91,103 +90,11 @@ ViewDashboardModel.prototype.setPositionIndicator = function(data) {
|
|||||||
this.getPositionIndicator(
|
this.getPositionIndicator(
|
||||||
function(response){
|
function(response){
|
||||||
if (response.length != 0) {
|
if (response.length != 0) {
|
||||||
that.putJson('dashboard/config', data);
|
that.helper.putJson('dashboard/config', data, that.baseUrl, that.oauthToken);
|
||||||
} else {
|
} else {
|
||||||
that.postJson('dashboard/config', data);
|
that.helper.postJson('dashboard/config', data, that.baseUrl, that.oauthToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -352,13 +352,13 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
|
|
||||||
/*-------------------------------clicks----------------------------*/
|
/*-------------------------------clicks----------------------------*/
|
||||||
$('body').on('click','.btn-compare', function() {
|
/*$('body').on('click','.btn-compare', function() {
|
||||||
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
|
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
|
||||||
.done(function(indicatorsVM) {
|
.done(function(indicatorsVM) {
|
||||||
fillIndicatorWidgets(indicatorsVM);
|
fillIndicatorWidgets(indicatorsVM);
|
||||||
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
|
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
|
||||||
});
|
});
|
||||||
});
|
});*/
|
||||||
|
|
||||||
$('#dashboardsList').on('click','.das-title-selector', function() {
|
$('#dashboardsList').on('click','.das-title-selector', function() {
|
||||||
var dashboardId = $(this).parent().data('dashboard-id');
|
var dashboardId = $(this).parent().data('dashboard-id');
|
||||||
@@ -409,14 +409,9 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initialDraw();
|
||||||
|
|
||||||
|
|
||||||
tsPresenter.initializePresenter()
|
|
||||||
.done(function (data){
|
|
||||||
bindTimeSeriesLists(tsPresenter);
|
|
||||||
initialDraw();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var hideScrollIfAllDivsAreVisible = function(){
|
var hideScrollIfAllDivsAreVisible = function(){
|
||||||
@@ -481,13 +476,20 @@ var initialDraw = function () {
|
|||||||
.then(function(dashboardsVM) {
|
.then(function(dashboardsVM) {
|
||||||
fillDashboardsList(dashboardsVM);
|
fillDashboardsList(dashboardsVM);
|
||||||
if (window.currentDashboardId == null) {return;}
|
if (window.currentDashboardId == null) {return;}
|
||||||
/**** window initialization with favorite dashboard*****/
|
|
||||||
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
|
console.log(tsPresenter);
|
||||||
.done(function(indicatorsVM) {
|
console.log(window.currentDashboardId);
|
||||||
fillIndicatorWidgets(indicatorsVM);
|
tsPresenter.initializePresenter(window.currentDashboardId)
|
||||||
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
|
.done(function (data){
|
||||||
setActiveDashboard();
|
bindTimeSeriesLists(tsPresenter);
|
||||||
});
|
/**** window initialization with favorite dashboard*****/
|
||||||
|
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
|
||||||
|
.done(function(indicatorsVM) {
|
||||||
|
fillIndicatorWidgets(indicatorsVM);
|
||||||
|
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
|
||||||
|
setActiveDashboard();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -374,21 +374,20 @@
|
|||||||
<div id="compareIndicators" class="row pull-left">
|
<div id="compareIndicators" class="row pull-left">
|
||||||
|
|
||||||
<div class="span4 pull-left">
|
<div class="span4 pull-left">
|
||||||
**Graph:
|
<span id="indicatorLabel"></span>
|
||||||
<select id="indicatorList"></select>
|
<select id="indicatorList"></select>
|
||||||
***Periodicty:
|
<span id="periodicityLabel"></span>
|
||||||
<select id="periodicityList" style="width:auto;"></select>
|
<select id="periodicityList" style="width:auto;"></select>
|
||||||
***From:
|
<span id="initPeriodLabel"></span>
|
||||||
<select id="initPeriodList"></select>
|
<select id="initPeriodList"></select>
|
||||||
<select id="initYearList"></select>
|
<select id="initYearList"></select>
|
||||||
***To:
|
<span id="endPeriodLabel"></span>
|
||||||
<select id="endPeriodList"></select>
|
<select id="endPeriodList"></select>
|
||||||
<select id="endYearList"></select>
|
<select id="endYearList"></select>
|
||||||
<input type="button" id="compareButton" value="**Compare"/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="span4 pull-left">
|
<div class="span4 pull-left">
|
||||||
<button type="button" class="btn btn-compare btn-success pull-right btn-date">{translate label="ID_DASH_COMPARE"}</button>
|
<button type="button" id="compareButton" class="btn btn-compare btn-success pull-right btn-date">{translate label="ID_DASH_COMPARE"}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -438,7 +437,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" id="compareGraph"></div>
|
|
||||||
|
<div class="process-div" id="compareDiv">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<ol id="comparisonBreadcrumb" class="breadcrumb">
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div id="compareGraph" style="padding:0 50px 0 50px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user