Index.cshtml 7.07 KB
Newer Older
Dmytro Bogatov's avatar
Dmytro Bogatov committed
1
@using StatusMonitor.Shared.Models.Entities
Dmytro Bogatov's avatar
Fix.  
Dmytro Bogatov committed
2 3 4
@using Microsoft.Extensions.Configuration

@inject IConfiguration Config
Dmytro Bogatov's avatar
Dmytro Bogatov committed
5 6 7 8 9 10 11 12 13 14 15 16

@{ 
    ViewData["Title"] = "Admin panel"; 
} 

<div class="container">

	<div class="block-header">
		<h2>Admin panel</h2>
	</div>

	<div class="row">
Dmytro Bogatov's avatar
Dmytro Bogatov committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

		<div class="col-md-6">

			<div class="row">

				<div class="col-md-6">
					<div class="card">
						<div class="card-header">
							<h2>
								Manual cleaunup
								<small>
									Run clean service manually with a specified max age
								</small>
							</h2>
						</div>
						<div class="card-body card-padding">
							<div class="row">
								<form 
									role="form" 
									asp-controller="Admin" 
									asp-action="Clean" 
									method="post"
									novalidate
								>
									<div class="col-md-8 col-sm-12">

										<h5>Set max age</h5>

										<select class="selectpicker" name="maxAge">
											<option value="0">Everything</option>
											<option value="1">1 minutes</option>
											<option value="10">10 minutes</option>
											<option value="20">30 minutes</option>
											<option value="60">1 hour</option>
											<option value="240">4 hours</option>
											<option value="720">12 hours</option>
											<option value="1440">1 day</option>
											<option value="4320">3 days</option>
											<option value="10080">1 week</option>
											<option value="43200">1 month</option>
										</select>
									</div>
									<div class="col-md-4 col-sm-12">
										<button type="submit" class="btn btn-danger btn-md waves-effect">Clean</button>
									</div>
								</form>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
63
							</div>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
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 89 90 91 92 93 94 95 96 97 98 99 100 101
						</div>
					</div>
				</div>

				<div class="col-md-6">
					<div class="card">
						<div class="card-header">
							<h2>
								Go to metric
								<small>
									Go to the metric's page
								</small>
							</h2>
						</div>
						<div class="card-body card-padding">
							<div class="row">
								<form 
									role="form" 
									asp-controller="Admin" 
									asp-action="Metric" 
									method="get"
									novalidate
								>
									<div class="col-md-8 col-sm-12">

										<h5>Metric</h5>

										<select class="selectpicker" name="metric" data-live-search="true">
											@foreach (var metric in ViewBag.Metrics)
											{
												<option value="@((Metrics)metric.Type)@@@(metric.Source)">@(metric.Title) from @(metric.Source)</option>
											}
										</select>
									</div>
									<div class="col-md-4 col-sm-12">
										<button type="submit" class="btn btn-primary btn-md waves-effect">Go</button>
									</div>
								</form>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
102
							</div>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
103
						</div>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
104 105
					</div>
				</div>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
106

Dmytro Bogatov's avatar
Dmytro Bogatov committed
107 108
			</div>

Dmytro Bogatov's avatar
Dmytro Bogatov committed
109 110 111 112 113 114 115 116
			<div class="row">

				<div class="col-md-12">

					<div class="card">
                        <div class="card-header">
                            <h2>Discrepancies
                                <small>
Dmytro Bogatov's avatar
Fix.  
Dmytro Bogatov committed
117 118 119 120
									@{
										var discrepancyDataStartDate = DateTime.UtcNow - new TimeSpan(0, 0, Convert.ToInt32(Config["ServiceManager:CleanService:MaxAge"]));
									}
									View the list of resolved and unresolved dicrepancies from <utc-time time="@discrepancyDataStartDate" show-date=true /> until now.
