Class ::xowiki::includelet::kibana (public)
::xowiki::IncludeletClass ::xowiki::includelet::kibana [ -from from ] \ [ -to to ] [ -hash hash ] [ -width width ] [ -height height ]
Defined in /var/www/openacs.org/packages/xowiki/tcl/kibana-procs.tcl
Include a Kibana chart identified by the provided hash
- Switches:
- -from (optional)
- start of time window (default now-24h)
- -to (optional)
- end of time window (default now-)
- -hash (optional)
- hash of the included visualization
- -width (optional)
- width of included content
- -height (optional)
- height of included content
- Testcases:
- No testcase defined.
Source code: namespace eval ::xowiki::includelet {} ::nsf::object::alloc ::xowiki::IncludeletClass ::xowiki::includelet::kibana {set :__default_metaclass ::xotcl::Class set :__default_superclass ::xotcl::Object set :aggregating false set :cacheable false set :localized true set :personalized true} ::xowiki::includelet::kibana proc grant_permission {object_id hash url} { nsv_set kibana_permissions [::xo::cc user_id] $object_id nsv_set kibana_hashes [::xo::cc user_id]-$hash 1 ns_log notice "kibana GRANT ACCESS for <$url> to [::xo::cc user_id]" ad_set_signed_cookie -discard t -scriptable f ad_kibana $object_id } ::xowiki::includelet::kibana proc check_permission url { #set grantAlways {^/kibana/(api|built_assets|bundles|node_modules|translations|ui)/} set grantAlways {^/kibana/(built_assets|bundles|node_modules|translations|ui)/} set grantNever {^/kibana/(elasticsearch)} set restricted { /kibana /kibana/app/canvas /kibana/app/maps /kibana/app/ml /kibana/app/infra /kibana/app/apm /kibana/app/uptime /kibana/app/siem /kibana/app/monitoring } set strippedUrl [string trimright $url /] # # Grant some access always and some access never. # #ns_log notice "kibana CHECK PERMISSIONS for <$strippedUrl> in restricted --> [expr {$strippedUrl in $restricted}]" if {[regexp $grantAlways $url]} { set when always set granted 1 } elseif {$strippedUrl in $restricted || [regexp $grantNever $url]} { set when never set granted 0 } else { # # Go into the details. # ::xo::ConnectionContext require set when sometimes set user_id [::xo::cc user_id] set method [ns_conn method] set granted [nsv_exists kibana_permissions $user_id] try { ad_get_signed_cookie ad_kibana } trap {AD_EXCEPTION NO_COOKIE} {errorMsg} { set cookie "" append when -nocookie } trap {AD_EXCEPTION INVALID_COOKIE} {errorMsg} { set cookie "" append when -invalidcookie } on ok {cookie} { } if {$granted} { # # Just allow one access to the main app. This is the first # call inside the iframe (should be actually # "/kibana/app/kibana") # nsv_unset kibana_permissions $user_id append when -first } elseif {$cookie ne ""} { # # The cookie is the object_id. Therefore, we can check whether # the current user_id has permissions on this object. # set granted [permission::permission_p -party_id $user_id -object_id $cookie -privilege read] append when -$granted if {$granted} { # # Check as well whether the user has rights on the hash. We # can this do just in limited cases. Since this hash is just # in a few queries. # if {$method eq "POST" && $url eq "/kibana/api/saved_objects/_bulk_get"} { set payload [ns_conn content] if {[regexp {"id":"([^\"]+)"} $payload . hash]} { # # We have the hash_code, the user_id and the object_id # set granted [nsv_exists kibana_hashes $user_id-$hash] ns_log notice "kibana CHECK PERMISSIONS $url hash $hash -> $granted" append when -payload=$granted } } else { # # For the time being, also allow the following cases, when the cookie is ok. # ns_log notice "kibana CHECK PERMISSIONS for $user_id [ns_conn request] // [ns_set array [ns_conn headers]]" if {$method eq "POST"} { ns_log notice "kibana CHECK PERMISSIONS payload [ns_conn content]" } } } } } if {$when ne "always"} { ns_log notice "kibana CHECK PERMISSIONS <$url> $when --> $granted" } return $granted } ::xowiki::includelet::kibana proc url path { set url $::xowiki::includelet::kibana_location$path #ns_log notice "xowiki KIBANA request: $url" return $url } ::xowiki::includelet::kibana instproc render {} { :get_parameters #set width 800 #set height 400 #set from now-24h #set to now #set hash [kibana get visitors-map-openacs] set refreshInterval {(pause:!t,value:0)} set time [subst {from:$from,mode:quick,to:$to}] set _g (refreshInterval:$refreshInterval,time:($time)) set url /kibana/app/kibana#/visualize/edit/$hash?embed=true&_g=[ns_urlencode $_g] #ns_log notice "kibana iframe src: $url" [self class] grant_permission [${:__including_page} item_id] $hash $url set HTML [subst {<iframe src="$url" width="$width" height="$height" frameborder="0"></iframe>}] return $HTML } ::xowiki::includelet::kibana instproc include_head_entries {} { next } ::xowiki::includelet::kibana instparametercmd id ::xowiki::includelet::kibana instparametercmd __decoration ::xowiki::includelet::kibana instparametercmd parameter_declaration ::nsf::relation::set ::xowiki::includelet::kibana superclass ::xowiki::Includelet ::nx::slotObj -container slot ::xowiki::includelet::kibana ::xowiki::includelet::kibana::slot eval {set :__parameter { {__decoration plain} {parameter_declaration { {-chart openacs-status-codes} {-from now-24h} {-to now} {-hash ""} {-width:integer 800} {-height:integer 400} }} {id "[xowiki::Includelet js_name [self]]"} }} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::kibana::slot::id {set :accessor public set :configurable true set :convert false set :default {[xowiki::Includelet js_name [self]]} set :defaultmethods {} set :disposition alias set :domain ::xowiki::includelet::kibana set :incremental 0 set :manager ::xowiki::includelet::kibana::slot::id set :methodname id set :multiplicity 1..1 set :name id set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::kibana::slot::parameter_declaration {set :accessor public set :configurable true set :convert false set :default { {-chart openacs-status-codes} {-from now-24h} {-to now} {-hash ""} {-width:integer 800} {-height:integer 400} } set :defaultmethods {} set :disposition alias set :domain ::xowiki::includelet::kibana set :incremental 0 set :manager ::xowiki::includelet::kibana::slot::parameter_declaration set :methodname parameter_declaration set :multiplicity 1..1 set :name parameter_declaration set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::kibana::slot::__decoration {set :accessor public set :configurable true set :convert false set :default plain set :defaultmethods {} set :disposition alias set :domain ::xowiki::includelet::kibana set :incremental 0 set :manager ::xowiki::includelet::kibana::slot::__decoration set :methodname __decoration set :multiplicity 1..1 set :name __decoration set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init}XQL Not present: Generic, PostgreSQL, Oracle