main.ssp 6.81 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
2
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
Peter van 't Hof's avatar
Peter van 't Hof committed
3
4
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
Peter van 't Hof's avatar
Peter van 't Hof committed
5
#import(scala.concurrent.Future)
Peter van 't Hof's avatar
Peter van 't Hof committed
6
<%@ var summary: SummaryDb %>
Peter van 't Hof's avatar
Peter van 't Hof committed
7
<%@ var indexPage: Future[ReportPage] %>
8
9
10
11
12
13
<%@ var reportName: String %>
<%@ var page: ReportPage %>
<%@ var path: List[String] %>
<%@ var args: Map[String, Any] %>
<%@ var rootPath: String %>
#{
Peter van 't Hof's avatar
Peter van 't Hof committed
14
15
    val iPage = Await.result(indexPage, Duration.Inf)

16
17
18
19
    def createMenu(page: ReportPage, path: List[String] = Nil, first: Boolean = true): String = {
        val buffer: StringBuffer = new StringBuffer()

        if (page.subPages.nonEmpty){
20
            buffer.append("<ul class=\"dropdown-menu list-group\">")
21
22
        }

Peter van 't Hof's avatar
Peter van 't Hof committed
23
        for (subPageFuture <- page.subPages.sortBy(_._1)) {
24

Peter van 't Hof's avatar
Peter van 't Hof committed
25
26
            val subPageName = subPageFuture._1
            val subPage = Await.result(subPageFuture._2, Duration.Inf)
27
            val href: String = {
Peter van 't Hof's avatar
Peter van 't Hof committed
28
29
                if (path.isEmpty) rootPath + subPageName + "/index.html"
                else rootPath + path.mkString("","/","/") + subPageName + "/index.html"
30
31
            }

32
33
34
35
36
37
38
39
//            buffer.append("<li")
//            if(subPage._2.subPages.nonEmpty) buffer.append(" class=\"dropdown-submenu list-group-item\"")
//            buffer.append("><span class=\"badge\">%d</span><a href=\"%s\"".format(subPage._2.subPages.size, href))
//            if (first) buffer.append(" tabindex=\"-1\"")
//            buffer.append(">%s</a>".format(subPage._1))
//            buffer.append(createMenu(subPage._2, path ::: subPage._1 :: Nil, first = false))
//            buffer.append("</li>")

Peter van 't Hof's avatar
Peter van 't Hof committed
40
            val listSubmenu = if(subPage.subPages.nonEmpty) "dropdown-submenu" else ""
41
42
43
44
45
46
//            val subMenuBadgeCount = if(subPage._2.subPages.nonEmpty && first) "<span class='badge'>%d</span>".format(subPage._2.subPages.size) else ""
            val tabIndex = if (first) " tabindex='-1'" else ""
//            val listGroupA = if(subPage._2.subPages.nonEmpty) "list-group-item" else ""

            var menuItem: String = "<li class='%s'>".format(listSubmenu) +
            "<a href='%s' class='%s'%s>".format(href, "", tabIndex) +
Peter van 't Hof's avatar
Peter van 't Hof committed
47
            "%s".format(subPageName) +
48
            "</a>" +
Peter van 't Hof's avatar
Peter van 't Hof committed
49
            createMenu(subPage, path ::: subPageName :: Nil, first = false) +
50
51
52
            "</li>"
            buffer.append(menuItem)

53
54
55
56
57
58
59
60
        }
        if(page.subPages.nonEmpty) {
            buffer.append("</ul>\n")
        }
        buffer.toString
    }

    def getSubPage(path:List[String]): ReportPage = {
Peter van 't Hof's avatar
Peter van 't Hof committed
61
        path.foldLeft(iPage)((c, p) => {
62
63
            val foundPages = c.subPages.filter(_._1 == p)
            require(foundPages.size == 1, "Name of page not found or duplicate is found, page:: " + p + " in path: " + path)
Peter van 't Hof's avatar
Peter van 't Hof committed
64
            Await.result(foundPages.head._2, Duration.Inf)
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
        })
    }
}#
<!DOCTYPE html>
<html>
    <head>
        <title>${reportName}</title>

        <!-- Bootstrap core JavaScript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <script src="${rootPath}ext/js/jquery.min.js"></script>

        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="${rootPath}ext/css/bootstrap.min.css">

        <!-- Optional theme -->
        <link rel="stylesheet" href="${rootPath}ext/css/bootstrap-theme.min.css">

        <!-- Latest compiled and minified JavaScript -->
        <script src="${rootPath}ext/js/bootstrap.min.js"></script>

        <link rel="stylesheet" type="text/css" href="${rootPath}ext/css/bootstrap_dashboard.css">
        <link rel="stylesheet" type="text/css" href="${rootPath}ext/css/sortable-theme-bootstrap.css">

        <!-- sortable tables //-->
        <script src="${rootPath}ext/js/sortable.min.js"></script>
