incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhir...@apache.org
Subject svn commit: r820937 - in /incubator/esme/trunk/server/src/main: scala/bootstrap/liftweb/Boot.scala scala/org/apache/esme/lib/UserMgr.scala scala/org/apache/esme/view/UserView.scala webapp/info_view/users.html
Date Fri, 02 Oct 2009 08:55:17 GMT
Author: rhirsch
Date: Fri Oct  2 08:55:17 2009
New Revision: 820937

URL: http://svn.apache.org/viewvc?rev=820937&view=rev
Log:
[ESME-86] The current user list page is very primitive 
Patches from Dave Briccetti applied 

Added:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/UserMgr.scala
    incubator/esme/trunk/server/src/main/webapp/info_view/users.html
Modified:
    incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/view/UserView.scala

Modified: incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala?rev=820937&r1=820936&r2=820937&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala Fri Oct  2 08:55:17
2009
@@ -113,7 +113,6 @@
 
     // Build SiteMap
     val entries = Menu(Loc("Home", List("index"), "Home")) ::
-    Menu(Loc("list_users", List("user_view", "all"), "List Users")) ::
     Menu(Loc("user", List("info_view", "user"), "User Info", Hidden,
       Loc.Snippet("user_info", TagDisplay.userInfo))) ::
     Menu(Loc("conv", List("user_view", "conversation"), "Conversation", Hidden)) ::
@@ -127,6 +126,7 @@
              EarlyResponse(() => {User.logUserOut; S.redirectTo(S.referer openOr "/")}),
              If(User.loggedIn_? _, "You must be logged in to log out"))) ::
     // User.sitemap :::
+    UserMgr.menuItems :::
     TrackMgr.menuItems :::
     ActionMgr.menuItems :::
     AuthMgr.menuItems :::

Added: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/UserMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/UserMgr.scala?rev=820937&view=auto
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/UserMgr.scala (added)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/UserMgr.scala Fri Oct 
2 08:55:17 2009
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2008-2009 WorldWide Conferencing, LLC
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.esme.lib
+
+import net.liftweb._
+import http._
+import SHtml._
+import js._
+import JsCmds._
+import JE._
+
+import sitemap._
+import Loc._
+
+import mapper._
+
+import util._
+import Helpers._
+
+import model._
+
+import scala.xml._
+
+/**
+ * Manage the sitemap and related snippets for the display of users
+ */
+object UserMgr {
+  def loggedIn_? = User.loggedIn_?
+
+  val ifIsLoggedIn = If(loggedIn_? _, strFuncToFailMsg(() => S.?("You must be logged in")))
+
+  val menuItems =
+  Menu(Loc("list_users", List("info_view", "users"), "List Users", ifIsLoggedIn,
+           Loc.Snippet("displayUsers", displayUsers))) ::
+  Nil
+
+  def displayUsers(in: NodeSeq): NodeSeq = {
+    val users = User.findAll(OrderBy(User.nickname, Ascending))
+    bind("disp", in,
+         "item" -> 
+         (lst => users.flatMap(u => {
+           val msg = lastMessage(u.id) 
+           bind("item", lst,
+             "nickname" -> u.nickname,
+             "firstName" -> u.firstName,
+             "lastName" -> u.lastName,
+             "imageUrl" -> profileImage(u.imageUrl),
+             "lastMsg" -> msg._1,
+             "lastMsgWhen" -> msg._2
+             )
+         }
+     )))
+  }
+  
+  private def lastMessage(id: Long): Tuple2[String,String] = {
+    Mailbox.mostRecentMessagesFor(id, 1) match {
+      case Nil => ("", "")
+      case msgs => {
+        val msg = msgs(0)._1
+        (msg.getText, msg.getWhen.toString)
+      }
+    }
+  }
+
+  private def profileImage(imageUrl: String): NodeSeq = {
+    if (imageUrl.length > 0) 
+      <img src={imageUrl}/>
+    else
+      <p/>
+  }
+
+}

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/view/UserView.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/view/UserView.scala?rev=820937&r1=820936&r2=820937&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/view/UserView.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/view/UserView.scala Fri Oct
 2 08:55:17 2009
@@ -57,9 +57,7 @@
 
   val dispatch = 
   Map("index" -> index _,
-      // "tag" -> displayTag _,
       "search" -> search _,
-      "all" -> allUsers _,
       "conversation" -> conversation _)
 
   def conversation(): Box[NodeSeq] =   {
@@ -211,47 +209,4 @@
     </div>
   </lift:surround>
 
-  /*
-  def displayTag(): Box[NodeSeq] =
-  (<lift:surround with="default" at="content">
-      {
-        val ui = for (tagText <- S.param("tag").map(_.trim);
-                      tag <- Tag.find(By(Tag.name, tagText))) yield {
-          val lst = tag.findMessages()
-          
-          (<div>
-              <fieldset>
-                <legend>{tag.name}</legend>
-                <ul>
-                  {
-                    lst.zipWithIndex.map{
-                      case (m, idx) =>
-                        <span id={"m5_"+idx}>
-                          {
-                            Script(OnLoad(JsFunc("displayMessages", JsArray(m.asJs), "m5_"+idx).cmd))
-                          }
-                        </span>
-                    }
-                  }
-                </ul>
-              </fieldset>
-           </div>)
-        }
-        ui openOr (<span>Tag Not Found</span>)
-      }
-   </lift:surround>)
-  */
-  def allUsers(): Box[NodeSeq] = 
-  <lift:surround with="default" at="content">
-    <fieldset>
-      <legend>Users</legend>
-      <ul>
-        {
-          User.findAll(OrderBy(User.nickname, Ascending)).
-          map(u => <li><a href={"/user/"+urlEncode(u.nickname.is)}>{u.niceName}</a>
{u.firstName} {u.lastName}</li>)
-        }
-      </ul>
-    </fieldset>
-  </lift:surround>
-
 }

Added: incubator/esme/trunk/server/src/main/webapp/info_view/users.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/info_view/users.html?rev=820937&view=auto
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/info_view/users.html (added)
+++ incubator/esme/trunk/server/src/main/webapp/info_view/users.html Fri Oct  2 08:55:17 2009
@@ -0,0 +1,21 @@
+<lift:surround with="default" at="content">
+
+    <fieldset style="width: 80em">
+      <legend>Users</legend>
+      <table>
+      <tr><th></th><th>Nickname</th><th>Name</th><th
colspan="2">Last Message</th></tr>
+          <lift:displayUsers>
+              <disp:item>
+                  <tr>
+                      <td><item:imageUrl/></td>
+                      <td><item:nickname/></td>
+                      <td><item:firstName/> <item:lastName/></td>

+                      <td><item:lastMsg/></td> 
+                      <td><item:lastMsgWhen/></td> 
+                  </tr>
+              </disp:item>
+          </lift:displayUsers>
+      </table>
+    </fieldset>
+
+</lift:surround>



Mime
View raw message