1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-20 14:03:49 +03:00

* Added a more aggresive cache for types, tables & guis (Less requests to server)

* Fixed ServicePools tables
* Fixed log tables
This commit is contained in:
Adolfo Gómez García 2015-10-16 07:43:03 +02:00
parent 162c84e21c
commit c9e9f60ed1
5 changed files with 65 additions and 43 deletions

View File

@ -180,8 +180,10 @@ class BasicModelRest
success_fnc {} success_fnc {}
return return
if cacheKey isnt "." and @cache.get(cacheKey) if cacheKey isnt "." and @cache.get(cacheKey)
api.doLog "Cache SUCCESS for " + cacheKey
success_fnc @cache.get(cacheKey) success_fnc @cache.get(cacheKey)
else else
api.doLog "Cache FAIL for " + cacheKey
$this = @ $this = @
api.doLog 'Obtaining json for ', path api.doLog 'Obtaining json for ', path
api.getJson path, api.getJson path,
@ -321,7 +323,7 @@ class BasicModelRest
path = @guiPath path = @guiPath
@_requestPath path, @_requestPath path,
cacheKey: "." cacheKey: path
success: success_fnc success: success_fnc
fail: fail_fnc fail: fail_fnc
@ -333,6 +335,7 @@ class BasicModelRest
path = @tableInfoPath path = @tableInfoPath
@_requestPath path, @_requestPath path,
cacheKey: path
success: success_fnc success: success_fnc
fail: fail_fnc fail: fail_fnc

View File

