[Lada-commits] [PATCH] Added UI for audit trail

Wald Commits scm-commit at wald.intevation.org
Fri Feb 24 14:33:15 CET 2017


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1487943175 -3600
# Node ID 7e9a6f0e55b3d3fcebf195017f12b06a40f1da5e
# Parent  3f499c52eee649b47c89b7fe8523177198537e91
Added UI for audit trail.
TODO: add more i18n strings.

diff -r 3f499c52eee6 -r 7e9a6f0e55b3 app/controller/form/Messung.js
--- a/app/controller/form/Messung.js	Thu Feb 23 12:49:28 2017 +0100
+++ b/app/controller/form/Messung.js	Fri Feb 24 14:32:55 2017 +0100
@@ -24,6 +24,9 @@
             'messungform button[action=discard]': {
                 click: this.discard
             },
+            'messungform button[action=audit]': {
+                click: this.showAuditTrail
+            },
             'messungform': {
                 dirtychange: this.dirtyForm
             }
@@ -135,5 +138,14 @@
                 form.owner.up('window').enableChildren();
             }
         }
+    },
+
+    showAuditTrail: function(button) {
+        Ext.create('Lada.view.window.AuditTrail', {
+            autoShow: true,
+            closeAction: 'destroy',
+            type: 'messung',
+            objectId: button.up('form').recordId
+        });
     }
 });
