main.ssp 6.74 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
<%@ var summary: SummaryDb %>
6
7
8
9
10
11
12
13
14
15
16
<%@ var indexPage: ReportPage %>
<%@ var reportName: String %>
<%@ var page: ReportPage %>
<%@ var path: List[String] %>
<%@ var args: Map[String, Any] %>
<%@ var rootPath: String %>
#{
    def createMenu(page: ReportPage, path: List[String] = Nil, first: Boolean = true): String = {
        val buffer: StringBuffer = new StringBuffer()

        if (page.subPages.nonEmpty){
17
            buffer.append("<ul class=\"dropdown-menu list-group\">")
18
19
        }

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

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

29
30
31
32
33
34
35
36
//            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
37
            val listSubmenu = if(subPage.subPages.nonEmpty) "dropdown-submenu" else ""
38
39
40
41
42
43
//            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
44
            "%s".format(subPageName) +
45
            "</a>" +
Peter van 't Hof's avatar
Peter van 't Hof committed
46
            createMenu(subPage, path ::: subPageName :: Nil, first = false) +
47
48
49
            "</li>"
            buffer.append(menuItem)

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

    def getSubPage(path:List[String]): ReportPage = {
        path.foldLeft(indexPage)((c, p) => {
            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
61
            Await.result(foundPages.head._2, Duration.Inf)
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
        })
    }
}#
<!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
89
        <script src="${rootPath}ext/js/d3.v3.5.5.min.js"></script>
90
91
92
93
94
95
        <script language="JavaScript">
            <!--
            $(document).ready(function() {
                Sortable.init()

                $('body').scrollspy({
96
                    target: '.bs-sidebar'
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
                });
            });

            //-->
        </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}
                    #if (indexPage.subPages.nonEmpty) <b class="caret"></b> #end
                </a>
                ${unescape(createMenu(indexPage))}
            </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
                            #if (indexPage.subPages.nonEmpty) <b class="caret"></b> #end
                        </a>
135
                        ${unescape(createMenu(indexPage, Nil, false))}
136
137
138
139
140
141
                    </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>
142
                        ${unescape(createMenu(getSubPage(path.slice(0, t)), path.slice(0, t), false))}
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
                    </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
170
            ${unescape(section.render(args ++ Map("args" -> args)))}
171
172
173
174
175
176
177
178
            </div>
        #end
    </div>
</div>
</div>

</body>
</html>