Skip to content

Commit

Permalink
HPCC-18601 Re-evaluate package maps widget in 7.0
Browse files Browse the repository at this point in the history
Improving some of the code in PackageMapQueryWidget.js to take advantage
of the ECLWatch framework. U/I was not loading in 7.0.0 due
to some changes in dependencies - that has been fixed. Also, improve overall usability and
performance.

Signed-off by: Miguel Vazquez <miguel.vazquez@lexisnexis.com>
  • Loading branch information
Miguel Vazquez committed Mar 13, 2018
1 parent 4192226 commit 6f5d98e
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 397 deletions.
124 changes: 12 additions & 112 deletions esp/src/eclwatch/ESPPackageProcess.js
Expand Up @@ -18,123 +18,25 @@ define([
"dojo/_base/array",
"dojo/_base/lang",
"dojo/_base/Deferred",
"dojo/data/ObjectStore",
"dojo/store/util/QueryResults",
"dojo/store/Observable",

"hpcc/WsPackageMaps",
"hpcc/ESPUtil"
"hpcc/ESPUtil",
"hpcc/ESPRequest"
], function (declare, arrayUtil, lang, Deferred,
ObjectStore, QueryResults, Observable,
WsPackageMaps, ESPUtil) {
Observable,
WsPackageMaps, ESPUtil, ESPRequest) {

var _packageMaps = {};
var Store = declare(null, {
var Store = declare([ESPRequest.Store], {
service: "WsPackageProcess",
action: "ListPackages",
responseQualifier: "ListPackagesResponse.PackageMapList.PackageListMapData",
idProperty: "Id",

_watched: {},

constructor: function (options) {
declare.safeMixin(this, options);
},

getIdentity: function (object) {
return object[this.idProperty];
},

get: function (id) {
if (!_packageMaps[id]) {
_packageMaps[id] = new packageMap({
Id: id
});
}
return _packageMaps[id];
},

sortPackageMaps: function (packageMaps, sortIn) {
packageMaps.sort(function(a, b){
var vA = a.Id;
var vB = b.Id;
if (sortIn.attribute === 'Target') {
vA = a.Target;
vB = b.Target;
}
else if (sortIn.attribute === 'Process') {
vA = a.Process;
vB = b.Process;
}
else if (sortIn.attribute === 'Description') {
vA = a.Description;
vB = b.Description;
}
else if (sortIn.attribute === 'Active') {
vA = a.Active;
vB = b.Active;
}
if (sortIn.descending) {
if (vA < vB) //sort string ascending
return 1;
if (vA > vB)
return -1;
}
else {
if (vA < vB)
return -1;
if (vA > vB)
return 1;
}
return 0 //default return value (no sorting)
})
return packageMaps;
},

query: function (query, options) {
var request = {};
lang.mixin(request, options.query);
if (options.query.Target)
request['Target'] = options.query.Target;
if (options.query.Process)
request['Process'] = options.query.Process;
if (options.query.ProcessFilter)
request['ProcessFilter'] = options.query.ProcessFilter;

var results = WsPackageMaps.PackageMapQuery({
request: request
});

var deferredResults = new Deferred();
deferredResults.total = results.then(function (response) {
if (lang.exists("ListPackagesResponse.NumPackages", response)) {
return response.ListPackagesResponse.NumPackages;
}
return 0;
preProcessRow: function (row) {
lang.mixin(row, {
calculatedID: row.Id + row.Target
});
var context = this;
Deferred.when(results, function (response) {
var packageMaps = [];
for (var key in context._watched) {
context._watched[key].unwatch();
}
this._watched = {};
if (lang.exists("ListPackagesResponse.PackageMapList.PackageListMapData", response)) {
arrayUtil.forEach(response.ListPackagesResponse.PackageMapList.PackageListMapData, function (item, index) {
var packageMap = context.get(item.Id);
packageMap.updateData(item);
packageMaps.push(packageMap);
context._watched[packageMap.Id] = packageMap.watch("__hpcc_changedCount", function (name, oldValue, newValue) {
if (oldValue !== newValue) {
context.notify(packageMap, packageMap.Id);
}
});
});
if (options.sort) {
packageMaps = context.sortPackageMaps(packageMaps, options.sort[0]);
}
}
deferredResults.resolve(packageMaps);
});

return QueryResults(deferredResults);
}
});

Expand All @@ -149,9 +51,7 @@ define([
return {
CreatePackageMapQueryObjectStore: function (options) {
var store = new Store(options);
store = Observable(store);
var objStore = new ObjectStore({ objectStore: store });
return objStore;
return Observable(store);
}
};
});
3 changes: 2 additions & 1 deletion esp/src/eclwatch/PackageMapDetailsWidget.js
Expand Up @@ -44,6 +44,7 @@ define([
templateString: template,
baseClass: "PackageMapDetailsWidget",
i18n: nlsHPCC,

borderContainer: null,
tabContainer: null,
validateWidget: null,
Expand Down Expand Up @@ -121,7 +122,7 @@ define([
this.process = params.process;
this.active = params.active;
if (params.packageMap) {
registry.byId(this.id + "Summary").set("title", params.packageMap);
registry.byId(this.id + "_Summary").set("title", params.packageMap);
domAttr.set(this.id + "PMID", "innerHTML", params.packageMap);
domAttr.set(this.id + "Target", "value", params.target);
domAttr.set(this.id + "Process", "value", params.process);
Expand Down

0 comments on commit 6f5d98e

Please sign in to comment.