Repository: tez Updated Branches: refs/heads/master e84231ebc -> af0d4d7c8
TEZ-3642. Tez UI: Auto-refresh is not stopping when DAG is the main entity (sree) Project: http://git-wip-us.apache.org/repos/asf/tez/repo Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/af0d4d7c Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/af0d4d7c Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/af0d4d7c Branch: refs/heads/master Commit: af0d4d7c81f407898057056b786b38d6679e90c7 Parents: e84231e Author: Sreenath Somarajapuram <[email protected]> Authored: Tue Mar 7 16:38:54 2017 +0530 Committer: Sreenath Somarajapuram <[email protected]> Committed: Tue Mar 7 16:38:54 2017 +0530 ---------------------------------------------------------------------- CHANGES.txt | 1 + tez-ui/src/main/webapp/app/entities/entity.js | 33 +++++++++---- .../webapp/tests/unit/entities/entity-test.js | 49 ++++++++++++++++++++ 3 files changed, 75 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tez/blob/af0d4d7c/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index a3a74bc..1d2af07 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -214,6 +214,7 @@ ALL CHANGES: TEZ-3630. Tez UI: Use DAG status for controlling auto-refresh polling TEZ-3639. Tez UI: Footer pagination is improper in landing page TEZ-3640. Tez UI: Add associated llap application id to queries page + TEZ-3642. Tez UI: Auto-refresh is not stopping when DAG is the main entity Release 0.8.5: Unreleased http://git-wip-us.apache.org/repos/asf/tez/blob/af0d4d7c/tez-ui/src/main/webapp/app/entities/entity.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/entities/entity.js b/tez-ui/src/main/webapp/app/entities/entity.js index 80a836e..d982811 100644 --- a/tez-ui/src/main/webapp/app/entities/entity.js +++ b/tez-ui/src/main/webapp/app/entities/entity.js @@ -32,6 +32,7 @@ var Entity = Ember.Object.extend(NameMixin, { params: query, urlParams: urlParams }).then(function (record) { + that.resetAllNeeds(loader, record, options); return that._loadAllNeeds(loader, record, options, urlParams); }); }, @@ -44,6 +45,7 @@ var Entity = Ember.Object.extend(NameMixin, { urlParams: urlParams }).then(function (records) { return Ember.RSVP.all(records.map(function (record) { + that.resetAllNeeds(loader, record, options); return that._loadAllNeeds(loader, record, options, urlParams); })).then(function () { return records; @@ -96,6 +98,14 @@ var Entity = Ember.Object.extend(NameMixin, { return Ember.Object.create(need, overrides); }, + setNeed: function (parentModel, name, model) { + if(!parentModel.get("isDeleted")) { + parentModel.set(name, model); + parentModel.refreshLoadTime(); + } + return parentModel; + }, + _loadNeed: function (loader, parentModel, needOptions, options, index) { var needLoader, that = this, @@ -128,10 +138,7 @@ var Entity = Ember.Object.extend(NameMixin, { } needLoader = needLoader.then(function (model) { - if(!parentModel.get("isDeleted")) { - parentModel.set(needOptions.name, model); - parentModel.refreshLoadTime(); - } + that.setNeed(parentModel, needOptions.name, model); return model; }); @@ -141,10 +148,7 @@ var Entity = Ember.Object.extend(NameMixin, { } if(needOptions.silent) { - if(!parentModel.get("isDeleted")) { - parentModel.set(needOptions.name, null); - parentModel.refreshLoadTime(); - } + that.setNeed(parentModel, needOptions.name, null); } else { throw(err); @@ -198,6 +202,19 @@ var Entity = Ember.Object.extend(NameMixin, { } }, + resetAllNeeds: function (loader, parentModel/*, options*/) { + var needs = parentModel.get("needs"), + that = this; + + if(needs) { + MoreObject.forEach(needs, function (name, needOptions) { + needOptions = that.normalizeNeed(name, needOptions, parentModel); + that.setNeed(parentModel, needOptions.name, null); + }); + } + + return parentModel; + }, }); export default Entity; http://git-wip-us.apache.org/repos/asf/tez/blob/af0d4d7c/tez-ui/src/main/webapp/tests/unit/entities/entity-test.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/tests/unit/entities/entity-test.js b/tez-ui/src/main/webapp/tests/unit/entities/entity-test.js index a7677a7..1e353f0 100644 --- a/tez-ui/src/main/webapp/tests/unit/entities/entity-test.js +++ b/tez-ui/src/main/webapp/tests/unit/entities/entity-test.js @@ -34,11 +34,14 @@ test('Basic creation test', function(assert) { assert.ok(entity.query); assert.ok(entity.normalizeNeed); + assert.ok(entity.setNeed); assert.ok(entity._loadNeed); assert.ok(entity.loadNeed); assert.ok(entity._loadAllNeeds); assert.ok(entity.loadAllNeeds); + + assert.ok(entity.resetAllNeeds); }); test('normalizeNeed test', function(assert) { @@ -206,6 +209,27 @@ test('loadAllNeeds silent=true test', function(assert) { }); }); +test('setNeed test', function(assert) { + let entity = this.subject(), + parentModel = Ember.Object.create({ + refreshLoadTime: function () { + assert.ok(true); + } + }), + testModel = {}, + testName = "name"; + + assert.expect(1 + 2); + + entity.setNeed(parentModel, testName, testModel); + assert.equal(parentModel.get(testName), testModel); + + parentModel.set("isDeleted", true); + parentModel.set(testName, undefined); + entity.setNeed(parentModel, testName, testModel); + assert.equal(parentModel.get(testName), undefined); +}); + test('_loadNeed single string type test', function(assert) { let entity = this.subject(), loader, @@ -300,3 +324,28 @@ test('_loadNeed test with silent false', function(assert) { assert.equal(err, testErr); }); }); + +test('resetAllNeeds test', function(assert) { + let entity = this.subject(), + parentModel = Ember.Object.create({ + needs : { + foo: {}, + bar: {} + }, + foo: 1, + bar: 2, + refreshLoadTime: function () { + assert.ok(true); + } + }); + + assert.expect(2 + 2 + 2); + + assert.equal(parentModel.get("foo"), 1); + assert.equal(parentModel.get("bar"), 2); + + entity.resetAllNeeds({}, parentModel); + + assert.equal(parentModel.get("foo"), null); + assert.equal(parentModel.get("bar"), null); +}); \ No newline at end of file
