Changeset 7952


Ignore:
Timestamp:
May 12, 2021, 8:02:49 AM (7 months ago)
Author:
Nicklas Nordborg
Message:

References #2250: Named transactions

Implemented functions in the web client to view change log for an entire sessions and a single transactions.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/ChangeHistory.java

    r7949 r7952  
    2929import org.hibernate.mapping.Table;
    3030
     31import net.sf.basedb.core.data.ChangeHistoryData;
    3132import net.sf.basedb.core.data.ChangeHistoryDetailData;
    3233import net.sf.basedb.core.hibernate.TypeWrapper;
     
    158159    return query;   
    159160  }
    160    
     161 
     162  /**
     163    Load information about a single transaction.
     164    @since 3.19
     165  */
     166  public static TransactionInfo getTransactionInfo(DbControl dc, int transactionId)
     167  {
     168    ChangeHistoryData transaction = HibernateUtil.loadData(dc.getHibernateSession(), ChangeHistoryData.class, transactionId);
     169    if (transaction == null) throw new ItemNotFoundException("Transaction[id="+transactionId+"]");
     170    return new TransactionInfo(transaction);
     171  }
     172 
    161173  /**
    162174    Delete all history entries that are linking to non-existing items. This method
     
    538550  }
    539551
     552  /**
     553    Holds information about a single transaction.
     554    @since 3.19
     555  */
     556  public static class TransactionInfo
     557  {
     558    private final ChangeHistoryData data;
     559   
     560    TransactionInfo(ChangeHistoryData data)
     561    {
     562      this.data = data;
     563    }
     564
     565    /**
     566      Get the ID of the transaction.
     567    */
     568    public int getTransactionId()
     569    {
     570      return data.getId();
     571    }
     572
     573    /**
     574      Get the date and time of the transaction.
     575    */
     576    public Date getTime()
     577    {
     578      return DateUtil.copy(data.getTime());
     579    }
     580   
     581    /**
     582      Get the name of the transaction.
     583    */
     584    public String getName()
     585    {
     586      return data.getName();
     587    }
     588   
     589    /**
     590      Get the ID of the user that executed the transaction.
     591    */
     592    public int getUserId()
     593    {
     594      return data.getUserId();
     595    }
     596   
     597    /**
     598      Load the user that made the change.
     599      @param dc A DbControl to use for database access
     600      @throws ItemNotFoundException If the user no longer exists in
     601        the database
     602      @throws PermissionDeniedException If the logged in user doesn't
     603        have permission to access the other user
     604    */
     605    public User getUser(DbControl dc)
     606    {
     607      return User.getById(dc, getUserId());
     608    }
     609   
     610    /**
     611      Get the ID of the session the transaction.
     612    */
     613    public int getSessionId()
     614    {
     615      return data.getSessionId();
     616    }
     617   
     618    /**
     619      Load the session in which the change was made.
     620      @param dc A DbControl to use for database access
     621      @throws ItemNotFoundException If the session no longer exists in
     622        the database
     623      @throws PermissionDeniedException If the logged in user doesn't
     624        have permission to access the session
     625    */
     626    public Session getSession(DbControl dc)
     627    {
     628      return Session.getById(dc, getSessionId());
     629    }
     630 
     631    /**
     632      Get the ID of the client application that was used in the transaction.
     633      @return The ID or null if the client application is not known
     634    */
     635    public Integer getClientId()
     636    {
     637      return data.getClientId();
     638    }
     639   
     640    /**
     641      Load the client application that was used in the transaction.
     642      @param dc A DbControl to use for database access
     643      @return A Client object or null if it is not known which client
     644        that was used
     645      @throws ItemNotFoundException If the client application no longer exists in
     646        the database
     647      @throws PermissionDeniedException If the logged in user doesn't
     648        have permission to access the client
     649    */
     650    public Client getClient(DbControl dc)
     651    {
     652      Integer id = getClientId();
     653      return id == null ? null : Client.getById(dc, id);
     654    }
     655 
     656    /**
     657      Get the ID of the project that was active during the transaction.
     658      @return The ID or null if no project was active
     659    */
     660    public Integer getProjectId()
     661    {
     662      return data.getProjectId();
     663    }
     664   
     665    /**
     666      Load the project that was active during the transaction.
     667      @param dc A DbControl to use for database access
     668      @return A Project object or null if no project was active
     669      @throws ItemNotFoundException If the client application no longer exists in
     670        the database
     671      @throws PermissionDeniedException If the logged in user doesn't
     672        have permission to access the project
     673    */
     674    public Project getProject(DbControl dc)
     675    {
     676      Integer id = getProjectId();
     677      return id == null ? null : Project.getById(dc, id);
     678    }
     679 
     680    /**
     681      Get the ID of the plug-in that was executing the transaction.
     682      @return The ID or null if the change was not made by a plug-in
     683    */
     684    public Integer getPluginId()
     685    {
     686      return data.getPluginId();
     687    }
     688   
     689    /**
     690      Load the plug-in that was executing the transaction.
     691      @param dc A DbControl to use for database access
     692      @return A PluginDefinition object or null if the change
     693        was not made by a plug-in
     694      @throws ItemNotFoundException If the plug-in no longer exists in
     695        the database
     696      @throws PermissionDeniedException If the logged in user doesn't
     697        have permission to access the plug-in
     698    */
     699    public PluginDefinition getPlugin(DbControl dc)
     700    {
     701      Integer id = getPluginId();
     702      return id == null ? null : PluginDefinition.getById(dc, id);
     703    }
     704 
     705    /**
     706      Get the ID of the job that was executing the transaction.
     707      @return The ID or null if the no job was executing
     708    */
     709    public Integer getJobId()
     710    {
     711      return data.getJobId();
     712    }
     713   
     714    /**
     715      Load the job that was executing the transaction.
     716      @param dc A DbControl to use for database access
     717      @return A Job object or null if no job was executing when the
     718        change was made
     719      @throws ItemNotFoundException If the job no longer exists in
     720        the database
     721      @throws PermissionDeniedException If the logged in user doesn't
     722        have permission to access the job
     723    */
     724    public Job getJob(DbControl dc)
     725    {
     726      Integer id = getJobId();
     727      return id == null ? null : Job.getById(dc, id);
     728    }
     729   
     730  }
    540731}
  • trunk/www/common/history/frameset.jsp

    r6402 r7952  
    3838Item sourceType = Item.valueOf(request.getParameter("item_type"));
    3939int sourceId = Values.getInt(request.getParameter("item_id"));
     40int transactId = Values.getInt(request.getParameter("transact_id"));
    4041%>
    4142  <base:page type="include">
     
    4546      data-source-type="<%=sourceType.name() %>"
    4647      data-source-id="<%=sourceId %>"
     48      data-transact-id="<%=transactId%>"
    4749    ></div>
    4850    <div class="absolutefull"><iframe name="history-frame" id="idHistory"
  • trunk/www/common/history/history.js

    r7951 r7952  
    6161    url += '&source_type='+Data.get('history-data', 'source-type');
    6262    url += '&source_id='+Data.get('history-data', 'source-id');
     63    url += '&transact_id='+Data.get('history-data', 'transact-id');
    6364    frames['history-frame'].location.replace(url);
    6465    loaded = true;
     
    6768  history.initElements = function(element, autoInit)
    6869  {
    69     if (autoInit != 'transact-box') return;
    70     Events.addEventHandler(element, 'mouseenter', history.mouseEnterTransactBox);
    71     Events.addEventHandler(element, 'mouseleave', history.mouseLeaveTransactBox);
     70    if (autoInit == 'transact-box')
     71    {
     72      Events.addEventHandler(element, 'mouseenter', history.mouseEnterTransactBox);
     73      Events.addEventHandler(element, 'mouseleave', history.mouseLeaveTransactBox);
     74    }
     75    else if (autoInit == 'transact-link')
     76    {
     77      Events.addEventHandler(element, 'click', history.viewTransaction);
     78    }
     79  }
     80 
     81  history.viewTransaction = function(event)
     82  {
     83    var url = App.getRoot()+Items.getController('SESSION').url + '?ID='+App.getSessionId();
     84    url += '&cmd=ViewTransaction&item_id='+Data.get(event.currentTarget, 'session-id');
     85    url += '&transact_id='+Data.get(event.currentTarget, 'transact-id');
     86    window.parent.location.href = url;
    7287  }
    7388 
  • trunk/www/common/history/index.jsp

    r7948 r7952  
    3131  import="net.sf.basedb.core.BasicItem"
    3232  import="net.sf.basedb.core.ChangeHistory"
     33  import="net.sf.basedb.core.Session"
    3334  import="net.sf.basedb.core.ItemQuery"
    3435  import="net.sf.basedb.core.ItemResultIterator"
     
    4445  import="net.sf.basedb.core.query.Restrictions"
    4546  import="net.sf.basedb.core.query.Expressions"
     47  import="net.sf.basedb.core.log.ChangeTypeFormatter"
    4648  import="net.sf.basedb.util.RemovableUtil"
    4749  import="net.sf.basedb.util.ShareableUtil"
    4850  import="net.sf.basedb.util.OwnableUtil"
    4951  import="net.sf.basedb.util.formatter.NameableFormatter"
     52  import="net.sf.basedb.util.formatter.ItemTypeFormatter"
    5053  import="net.sf.basedb.clients.web.Base"
    5154  import="net.sf.basedb.clients.web.WebException"
     
    5659  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
    5760  import="net.sf.basedb.clients.web.plugins.ChangeHistoryDetailLoader"
     61  import="net.sf.basedb.clients.web.plugins.ChangeHistoryItemLoader"
    5862  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
    5963  import="net.sf.basedb.clients.web.extensions.JspContext"
     
    6165  import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
    6266  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
     67  import="net.sf.basedb.clients.web.formatter.AutoItemExportFormatter"
    6368  import="java.util.Enumeration"
    6469  import="java.util.Set"
     
    7984    cc.setObject("export.dataloader.oldValue", new ChangeHistoryDetailLoader(true));
    8085    cc.setObject("export.dataloader.newValue", new ChangeHistoryDetailLoader(false));
     86    cc.setObject("export.dataloader.item", new ChangeHistoryItemLoader());
     87    cc.setObject("export.formatter.item", new AutoItemExportFormatter());
     88    cc.setObject("export.formatter.changeType", new ChangeTypeFormatter());
     89    cc.setObject("export.formatter.itemType", new ItemTypeFormatter());
    8190  }
    8291%>
     
    8594final Item sourceType = request.getParameter("source_type") != null ?
    8695    Item.valueOf(request.getParameter("source_type")) : null;
     96final boolean isSessionLog = sourceType == Item.SESSION;
     97final String subContext = isSessionLog ? "session-log":"";
    8798
    8899final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
     
    93104final String callback = request.getParameter("callback");
    94105final String itemId = request.getParameter("item_id");
     106final int transactId = Values.getInt(request.getParameter("transact_id"));
    95107final String listPage = "list_history.jsp?ID="+ID
    96108  +"&source_id="+sourceId
     
    98110  +(mode == null ? "" : "&mode="+mode)
    99111  +(callback == null ? "" : "&callback="+callback)
    100   +(itemId == null ? "" : "&item_id="+itemId);
     112  +(itemId == null ? "" : "&item_id="+itemId)
     113  +(transactId == 0 ? "" : "&transact_id="+transactId);
    101114final String viewPage = "view_history.jsp?ID="+ID;
    102115
     
    111124  {
    112125    // Display the list page without updatinging the current context
    113     Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
     126    Base.getAndSetCurrentContext(sc, itemType, subContext, (PageContext)null, defaultContext, true);
    114127    redirect = listPage;
    115128  }
     
    117130  {
    118131    // Display the list page after updating the current context from the request parameters
    119     Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     132    Base.getAndSetCurrentContext(sc, itemType, subContext, pageContext, defaultContext);
    120133    redirect = listPage;
    121134  }
     
    131144  {
    132145    // Display the view page for a single item
    133     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     146    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, pageContext, defaultContext);
    134147    forward = viewPage;
    135148  }
     
    137150  {
    138151    // Run an export plugin in a list context
    139     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     152    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, pageContext, defaultContext);
    140153    dc = sc.newDbControl();
    141154    BasicItem source = sourceType.getById(dc, sourceId);
    142     final ItemQuery<ChangeHistory> query = ChangeHistory.getHistoryOf(source);
     155    final ItemQuery<ChangeHistory> query = isSessionLog ? ChangeHistory.getChangesIn((Session)source) : ChangeHistory.getHistoryOf(source);
    143156    JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null);
    144157    cc.configureQuery(dc, query, jspContext, true);
     158    if (transactId > 0)
     159    {
     160      query.restrict(Restrictions.eq(Hql.property("hst", "id"), Expressions.integer(transactId)));
     161    }
    145162    registerExportUtils(cc);
    146163    cc.setQuery(query);
     
    148165    listInvoker.render(new ListColumnExportRenderer<ChangeHistory>(cc));
    149166    dc.close();
    150     redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+change+history";
     167    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&subcontext="+subContext+"&title=Export+change+history";
    151168  }
    152169  else if ("ExportItem".equals(cmd))
     
    154171    // Run an export plugin in single-item context
    155172    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    156     redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+change+history";
     173    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&subcontext="+subContext+"&title=Export+change+history";
    157174  }
    158175  else
  • trunk/www/common/history/list_history.jsp

    r7949 r7952  
    2828  import="net.sf.basedb.core.Item"
    2929  import="net.sf.basedb.core.BasicItem"
     30  import="net.sf.basedb.core.Session"
    3031  import="net.sf.basedb.core.ChangeHistory"
    3132  import="net.sf.basedb.core.Permission"
    3233  import="net.sf.basedb.core.Nameable"
     34  import="net.sf.basedb.core.Metadata"
    3335  import="net.sf.basedb.core.ItemContext"
    3436  import="net.sf.basedb.core.ItemQuery"
     
    3840  import="net.sf.basedb.core.query.Orders"
    3941  import="net.sf.basedb.core.query.Hql"
     42  import="net.sf.basedb.core.query.Expressions"
     43  import="net.sf.basedb.core.query.Restrictions"
    4044  import="net.sf.basedb.core.plugin.GuiContext"
    4145  import="net.sf.basedb.core.plugin.Plugin"
     
    6973  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
    7074  private static String[] COLORS = {"#ffb700","#ffc547","#ffd270","#ffdf96","#ffebbc","#f6dcb9","#f2c094","#efa177","#eb8064","#e65a5a"};
     75
     76  private static final Enumeration<String, String> items = new Enumeration<String, String>();
     77  static
     78  {
     79    for (Item item : Metadata.getRemovableItems())
     80    {
     81      items.add(Integer.toString(item.getValue()), item.toString());
     82    }
     83  }
    7184%>
    7285<%
     86final Item sourceType = Item.valueOf(request.getParameter("source_type"));
     87final int sourceId = Values.getInt(request.getParameter("source_id"));
     88final int transactId = Values.getInt(request.getParameter("transact_id"));
     89final boolean isSessionLog = sourceType == Item.SESSION;
     90final String subContext = isSessionLog?"session-log": "";
     91
    7392final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
    7493final String ID = sc.getId();
    75 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    76 
    77 final Item sourceType = Item.valueOf(request.getParameter("source_type"));
    78 final int sourceId = Values.getInt(request.getParameter("source_id"));
     94final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null);
     95
    7996final float scale = Base.getScale(sc);
    8097final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
     
    83100final DbControl dc = sc.newDbControl();
    84101ItemResultIterator<ChangeHistory> history = null;
    85 
    86102try
    87103{
     
    92108  {
    93109    final ItemQuery<ChangeHistory> query =
    94       Base.getConfiguredQuery(dc, cc, jspContext, true, ChangeHistory.getHistoryOf(source), mode);
     110      Base.getConfiguredQuery(dc, cc, jspContext, true, isSessionLog ? ChangeHistory.getChangesIn((Session)source) : ChangeHistory.getHistoryOf(source), mode);
     111    if (transactId > 0)
     112    {
     113      query.restrict(Restrictions.eq(Hql.property("hst", "id"), Expressions.integer(transactId)));
     114    }
    95115    query.order(cc.getSortDirection().sortBy(Hql.property("id")));
    96116    history = query.iterate(dc);
     
    151171      subclass="fulltable"
    152172      stickyheaders="time"
     173      subcontext="<%=subContext%>"
    153174      >
    154175      <tbl:hidden
     
    160181        value="<%=sourceType.name()%>"
    161182      />
    162       <tbl:columndef
    163          id="id"
     183      <tbl:hidden
     184        name="transact_id"
     185        value="<%=String.valueOf(transactId)%>"
     186      />
     187      <tbl:columndef
     188        id="id"
    164189        clazz="uniquecol"
    165          property="id"
    166          datatype="int"
    167          title="ID"
    168          sortable="true"
    169          filterable="true"
    170          exportable="true"
     190        property="id"
     191        datatype="int"
     192        title="ID"
     193        sortable="true"
     194        filterable="true"
     195        exportable="true"
    171196      />
    172197      <tbl:columndef
     
    209234      />
    210235      <tbl:columndef
     236        id="item"
     237        title="Item"
     238        exportable="true"
     239        exportproperty="item"
     240        show="<%=isSessionLog?"auto":"never"%>"
     241      />
     242      <tbl:columndef
     243        id="itemType"
     244        property="itemType"
     245        datatype="int"
     246        title="Item type"
     247        enumeration="<%=items%>"
     248        filterable="true"
     249        exportable="true"
     250        show="<%=isSessionLog?"auto":"never"%>"
     251      />
     252      <tbl:columndef
    211253        id="user"
    212254        property="$hst.user.name"
     
    227269        filterable="true"
    228270        exportable="true"
     271        show="<%=isSessionLog?"never":"auto" %>"
    229272      />
    230273      <tbl:columndef
     
    404447            int colorNo = 0;
    405448            int prevTransactId = 0;
    406             int transactId = 0;
     449            int thisTransactId = 0;
    407450            int nextTransactId = 0;
    408451            // TransactionID->Color is mapped on first entry with given TransactionID
     
    422465              numListed++;
    423466             
    424               prevTransactId = transactId;
    425               transactId = item.getTransactionId();
     467              prevTransactId = thisTransactId;
     468              thisTransactId = item.getTransactionId();
    426469              nextTransactId = nextItem != null ? nextItem.getTransactionId() : 0;             
    427               String color = colors.get(transactId);
     470              String color = colors.get(thisTransactId);
    428471              if (color == null)
    429472              {
    430473                color = COLORS[colorNo % COLORS.length];
    431474                colorNo++;
    432                 colors.put(transactId, color);
    433                 transactStyles.append(".transact-"+transactId+" .transact-box.transact-"+transactId+" { border-width: 2px; border-color: black; }\n");
     475                colors.put(thisTransactId, color);
     476                transactStyles.append(".transact-"+thisTransactId+" .transact-box.transact-"+thisTransactId+" { border-width: 2px; border-color: black; }\n");
    434477              }
    435478              %>
    436               <tbl:row subclass="auto-init" data-auto-init="transact-box" data-transact-id="<%=transactId%>">
     479              <tbl:row subclass="auto-init" data-auto-init="transact-box" data-transact-id="<%=thisTransactId%>">
    437480                <tbl:header clazz="row-index bg-filled-100">
    438481                  <div class="index-<%=mode.getName()%>">
     
    454497                      />
    455498                    </div>
    456                     <div class="icons transact-box transact-<%=transactId%><%=transactId==prevTransactId?" same-as-previous":""%><%=transactId==nextTransactId?" same-as-next":""%>"
    457                       data-transact-id="<%=transactId%>" style="background-color: <%=color%>;"></div>
     499                    <div class="icons transact-box transact-<%=thisTransactId%><%=thisTransactId==prevTransactId?" same-as-previous":""%><%=thisTransactId==nextTransactId?" same-as-next":""%>"
     500                      data-transact-id="<%=thisTransactId%>" style="background-color: <%=color%>;"></div>
    458501                  </div>
    459502                </tbl:header>
     
    464507                    title="<%=tooltip%>" style="white-space: nowrap;"><%=dateFormatter.format(item.getTime())%></div>
    465508                  </tbl:cell>
    466                 <tbl:cell column="transaction"><%=HTML.encodeTags(item.getName())%></tbl:cell>
     509                <tbl:cell column="transaction"><span class="link auto-init" data-auto-init="transact-link" data-session-id="<%=item.getSessionId()%>" data-transact-id="<%=item.getTransactionId()%>" title="View changes in this transaction"><%=HTML.encodeTags(item.getName())%></span></tbl:cell>
    467510                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
    468511                <tbl:cell column="changeType"><%=item.getChangeType()%></tbl:cell>
     512                <tbl:cell column="item"><%=ChangeHistoryUtil.getItem(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
     513                <tbl:cell column="itemType"><%=item.getItemType()%></tbl:cell>
    469514                <tbl:cell column="changeInfo"><%=HTML.niceFormat(item.getChangeInfo())%></tbl:cell>
    470515                <tbl:cell column="oldValue"><%=HTML.niceFormat(item.getOldValue())%></tbl:cell>
    471516                <tbl:cell column="newValue"><%=HTML.niceFormat(item.getNewValue())%></tbl:cell>
    472517                <tbl:cell column="user"><%=ChangeHistoryUtil.getUser(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
    473                 <tbl:cell column="session"><%=ChangeHistoryUtil.getSession(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
     518                <tbl:cell column="session"><%=ChangeHistoryUtil.getSession(dc, item, mode.hasPropertyLink(), false)%></tbl:cell>
    474519                <tbl:cell column="client"><%=ChangeHistoryUtil.getClient(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
    475520                <tbl:cell column="project"><%=ChangeHistoryUtil.getProject(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
  • trunk/www/include/scripts/main-2.js

    r7943 r7952  
    21022102    controllers['ROLE'] = { url:'admin/roles/index.jsp', width:600, height:400 };
    21032103    controllers['SAMPLE'] = { url:'biomaterials/samples/index.jsp', width:750, height:500 };
    2104     controllers['SESSION'] = { url:'views/sessions/index.jsp', width:450, height:300, popup:true, edit:false, noAnyToAny:true };
     2104    controllers['SESSION'] = { url:'views/sessions/index.jsp', width:450, height:300, edit:false, noAnyToAny:true };
    21052105    controllers['SOFTWARE'] = { url:'admin/software/index.jsp', width:800, height:500 };
    21062106    controllers['TAG'] = { url:'biomaterials/tags/index.jsp', width:800, height:500 };
  • trunk/www/include/scripts/table.js

    r7943 r7952  
    287287        {
    288288          var col = colDefs[i];
    289           if (!col.alwaysShow)
     289          if (!col.alwaysShow && !col.alwaysHide)
    290290          {
    291291            if (col.isAnnotation != hasAnnotationSeparator)
  • trunk/www/views/devices/view_device.jsp

    r7818 r7952  
    277277                %>
    278278                <tbl:row>
    279                   <tbl:cell column="loginTime"><%=dateTimeFormatter.format(item.getLoginTime())%></tbl:cell>
     279                  <tbl:cell column="loginTime"><%=Base.getLink(ID, dateTimeFormatter.format(item.getLoginTime()), Item.SESSION, item.getId(), false)%></tbl:cell>
    280280                  <tbl:cell column="logoutTime"><%=dateTimeFormatter.format(item.getLogoutTime())%></tbl:cell>
    281281                  <tbl:cell column="authenticationMethod"><%=HTML.encodeTags(item.getAuthenticationMethod())%></tbl:cell>
  • trunk/www/views/sessions/index.jsp

    r7914 r7952  
    7676final String callback = request.getParameter("callback");
    7777final String itemId = request.getParameter("item_id");
     78final String transactId = request.getParameter("transact_id");
    7879final String listPage = "list_sessions.jsp?ID="+ID
    7980  +(mode == null ? "" : "&mode="+mode)
     
    116117    forward = viewPage;
    117118  }
    118   /*
    119   else if ("EditItem".equals(cmd))
     119  else if ("ViewTransaction".equals(cmd))
    120120  {
    121     // Display the edit page for a single item (should be opened in a popup)
     121    // Display the view page for a single item (opens in a popup)
    122122    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    123     redirect = editPage;
     123    redirect = viewPage+"&tab=history&transact_id="+HTML.urlEncode(transactId);
    124124  }
    125   */
    126125  else if ("ExportItems".equals(cmd))
    127126  {
  • trunk/www/views/sessions/sessions.js

    r7604 r7952  
    3939      var attributes = {'item-type': 'SESSION', 'item-id': itemId};
    4040     
    41       Buttons.addClickHandler('close', App.closeWindow);
     41      TabControl.addTabActivateListener('main.history', History.loadOnce);
    4242    }
    4343    else if (pageId == 'list-page')
  • trunk/www/views/sessions/view_session.jsp

    r7414 r7952  
    3535  import="net.sf.basedb.core.UserDevice"
    3636  import="net.sf.basedb.core.Client"
     37  import="net.sf.basedb.core.Project"
     38  import="net.sf.basedb.core.Job"
     39  import="net.sf.basedb.core.ChangeHistory"
     40  import="net.sf.basedb.core.ChangeHistory.TransactionInfo"
    3741  import="net.sf.basedb.core.PermissionDeniedException"
    3842  import="net.sf.basedb.core.PluginDefinition"
     
    4044  import="net.sf.basedb.core.plugin.Plugin"
    4145  import="net.sf.basedb.clients.web.Base"
     46  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
    4247  import="net.sf.basedb.clients.web.util.HTML"
     48  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
     49  import="net.sf.basedb.clients.web.extensions.JspContext"
     50  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
     51  import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction"
     52  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
     53  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
    4354  import="net.sf.basedb.util.GeoLocation"
    4455  import="net.sf.basedb.util.Values"
     
    5162%>
    5263<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     64<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
     65<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
     66<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
    5367<%!
    5468  private static final Item itemType = Item.SESSION;
     
    6074final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
    6175final int itemId = cc.getId();
    62 final String tab = Values.getString(request.getParameter("tab"), "properties");
     76final String tab = Values.getString(request.getParameter("tab"));
     77int transactId = Values.getInt(request.getParameter("transact_id"));
    6378final float scale = Base.getScale(sc);
    6479final DbControl dc = sc.newDbControl();
     
    6681{
    6782  Session s = Session.getById(dc, itemId);
     83  TransactionInfo tact = transactId > 0 ? ChangeHistory.getTransactionInfo(dc, transactId) : null;
    6884 
    69   boolean readUser = true;
    70   User user = null;
    71   try
    72   {
    73     user = s.getUser();
    74   }
    75   catch (Exception ex)
    76   {
    77     readUser = false;
    78   }
    79   boolean readClient = true;
    80   Client client = null;
    81   try
    82   {
    83     client = s.getClient();
    84   }
    85   catch (Exception ex)
    86   {
    87     readClient = false;
    88   }
    89   boolean readDevice = true;
    90   UserDevice device = null;
    91   try
    92   {
    93     device = s.getDevice();
    94   }
    95   catch (Exception ex)
    96   {
    97     readDevice = false;
    98   }
     85  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     86
    9987  final String mapURL = GeoLocation.getURLToMap(s.getLocationLatitude(), s.getLocationLongitude());
    10088  String title = "View session";
    10189  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
     90  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, s);
     91  ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
    10292  %>
    103   <base:page type="popup" title="<%=title%>" id="view-page">
    104   <base:head scripts="~sessions.js" />
    105   <base:body data-read-only="1">
    106    
    107     <h1><%=title%> <base:help helpid="session.view" /></h1>
     93  <base:page title="<%=title%>" id="view-page">
     94  <base:head scripts="tabcontrol-2.js,~sessions.js" styles="toolbar.css,headertabcontrol.css,path.css">
     95    <ext:scripts context="<%=jspContext%>" />
     96    <ext:stylesheets context="<%=jspContext%>" />
     97  </base:head>
     98  <base:body>
     99   
     100    <p:path><p:pathelement
     101      title="Sessions" href="<%="index.jsp?ID="+ID%>"
     102      /><%
     103      if (tact == null)
     104      {
     105        %><p:pathelement title="<%=dateTimeFormatter.format(s.getLoginTime()) +" <span class=\\\"itemsubtype\\\">(Session)</span>"%>"
     106        /><%
     107      }
     108      else
     109      {
     110        %><p:pathelement title="<%=dateTimeFormatter.format(tact.getTime()) +" <span class=\\\"itemsubtype\\\">(Transaction)</span>"%>"
     111        /><%
     112      }
     113      %></p:path>
     114     
    108115    <div id="page-data" data-item-id="<%=itemId%>"></div>
    109116   
    110     <div class="content">
    111       <table class="fullform larger bottomborder outlined">
     117    <t:tabcontrol
     118      id="main"
     119      subclass="content mastertabcontrol"
     120      active="<%=tab%>">
     121    <t:tab id="properties" title="Properties">
     122      <div>
     123      <table class="fullform bottomborder">
     124      <tr>
     125        <th class="itemstatus">
     126        </th>
     127        <td style="padding: 0px;">
     128          <tbl:toolbar subclass="bottomborder bg-filled-50">
     129            <tbl:button
     130              id="btnExport"
     131              image="export.png"
     132              data-plugin-type="EXPORT"
     133              title="Export&hellip;"
     134              tooltip="Export data"
     135              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
     136            />
     137            <tbl:button
     138              id="btnRunPlugin"
     139              image="runplugin.png" 
     140              data-plugin-type="OTHER"
     141              title="Run plugin&hellip;"
     142              tooltip="Run a plugin"
     143              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
     144            />
     145            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>"
     146              wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/>
     147            <tbl:button
     148              image="help.png"
     149              subclass="auto-init"
     150              data-auto-init="help"
     151              data-help-id="session.view.properties"
     152              title="Help&hellip;"
     153              tooltip="Get help about this page"
     154            />
     155          </tbl:toolbar>
     156        </td>
     157      </tr>
     158      <%
     159      if (tact != null)
     160      {
     161        Project project = null;
     162        boolean deniedProject = false;
     163        try
     164        {
     165          project = tact.getProject(dc);
     166        }
     167        catch (PermissionDeniedException ex)
     168        {
     169          deniedProject = true;
     170        }
     171        PluginDefinition plugin = null;
     172        boolean deniedPlugin = false;
     173        try
     174        {
     175          plugin = tact.getPlugin(dc);
     176        }
     177        catch (PermissionDeniedException ex)
     178        {
     179          deniedPlugin = true;
     180        }
     181        Job job = null;
     182        boolean deniedJob = false;
     183        try
     184        {
     185          job = tact.getJob(dc);
     186        }
     187        catch (PermissionDeniedException ex)
     188        {
     189          deniedJob = true;
     190        }
     191        %>
     192        <tr>
     193          <th>Transaction</th>
     194          <td><%=HTML.encodeTags(tact.getName()) %></td>
     195        </tr>
     196        <tr>
     197          <th>Time</th>
     198          <td><%=dateTimeFormatter.format(tact.getTime()) %></td>
     199        </tr>
     200        <tr>
     201          <th>Active project</th>
     202          <td><%=Base.getLinkedName(ID, project, deniedProject, true) %></td>
     203        </tr>
     204        <tr>
     205          <th>Plug-in</th>
     206          <td><%=Base.getLinkedName(ID, plugin, deniedPlugin, true) %></td>
     207        </tr>
     208        <tr>
     209          <th>Job</th>
     210          <td><%=Base.getLinkedName(ID, job, deniedJob, true) %></td>
     211        </tr>
     212        <%
     213      }
     214      %>
    112215      <tr>
    113216        <th>User</th>
    114         <td><%=Base.getEncodedName(user, readUser)%></td>
     217        <td><base:propertyvalue item="<%=s%>" property="user" /></td>
    115218      </tr>
    116219      <tr>
    117220        <th>Client application</th>
    118         <td><%=Base.getEncodedName(client, !readClient)%></td>
     221        <td><base:propertyvalue item="<%=s%>" property="client" /></td>
    119222      </tr>
    120223      <tr>
    121224        <th>Device</th>
    122         <td><%=Base.getEncodedName(device, !readDevice)%></td>
     225        <td><base:propertyvalue item="<%=s%>" property="device" /></td>
    123226      </tr>
    124227      <tr>
     
    148251        <td><%=s.getImpersonated()%></td>
    149252      </tr>
    150       <tr class="dynamic">
     253      <tr>
    151254        <th>Comment</th>
    152255        <td><%=HTML.niceFormat(s.getLoginComment())%></td>
    153256      </tr>
    154257      </table>
    155     </div>
    156     <base:buttongroup subclass="dialogbuttons">
    157       <base:button id="close" title="Close" />
    158     </base:buttongroup>
    159 
     258      </div>
     259    </t:tab>
     260   
     261    <t:tab id="history" title="Change log"
     262      tooltip="Displays a log with the changes made in this session"
     263      visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
     264      <jsp:include page="../../common/history/frameset.jsp">
     265        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     266        <jsp:param name="item_id" value="<%=itemId%>" />
     267        <jsp:param name="ID" value="<%=ID%>" />
     268        <jsp:param name="transact_id" value="<%=transactId%>" />
     269      </jsp:include>
     270    </t:tab>
     271    </t:tabcontrol>
     272   
    160273  </base:body>
    161274  </base:page>
     
    166279  if (dc != null) dc.commit();
    167280}
    168 
    169281%>
Note: See TracChangeset for help on using the changeset viewer.