source: trunk/www/my_base/projects/view_project.jsp @ 2918

Last change on this file since 2918 was 2918, checked in by Nicklas Nordborg, 17 years ago

References #348: Take ownership of items

Implemented on all pages in the "View" menu.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 9.7 KB
Line 
1<%-- $Id: view_project.jsp 2918 2006-11-15 11:21:13Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.SystemItems"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.Project"
35  import="net.sf.basedb.core.User"
36  import="net.sf.basedb.core.Group"
37  import="net.sf.basedb.core.ItemQuery"
38  import="net.sf.basedb.core.ItemResultList"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.core.PluginDefinition"
41  import="net.sf.basedb.core.plugin.GuiContext"
42  import="net.sf.basedb.core.plugin.Plugin"
43  import="net.sf.basedb.core.query.Orders"
44  import="net.sf.basedb.core.query.Hql"
45  import="net.sf.basedb.clients.web.Base"
46  import="net.sf.basedb.clients.web.PermissionUtil"
47  import="net.sf.basedb.clients.web.util.HTML"
48  import="net.sf.basedb.util.Values"
49  import="java.util.Date"
50  import="java.util.Map"
51  import="java.util.Set"
52  import="java.util.List"
53%>
54<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
55<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
56<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
57<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
58<%!
59  private static final Item itemType = Item.PROJECT;
60  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
61%>
62<%
63final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
64final String ID = sc.getId();
65final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
66final int itemId = cc.getId();
67final String tab = Values.getString(request.getParameter("tab"), "properties");
68final float scale = Base.getScale(sc);
69final DbControl dc = sc.newDbControl();
70try
71{
72  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
73
74  String title = null;
75  Project project = Project.getById(dc, itemId);
76 
77  final boolean usePermission = project.hasPermission(Permission.USE);
78  final boolean writePermission = project.hasPermission(Permission.WRITE);
79  final boolean deletePermission = project.hasPermission(Permission.DELETE);
80  final boolean setOwnerPermission = project.hasPermission(Permission.SET_OWNER);
81  final boolean isOwner = project.isOwner();
82  %>
83
84  <base:page title="<%=title%>">
85  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
86    <script language="JavaScript">
87    function editItem()
88    {
89      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
90    }
91    function deleteItem()
92    {
93      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
94    }
95    function restoreItem()
96    {
97      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
98    }
99    function takeOwnership()
100    {
101      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
102      {
103        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
104      }
105    }
106    function runPlugin(cmd)
107    {
108      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
109    }
110    function setToActive()
111    {
112      Main.openPopup('set_active.jsp?ID=<%=ID%>&project_id=<%=itemId%>', 'ActivateProject', 300, 140);
113    }
114    function viewItems()
115    {
116      location.href = 'items/index.jsp?ID=<%=ID%>&project_id=<%=itemId%>';
117    }
118    function switchTab(tabControlId, tabId)
119    {
120      if (tabId == 'items')
121      {
122        viewItems();
123      }
124      else
125      {
126        TabControl.setActiveTab(tabControlId, tabId);
127      }
128    }
129    </script>
130  </base:head>
131  <base:body>
132    <p>
133    <p:path>
134      <p:pathelement title="Projects" href="<%="index.jsp?ID="+ID%>" />
135      <p:pathelement title="<%=HTML.encodeTags(project.getName())%>" />
136    </p:path>
137   
138    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab">
139    <t:tab id="properties" title="Properties">
140
141    <tbl:toolbar
142      >
143      <tbl:button 
144        disabled="<%=writePermission ? false : true%>" 
145        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
146        onclick="editItem()" 
147        title="Edit&hellip;" 
148        tooltip="<%=writePermission ? "Edit this project" : "You do not have permission to edit this project"%>" 
149      />
150      <tbl:button 
151        disabled="<%=deletePermission ? false : true%>" 
152        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
153        onclick="deleteItem()" 
154        title="Delete"
155        visible="<%=!project.isRemoved()%>"
156        tooltip="<%=deletePermission ? "Delete this project" : "You do not have permission to delete this project"%>" 
157      />
158      <tbl:button 
159        disabled="<%=writePermission ? false : true%>" 
160        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
161        onclick="restoreItem()" 
162        title="Restore"
163        visible="<%=project.isRemoved()%>"
164        tooltip="<%=writePermission ? "Restore this project" : "You do not have permission to restore this project"%>" 
165      />
166      <tbl:button 
167        disabled="<%=setOwnerPermission ? false : true%>"
168        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
169        onclick="takeOwnership()" 
170        title="Take ownership&hellip;"
171        visible="<%=!isOwner%>"
172        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
173      />
174      <tbl:button 
175        onclick="setToActive()" 
176        image="bullet.gif"
177        title="Set active"
178        tooltip="Set this project to the active project"
179      />
180      <tbl:button 
181        image="import.gif" 
182        onclick="runPlugin('ImportItem')" 
183        title="Import&hellip;" 
184        tooltip="Import data" 
185        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
186      />
187      <tbl:button 
188        image="export.gif" 
189        onclick="runPlugin('ExportItem')" 
190        title="Export&hellip;" 
191        tooltip="Export data" 
192        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
193      />
194      <tbl:button 
195        image="runplugin.gif" 
196        onclick="runPlugin('RunPlugin')" 
197        title="Run plugin&hellip;" 
198        tooltip="Run a plugin" 
199        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
200      />
201      <tbl:button
202        image="help.gif"
203        onclick="<%="Main.openHelp('" + ID +"', 'project.view.properties')"%>"
204        title="Help&hellip;"
205        tooltip="Get help about this page"
206      />
207      </tbl:toolbar>
208    <div class="boxedbottom">
209      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(project)%></i></div>
210      <%
211      if (project.isRemoved())
212      {
213        %>
214        <div class="itemstatus">
215          <base:icon image="deleted.gif" 
216            visible="<%=project.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
217        </div>
218        <%
219      }
220      %>
221      <table class="form" cellspacing=0>
222      <tr>
223        <td class="prompt">Name</td>
224        <td><%=HTML.encodeTags(project.getName())%></td>
225      </tr>
226      <tr>
227        <td class="prompt">Owner</td>
228        <td><base:propertyvalue item="<%=project%>" property="owner" /></td>
229      </tr>
230      <tr>
231        <td class="prompt">Description</td>
232        <td><%=HTML.niceFormat(project.getDescription())%></td>
233      </tr>
234      </table>
235     
236      <h4 class="docked">Members</h4>
237     
238      <tbl:table
239        id="members"
240        clazz="itemlist"
241        columns="all"
242        >
243        <tbl:columndef
244          id="type"
245          title="User/Group"
246        />
247        <tbl:columndef
248          id="name"
249          title="Name"
250        />
251        <tbl:columndef
252          id="permissions"
253          title="Permissions"
254        />
255        <tbl:data>
256          <tbl:columns />
257          <tbl:rows>
258          <%
259          // Query to retrieve child groups
260          ItemQuery<Group> groupQuery = project.getGroups();
261          groupQuery.order(Orders.asc(Hql.property("name")));
262          ItemResultList<Group> groups = groupQuery.list(dc);
263          for (Group group : groups)
264          {
265            Set<Permission> permissions = project.getPermissions(group);
266            %>
267            <tbl:row>
268              <tbl:cell column="type">Group</tbl:cell>
269              <tbl:cell column="name"><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
270              <tbl:cell column="permissions"><%=permissions.toString().replaceAll("\\[|\\]", "")%></tbl:cell>
271            </tbl:row>
272            <%
273          }
274     
275          // Query to retrieve user members
276          ItemQuery<User> userQuery = project.getUsers();
277          userQuery.order(Orders.asc(Hql.property("name")));
278          ItemResultList<User> users = userQuery.list(dc);
279          for (User user : users)
280          {
281            Set<Permission> permissions = project.getPermissions(user);
282            %>
283            <tbl:row>
284              <tbl:cell column="type">User</tbl:cell>
285              <tbl:cell column="name"><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
286              <tbl:cell column="permissions"><%=permissions.toString().replaceAll("\\[|\\]", "")%></tbl:cell>
287            </tbl:row>
288            <%
289          }
290          %>
291          </tbl:rows>
292        </tbl:data>
293      </tbl:table>
294    </div>
295      </t:tab>
296     
297      <t:tab id="items" title="Items" tooltip="List all items in this project" />
298     
299      </t:tabcontrol>
300
301  </base:body>
302  </base:page>
303  <%
304}
305finally
306{
307  if (dc != null) dc.close();
308}
309
310%>
Note: See TracBrowser for help on using the repository browser.