source: trunk/www/common/history/list_history.jsp @ 6604

Last change on this file since 6604 was 6604, checked in by Nicklas Nordborg, 9 years ago

References #1890: Improve skinnability of BASE

Updated table listings with some new css classes to make it easier to modify background color.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 12.8 KB
Line 
1<%-- $Id: list_history.jsp 6604 2014-11-18 10:39:22Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.0
24--%>
25<%@ page pageEncoding="UTF-8" session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.core.BasicItem"
30  import="net.sf.basedb.core.ChangeHistory"
31  import="net.sf.basedb.core.Permission"
32  import="net.sf.basedb.core.Nameable"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.ItemQuery"
35  import="net.sf.basedb.core.ItemResultIterator"
36  import="net.sf.basedb.core.PermissionDeniedException"
37  import="net.sf.basedb.core.PluginDefinition"
38  import="net.sf.basedb.core.query.Orders"
39  import="net.sf.basedb.core.query.Hql"
40  import="net.sf.basedb.core.plugin.GuiContext"
41  import="net.sf.basedb.core.plugin.Plugin"
42  import="net.sf.basedb.core.log.ChangeType"
43  import="net.sf.basedb.util.Values"
44  import="net.sf.basedb.util.Enumeration"
45  import="net.sf.basedb.util.formatter.Formatter"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.ModeInfo"
48  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
49  import="net.sf.basedb.clients.web.util.HTML"
50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
51  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
52  import="net.sf.basedb.clients.web.extensions.JspContext"
53  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
54  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
55  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
56  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
57  import="java.util.List"
58  import="java.util.Date"
59  import="java.util.Map"
60%>
61<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
62<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
63<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
64<%!
65  private static final Item itemType = Item.CHANGEHISTORY;
66  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
67%>
68<%
69final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
70final String ID = sc.getId();
71final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
72
73final Item sourceType = Item.valueOf(request.getParameter("source_type"));
74final int sourceId = Values.getInt(request.getParameter("source_id"));
75final float scale = Base.getScale(sc);
76final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
77final String callback = request.getParameter("callback");
78final String title = mode.generateTitle("history entry", "history entries");
79final DbControl dc = sc.newDbControl();
80ItemResultIterator<ChangeHistory> history = null;
81
82try
83{
84  final BasicItem source = sourceType.getById(dc, sourceId); 
85  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
86  try
87  {
88    final ItemQuery<ChangeHistory> query = 
89      Base.getConfiguredQuery(dc, cc, true, ChangeHistory.getHistoryOf(source), mode);
90    query.order(cc.getSortDirection().sortBy(Hql.property("id")));
91    history = query.iterate(dc);
92    //cc.setMessage(query.toString());
93  }
94  catch (Throwable t)
95  {
96    cc.setMessage(t.getMessage());
97    t.printStackTrace();
98  }
99  Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc);
100  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
101  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
102  ExtensionsInvoker columnsInvoker = ListColumnUtil.useExtensions(jspContext);
103  int numListed = 0;
104  %>
105  <base:page type="iframe" id="list-history">
106  <base:head scripts="table.js,~history.js" styles="table.css,toolbar.css">
107    <ext:scripts context="<%=jspContext%>" />
108    <ext:stylesheets context="<%=jspContext%>" />
109  </base:head>
110  <base:body>
111    <tbl:table 
112      id="history"
113      columns="<%=cc.getSetting("columns")%>"
114      sortby="<%=cc.getSortProperty()%>" 
115      direction="<%=cc.getSortDirection()%>"
116      action="index.jsp"
117      sc="<%=sc%>"
118      item="<%=itemType%>"
119      subclass="fulltable"
120      >
121      <tbl:hidden 
122        name="source_id"
123        value="<%=String.valueOf(sourceId)%>" 
124      />
125      <tbl:hidden 
126        name="source_type" 
127        value="<%=sourceType.name()%>" 
128      />
129      <tbl:columndef 
130         id="id"
131        clazz="uniquecol"
132         property="id"
133         datatype="int"
134         title="ID"
135         sortable="true" 
136         filterable="true"
137         exportable="true"
138      />
139      <tbl:columndef 
140        id="time"
141        property="$hst.time"
142        exportproperty="changeHistory.time"
143        datatype="timestamp"
144        title="Time"
145        sortable="true" 
146        filterable="true"
147        exportable="true"
148        show="always" 
149      />
150      <%
151      Enumeration<String, String> types = new Enumeration<String, String>();
152      for (ChangeType ct : ChangeType.values())
153      {
154        types.add(Integer.toString(ct.getValue()), ct.toString());
155      }
156      %>
157      <tbl:columndef 
158        id="changeType"
159        property="changeType"
160        datatype="int"
161        title="Type"
162        sortable="true" 
163        filterable="true"
164        exportable="true"
165        enumeration="<%=types%>"
166      />
167      <tbl:columndef 
168        id="user"
169        property="$hst.user.name"
170        exportproperty="changeHistory.user.name"
171        datatype="string"
172        title="User"
173        sortable="true" 
174        filterable="true"
175        exportable="true"
176      />
177      <tbl:columndef 
178        id="session"
179        property="$hst.session.loginTime"
180        exportproperty="changeHistory.session.loginTime"
181        datatype="date"
182        title="Session"
183        sortable="true" 
184        filterable="true"
185        exportable="true"
186      />
187      <tbl:columndef 
188        id="client"
189        property="$hst.client.name"
190        exportproperty="changeHistory.client.name"
191        datatype="string"
192        title="Client"
193        sortable="true" 
194        filterable="true"
195        exportable="true"
196      />
197      <tbl:columndef 
198        id="project"
199        property="$hst.project.name"
200        exportproperty="changeHistory.project.name"
201        datatype="string"
202        title="Project"
203        sortable="true" 
204        filterable="true"
205        exportable="true"
206      />
207      <tbl:columndef 
208        id="plugin"
209        property="$hst.plugin.name"
210        exportproperty="changeHistory.plugin.name"
211        datatype="string"
212        title="Plugin"
213        sortable="true"
214        filterable="true"
215        exportable="true"
216      />
217      <tbl:columndef 
218        id="job"
219        property="$hst.job.name"
220        exportproperty="changeHistory.job.name"
221        datatype="string"
222        title="Job"
223        sortable="true" 
224        filterable="true"
225        exportable="true"
226      />
227      <tbl:columndef 
228        id="changeInfo"
229        property="changeInfo"
230        datatype="string"
231        title="Change info" 
232        sortable="true" 
233        filterable="true" 
234        exportable="true"
235      />
236      <%
237      if (sc.hasPermission(Permission.READ, Item.CHANGEHISTORY_VALUES))
238      {
239        %>
240        <tbl:columndef
241          id="oldValue"
242          property="oldValue"
243          datatype="string"
244          title="Old value"
245          sortable="true" 
246          filterable="true"
247          exportable="true"
248        />
249        <tbl:columndef
250          id="newValue"
251          property="newValue"
252          datatype="string"
253          title="New value"
254          sortable="true" 
255          filterable="true" 
256          exportable="true"
257        />
258        <%
259      }
260      %>
261      <tbl:columndef 
262        id="xt-columns" 
263        extensions="<%=columnsInvoker%>" 
264        jspcontext="<%=jspContext%>" 
265      />
266      <div class="panelgroup bg-filled-50 bottomborder">
267        <tbl:toolbar
268          visible="<%=mode.hasToolbar()%>"
269          subclass="bottomborder"
270          >
271          <tbl:button 
272            id="btnColumns"
273            image="columns.png" 
274            title="Columns&hellip;" 
275            tooltip="Show, hide and re-order columns" 
276          />
277          <tbl:button 
278            id="btnExport"
279            data-plugin-type="EXPORT"
280            image="export.png" 
281            title="Export&hellip;" 
282            tooltip="Export data" 
283            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
284          />
285          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
286            wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
287        </tbl:toolbar>
288        <tbl:panel>
289          <tbl:presetselector />
290          <tbl:navigator
291            page="<%=cc.getPage()%>" 
292            rowsperpage="<%=cc.getRowsPerPage()%>" 
293            totalrows="<%=history == null ? 0 : history.getTotalCount()%>" 
294            visible="<%=mode.hasNavigator()%>"
295          />
296        </tbl:panel>
297      </div>
298      <tbl:data>
299        <tbl:headers>
300          <tbl:headerrow>
301            <tbl:header colspan="3" />
302            <tbl:columnheaders />
303          </tbl:headerrow>
304          <tbl:headerrow>
305            <tbl:header subclass="index" />
306            <tbl:header 
307              subclass="check" 
308              visible="<%=mode.hasCheck()%>"
309              ><base:icon 
310                id="check.uncheck"
311                image="check_uncheck.png" 
312                tooltip="Check/uncheck all" 
313                 
314              /></tbl:header>
315            <tbl:header 
316              subclass="check" 
317              visible="<%=mode.hasRadio()%>"
318              />
319            <tbl:header 
320              subclass="icons" 
321              visible="<%=mode.hasIcons()%>"
322              />
323            <tbl:propertyfilter />
324          </tbl:headerrow>
325        </tbl:headers>
326        <tbl:rows>
327          <%
328          if (cc.getMessage() != null)
329          {
330            %>
331            <tbl:panel subclass="bg-filled-50">
332              <div class="messagecontainer error"><%=cc.getMessage()%></div>
333            </tbl:panel>
334            <%
335            cc.setMessage(null);
336          }
337          int index = cc.getPage()*cc.getRowsPerPage();
338          int selectedItemId = cc.getId();
339          if (history != null)
340          {           
341            while (history.hasNext())
342            {
343              ChangeHistory item = history.next();
344              int itemId = item.getId();
345              String tooltip = mode.isSelectionMode() ? 
346                  "Select this item" : "View this item";
347              index++;
348              numListed++;
349              %>
350              <tbl:row>
351                <tbl:header 
352                  clazz="index"
353                  ><%=index%></tbl:header>
354                <tbl:header 
355                  clazz="check" 
356                  visible="<%=mode.hasCheck()%>"
357                  ><input 
358                    type="checkbox" 
359                    name="<%=itemId%>" 
360                    value="<%=itemId%>" 
361                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
362                  ></tbl:header>
363                <tbl:header 
364                  clazz="check" 
365                  visible="<%=mode.hasRadio()%>"
366                  ><input 
367                    type="radio" 
368                    name="item_id" 
369                    value="<%=itemId%>" 
370                    <%=selectedItemId == itemId ? "checked" : ""%>
371                  ></tbl:header>
372                <tbl:header 
373                  clazz="icons" 
374                  visible="<%=mode.hasIcons()%>"
375                  >&nbsp;</tbl:header>
376                <tbl:cell column="time"><div 
377                    class="link table-item"
378                    data-item-id="<%=itemId%>"
379                    data-no-edit="1" tabindex="0"
380                    title="<%=tooltip%>"><%=dateFormatter.format(item.getTime())%></div>
381                  </tbl:cell>
382                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
383                <tbl:cell column="changeType"><%=item.getChangeType()%></tbl:cell>
384                <tbl:cell column="changeInfo"><%=HTML.niceFormat(item.getChangeInfo())%></tbl:cell>
385                <tbl:cell column="oldValue"><%=HTML.niceFormat(item.getOldValue())%></tbl:cell>
386                <tbl:cell column="newValue"><%=HTML.niceFormat(item.getNewValue())%></tbl:cell>
387                <tbl:cell column="user"><%=ChangeHistoryUtil.getUser(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
388                <tbl:cell column="session"><%=ChangeHistoryUtil.getSession(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
389                <tbl:cell column="client"><%=ChangeHistoryUtil.getClient(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
390                <tbl:cell column="project"><%=ChangeHistoryUtil.getProject(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
391                <tbl:cell column="plugin"><%=ChangeHistoryUtil.getPlugin(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
392                <tbl:cell column="job"><%=ChangeHistoryUtil.getJob(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
393                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
394                  <tbl:cell column="xt-columns" />
395                </tbl:xt-cells>
396              </tbl:row>
397              <%
398              }
399            }
400          if (numListed == 0)
401          {
402            %>
403            <tbl:panel subclass="bg-filled-50">
404              <div class="messagecontainer note">
405              <%=history == null || history.getTotalCount() == 0 ? "No history entries were found" : "No history entries on this page. Please select another page!" %>
406              </div>
407            </tbl:panel>
408            <%
409          }
410          %>
411        </tbl:rows>
412      </tbl:data>
413    </tbl:table>
414     
415     
416  </base:body>
417  </base:page>
418  <%
419}
420finally
421{
422  if (dc != null) dc.close();
423}
424
425%>
Note: See TracBrowser for help on using the repository browser.