@ -117,7 +117,7 @@ gui.servicesPools.link = (event) ->
api.templates.get "services_pool", (tmpl) -> api.templates.get "services_pool", (tmpl) ->
gui.appendToWorkspace api.templates.evaluate(tmpl, gui.appendToWorkspace api.templates.evaluate(tmpl,
deployed_services: "deployed-services-placeholder" deployed_services: "deployed-services-placeholder"
pool_info: "pool-info" pool_info: "pool-info-placeholder"
assigned_services: "assigned-services-placeholder" assigned_services: "assigned-services-placeholder"
cache: "cache-placeholder" cache: "cache-placeholder"
groups: "groups-placeholder" groups: "groups-placeholder"
@ -176,6 +176,10 @@ gui.servicesPools.link = (event) ->
return return
$("#detail-placeholder").removeClass "hidden" $("#detail-placeholder").removeClass "hidden"
$('#detail-placeholder a[href="#pool-info-placeholder"]').tab('show')
# Load provider "info"
gui.methods.typedShow gui.servicesPools, selected[0], '#pool-info-placeholder .well', gettext('Error accessing data')
# #
# * Cache Part # * Cache Part
@ -186,11 +190,13 @@ gui.servicesPools.link = (event) ->
# Shows/hides cache # Shows/hides cache
if info.uses_cache or info.uses_cache_l2 if info.uses_cache or info.uses_cache_l2
$("#cache-placeholder_tab").removeClass "hidden" $("#cache-placeholder_tab").removeClass "hidden"
cachedItems = new GuiElement(api.servicesPools.detail(servPool.id, "cache", { permission: servPool.permission }), "cache") cachedItems = new GuiElement(api.servicesPools.detail(servPool.id, "cache", { permission: servPool.permission }), "cache")
# Cached items table # Cached items table
prevCacheLogTbl = null prevCacheLogTbl = null
cachedItemsTable = cachedItems.table( cachedItemsTable = cachedItems.table(
doNotLoadData: true
icon: 'cached' icon: 'cached'
container: "cache-placeholder_tbl" container: "cache-placeholder_tbl"
rowSelect: "single" rowSelect: "single"
@ -205,7 +211,6 @@ gui.servicesPools.link = (event) ->
return return
onRowSelect: (selected) -> onRowSelect: (selected) ->
gui.do
cached = selected[0] cached = selected[0]
if prevCacheLogTbl if prevCacheLogTbl
$tbl = $(prevCacheLogTbl).dataTable() $tbl = $(prevCacheLogTbl).dataTable()
@ -234,6 +239,7 @@ gui.servicesPools.link = (event) ->
# Groups items table # Groups items table
groupsTable = groups.table( groupsTable = groups.table(
doNotLoadData: true
icon: 'groups' icon: 'groups'
container: "groups-placeholder" container: "groups-placeholder"
rowSelect: "single" rowSelect: "single"
@ -310,6 +316,7 @@ gui.servicesPools.link = (event) ->
prevAssignedLogTbl = null prevAssignedLogTbl = null
assignedServices = new GuiElement(api.servicesPools.detail(servPool.id, "services", { permission: servPool.permission }), "services") assignedServices = new GuiElement(api.servicesPools.detail(servPool.id, "services", { permission: servPool.permission }), "services")
assignedServicesTable = assignedServices.table( assignedServicesTable = assignedServices.table(
doNotLoadData: true
icon: 'assigned' icon: 'assigned'
container: "assigned-services-placeholder_tbl" container: "assigned-services-placeholder_tbl"
rowSelect: "single" rowSelect: "single"
@ -356,6 +363,7 @@ gui.servicesPools.link = (event) ->
# Transports items table # Transports items table
transportsTable = transports.table( transportsTable = transports.table(
doNotLoadData: true
icon: 'transports' icon: 'transports'
container: "transports-placeholder" container: "transports-placeholder"
doNotLoadData: true doNotLoadData: true
@ -424,6 +432,7 @@ gui.servicesPools.link = (event) ->
# Publications table # Publications table
publicationsTable = publications.table( publicationsTable = publications.table(
doNotLoadData: true
icon: 'publications' icon: 'publications'
container: "publications-placeholder" container: "publications-placeholder"
doNotLoadData: true doNotLoadData: true
@ -513,6 +522,7 @@ gui.servicesPools.link = (event) ->
# * Log table # * Log table
# #
logTable = gui.servicesPools.logTable(servPool.id, logTable = gui.servicesPools.logTable(servPool.id,
doNotLoadData: true
container: "logs-placeholder" container: "logs-placeholder"
) )
prevTables.push logTable prevTables.push logTable
@ -538,7 +548,7 @@ gui.servicesPools.link = (event) ->
return return
onNew: gui.methods.typedNew(gui.servicesPools, gettext("New service pool"), "Service pool " + gettext("creation error"), onNew: gui.methods.typedNew(gui.servicesPools, gettext("New service pool"), "Service pool " + gettext("creation error"),
guiProcessor: (guiDef) -> # Create has "save on publish" field guiProcessor: (guiDef) -> # Create has "publish on save" field
editMode = false editMode = false
gui.doLog guiDef gui.doLog guiDef
newDef = [].concat(guiDef).concat([ newDef = [].concat(guiDef).concat([

View File

@ -428,7 +428,7 @@
data: data data: data
deferRender: tblParams.deferedRender or tblParams.deferRender or false deferRender: tblParams.deferedRender or tblParams.deferRender or false
oLanguage: gui.config.dataTablesLanguage language: gui.config.dataTablesLanguage
# If row is "styled" # If row is "styled"
@ -436,9 +436,14 @@
field = row_style.field field = row_style.field
dct = row_style.dict dct = row_style.dict
prefix = row_style.prefix prefix = row_style.prefix
dataTableOptions.fnCreatedRow = (nRow, aData, iDataIndex) -> dataTableOptions.createdRow = (row, data, dataIndex) ->
v = (if dct? then dct[@fnGetData(iDataIndex)[field]] else @fnGetData(iDataIndex)[field]) # gui.doLog row, data, dataIndex, data[field]
$(nRow).addClass prefix + v try
v = (if dct? then dct[data[field]] else data[field])
$(row).addClass prefix + v
catch err
gui.doLog "Exception got: ", err
return return
dTable = $("#" + tableId).DataTable dataTableOptions dTable = $("#" + tableId).DataTable dataTableOptions
@ -615,27 +620,25 @@
$("#" + tblParams.container).append table.text $("#" + tblParams.container).append table.text
# Responsive style for tables, using tables.css and this code generates the "titles" for vertical display on small sizes # Responsive style for tables, using tables.css and this code generates the "titles" for vertical display on small sizes
$("#style-" + tableId).remove() # Remove existing style for table before adding new one
$(api.templates.evaluate("tmpl_comp_responsive_table",
tableId: tableId
columns: columns
)).appendTo "head"
initLog = (data) -> initLog = (data) ->
gui.doLog data $("#" + tableId).DataTable
$("#" + tableId).dataTable data: data
aaData: data ordering: true
aaSorting: [[ order: [[ 1, 'desc' ]]
0
"desc" columns: columns
]] language: gui.config.dataTablesLanguage
# dom: '<"' + tbId + ' btns-tables">fr<"uds-table"t>ip'
dom: "<'row'<'col-xs-8'T><'col-xs-4'f>r>t<'row'<'col-xs-5'i><'col-xs-7'p>>"
deferRender: tblParams.deferedRender or tblParams.deferRender or false
# bDeferRender: tblParams.deferedRender or false
createdRow: (row, data, dataIndex) ->
try
v = "log-" + logRenderer(data.level)
$(row).addClass v
catch error
gui.doLog "Log cretedRow error", error
aoColumns: columns
oLanguage: gui.config.dataTablesLanguage
sDom: "<'row'<'col-xs-8'T><'col-xs-4'f>r>t<'row'<'col-xs-5'i><'col-xs-7'p>>"
bDeferRender: tblParams.deferedRender or false
fnCreatedRow: (nRow, aData, iDataIndex) ->
v = "log-" + logRenderer(@fnGetData(iDataIndex).level)
$(nRow).addClass v
return return

View File

@ -20,18 +20,19 @@
# Several convenience "constants" for tables # Several convenience "constants" for tables
gui.config.dataTablesLanguage = gui.config.dataTablesLanguage =
sLengthMenu: gettext("_MENU_ records per page") sLengthMenu: gettext("_MENU_ records per page")
sZeroRecords: gettext("Empty") emptyTable: gettext("Empty")
sInfo: gettext("Records _START_ to _END_ of _TOTAL_") zeroRecords: gettext("No records")
sInfoEmpty: gettext("No records") info: gettext("Records _START_ to _END_ of _TOTAL_")
sInfoFiltered: gettext("(filtered from _MAX_ total records)") infoEmpty: gettext("No records")
sProcessing: gettext("Please wait, processing") infoFiltered: ' ' + gettext("(filtered from _MAX_ total records)")
sSearch: gettext("Filter") processing: gettext("Please wait, processing")
sInfoThousands: django.formats.THOUSAND_SEPARATOR search: gettext("Filter")
oPaginate: thousands: django.formats.THOUSAND_SEPARATOR
sFirst: "<span class=\"fa fa-fast-backward \"></span> " paginate:
sLast: "<span class=\"fa fa-fast-forward\"></span> " first: "<span class=\"fa fa-fast-backward \"></span> "
sNext: "<span class=\"fa fa-forward\"></span> " last: "<span class=\"fa fa-fast-forward\"></span> "
sPrevious: "<span class=\"fa fa-backward\"></span> " next: "<span class=\"fa fa-forward\"></span> "
previous: "<span class=\"fa fa-backward\"></span> "
select: select:
rows: rows:
_: gettext("Selected %d rows") _: gettext("Selected %d rows")

View File

@ -29,15 +29,20 @@
<ul class="bottom_tabs nav nav-tabs"> <ul class="bottom_tabs nav nav-tabs">
<li class="active"><a href="#{{ pool_info }}" data-toggle="tab">{% endverbatim %}{% trans 'Overview' %}{% verbatim %}</a></li> <li class="active"><a href="#{{ pool_info }}" data-toggle="tab">{% endverbatim %}{% trans 'Overview' %}{% verbatim %}</a></li>
<li><a href="#{{ assigned_services }}" data-toggle="tab">{% endverbatim %}{% trans 'Assigned services' %}{% verbatim %}</a></li> <li><a href="#{{ assigned_services }}" data-toggle="tab">{% endverbatim %}{% trans 'Assigned services' %}{% verbatim %}</a></li>
<li><a href="#{{ cache }}" data-toggle="tab">{% endverbatim %}{% trans 'Cache' %}{% verbatim %}</a></li> <li><a id="{{ cache }}_tab" href="#{{ cache }}" data-toggle="tab">{% endverbatim %}{% trans 'Cache' %}{% verbatim %}</a></li>
<li><a href="#{{ groups }}" data-toggle="tab">{% endverbatim %}{% trans 'Groups' %}{% verbatim %}</a></li> <li><a href="#{{ groups }}" data-toggle="tab">{% endverbatim %}{% trans 'Groups' %}{% verbatim %}</a></li>
<li><a href="#{{ transports }}" data-toggle="tab">{% endverbatim %}{% trans 'Transports' %}{% verbatim %}</a></li> <li><a href="#{{ transports }}" data-toggle="tab">{% endverbatim %}{% trans 'Transports' %}{% verbatim %}</a></li>
<li><a href="#{{ publications }}_pane" data-toggle="tab">{% endverbatim %}{% trans 'Publications' %}{% verbatim %}</a></li> <li><a id="{{ publications }}_tab" href="#{{ publications }}" data-toggle="tab">{% endverbatim %}{% trans 'Publications' %}{% verbatim %}</a></li>
<li><a href="#{{ logs }}" data-toggle="tab">{% endverbatim %}{% trans 'Logs' %}{% verbatim %}</a></li> <li><a href="#{{ logs }}" data-toggle="tab">{% endverbatim %}{% trans 'Logs' %}{% verbatim %}</a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane fade in active" id="{{ pool_info }}"> <div class="tab-pane fade in active" id="{{ pool_info }}">
... <div class="row">
<div class="col-xs-12">
<div class="well">
</div>
</div>
</div>
</div> </div>
<div class="tab-pane fade" id="{{ assigned_services }}"> <div class="tab-pane fade" id="{{ assigned_services }}">
<div class="row"> <div class="row">
@ -61,7 +66,7 @@
</div> </div>
<div class="tab-pane fade" id="{{ groups }}">...</div> <div class="tab-pane fade" id="{{ groups }}">...</div>
<div class="tab-pane fade" id="{{ transports }}">...</div> <div class="tab-pane fade" id="{{ transports }}">...</div>
<div class="tab-pane fade" id="{{ publications }}_pane"> <div class="tab-pane fade" id="{{ publications }}">
<div id="{{ publications }}"> <div id="{{ publications }}">
</div> </div>
<div id="{{ changelog }}"> <div id="{{ changelog }}">