diff -r 3f499c52eee6 -r 7e9a6f0e55b3 app/controller/form/Probe.js
--- a/app/controller/form/Probe.js	Thu Feb 23 12:49:28 2017 +0100
+++ b/app/controller/form/Probe.js	Fri Feb 24 14:32:55 2017 +0100
@@ -12,6 +12,10 @@
 Ext.define('Lada.controller.form.Probe', {
     extend: 'Ext.app.Controller',
 
+    requires: [
+        'Lada.view.window.AuditTrail'
+    ],
+
     /**
      * Initialize the Controller
      * It has 4 listeners
@@ -24,6 +28,9 @@
             'probeform button[action=discard]': {
                 click: this.discard
             },
+            'probeform button[action=audit]': {
+                click: this.showAuditTrail
+            },
             'probeform': {
                 dirtychange: this.dirtyForm
             },
@@ -304,6 +311,14 @@
         for (var i = field.layer + 1; i < 12; i++) {
             allS[i].clearValue();
         }
+    },
+
+    showAuditTrail: function(button) {
+        Ext.create('Lada.view.window.AuditTrail', {
+            autoShow: true,
+            closeAction: 'destroy',
+            type: 'probe',
+            objectId: button.up('form').recordId
+        });
     }
-
 });
diff -r 3f499c52eee6 -r 7e9a6f0e55b3 app/view/form/Messung.js
--- a/app/view/form/Messung.js	Thu Feb 23 12:49:28 2017 +0100
+++ b/app/view/form/Messung.js	Fri Feb 24 14:32:55 2017 +0100
@@ -55,6 +55,12 @@
                         borderRight: '1px solid #b5b8c8 !important'
                     },
                     items: ['->', {
+                        text: i18n.getMsg('audittrail'),
+                        qtip: i18n.getMsg('qtip.audit'),
+                        icon: 'resources/img/distribute-vertical-center.png',
+                        action: 'audit',
+                        disabled: this.recordId === null
+                    }, {
                         text: 'Speichern',
                         qtip: 'Daten speichern',
                         icon: 'resources/img/dialog-ok-apply.png',
diff -r 3f499c52eee6 -r 7e9a6f0e55b3 app/view/form/Probe.js
--- a/app/view/form/Probe.js	Thu Feb 23 12:49:28 2017 +0100
+++ b/app/view/form/Probe.js	Fri Feb 24 14:32:55 2017 +0100
@@ -60,6 +60,12 @@
                         borderRight: '1px solid #b5b8c8 !important'
                     },
                     items: ['->', {
+                        text: i18n.getMsg('audittrail'),
+                        qtip: i18n.getMsg('qtip.audit'),
+                        icon: 'resources/img/distribute-vertical-center.png',
+                        action: 'audit',
+                        disabled: this.recordId === null
+                    }, {
                         text: 'Speichern',
                         qtip: 'Daten speichern',
                         icon: 'resources/img/dialog-ok-apply.png',
diff -r 3f499c52eee6 -r 7e9a6f0e55b3 app/view/window/AuditTrail.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/window/AuditTrail.js	Fri Feb 24 14:32:55 2017 +0100
@@ -0,0 +1,142 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Window with information about history of probe/messung objects..
+ */
+Ext.define('Lada.view.window.AuditTrail', {
+    extend: 'Ext.window.Window',
+
+    layout: 'fit',
+
+    width: 300,
+    height: 300,
+
+    type: null,
+
+    objectId: null,
+
+
+    /**
+     * This function initialises the Window
+     */
+    initComponent: function() {
+        var me = this;
+        var i18n = Lada.getApplication().bundle;
+        me.on({
+            show: function() {
+                me.initData();
+            }
+        });
+
+        me.title = i18n.getMsg("audit.title");
+        me.buttons = [{
+            text: i18n.getMsg('close'),
+            scope: me,
+            handler: me.close
+        }];
+        me.items = [{
+            border: 0,
+            //autoscroll: true,
+            overflowY: 'auto',
+            items: [{
+                border: 0,
+                name: 'auditcontainer'
+            }]
+        }];
+        me.callParent(arguments);
+    },
+
+    initData: function() {
+        if (this.type === null || this.objectId === null) {
+            return;
+        }
+        Ext.Ajax.request({
+            url: 'lada-server/rest/audit/' + this.type + '/' + this.objectId,
+            method: 'GET',
+            scope: this,
+            success: this.loadSuccess,
+            failure: this.loadFailure
+        });
+    },
+
+    loadSuccess: function(response) {
+        var json = Ext.decode(response.responseText);
+        var container = this.down('panel[name=auditcontainer]');
+        if (this.type === 'probe') {
+            var html = this.createHtmlProbe(json);
+            container.update(html);
+        }
+        else if (this.type === 'messung') {
+            container.update(this.createHtmlMessung(json));
+        }
+    },
+
+    createHtmlProbe: function(json) {
+        var i18n = Lada.getApplication().bundle;
+        var html = '<p><strong>Probe: ' + json.data.identifier + '</strong><br></p>';
+        var audit = json.data.audit;
+        if (audit.length === 0) {
+            html += '<p>Keine Änderungen</p>';
+        }
+        else {
+            for (var i = 0; i < audit.length; i++) {
+                html += '<p style="margin-bottom:0"><b>' + i18n.getMsg('date') + ': ' +
+                (Ext.Date.format(new Date(audit[i].timestamp), 'd.m.Y H:i')) + '</b>';
+                if (!Ext.isObject(audit[i].identifier)) {
+                    if (audit[i].type !== 'probe') {
+                        html += '<br>' + i18n.getMsg(audit[i].type) + ': ';
+                        html += audit[i].identifier;
+                    }
+                }
+                else {
+                    html += '<br>' + i18n.getMsg('messung') + ': ' +
+                        audit[i].identifier.messung + ' -> ' +
+                        i18n.getMsg(audit[i].type) + ': ' +
+                        audit[i].identifier.identifier;
+
+                }
+                html += '<br>geändert<br><div style="margin-left:2em;">'
+                for (var key in audit[i].changedFields) {
+                    html += '' + i18n.getMsg(key) + ': ' +
+                        audit[i].changedFields[key] + '<br>';
+                }
+                html += '</div>';
+                html += '</p>';
+            }
+        }
+        return html;
+    },
+
+    createHtmlMessung: function(json) {
+        var i18n = Lada.getApplication().bundle;
+        var html = '<p><strong>Messung: ' + json.data.identifier + '</strong><br></p>';
+        var audit = json.data.audit;
+        if (audit.length === 0) {
+            html += '<p>Keine Änderungen</p>';
+        }
+        else {
+            for (var i = 0; i < audit.length; i++) {
+                html += '<p style="margin-bottom:0"><b>' + i18n.getMsg('date') + ': ' +
+                (Ext.Date.format(new Date(audit[i].timestamp), 'd.m.Y H:i')) + '</b>';
+                if (audit[i].type !== 'messung') {
+                    html += '<br>' + i18n.getMsg(audit[i].type) + ': ';
+                    html += audit[i].identifier;
+                }
+                html += '<br>geändert<br><div style="margin-left:2em;">'
+                for (var key in audit[i].changedFields) {
+                    html += '' + i18n.getMsg(key) + ': ' +
+                        audit[i].changedFields[key] + '<br>';
+                }
+                html += '</div>';
+                html += '</p>';
+            }
+        }
+        return html;
+    }
+});
diff -r 3f499c52eee6 -r 7e9a6f0e55b3 resources/i18n/Lada_de-DE.properties
--- a/resources/i18n/Lada_de-DE.properties	Thu Feb 23 12:49:28 2017 +0100
+++ b/resources/i18n/Lada_de-DE.properties	Fri Feb 24 14:32:55 2017 +0100
@@ -106,6 +106,12 @@
 messzeitpunkt: Messzeitpunkt
 messgroesse: Messgröße
 pflichtmessgroesse: Pflichtmessgröße
+audittrail:Verlauf
+date:Datum
+messwert:Messwert
+messdauer:Messdauer
+probenart_id:Probenart
+probe_nehmer_id:Probenehmer
 
 emptytext.probenintervall:Wählen Sie ein Probenintervall
 emptytext.datenbasis:Wählen Sie eine Datenbasis
@@ -141,6 +147,7 @@
 messprogrammort.button.title:Ort angeben
 about.window.title:Über
 about.button.title:Über
+audit.title:Verlauf
 
 about.window.text.login:Sie sind angemeldet mit der Kennung:
 about.window.text.roles:Sie sind Mitglied der folgenden Gruppen:
diff -r 3f499c52eee6 -r 7e9a6f0e55b3 resources/img/distribute-vertical-center.png
Binary file resources/img/distribute-vertical-center.png has changed


More information about the Lada-commits mailing list