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