I'm working on this application where I need to fill in a grid/table
with test results.
The final table would have about 40-50 rows and about 10 columns.
The way I get the test results from the database is something like this:
val testResultNoSSL= Map(
"Sol 10 Sparc 32Bit" -> ("Solaris", "PASS"),
"Sol 10 Sparc 64" -> ("Solaris", "PASS"),
"Sol 10 x86 64" -> ("Solaris", "FAIL")
)
val testResultSSL= Map(
"Sol 10 Sparc 32Bit" -> ("Solaris", "PASS"),
"Sol 10 Sparc 64" -> ("Solaris", "FAIL"),
"Sol 10 x86 64" -> ("Solaris", "FAIL")
)
in the final app, those maps would have about 40-50 different entries,
and they may not all have the same "keys", because we do not get the
results for all tests at the same time. In the UI, the "missing
entries" should show as N/A or something like that.
testResultNoSSL has the results for "the first column, testResultSSL
for the second column and I have 8 more vals with similar results.
What I can't get in a clean way is a way to add this information to a
page, so I was hoping someone on the list would be able to help me.
As this may be a bit confusing, I posted a small lift app on github
https://github.com/fmpwizard/lift-grid
so that you guys can try different things.
Once you get the branch, you can run it under sbt
sbt
> update
> ~jetty-run
and you can go to
http://127.0.0.1:8080/agent-details?v=2.4.0.1090
to see the page I'm talking about.
Thanks
Diego
--
Diego Medina
Web Developer
http://www.fmpwizard.com
case class Result(OS: String, pass: Boolean) {def clss = if (pass) "success" else "error"}
case class TestRow(tests: Map[Int, Option[Result]])
// a list of all our testsval tests = List(testResultNoSSL, testResultSSL, testResultNoSSLQuan, testResultSSLQuan, testResult200Scalability)
// a set of the keys of the testsval osSet = Set(tests.flatMap(_.keys) :_*)
val results: Map[String, TestRow] = Map(osSet.toSeq.map{set =>(set, TestRow(Map(tests.zipWithIndex.map {case (test, idx) => idx -> test.get(set).map{ case (os, pass) => Result(os, pass == "PASS")}} :_*)))}:_*)
ClearClearable andThen"h2 *" #> *(_ ++ Text(showingVersion)) &"#row *" #> results.map {case (name, row) => "#col" #> (("* *" #> name) :: row.tests.toList.map {case (pos, Some(res)) => "* *" #> res.OS & "* [class]" #> res.clsscase (pos, _) => "* *" #> "N/A"})}
#col" #> (("* *" #> name) :: row.tests.toList.map {case (pos, Some(res)) => "* *" #> res.OS & "* [class]" #> res.clsscase (pos, _) => "* *" #> "N/A"})
<lift:AgentDetails.renderAgentResult><h2>Agent results for version: </h2><table><tr><th>Platform</th><th>NO SSL</th><th>SSL</th><th>Agent, Proxy <br />(No SSL, QUAN)</th><th>Agent, Proxy <br />(SSL, QUAN)</th><th>200 Agent scalability</th></tr>
<tr id="row"><td id="col">Sol 10 Sparc 32Bit</td><td class="clearable"> No SSL </td><td class="clearable"> ssl </td><td class="clearable"> agent_proxy_no_ssl_quan </td><td class="clearable"> agent_proxy_ssl_quan </td><td class="clearable"> 200_agent_scalability </td></tr>
<tr class="clearable"><td id="col">Sol 10 Sparc 32Bit</td><td > No SSL </td><td class="clearbale"> ssl </td><td class="clearable"> agent_proxy_no_ssl_quan </td><td class="clearable"> agent_proxy_ssl_quan </td><td class="clearable"> 200_agent_scalability </td></tr>
<tr class="clearable"><td id="col">Sol 10 Sparc 32Bit</td><td > No SSL </td><td class="clearbale"> ssl </td><td class="clearable"> agent_proxy_no_ssl_quan </td><td class="clearable"> agent_proxy_ssl_quan </td><td class="clearable"> 200_agent_scalability </td></tr></table></lift:AgentDetails.renderAgentResult>
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Just one question:
On Thu, Dec 23, 2010 at 12:25 PM, David Pollak
<feeder.of...@gmail.com> wrote:
[snip]
> Next, take the tests and normalize them:
>
> val results: Map[String, TestRow] = Map(osSet.toSeq.map{
> set =>
> (set, TestRow(Map(tests.zipWithIndex.map {
> case (test, idx) => idx -> test.get(set).map{ case (os, pass) =>
> Result(os, pass == "PASS")}
> } :_*)))
> }:_*)
>
what does the :_*) do/mean?
Again, thanks, I did not think of using case classes, but even if I
did, the way you used it and the css selectors is something I need to
read more about.
Diego
It did everything I asked for :)
Thanks David, it works great!
Just one question:
On Thu, Dec 23, 2010 at 12:25 PM, David Pollak
<feeder.of...@gmail.com> wrote:
[snip]
> Next, take the tests and normalize them:what does the :_*) do/mean?
>
> val results: Map[String, TestRow] = Map(osSet.toSeq.map{
> set =>
> (set, TestRow(Map(tests.zipWithIndex.map {
> case (test, idx) => idx -> test.get(set).map{ case (os, pass) =>
> Result(os, pass == "PASS")}
> } :_*)))
> }:_*)
>