github.com/vlifesystems/rulehunter@v0.0.0-20180501090014-673078aa4a83/html/front_tpl.go (about)

     1  // Copyright (C) 2016-2017 vLife Systems Ltd <http://vlifesystems.com>
     2  // Licensed under an MIT licence.  Please see LICENSE.md for details.
     3  
     4  package html
     5  
     6  const frontTpl = `
     7  <!DOCTYPE html>
     8  <html>
     9  	<head>
    10  		{{ index .Html "head" }}
    11  		<title>Rulehunter</title>
    12  	</head>
    13  
    14  	<body>
    15  		{{ index .Html "nav" }}
    16  
    17  		<div id="content">
    18  			<div class="container">
    19  
    20  				<div class="row">
    21  				  <div class="col-md-12">
    22  						<div class="page-header">
    23  							<h1>Rulehunter<br />
    24  								<small>Find simple rules in your data to meet your goals</small>
    25  							</h1>
    26  						</div>
    27  					</div>
    28  				</div>
    29  
    30  				<div class="row">
    31  					<div class="col-md-6">
    32  						<h2>Categories</h2>
    33  						{{if .Categories}}
    34  							<ul id="front-categories">
    35  								{{range $category, $catLink := .Categories}}
    36  									<li><a href="{{ $catLink }}">{{ $category }}</a></li>
    37  								{{end}}
    38  							</ul>
    39  						{{else}}
    40  							<p>No categories are currently being used.</p>
    41  						{{end}}
    42  
    43  						<p><a href="reports/nocategory/">See uncategorized reports</a></p>
    44  						<br />
    45  
    46  						<h2>Tags</h2>
    47  						{{if .Tags}}
    48  							<ul id="front-tags">
    49  								{{range $tag, $tagLink := .Tags}}
    50  									<li><a href="{{ $tagLink }}">{{ $tag }}</a></li>
    51  								{{end}}
    52  							</ul>
    53  						{{else}}
    54  							<p>No tags are currently being used.</p>
    55  						{{end}}
    56  					</div>
    57  
    58  					<div class="col-md-6">
    59  						<h2>Latest Reports</h2>
    60  						{{if .Reports}}
    61  							<ul id="front-reports">
    62  								{{range .Reports}}
    63  									<li>
    64  										<a href="{{ .Filename }}">{{ .Title }}</a> &nbsp;
    65  										<span class="details">
    66  											{{if .Category}}
    67  												(<a href="{{ .CategoryURL }}">{{ .Category }}</a>)
    68  											{{end}}
    69  										</span>
    70  									</li>
    71  								{{end}}
    72  							</ul>
    73  
    74  							<p><a href="reports/">See more reports</a></p>
    75  						{{else}}
    76  							<p>There aren't currently any reports.</p>
    77  						{{end}}
    78  					</div>
    79  				</div>
    80  
    81  				<div class="row">
    82  					<div class="col-md-12">
    83  						<h2>Activity</h2>
    84  						<div id="front-activity-container">
    85  							{{if .Experiments}}
    86  								{{range .Experiments}}
    87  									{{if .Title}}
    88  										<strong>{{ .Title }}</strong>
    89  									{{end}}
    90  									{{if .Category}}
    91  										&nbsp ({{ .Category }})
    92  									{{end}}
    93  									<br />
    94  									<span class="status-{{ .Status }}">{{ .Status | ToTitle }}</span> &nbsp;
    95  									{{if gt .Percent 0.0}}
    96  										{{ .Msg }}<br />
    97  										<progress max="100" value="{{ .Percent }}">
    98  											Progress: {{ .Percent }}%
    99  										</progress>
   100  									{{else}}
   101  										{{ .Msg }}
   102  									{{end}}
   103  								{{end}}
   104  							{{else}}
   105  							<p>Not currently processing any experiments.</p>
   106  							{{end}}
   107  						</div>
   108  					</div>
   109  				</div>
   110  
   111  			</div>
   112  		</div>
   113  
   114  		<div id="footer" class="container">
   115  			{{ index .Html "footer" }}
   116  		</div>
   117  
   118  		{{ index .Html "bootstrapJS" }}
   119  
   120  		<script>
   121  			(function refreshWorker(){
   122  					// Don't cache ajax or content won't fresh
   123  					$.ajaxSetup ({
   124  							cache: false,
   125  							complete: function() {
   126  								// Schedule next request when current one is complete
   127  								setTimeout(refreshWorker, 10000);
   128  							}
   129  					});
   130  					var ajaxLoad = "<img src='img/ring.gif' style='width:48px; height:48px' alt='loading...' />";
   131  					var loadUrl = " #front-activity-container";
   132  					$("#front-activity-container").html(ajaxLoad).load(loadUrl);
   133  			})();
   134  		</script>
   135  	</body>
   136  </html>`