1 | <%-- $Id: overview.jsp 5950 2012-02-09 10:30:23Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Nicklas Nordborg |
---|
4 | Copyright (C) 2007 Johan Enell |
---|
5 | |
---|
6 | This file is part of BASE - BioArray Software Environment. |
---|
7 | Available at http://base.thep.lu.se/ |
---|
8 | |
---|
9 | BASE is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 3 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | BASE is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | ------------------------------------------------------------------ |
---|
22 | |
---|
23 | @author Nicklas |
---|
24 | @version 2.0 |
---|
25 | --%> |
---|
26 | <%@ page pageEncoding="UTF-8" session="false" |
---|
27 | import="net.sf.basedb.core.SessionControl" |
---|
28 | import="net.sf.basedb.core.DbControl" |
---|
29 | import="net.sf.basedb.core.DiskUsage" |
---|
30 | import="net.sf.basedb.core.DiskUsageStatistics" |
---|
31 | import="net.sf.basedb.core.SystemItems" |
---|
32 | import="net.sf.basedb.core.Item" |
---|
33 | import="net.sf.basedb.core.Location" |
---|
34 | import="net.sf.basedb.core.QuotaType" |
---|
35 | import="net.sf.basedb.core.ItemContext" |
---|
36 | import="net.sf.basedb.core.ItemQuery" |
---|
37 | import="net.sf.basedb.core.ItemResultList" |
---|
38 | import="net.sf.basedb.core.query.Orders" |
---|
39 | import="net.sf.basedb.core.query.Expression" |
---|
40 | import="net.sf.basedb.core.query.Hql" |
---|
41 | import="net.sf.basedb.core.query.Restrictions" |
---|
42 | import="net.sf.basedb.core.query.Expressions" |
---|
43 | import="net.sf.basedb.clients.web.Base" |
---|
44 | import="net.sf.basedb.clients.web.util.HTML" |
---|
45 | import="net.sf.basedb.util.Values" |
---|
46 | import="java.util.List" |
---|
47 | %> |
---|
48 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
49 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
50 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
51 | <%! |
---|
52 | private static final Item itemType = Item.DISKUSAGE; |
---|
53 | %> |
---|
54 | <% |
---|
55 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
56 | final String ID = sc.getId(); |
---|
57 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
58 | final int itemId = cc.getId(); |
---|
59 | final float scale = Base.getScale(sc); |
---|
60 | final DbControl dc = sc.newDbControl(); |
---|
61 | try |
---|
62 | { |
---|
63 | DiskUsageStatistics du = (DiskUsageStatistics)sc.getSessionSetting("diskUsageStatistics"); |
---|
64 | if (du == null) |
---|
65 | { |
---|
66 | du = DiskUsage.getStatistics(dc); |
---|
67 | sc.setSessionSetting("diskUsageStatistics", du); |
---|
68 | } |
---|
69 | du.setDbControl(dc); |
---|
70 | List<QuotaType> quotaTypes = du.getQuotaTypes(); |
---|
71 | DiskUsageStatistics.Summary summary = du.getTotalSummary(); |
---|
72 | %> |
---|
73 | |
---|
74 | <base:page title="Disk usage"> |
---|
75 | <base:head scripts="tabcontrol.js" styles="headertabcontrol.css"> |
---|
76 | <script language="JavaScript"> |
---|
77 | function switchTab(tabControlId, tabId) |
---|
78 | { |
---|
79 | if (tabId == 'users') |
---|
80 | { |
---|
81 | location.href = 'index.jsp?ID=<%=ID%>&cmd=ListUsers'; |
---|
82 | } |
---|
83 | else if (tabId == 'groups') |
---|
84 | { |
---|
85 | location.href = 'index.jsp?ID=<%=ID%>&cmd=ListGroups'; |
---|
86 | } |
---|
87 | else |
---|
88 | { |
---|
89 | TabControl.setActiveTab(tabControlId, tabId); |
---|
90 | } |
---|
91 | } |
---|
92 | </script> |
---|
93 | <style> |
---|
94 | |
---|
95 | table.special |
---|
96 | { |
---|
97 | border-collapse: collapse; |
---|
98 | width: auto; |
---|
99 | } |
---|
100 | table.special td, table.special tr:first-child th |
---|
101 | { |
---|
102 | text-align: right; |
---|
103 | border-right: 1px dotted #A0A0A0; |
---|
104 | } |
---|
105 | |
---|
106 | </style> |
---|
107 | |
---|
108 | </base:head> |
---|
109 | <base:body> |
---|
110 | <h1>Disk usage</h1> |
---|
111 | |
---|
112 | <t:tabcontrol |
---|
113 | id="main" |
---|
114 | subclass="mastertabcontrol content" |
---|
115 | active="overview" switch="switchTab"> |
---|
116 | <t:tab id="overview" title="Overview"> |
---|
117 | |
---|
118 | <table class="special fullform bottomborder rightborder"> |
---|
119 | <tr> |
---|
120 | <th style="width: 10em;"></th> |
---|
121 | <th style="width: 12em;">Total</td> |
---|
122 | <th style="width: 12em;">Primary</td> |
---|
123 | <th style="width: 12em;">Secondary</td> |
---|
124 | <th style="width: 12em;">Offline</td> |
---|
125 | <th style="width: 12em;">External</td> |
---|
126 | </tr> |
---|
127 | <tr style="border-top: 1px solid #A0A0A0;" class="highlight"> |
---|
128 | <th>Total</th> |
---|
129 | <td><%=Values.formatBytes(summary.getTotal())%></td> |
---|
130 | <td><%=Values.formatBytes(summary.getTotal(Location.PRIMARY))%></td> |
---|
131 | <td><%=Values.formatBytes(summary.getTotal(Location.SECONDARY))%></td> |
---|
132 | <td><%=Values.formatBytes(summary.getTotal(Location.OFFLINE))%></td> |
---|
133 | <td><%=Values.formatBytes(summary.getTotal(Location.EXTERNAL))%></td> |
---|
134 | </tr> |
---|
135 | <% |
---|
136 | for (QuotaType qt : quotaTypes) |
---|
137 | { |
---|
138 | %> |
---|
139 | <tr class="highlight"> |
---|
140 | <th><%=HTML.encodeTags(qt.getName())%></th> |
---|
141 | <td><%=Values.formatBytes(summary.getTotal(qt))%></td> |
---|
142 | <td><%=Values.formatBytes(summary.getTotal(qt, Location.PRIMARY))%></td> |
---|
143 | <td><%=qt.hasSecondaryLocation() ? Values.formatBytes(summary.getTotal(qt, Location.SECONDARY)) : "n/a"%></td> |
---|
144 | <td><%=qt.getSystemId().equals(QuotaType.FILE) ? Values.formatBytes(summary.getTotal(qt, Location.OFFLINE)) : "n/a"%></td> |
---|
145 | <td><%=qt.getSystemId().equals(QuotaType.FILE) ? Values.formatBytes(summary.getTotal(qt, Location.EXTERNAL)) : "n/a"%></td> |
---|
146 | </tr> |
---|
147 | <% |
---|
148 | } |
---|
149 | %> |
---|
150 | </table> |
---|
151 | </t:tab> |
---|
152 | <t:tab id="users" title="Per user" /> |
---|
153 | <t:tab id="groups" title="Per group" /> |
---|
154 | </t:tabcontrol> |
---|
155 | |
---|
156 | </base:body> |
---|
157 | </base:page> |
---|
158 | <% |
---|
159 | } |
---|
160 | finally |
---|
161 | { |
---|
162 | if (dc != null) dc.close(); |
---|
163 | } |
---|
164 | |
---|
165 | %> |
---|