Bug 17666 - AJAX-Anzeige von Logdateien
AJAX-Anzeige von Logdateien
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC (Generic)
UCS 2.2
Other Linux
: P3 enhancement (vote)
: UCS 2.4
Assigned To: Sönke Schwardt-Krummrich
Andreas Büsching
:
Depends on:
Blocks: 19193
  Show dependency treegraph
 
Reported: 2010-02-16 14:21 CET by Sönke Schwardt-Krummrich
Modified: 2010-08-31 13:23 CEST (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Usability
Max CVSS v3 score:


Attachments
Proof-Of-Concept für ajax-basiertes tail (4.01 KB, patch)
2010-02-16 14:21 CET, Sönke Schwardt-Krummrich
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Schwardt-Krummrich univentionstaff 2010-02-16 14:21:12 CET
Created attachment 2300 [details]
Proof-Of-Concept für ajax-basiertes tail

Im Anhang befindet sich ein Proof-Of-Concept, um eine wachsende Logdatei über
ein Ajax-Widget anzuzeigen, ohne dass ein Pagerefresh notwendig ist.

Patch wurde gegen univention-updater aus UCS 2.2 erstellt.
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2010-05-07 11:21:37 CEST
umcd.RefreshFrame() wurde im SrcPaket univention-management-console hinzugefügt.

Dokumentation im Wiki fehlt noch (kann der Inline-Doku von dialog/ajax.py entnommen werden).
Comment 2 Sönke Schwardt-Krummrich univentionstaff 2010-05-07 15:02:39 CEST
Doku im Wiki wurde ergänzt.
Comment 3 Sönke Schwardt-Krummrich univentionstaff 2010-05-12 10:52:33 CEST
Changelog-Eintrag fehlt...
Comment 4 Sönke Schwardt-Krummrich univentionstaff 2010-07-09 11:39:10 CEST
class RefreshFrame( base.HTML ):
    def __init__( self, sessionid, command, opts = {}, attributes = {}, 
                  maxlen=300000, refresh_interval=3000 ):

Returns a frame with specified geometry and refreshes its content every
'refresh_interval' miliseconds by calling specified 'command' and passing
'opts' as command options.
Arguments:
- sessionid: the session id (required)
- command: umcp command to be called for getting new content
- opts: options passed to umcp command
- attributes: dictionary with widget attributes 
  (colspan, width (in pixel), height (in pixel))
- maxlen: maximum length of data shown in frame (don't use too large
  values - it will slow down or crash your or customers browser)
- refresh_interval: interval in miliseconds

Example for revamp:
result.add_row( [ 
  umcd.RefreshFrame( self._sessionid, 
                     'some/command', 
                     { 'foo1': 3, 'ding': 'dong' }, 
                     attributes = { 'colspan': '3', 
                                    'width': '750', 
                                    'height': '400' }, 
                     refresh_interval=1000) ] )

from json import JsonWriter
def _web_some_command(self, object, res):
    data = { 'contentappend': 
                      '%s ==> %s\n' % (time.ctime(), repr(object.options)) }
    json = JsonWriter()
    content = json.write(data)
    content_type = 'application/json'
    res.dialog = { 'Content-Type': content_type, 'Content': content }
    self.revamped( object.id(), res, rawresult = True )


Im Dictionary 'data' können unterschiedliche Keys definiert werden. Die Keys 'content' und 'contentappend' sind fest vordefiniert.
- content: Der Inhalt des RefreshFrames wird mit data['content'] ausgetauscht.
- contentappend: Der Inhalt des RefreshFrames wird am Ende um data['contentappend'] erweitert.

Bei allen weiteren Keys wird ein HTML-Tag gesucht, bei dem der Key mit der ID des HTML-Tags übereinstimmt. Das 'innerHTML' wird dann durch den Value ausgetauscht:
!Pseudocode!: dojo.byId( KEY ).innerHTML = data[KEY];

Auf diese Weise kann nicht nur der Inhalt des RefreshFrames aktualisiert werden, sondern auch z.B. Überschriften oder Beschreibungstexte.

<h2 id="headline">Installation in progress...</h2>

==> data['headline'] = _('Installation finished successfully.')
Comment 5 Sönke Schwardt-Krummrich univentionstaff 2010-07-09 13:12:50 CEST
Changelog-Eintrag ist vorhanden.

Bitte bei der QA mit unterschiedlichen Browsern testen.
Comment 6 Andreas Büsching univentionstaff 2010-08-17 21:37:03 CEST
Firefox: ok
Google Chrome 6.0: ok
IE8: Der Zeilenumbruch funktioniert nicht. Das gesamte Log wird in einer Zeile dargestellt

ChangeLog-Eintrag vorhanden
Comment 7 Sönke Schwardt-Krummrich univentionstaff 2010-08-18 11:09:20 CEST
r"\r?\n" wird jetzt nach "<br>" umgeschrieben. Keine Ahnung, warum die <pre>-Umgebung des IE8 die Newlines ignoriert. Auf jeden Fall beherzigen sowohl Firefox als auch IE8 das <br>-Tag innerhalb einer <pre>-Umgebung, was mindestens genauso verwirrend ist.
Fixed.
Comment 8 Andreas Büsching univentionstaff 2010-08-18 15:07:08 CEST
(In reply to comment #7)
> r"\r?\n" wird jetzt nach "<br>" umgeschrieben. Keine Ahnung, warum die
> <pre>-Umgebung des IE8 die Newlines ignoriert. Auf jeden Fall beherzigen sowohl
> Firefox als auch IE8 das <br>-Tag innerhalb einer <pre>-Umgebung, was
> mindestens genauso verwirrend ist.
> Fixed.

Funktioniert jetzt mit Firefox, IE8 und Chrome
Comment 9 Sönke Schwardt-Krummrich univentionstaff 2010-08-19 11:08:03 CEST
Im Zuge von Bug 14346 wurde die angezeigte Datenmenge auf 120k (default: 300k) und das Refresh-Intervall auf 1500ms (vorher: 1000ms) geändert, da sonst die Last für den Browser zu hoch wird.
Comment 10 Stefan Gohmann univentionstaff 2010-08-31 13:23:00 CEST
UCS 2.4 wurde veröffentlicht. Sollte der hier beschriebene Bug mit einer
neueren Version von UCS erneut auftreten, so sollte der Bug dupliziert werden:
"Clone This Bug".