Author: vdichev
Date: Sun Jul 26 22:08:27 2009
New Revision: 797993
URL: http://svn.apache.org/viewvc?rev=797993&view=rev
Log:
ESME-80 Stream filters for resent messages and for messages in pools
Added:
incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala
(with props)
incubator/esme/trunk/server/src/main/webapp/info_view/streams.html (with
props)
Modified:
incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
incubator/esme/trunk/server/src/main/webapp/templates-hidden/default.html
incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html
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=797993&r1=797992&r2=797993&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 Sun
Jul 26 22:08:27 2009
@@ -116,7 +116,8 @@
TrackMgr.menuItems :::
ActionMgr.menuItems :::
AuthMgr.menuItems :::
- AccessPoolMgr.menuItems
+ AccessPoolMgr.menuItems :::
+ StreamMgr.menuItems
LiftRules.setSiteMap(SiteMap(entries:_*))
Added:
incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala
URL:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala?rev=797993&view=auto
==============================================================================
---
incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala
(added)
+++
incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala
Sun Jul 26 22:08:27 2009
@@ -0,0 +1,170 @@
+/**
+ * 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 Streams
+ */
+object StreamMgr {
+ val AnyResender = User.id.defaultValue
+ val PublicPool = AccessPool.id.defaultValue
+
+ def loggedIn_? = User.loggedIn_?
+
+ val ifIsLoggedIn = If(loggedIn_? _, strFuncToFailMsg(() => S.?("You must be
logged in")))
+
+ val menuItems =
+ Menu(Loc("streams", List("info_view", "streams"), "Streams", ifIsLoggedIn,
+ Loc.Snippet("displayStream", displayStream),
+ Loc.Snippet("streamFilters", streamFilters))) ::
+ Nil
+
+ object updateStream extends RequestVar[() => JsCmd](() => Noop)
+ object resenderId extends RequestVar[Long](AnyResender)
+ object filterResent_? extends RequestVar[Boolean](false)
+ object poolId extends RequestVar[Long](PublicPool)
+ object filterPools_? extends RequestVar[Boolean](false)
+
+ def displayStream(in: NodeSeq): NodeSeq = {
+ // get the span name to update
+ val spanName = S.attr("the_id") openOr "StreamSpan"
+ // get the current user
+ val user = User.currentUser
+
+ // bind the dynamic content to the incoming nodeseq
+ def doRender(): NodeSeq = {
+ val resentQuery =
+ if (filterResent_?.is == false) Nil
+ else {
+ val queryParam = resenderId.is match {
+ case AnyResender => NotBy(Mailbox.resentBy, Empty)
+ case id => By(Mailbox.resentBy, id)
+ }
+ List(In(Message.id,Mailbox.message,By(Mailbox.user, user), queryParam))
+ }
+
+ val poolsQuery =
+ if (filterPools_?.is == false) Nil
+ else List(poolId.is match {
+ case PublicPool => By(Message.pool, Empty)
+ case id => By(Message.pool, id)
+ })
+
+ val query = poolsQuery :::
+ resentQuery :::
+ List[QueryParam[Message]](OrderBy(Message.id, Ascending),
MaxRows(40))
+
+ Message.findAll(query: _*) match {
+ case Nil => NodeSeq.Empty
+ case xs => bind("disp", in,
+ "item" ->
+ (lst => xs.flatMap(i => bind("item", lst,
+ "author" ->
i.author.obj.map(_.nickname.is).openOr(""),
+ "text" -> i.getText,
+ "date" -> new
java.util.Date(i.when.toLong).toString
+ ))))
+ }
+ }
+
+ def updateSpan(): JsCmd = SetHtml(spanName, doRender())
+
+ updateStream.set(updateSpan)
+ doRender()
+ }
+
+ def streamFilters(in: NodeSeq): NodeSeq = {
+ val redisplayStream = updateStream.is
+ val resenderInput = "resender_input"
+ val poolInput = "pool_input"
+ val filterResentInput = "filter_resent_input"
+ val filterPoolsInput = "filter_pools_input"
+ val user = User.currentUser
+
+ var resender = AnyResender
+ var pool = PublicPool
+ var filterResent = false
+ var filterPools = false
+
+ val following = (AnyResender.toString, "--any--") ::
+ (user match {
+ case Full(u) => u.following.map(u => (u.id.is.toString, u.nickname.is) )
+ case _ => Nil
+ })
+
+ val pools = (PublicPool.toString, "--default--") ::
+ (user match {
+ case Full(u)=> Privilege.findViewablePools(u.id).map(
+ p => (p.toString, AccessPool.find(p).get.getName)).toList
+ case _ => Nil
+ })
+
+ def redisplay(): JsCmd = {
+ resenderId.set(resender)
+ poolId.set(pool)
+ filterResent_?.set(filterResent)
+ filterPools_?.set(filterPools)
+ redisplayStream()
+ }
+
+ bind("main", in,
+ "resent" -> ajaxSelect(following,
+ Empty,
+ u => {resender = u.toLong
+ redisplay()},
+ "id" -> resenderInput),
+ "pools" -> ajaxSelect(pools,
+ Empty,
+ p => {pool = p.toLong
+ redisplay()},
+ "id" -> poolInput),
+ "filterResent" -> ajaxCheckbox(false,
+ r_? => {filterResent = r_?
+ redisplay()},
+ "id" -> filterResentInput),
+ "filterPools" -> ajaxCheckbox(false,
+ p_? => {filterPools = p_?
+ redisplay()},
+ "id" -> filterPoolsInput)
+ )
+
+ }
+
+}
Propchange:
incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/StreamMgr.scala
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/esme/trunk/server/src/main/webapp/info_view/streams.html
URL:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/info_view/streams.html?rev=797993&view=auto
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/info_view/streams.html (added)
+++ incubator/esme/trunk/server/src/main/webapp/info_view/streams.html Sun Jul
26 22:08:27 2009
@@ -0,0 +1,31 @@
+<lift:surround with="default" at="content">
+
+ Manage your streams: <br/>
+ <span id="StreamSpan">
+ <lift:ignore>
+ <!--
+ The displayStreams snippet *MUST* appear on the page before
+ the main snippet
+ -->
+ </lift:ignore>
+ <lift:displayStream the_id="StreamSpan">
+ <table>
+ <thead>
+ <tr> <th>Author</th> <th>Text</th> <th>Date</th></tr>
+ </thead>
+
+ <tbody>
+ <disp:item>
+ <tr><td><item:author/></td> <td><item:text/></td>
<td><item:date/></td></tr>
+ </disp:item>
+ </tbody>
+ </table>
+ </lift:displayStream>
+ </span>
+
+ <lift:streamFilters>
+ Filter by resent <main:filterResent/> Resent by: <main:resent/><br/>
+ Filter by pool <main:filterPools/> In pool: <main:pools/>
+ </lift:streamFilters>
+
+</lift:surround>
Propchange: incubator/esme/trunk/server/src/main/webapp/info_view/streams.html
------------------------------------------------------------------------------
svn:executable = *
Modified:
incubator/esme/trunk/server/src/main/webapp/templates-hidden/default.html
URL:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/templates-hidden/default.html?rev=797993&r1=797992&r2=797993&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/templates-hidden/default.html
(original)
+++ incubator/esme/trunk/server/src/main/webapp/templates-hidden/default.html
Sun Jul 26 22:08:27 2009
@@ -25,6 +25,7 @@
<li><lift:Menu.item name="actionMgt"/></li>
<li><lift:Menu.item name="authToken"/></li>
<li><lift:Menu.item name="accessPools"/></li>
+ <li><lift:Menu.item name="streams"/></li>
<li><lift:Menu.item name="Logout"/></li>
</ul>
</div>
Modified:
incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html
URL:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html?rev=797993&r1=797992&r2=797993&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html
(original)
+++ incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html
Sun Jul 26 22:08:27 2009
@@ -119,6 +119,7 @@
<li><lift:Menu.item name="actionMgt"/></li>
<li><lift:Menu.item name="authToken"/></li>
<li><lift:Menu.item name="accessPools"/></li>
+ <li><lift:Menu.item name="streams"/></li>
<li><lift:Menu.item name="Logout"/></li>
</ul>
</div>