annotate app/view/window/AuditTrail.js @ 1386:7e9a6f0e55b3

Added UI for audit trail. TODO: add more i18n strings.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 24 Feb 2017 14:32:55 +0100
parents
children e53e398df409
rev   line source
1386
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 /**
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 * Window with information about history of probe/messung objects..
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 */
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.view.window.AuditTrail', {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.window.Window',
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 layout: 'fit',
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 width: 300,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 height: 300,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 type: null,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 objectId: null,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 /**
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 * This function initialises the Window
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 */
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 initComponent: function() {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 var me = this;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 var i18n = Lada.getApplication().bundle;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 me.on({
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 show: function() {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 me.initData();
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 });
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 me.title = i18n.getMsg("audit.title");
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 me.buttons = [{
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 text: i18n.getMsg('close'),
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 scope: me,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 handler: me.close
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 }];
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 me.items = [{
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 border: 0,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 //autoscroll: true,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 overflowY: 'auto',
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 items: [{
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 border: 0,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 name: 'auditcontainer'
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 }]
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 }];
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 me.callParent(arguments);
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 },
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 initData: function() {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 if (this.type === null || this.objectId === null) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 return;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 Ext.Ajax.request({
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 url: 'lada-server/rest/audit/' + this.type + '/' + this.objectId,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 method: 'GET',
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 scope: this,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 success: this.loadSuccess,
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 failure: this.loadFailure
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 });
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 },
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 loadSuccess: function(response) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 var json = Ext.decode(response.responseText);
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 var container = this.down('panel[name=auditcontainer]');
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 if (this.type === 'probe') {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 var html = this.createHtmlProbe(json);
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 container.update(html);
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 else if (this.type === 'messung') {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 container.update(this.createHtmlMessung(json));
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 },
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 createHtmlProbe: function(json) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 var i18n = Lada.getApplication().bundle;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 var html = '<p><strong>Probe: ' + json.data.identifier + '</strong><br></p>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 var audit = json.data.audit;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 if (audit.length === 0) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 html += '<p>Keine Änderungen</p>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 else {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 for (var i = 0; i < audit.length; i++) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 html += '<p style="margin-bottom:0"><b>' + i18n.getMsg('date') + ': ' +
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 (Ext.Date.format(new Date(audit[i].timestamp), 'd.m.Y H:i')) + '</b>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 if (!Ext.isObject(audit[i].identifier)) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 if (audit[i].type !== 'probe') {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 html += '<br>' + i18n.getMsg(audit[i].type) + ': ';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 html += audit[i].identifier;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 else {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 html += '<br>' + i18n.getMsg('messung') + ': ' +
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 audit[i].identifier.messung + ' -> ' +
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 i18n.getMsg(audit[i].type) + ': ' +
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 audit[i].identifier.identifier;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 html += '<br>geändert<br><div style="margin-left:2em;">'
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 for (var key in audit[i].changedFields) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 html += '' + i18n.getMsg(key) + ': ' +
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 audit[i].changedFields[key] + '<br>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 html += '</div>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 html += '</p>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 return html;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 },
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 createHtmlMessung: function(json) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 var i18n = Lada.getApplication().bundle;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 var html = '<p><strong>Messung: ' + json.data.identifier + '</strong><br></p>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 var audit = json.data.audit;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 if (audit.length === 0) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 html += '<p>Keine Änderungen</p>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 else {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 for (var i = 0; i < audit.length; i++) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 html += '<p style="margin-bottom:0"><b>' + i18n.getMsg('date') + ': ' +
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 (Ext.Date.format(new Date(audit[i].timestamp), 'd.m.Y H:i')) + '</b>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 if (audit[i].type !== 'messung') {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 html += '<br>' + i18n.getMsg(audit[i].type) + ': ';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 html += audit[i].identifier;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 html += '<br>geändert<br><div style="margin-left:2em;">'
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 for (var key in audit[i].changedFields) {
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 html += '' + i18n.getMsg(key) + ': ' +
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 audit[i].changedFields[key] + '<br>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 html += '</div>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 html += '</p>';
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 return html;
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 }
7e9a6f0e55b3 Added UI for audit trail.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 });

http://lada.wald.intevation.org