mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-03 01:17:56 +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:
parent
162c84e21c
commit
c9e9f60ed1
@ -180,8 +180,10 @@ class BasicModelRest
|
||||
success_fnc {}
|
||||
return
|
||||
if cacheKey isnt "." and @cache.get(cacheKey)
|
||||
api.doLog "Cache SUCCESS for " + cacheKey
|
||||
success_fnc @cache.get(cacheKey)
|
||||
else
|
||||
api.doLog "Cache FAIL for " + cacheKey
|
||||
$this = @
|
||||
api.doLog 'Obtaining json for ', path
|
||||
api.getJson path,
|
||||
@ -321,7 +323,7 @@ class BasicModelRest
|
||||
path = @guiPath
|
||||
|
||||
@_requestPath path,
|
||||
cacheKey: "."
|
||||
cacheKey: path
|
||||
success: success_fnc
|
||||
fail: fail_fnc
|
||||
|
||||
@ -333,6 +335,7 @@ class BasicModelRest
|
||||
|
||||
path = @tableInfoPath
|
||||
@_requestPath path,
|
||||
cacheKey: path
|
||||
success: success_fnc
|
||||
fail: fail_fnc
|
||||
|
||||
|
@ -117,7 +117,7 @@ gui.servicesPools.link = (event) ->
|
||||
api.templates.get "services_pool", (tmpl) ->
|
||||
gui.appendToWorkspace api.templates.evaluate(tmpl,
|
||||
deployed_services: "deployed-services-placeholder"
|
||||
pool_info: "pool-info"
|
||||
pool_info: "pool-info-placeholder"
|
||||
assigned_services: "assigned-services-placeholder"
|
||||
cache: "cache-placeholder"
|
||||
groups: "groups-placeholder"
|
||||
@ -176,6 +176,10 @@ gui.servicesPools.link = (event) ->
|
||||
return
|
||||
|
||||
$("#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
|
||||
@ -186,11 +190,13 @@ gui.servicesPools.link = (event) ->
|
||||
# Shows/hides cache
|
||||
if info.uses_cache or info.uses_cache_l2
|
||||
$("#cache-placeholder_tab").removeClass "hidden"
|
||||
|
||||
cachedItems = new GuiElement(api.servicesPools.detail(servPool.id, "cache", { permission: servPool.permission }), "cache")
|
||||
|
||||
# Cached items table
|
||||
prevCacheLogTbl = null
|
||||
cachedItemsTable = cachedItems.table(
|
||||
doNotLoadData: true
|
||||
icon: 'cached'
|
||||
container: "cache-placeholder_tbl"
|
||||
rowSelect: "single"
|
||||
@ -205,7 +211,6 @@ gui.servicesPools.link = (event) ->
|
||||
return
|
||||
|
||||
onRowSelect: (selected) ->
|
||||
gui.do
|
||||
cached = selected[0]
|
||||
if prevCacheLogTbl
|
||||
$tbl = $(prevCacheLogTbl).dataTable()
|
||||
@ -234,6 +239,7 @@ gui.servicesPools.link = (event) ->
|
||||
|
||||
# Groups items table
|
||||
groupsTable = groups.table(
|
||||
doNotLoadData: true
|
||||
icon: 'groups'
|
||||
container: "groups-placeholder"
|
||||
rowSelect: "single"
|
||||
@ -310,6 +316,7 @@ gui.servicesPools.link = (event) ->
|
||||
prevAssignedLogTbl = null
|
||||
assignedServices = new GuiElement(api.servicesPools.detail(servPool.id, "services", { permission: servPool.permission }), "services")
|
||||
assignedServicesTable = assignedServices.table(
|
||||
doNotLoadData: true
|
||||
icon: 'assigned'
|
||||
container: "assigned-services-placeholder_tbl"
|
||||
rowSelect: "single"
|
||||
@ -356,6 +363,7 @@ gui.servicesPools.link = (event) ->
|
||||
|
||||
# Transports items table
|
||||
transportsTable = transports.table(
|
||||
doNotLoadData: true
|
||||
icon: 'transports'
|
||||
container: "transports-placeholder"
|
||||
doNotLoadData: true
|
||||
@ -424,6 +432,7 @@ gui.servicesPools.link = (event) ->
|
||||
|
||||
# Publications table
|
||||
publicationsTable = publications.table(
|
||||
doNotLoadData: true
|
||||
icon: 'publications'
|
||||
container: "publications-placeholder"
|
||||
doNotLoadData: true
|
||||
@ -513,6 +522,7 @@ gui.servicesPools.link = (event) ->
|
||||
# * Log table
|
||||
#
|
||||
logTable = gui.servicesPools.logTable(servPool.id,
|
||||
doNotLoadData: true
|
||||
container: "logs-placeholder"
|
||||
)
|
||||
prevTables.push logTable
|
||||
@ -538,7 +548,7 @@ gui.servicesPools.link = (event) ->
|
||||
return
|
||||
|
||||
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
|
||||
gui.doLog guiDef
|
||||
newDef = [].concat(guiDef).concat([
|
||||
|
@ -428,7 +428,7 @@
|
||||
data: data
|
||||
deferRender: tblParams.deferedRender or tblParams.deferRender or false
|
||||
|
||||
oLanguage: gui.config.dataTablesLanguage
|
||||
language: gui.config.dataTablesLanguage
|
||||
|
||||
|
||||
# If row is "styled"
|
||||
@ -436,9 +436,14 @@
|
||||
field = row_style.field
|
||||
dct = row_style.dict
|
||||
prefix = row_style.prefix
|
||||
dataTableOptions.fnCreatedRow = (nRow, aData, iDataIndex) ->
|
||||
v = (if dct? then dct[@fnGetData(iDataIndex)[field]] else @fnGetData(iDataIndex)[field])
|
||||
$(nRow).addClass prefix + v
|
||||
dataTableOptions.createdRow = (row, data, dataIndex) ->
|
||||
# gui.doLog row, data, dataIndex, data[field]
|
||||
try
|
||||
v = (if dct? then dct[data[field]] else data[field])
|
||||
$(row).addClass prefix + v
|
||||
catch err
|
||||
gui.doLog "Exception got: ", err
|
||||
|
||||
return
|
||||
|
||||
dTable = $("#" + tableId).DataTable dataTableOptions
|
||||
@ -615,27 +620,25 @@
|
||||
$("#" + tblParams.container).append table.text
|
||||
|
||||
# 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) ->
|
||||
gui.doLog data
|
||||
$("#" + tableId).dataTable
|
||||
aaData: data
|
||||
aaSorting: [[
|
||||
0
|
||||
"desc"
|
||||
]]
|
||||
$("#" + tableId).DataTable
|
||||
data: data
|
||||
ordering: true
|
||||
order: [[ 1, '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
|
||||
|
||||
|
||||
|
@ -20,18 +20,19 @@
|
||||
# Several convenience "constants" for tables
|
||||
gui.config.dataTablesLanguage =
|
||||
sLengthMenu: gettext("_MENU_ records per page")
|
||||
sZeroRecords: gettext("Empty")
|
||||
sInfo: gettext("Records _START_ to _END_ of _TOTAL_")
|
||||
sInfoEmpty: gettext("No records")
|
||||
sInfoFiltered: gettext("(filtered from _MAX_ total records)")
|
||||
sProcessing: gettext("Please wait, processing")
|
||||
sSearch: gettext("Filter")
|
||||
sInfoThousands: django.formats.THOUSAND_SEPARATOR
|
||||
oPaginate:
|
||||
sFirst: "<span class=\"fa fa-fast-backward \"></span> "
|
||||
sLast: "<span class=\"fa fa-fast-forward\"></span> "
|
||||
sNext: "<span class=\"fa fa-forward\"></span> "
|
||||
sPrevious: "<span class=\"fa fa-backward\"></span> "
|
||||
emptyTable: gettext("Empty")
|
||||
zeroRecords: gettext("No records")
|
||||
info: gettext("Records _START_ to _END_ of _TOTAL_")
|
||||
infoEmpty: gettext("No records")
|
||||
infoFiltered: ' ' + gettext("(filtered from _MAX_ total records)")
|
||||
processing: gettext("Please wait, processing")
|
||||
search: gettext("Filter")
|
||||
thousands: django.formats.THOUSAND_SEPARATOR
|
||||
paginate:
|
||||
first: "<span class=\"fa fa-fast-backward \"></span> "
|
||||
last: "<span class=\"fa fa-fast-forward\"></span> "
|
||||
next: "<span class=\"fa fa-forward\"></span> "
|
||||
previous: "<span class=\"fa fa-backward\"></span> "
|
||||
select:
|
||||
rows:
|
||||
_: gettext("Selected %d rows")
|
||||
|
@ -29,15 +29,20 @@
|
||||
<ul class="bottom_tabs nav nav-tabs">
|
||||
<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="#{{ 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="#{{ 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>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<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 class="tab-pane fade" id="{{ assigned_services }}">
|
||||
<div class="row">
|
||||
@ -61,7 +66,7 @@
|
||||
</div>
|
||||
<div class="tab-pane fade" id="{{ groups }}">...</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>
|
||||
<div id="{{ changelog }}">
|
||||
|
Loading…
Reference in New Issue
Block a user