Return-Path: Delivered-To: apmail-incubator-esme-commits-archive@minotaur.apache.org Received: (qmail 83035 invoked from network); 26 Jul 2009 22:07:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Jul 2009 22:07:52 -0000 Received: (qmail 96153 invoked by uid 500); 26 Jul 2009 22:08:57 -0000 Delivered-To: apmail-incubator-esme-commits-archive@incubator.apache.org Received: (qmail 96123 invoked by uid 500); 26 Jul 2009 22:08:57 -0000 Mailing-List: contact esme-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: esme-dev@incubator.apache.org Delivered-To: mailing list esme-commits@incubator.apache.org Received: (qmail 96113 invoked by uid 99); 26 Jul 2009 22:08:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Jul 2009 22:08:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Jul 2009 22:08:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 51CE5238889B; Sun, 26 Jul 2009 22:08:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r797993 - in /incubator/esme/trunk/server/src/main: scala/bootstrap/liftweb/Boot.scala scala/org/apache/esme/lib/StreamMgr.scala webapp/info_view/streams.html webapp/templates-hidden/default.html webapp/templates-hidden/message.html Date: Sun, 26 Jul 2009 22:08:29 -0000 To: esme-commits@incubator.apache.org From: vdichev@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090726220830.51CE5238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ + + + Manage your streams:
+ + + + + + + + + + + + + + + +
Author Text Date
+
+
+ + + Filter by resent Resent by:
+ Filter by pool In pool: +
+ +
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 @@
  • +
  • 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 @@
  • +