diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2012-03-22 17:03:57 +0100 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2012-03-29 13:39:37 +0200 |
commit | bbe672a2aea1651a4a0eeca20b8339f0799f3431 (patch) | |
tree | 6f14a8c94472b33f1c6373fd0e0f6ba51b790e96 /install/ui/facet.js | |
parent | 5cfee2338d548035151926c5c235f3426fca0499 (diff) | |
download | freeipa.git-bbe672a2aea1651a4a0eeca20b8339f0799f3431.tar.gz freeipa.git-bbe672a2aea1651a4a0eeca20b8339f0799f3431.tar.xz freeipa.git-bbe672a2aea1651a4a0eeca20b8339f0799f3431.zip |
Facet expiration flag
Problem:
For performance reason a facet may cache the data in browser's memory. There should be a flag to indicate whether a facet has expired and should be refreshed. The expired flag could be set by these events:
1) any update operation
2) changing search filter in search facet
3) switching page in a multi-paged search/association facet
4) switching direct/indirect view in association facet
5) facet expiration time
A facet should be able to use these methods to refresh itself:
6) on demand: an expired facet should be refreshed when a user opens it.
7) automatic: an open facet should automatically refresh itself when it expires.
Solution:
This patch solves cases: #2, #3, #5, #6. Case #4 works without any change. Case #1 will be solved later. Case #7 is deffered.
Default expiration timeout was set to 10 minutes.
In this patch are also updated facet.needs_update methods to reflect changes in containing facets.
https://fedorahosted.org/freeipa/ticket/2075
Diffstat (limited to 'install/ui/facet.js')
-rw-r--r-- | install/ui/facet.js | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/install/ui/facet.js b/install/ui/facet.js index ab71f820..a38bcddf 100644 --- a/install/ui/facet.js +++ b/install/ui/facet.js @@ -45,6 +45,9 @@ IPA.facet = function(spec) { that.header = spec.header || IPA.facet_header({ facet: that }); that._needs_update = spec.needs_update; + that.expired_flag = true; + that.last_updated = null; + that.expire_timeout = spec.expire_timeout || 600; //[seconds] that.dialogs = $.ordered_map(); @@ -140,8 +143,34 @@ IPA.facet = function(spec) { }; that.needs_update = function() { + if (that._needs_update !== undefined) return that._needs_update; - return true; + + var needs_update = false; + + if (that.expire_timeout && that.expire_timeout > 0) { + + if (!that.last_updated) { + needs_update = true; + } else { + var now = Date.now(); + needs_update = (now - that.last_updated) > that.expire_timeout * 1000; + } + } + + needs_update = needs_update || that.expired_flag; + needs_update = needs_update || that.error_displayed(); + + return needs_update; + }; + + that.set_expired_flag = function() { + that.expired_flag = true; + }; + + that.clear_expired_flag = function() { + that.expired_flag = false; + that.last_updated = Date.now(); }; that.is_dirty = function() { @@ -263,6 +292,7 @@ IPA.facet = function(spec) { that.facet_create = that.create; that.facet_create_header = that.create_header; that.facet_create_content = that.create_content; + that.facet_needs_update = that.needs_update; that.facet_show = that.show; that.facet_hide = that.hide; that.facet_load = that.load; @@ -583,6 +613,8 @@ IPA.table_facet = function(spec) { that.table.total_pages_span.text(that.table.total_pages); that.table.pagination_control.css('visibility', 'visible'); + + that.clear_expired_flag(); }; @@ -821,6 +853,7 @@ IPA.table_facet = function(spec) { if (that.table.current_page > 1) { var state = {}; state[that.entity.name+'-page'] = that.table.current_page - 1; + that.set_expired_flag(); IPA.nav.push_state(state); } }; @@ -829,6 +862,7 @@ IPA.table_facet = function(spec) { if (that.table.current_page < that.table.total_pages) { var state = {}; state[that.entity.name+'-page'] = that.table.current_page + 1; + that.set_expired_flag(); IPA.nav.push_state(state); } }; @@ -841,6 +875,7 @@ IPA.table_facet = function(spec) { } var state = {}; state[that.entity.name+'-page'] = page; + that.set_expired_flag(); IPA.nav.push_state(state); }; }; |