Peter van 't Hof's avatar
Peter van 't Hof committed
92
        <script src="${rootPath}ext/js/d3.v3.5.5.min.js"></script>
93
94
95
96
97
98
        <script language="JavaScript">
            <!--
            $(document).ready(function() {
                Sortable.init()

                $('body').scrollspy({
99
                    target: '.bs-sidebar'
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
                });
            });

            //-->
        </script>
    </head>
<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>

        <ul class="nav navbar-nav">
            <li class="root #if (path.isEmpty) active #end">
                <a class="navbar-brand" href="${rootPath}index.html">${reportName}
Peter van 't Hof's avatar
Peter van 't Hof committed
121
                    #if (iPage.subPages.nonEmpty) <b class="caret"></b> #end
122
                </a>
Peter van 't Hof's avatar
Peter van 't Hof committed
123
                ${unescape(createMenu(iPage))}
124
125
126
127
128
129
130
131
132
133
134
135
            </li>
        </ul>
    </div>

    <div class="collapse navbar-collapse navbar-ex1-collapse">
        <ul class="nav navbar-nav">
            <!-- ${path.size} //-->
            <!-- ${path} //-->
            #for (t <- 1 to path.size)
                #if(t == 0)
                    <li class="root">
                        <a href="${rootPath}index.html">Home
Peter van 't Hof's avatar
Peter van 't Hof committed
136
                            #if (iPage.subPages.nonEmpty) <b class="caret"></b> #end
137
                        </a>
Peter van 't Hof's avatar
Peter van 't Hof committed
138
                        ${unescape(createMenu(iPage, Nil, false))}
139
140
141
142
143
144
                    </li>
                #else
                    <li class="root #if (t == path.size) active #end">
                        <a href="${rootPath}${path.slice(0,t).mkString("", "/", "/")}index.html">${path( t - 1 )}
                            #if (getSubPage(path.slice(0, t)).subPages.nonEmpty) <b class="caret"></b> #end
                        </a>
145
                        ${unescape(createMenu(getSubPage(path.slice(0, t)), path.slice(0, t), false))}
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
                    </li>
                #end
            #end

        </ul>
    </div>
    <!--/.nav-collapse -->
</div>
</nav>

<div class="container-fluid">
<div class="row">
    <div id="side-nav" class="col-sm-3 col-md-2 sidebar">
        <ul class="nav nav-sidebar nav-list bs-sidebar">
            #for ((name, url) <- page.sections)
                <li><a href="#${name}">${name}</a></li>
            #end
        </ul>
    </div>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main content">
        #for ((name, section) <- page.sections)
            <div id="${name}" class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title" id="panel-title">
                        ${name}
                    </h3>
                </div>
Peter van 't Hof's avatar
Peter van 't Hof committed
173
            ${unescape(section.render(args ++ Map("args" -> args)))}
174
175
176
177
178
179
180
181
            </div>
        #end
    </div>
</div>
</div>

</body>
</html>