Dmytro Bogatov's avatar
Dmytro Bogatov committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
                                </small>
                            </h2>
                        </div>

                        <div class="card-body card-padding">
                            <div role="tabpanel">
                                <ul class="tab-nav" role="tablist">
                                    <li class="active">
										<a 
											href="#unresolved" 
											aria-controls="unresolved" 
											role="tab" 
											data-toggle="tab" 
											aria-expanded="true"
										>
											Unresolved ( @(((IEnumerable<Discrepancy>)ViewBag.Discrepancies).Count(d => !d.Resolved)) )
										</a>
									</li>
                                    <li class="">
										<a 
											href="#resovled" 
											aria-controls="resovled" 
											role="tab" 
											data-toggle="tab" 
											aria-expanded="false"
										>
											Resolved ( @(((IEnumerable<Discrepancy>)ViewBag.Discrepancies).Count(d => d.Resolved)) )
										</a>
                                    </li>
                                </ul>

                                <div class="tab-content">
                                    <div role="tabpanel" class="tab-pane active" id="unresolved">
										@if ( ((IEnumerable<Discrepancy>)ViewBag.Discrepancies).Any(d => !d.Resolved) )
										{
											@foreach (var dicrepancy in ((IEnumerable<Discrepancy>)ViewBag.Discrepancies).Where(d => !d.Resolved))
											{
Dmytro Bogatov's avatar
Dmytro Bogatov committed
158 159 160 161 162
												<vc:discrepancy-card 
													model=dicrepancy
													number=0
													hidden=false
												></vc:discrepancy-card>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
163 164 165 166 167 168 169 170 171 172
											}
										}
										else
										{
                                        	@: <h3>No outstanding issues! Well done!</h3>
										}
                                    </div>
                                    <div role="tabpanel" class="tab-pane" id="resovled">
                                        @if ( ((IEnumerable<Discrepancy>)ViewBag.Discrepancies).Any(d => d.Resolved) )
										{
Dmytro Bogatov's avatar
Dmytro Bogatov committed
173 174
											var number = 1;

Dmytro Bogatov's avatar
Dmytro Bogatov committed
175 176
											@foreach (var dicrepancy in ((IEnumerable<Discrepancy>)ViewBag.Discrepancies).Where(d => d.Resolved))
											{
Dmytro Bogatov's avatar
Dmytro Bogatov committed
177 178 179 180 181 182 183 184 185
												var hidden = number > 10;

												<vc:discrepancy-card 
													model=dicrepancy 
													number=number
													hidden=hidden
												></vc:discrepancy-card>

												number++;
Dmytro Bogatov's avatar
Dmytro Bogatov committed
186
											}
Dmytro Bogatov's avatar
Dmytro Bogatov committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
											<div class="w-100 text-center p-t-10">

												<button 
													type="type" 
													id="load-more-resolved-btn" 
													class="btn btn-primary btn-md waves-effect"
													style="@( ((IEnumerable<Discrepancy>)ViewBag.Discrepancies).Count(d => d.Resolved) <= 10 ? "display: none;" : "")"
												>
													Show another 10
												</button>

												<button 
													type="type" 
													id="load-less-resolved-btn" 
													class="btn btn-warning btn-md waves-effect" 
													style="display: none;"
												>
													Hide another 10
												</button>
											</div>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
207 208 209 210 211 212 213 214 215 216 217
										}
										else
										{
                                        	@: <h3>No discrepancies have been noticed.</h3>
										}
                                    </div>
                                </div>
                            </div>

                        </div>

Dmytro Bogatov's avatar
Dmytro Bogatov committed
218
					</div>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
219

Dmytro Bogatov's avatar
Dmytro Bogatov committed
220
				</div>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
221

Dmytro Bogatov's avatar
Dmytro Bogatov committed
222 223
			</div>

Dmytro Bogatov's avatar
Dmytro Bogatov committed
224
		</div>
Dmytro Bogatov's avatar
Dmytro Bogatov committed
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

		<div class="col-md-6">
			<div class="card">
				<div class="card-header">
					<h2>
						Current settings
						<small>
							These are the settings read from <em>appsettings.json</em>.
							Modify the file to update them.
						</small>
					</h2>
				</div>
				<div class="card-body card-padding">
					<settings-viewer />
				</div>
			</div>
		</div>
	</div>

</div>

@section scripts {

	<environment names="Development">
		<script src="/js/ts/admin.js"></script>
	</environment>
	<environment names="Staging,Production">
		<script src="/js/admin.min.js"></script>
	</environment>

}