swirl/views/service/stats.jet
2018-03-23 17:44:54 +08:00

117 lines
4.7 KiB
Go

{{ extends "_base" }}
{{ import "../_modules/detail" }}
{{ import "../_modules/form" }}
{{ block script() }}
<script src="/assets/chart/chart.bundle.min.js?v=2.7.2"></script>
<script>$(() => new Swirl.Service.StatsPage())</script>
{{ end }}
{{ block body_content() }}
<div class="container">
<nav class="breadcrumb has-succeeds-separator is-small is-marginless" aria-label="breadcrumbs">
<ul>
<li><a href="/">{{ i18n("menu.home") }}</a></li>
<li><a href="/service/">{{ i18n("menu.service") }}</a></li>
<li class="is-active"><a>{{ i18n("menu.stats") }}</a></li>
</ul>
</nav>
</div>
<section class="hero is-small is-light">
<div class="hero-body">
<div class="container">
<h2 id="h2-service-name" class="title is-2">{{ .Service.Spec.Name }}</h2>
</div>
</div>
</section>
<nav class="navbar has-shadow">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item is-tab" href="/service/{{.Service.Spec.Name}}/detail">{{ i18n("menu.detail") }}</a>
<a class="navbar-item is-tab" href="/service/{{.Service.Spec.Name}}/raw">{{ i18n("menu.raw") }}</a>
<a class="navbar-item is-tab" href="/service/{{.Service.Spec.Name}}/logs">{{ i18n("menu.log") }}</a>
<a class="navbar-item is-tab" href="/service/{{.Service.Spec.Name}}/edit">{{ i18n("menu.edit") }}</a>
<a class="navbar-item is-tab" href="/service/{{.Service.Spec.Name}}/perm">{{ i18n("menu.perm") }}</a>
<a class="navbar-item is-tab is-active" href="/service/{{.Service.Spec.Name}}/stats">{{ i18n("menu.stats") }}</a>
</div>
</div>
</nav>
<section class="section">
<div class="container">
{{ if .Charts }}
<nav class="level">
<form>
<div class="level-left">
<div class="level-item">
<div class="field has-addons">
<p class="control">
<a class="button is-static">Time</a>
</p>
<p class="control">
<div class="select">
<select id="cb-time" name="time">
{{ yield option(value="30m", label="Last 30 minutes", selected=.Time) }}
{{ yield option(value="1h", label="Last 1 hour", selected=.Time) }}
{{ yield option(value="3h", label="Last 3 hours", selected=.Time) }}
{{ yield option(value="6h", label="Last 6 hours", selected=.Time) }}
{{ yield option(value="12h", label="Last 12 hours", selected=.Time) }}
{{ yield option(value="24h", label="Last 24 hours", selected=.Time) }}
</select>
</div>
</p>
</div>
</div>
<div class="level-item">
<div class="field">
<input id="cb-refresh" name="refresh" value="true" type="checkbox" class="switch is-success is-rounded"{{if .Refresh}} checked{{end}}>
<label for="cb-refresh">Auto refresh</label>
</div>
</div>
</div>
</form>
<div class="level-right">
<div class="level-item">
<button id="btn-add" class="button is-success"><span class="icon"><i class="fas fa-plus"></i></span><span>{{ i18n("button.add") }}</span></button>
</div>
</div>
</nav>
<div id="div-charts" class="columns is-multiline">
{{ range .Charts }}
<div class="column is-{{ .Width }}" data-chart-name="{{ .Name }}" data-chart-type="{{ .Type }}" data-chart-unit="{{ .Unit }}" data-chart-height="{{ .Height }}">
<div class="card">
<header class="card-header">
<p class="card-header-title">{{ .Title }}</p>
<a data-action="remove-chart" class="card-header-icon is-paddingless" aria-label="remove chart">
<span class="icon">
<i class="fas fa-times has-text-danger" aria-hidden="true"></i>
</span>
</a>
<a data-action="edit-options" class="card-header-icon" aria-label="edit options">
<span class="icon">
<i class="fas fa-ellipsis-h has-text-info" aria-hidden="true"></i>
</span>
</a>
</header>
<div class="card-content">
<canvas id="canvas_{{ .Name }}"></canvas>
</div>
</div>
</div>
{{ end }}
</div>
{{ else }}
<div class="notification is-info">
NOTICE: To enable this feature, you must set <b>Metrics</b> option on <a href="/system/setting/">Setting</a> page first.
</div>
{{ end }}
<a href="/service/" class="button is-primary">
<span class="icon"><i class="fas fa-reply"></i></span>
<span>{{ i18n("button.return") }}</span>
</a>
</div>
</section>
{{ end }}