|
@@ -3,19 +3,52 @@ var setItemLocalStorage = global.setItemLocalStorage;
|
|
|
var p5WFS_GetFeature = global.p5WFS_GetFeature;
|
|
|
var renderGraph = global.renderGraph; // @from sankey-init
|
|
|
var DBG = DBG || 0;
|
|
|
+var DBG1 = 1;
|
|
|
|
|
|
+// requestId - job/task id int (auto increment or timestamp)
|
|
|
+// TODO: if (requestId > idSentToRender) // then still loading, but rendered old response
|
|
|
+var graphShowHide__requestId = 0;
|
|
|
+var graphShowHide__idSentToRender = 0;
|
|
|
function graphShowHide(nameSection) {
|
|
|
+ graphShowHide__requestId++;
|
|
|
+ var this__requestId = graphShowHide__requestId;
|
|
|
var node = $('#smad-'+nameSection+'-graph-view')
|
|
|
if (!node || !node.length) return;
|
|
|
if ('block' !== node.css('display')) {
|
|
|
+ DBG && console.log("DBG:graphShowHide: sending Request("+this__requestId+") ...", { graphShowHide__requestId, graphShowHide__idSentToRender });
|
|
|
node.show()
|
|
|
- graphFetchData(node.get(0), nameSection)
|
|
|
+ var graphResultNode = node.get(0)
|
|
|
+ graphFetchData(nameSection).then(function (response) {
|
|
|
+ return {
|
|
|
+ requestId: this__requestId,
|
|
|
+ response: response
|
|
|
+ };
|
|
|
+ }).then(function (graphJobResponse) {
|
|
|
+ var requestId = graphJobResponse.requestId;
|
|
|
+ var items = graphJobResponse.response;
|
|
|
+ DBG && console.warn("DBG:graphShowHide: Response("+requestId+") received", { requestId, graphShowHide__requestId, graphShowHide__idSentToRender, items });
|
|
|
+
|
|
|
+ if (graphShowHide__idSentToRender > requestId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ graphShowHide__idSentToRender = requestId;
|
|
|
+ graphRaportRender({
|
|
|
+ msg: "Pobrano dane",
|
|
|
+ typeName: ('pracownicy' === nameSection) ? 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY' : 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
|
+ items: items
|
|
|
+ }, graphResultNode)
|
|
|
+ }).catch(function (err) {
|
|
|
+ if(DBG)console.log('p5WFS_GetFeature: err: ', err);
|
|
|
+ // graphRaportRender({ msg: "Wystąpiły błędy podczas pobierania danych", nameSection: nameSection, err: err }, node)
|
|
|
+ })
|
|
|
} else {
|
|
|
+ DBG && console.warn("DBG:graphShowHide: hide");
|
|
|
node.hide()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function graphFetchData(node, nameSection) {
|
|
|
+function graphFetchData(nameSection) {
|
|
|
var page = page || getItemLocalStorage('Bocian.biAuditForm.'+nameSection+'.pagination.page');
|
|
|
if ( page === 1) {
|
|
|
setItemLocalStorage('Bocian.biAuditForm.'+nameSection+'.pagination.page', 1);
|
|
@@ -88,7 +121,7 @@ function graphFetchData(node, nameSection) {
|
|
|
return flatList;
|
|
|
}
|
|
|
|
|
|
- p5WFS_GetFeature(('pracownicy' === nameSection) ? 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY' : 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
|
+ return p5WFS_GetFeature(('pracownicy' === nameSection) ? 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY' : 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
|
Object.assign({
|
|
|
sortBy: 'ID+D',
|
|
|
maxFeatures: paginationLimit,
|
|
@@ -171,17 +204,7 @@ function graphFetchData(node, nameSection) {
|
|
|
}
|
|
|
: {}
|
|
|
)
|
|
|
- ).then(function (items) {
|
|
|
- if(DBG)console.log('p5WFS_GetFeature: items: ', items);
|
|
|
- graphRaportRender({
|
|
|
- msg: "Pobrano dane",
|
|
|
- typeName: ('pracownicy' === nameSection) ? 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY' : 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
|
- items: items
|
|
|
- }, node)
|
|
|
- }).catch(function (err) {
|
|
|
- if(DBG)console.log('p5WFS_GetFeature: err: ', err);
|
|
|
- // graphRaportRender({ msg: "Wystąpiły błędy podczas pobierania danych", nameSection: nameSection, err: err }, node)
|
|
|
- })
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
function graphRender(props, wrapNode) {
|