source: trunk/www/main.jsp @ 5918

Last change on this file since 5918 was 5918, checked in by Nicklas Nordborg, 10 years ago

References #1655: GUI improvements

Started with the redesign of list and view pages. I am using the biosource and sample pages for testing.
Changes affect more of the non-fixed pages since a lot of the contents is generated by taglibs. This means that the non-fixed pages doesn't look very good at the moment.

Table listings has only been fixed so that they display and can be used. Much more work is needed as part of #160.

I have also fixed the following pages:

  • The main menu
  • Login page + Home page
  • Item overview frameset
  • Plugins and extensions overview
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.6 KB
Line 
1<%-- $Id: main.jsp 5918 2011-12-21 10:43:35Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
5  Copyright (C) 2007 Nicklas Nordborg
6
7  This file is part of BASE - BioArray Software Environment.
8  Available at http://base.thep.lu.se/
9
10  BASE is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License
12  as published by the Free Software Foundation; either version 3
13  of the License, or (at your option) any later version.
14
15  BASE is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with BASE. If not, see <http://www.gnu.org/licenses/>.
22  ------------------------------------------------------------------
23
24  This is the front page of BASE. It displays a login form
25  and some of the relevant news items.
26
27  @param login The value to display in the login input field.
28  @param error An error message that should be displayed
29
30  @author Nicklas
31  @version 2.0
32--%>
33<%@ page pageEncoding="UTF-8" session="false"
34  import="net.sf.basedb.core.Application"
35  import="net.sf.basedb.core.SessionControl"
36  import="net.sf.basedb.core.DbControl"
37  import="net.sf.basedb.core.News"
38  import="net.sf.basedb.core.ItemQuery"
39  import="net.sf.basedb.core.ItemResultList"
40  import="net.sf.basedb.core.query.Orders"
41  import="net.sf.basedb.core.query.Hql"
42  import="net.sf.basedb.clients.web.Base"
43  import="net.sf.basedb.clients.web.util.HTML"
44  import="net.sf.basedb.util.formatter.Formatter"
45  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
46  import="net.sf.basedb.clients.web.servlet.RssNewsFeed"
47  import="net.sf.basedb.util.Values"
48  import="java.util.Date"
49%>
50<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
51<%
52final String login = Values.getString(request.getParameter("login"), "");
53final String error = Values.getString(request.getParameter("error"), null);
54final String root = request.getContextPath()+"/";
55
56final SessionControl sc = Base.getSessionControl(pageContext, true);
57final String ID = sc.getId();
58final Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
59final DbControl dc = sc.newDbControl();
60String broadcastTitle = (String)application.getAttribute("broadcast.title");
61String broadcastMessage = (String)application.getAttribute("broadcast.message");
62boolean denyLogin = Boolean.TRUE.equals(application.getAttribute("broadcast.deny-login"));
63ItemResultList<News> news = null;
64try
65{
66  %>
67  <base:page type="default" title="">
68  <base:head styles="login.css">
69    <script language="JavaScript" type="text/javascript">
70    // Set foucs on the login form
71    function init()
72    {
73      setFocus();
74    }
75   
76    // Set the focus on either the login or password field.
77    function setFocus()
78    {
79      frm = document.forms['login'];
80      if (frm.login.value == '' && window.parent.lastLogin) frm.login.value = window.parent.lastLogin;
81      if (frm.login.value == '')
82      {
83        frm.login.focus();
84        frm.login.select();
85      }
86      else
87      {
88        frm.password.focus();
89        frm.password.select();
90      }
91    }
92    function saveLogin()
93    {
94      var frm = document.forms['login'];
95      window.parent.lastLogin = frm.login.value;
96      return true;
97    }
98    function doLogin()
99    {
100      var frm = document.forms['login'];
101      if (frm.login.disabled) return;
102      var denyLogin = <%=denyLogin ? "true" : "false"%>;
103      if (denyLogin && !confirm('Login has been disabled by an administrator. Do you want to continue anyway?'))
104      {
105        return false;
106      }
107      saveLogin();
108      frm.submit();
109    }
110    function enableLogin()
111    {
112      var frm = document.forms['login'];
113      Main.hide('loginAnyway');
114      frm.login.disabled = false;
115      frm.password.disabled = false;
116      frm.login.focus();
117      Main.removeClass(document.getElementById('loginBtn'), 'disabled');
118    }
119    </script>
120  </base:head>
121 
122  <base:body onload="init();">
123    <form name="login" action="login.jsp" method="post" onsubmit="doLogin();">
124    <input type="hidden" name="ID" value="<%=ID%>">
125    <input type="hidden" name="nextpage" value="<%=root%>my_base/user/index.jsp">
126   
127    <table style="margin: auto; width: 600px; margin-top:5em; ">
128    <tr>
129    <td>
130      <table style="width: 100%;">
131      <tr>
132        <td style="background-color: #000000; border-radius: 4px 0px 0px 4px;"><img src="images/baselogo.png" alt="BASE logo"></td>
133        <td>
134          <div id="loginform">
135          <table>
136            <tr>
137              <th>Login</th>
138              <td><input class="text" type="text" name="login" value="<%=HTML.encodeTags(login)%>" 
139                maxlength="100" style="width: 12em;" <%=denyLogin ? "disabled" : ""%>
140                tabindex="0"
141                >
142              </td>
143              <td></td>
144            </tr>
145            <tr>
146              <th>Password</th>
147              <td>
148                <input class="text" type="password" name="password" maxlength="80"
149                  onkeypress="return Forms.submitOnEnter(event, doLogin)"
150                  style="width: 12em;" <%=denyLogin ? "disabled" : ""%>
151                  tabindex="0"
152                  >
153              </td>
154              <td><base:button 
155                id="loginBtn"
156                subclass="<%=denyLogin ? "disabled" : ""%>"
157                image="login.png" title="Login" 
158                onclick="doLogin();" tooltip="<%=HTML.encodeTags(broadcastTitle)%>" /></td>
159            </tr>
160            <tr>
161              <th></th>
162              <td colspan="2">
163              <%
164              String forgotPassword = sc.getClientDefaultSetting("server.forgotten.password");
165              String getAccount = sc.getClientDefaultSetting("server.get.account");
166              if (forgotPassword != null)
167              {
168                %>
169                <base:icon image="bullet.gif" />
170                <a href="javascript:Main.openPopup('info/forgot_password.jsp?ID=<%=ID%>', 'ForgotPassword', 450, 300)" title="Click here if you have forgotten your password">Forgot your password?</a>
171                <%
172              }
173              if (getAccount != null)
174              {
175                %>
176                <base:icon image="bullet.gif" />
177                <a href="javascript:Main.openPopup('info/get_account.jsp?ID=<%=ID%>', 'GetAccount', 450, 300)" title="Click here if you want to get an account on this server">Get an account!</a>
178                <%
179              }
180              %>
181              </td>
182            </tr>
183            </table>
184          </div>
185       
186       
187        </td>
188      </tr>
189      </table>
190   
191     
192      <%
193      if (error != null) 
194      {
195        %>
196        <div class="messagecontainer error"><%=error%></div>
197        <%
198      }
199      %>
200      <%
201      if (denyLogin)
202      {
203        %>
204        <div id="denyLogin">
205          <div class="messagecontainer help"">
206          <b><%=HTML.encodeTags(broadcastTitle) %> (login disabled)</b><br>
207          <%=HTML.niceFormat(broadcastMessage)%>
208          </div>
209          <base:buttongroup id="loginAnyway">
210            <base:button title="Login anyway" onclick="enableLogin()" image="login.png" tooltip="At your own risk!" />
211          </base:buttongroup>
212        </div>
213        <%
214      }
215      %>
216     
217      <%
218      String aboutServer = sc.getClientDefaultSetting("server.about");
219      if (aboutServer != null)
220      {
221        %>
222        <h3 style="margin-top: 1em;">About this server</h3>
223        <p>
224          <%=aboutServer%>
225        </p>
226        <base:icon image="bullet.gif" />
227        <a href="javascript:Main.openPopup('info/about.jsp?ID=<%=ID%>&page=about', 'About', 600, 400)">More about this server</a>
228        <%
229      }
230      %>
231     
232      <h3 style="margin-top: 1em;">News and announcements
233      <%
234      if (RssNewsFeed.isEnabled()) 
235      {
236        %>
237        <a href="info/news.rss" 
238          title="Subscribe to news from this BASE server"
239          ><base:icon image="rss.png" style="float: right; margin-top: 1px;"/></a>
240        <%
241      }
242      %>
243      </h3>
244      <div id="news" class="news">
245      <%
246      if (broadcastTitle != null)
247      {
248        %>
249        <div class="item"><base:icon image="warning.gif" />
250          <span class="date"><%=dateFormatter.format(new Date())%></span>
251          <span class="headline"><%=HTML.encodeTags(broadcastTitle)%><%=denyLogin ? " (login disabled)" : "" %></span><br>
252          <span class="text"><%=HTML.niceFormat(broadcastMessage)%></span>
253        </div>
254        <% 
255      }
256     
257      ItemQuery<News> query = News.getQuery();
258      query.order(Orders.desc(Hql.property("newsDate")));
259      query.order(Orders.desc(Hql.property("id")));
260      query.setCacheResult(true);
261      query.setReturnTotalCount(true);
262      query.setMaxResults(10);
263      news = query.list(dc);
264      for (News n : news)
265      {
266        %>
267        <div class="item">
268          <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>
269          <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br>
270          <span class="text"><%=HTML.niceFormat(n.getDescription())%></span>
271        </div>
272        <%
273      }
274      if (news.getTotalCount() > 10)
275      {
276        %>
277        <base:icon image="bullet.gif" /><a href="info/news.jsp" 
278          title="Show older news..."><%=news.getTotalCount()-10%> more</a>
279        <%
280      }
281      %>
282      </div>
283    </td>
284    </tr>
285    </table>
286
287    </form>
288  </base:body>
289  </base:page>
290  <%
291}
292finally
293{
294  if (dc != null) dc.close();
295}
296%>
297
Note: See TracBrowser for help on using the repository browser.