Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d1b27fb

Browse files
committed
ui: add experiment details page
1 parent 80082f1 commit d1b27fb

13 files changed

Lines changed: 451 additions & 53 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ warp = "0.1.3"
6060
http = "0.1.10"
6161
hyper = "0.12.8"
6262
bytes = "0.4.9"
63+
chrono-humanize = "0.0.11"
6364

6465
[build-dependencies]
6566
git2 = "0.6"

assets/ui.css

Lines changed: 120 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ a:hover {
4141
}
4242

4343
.text-center {
44-
text-align: center;
44+
text-align: center !important;
4545
}
4646

4747
.empty {
@@ -98,6 +98,49 @@ header ul li {
9898
margin-left: 0.7em;
9999
}
100100

101+
102+
div.title {
103+
display: flex;
104+
margin: 1.5em 0;
105+
align-items: center;
106+
}
107+
108+
div.title h1 {
109+
flex: 1;
110+
margin: 0;
111+
112+
font-weight: 400;
113+
color: #444;
114+
}
115+
116+
div.title h1 b {
117+
font-weight: 400;
118+
color: #000;
119+
}
120+
121+
div.title div.toolbar {
122+
flex: 0 content;
123+
}
124+
125+
div.title div.toolbar a.button {
126+
display: inline-block;
127+
padding: 0.5em 0.7em;
128+
129+
border: 1px solid #00f;
130+
border-radius: 0.2em;
131+
}
132+
133+
div.title div.toolbar a.button + a.button {
134+
margin-left: 0.5em;
135+
}
136+
137+
div.title div.toolbar a.button:hover {
138+
color: #fff;
139+
background: #00f;
140+
text-decoration: none;
141+
}
142+
143+
101144
div.card {
102145
display: block;
103146

@@ -116,27 +159,94 @@ div.card > *:last-child {
116159
margin-bottom: 0 !important;
117160
}
118161

162+
div.card ul {
163+
margin: 1em 0;
164+
padding: 0;
165+
list-style: none;
166+
}
167+
168+
div.card ul li {
169+
margin: 0;
170+
padding: 0;
171+
margin-top: 0.4em;
172+
173+
color: #888;
174+
}
119175

120-
table {
176+
div.card ul li:first-child {
177+
margin-top: 0;
178+
}
179+
180+
div.card ul li b {
181+
color: #000;
182+
font-weight: inherit;
183+
display: inline-block;
184+
margin-left: 0.5em;
185+
}
186+
187+
188+
div.columns {
189+
display: flex;
190+
margin: 0 -0.5em;
191+
}
192+
193+
div.columns div.col {
194+
flex: 1;
195+
margin: 0 0.5em;
196+
}
197+
198+
div.col > *:first-child {
199+
margin-top: 0 !important;
200+
}
201+
202+
div.col > *:last-child {
203+
margin-bottom: 0 !important;
204+
}
205+
206+
207+
table.list {
121208
width: 63rem;
122209
border-collapse: collapse;
123210
}
124211

125-
table tr th, table tr td {
212+
table.list tr th, table.list tr td {
126213
padding: 0.7em 0.5em;
127214
}
128215

129-
table tr th {
216+
table.list tr th {
130217
font-weight: 400;
131218
text-align: left;
132219
color: #888;
133220
}
134221

135-
table tr td {
222+
table.list tr td {
136223
border-top: 1px solid #eee;
137224
}
138225

139226

227+
table.details {
228+
width: 100%;
229+
}
230+
231+
table.details th {
232+
font-weight: 400;
233+
color: #888;
234+
text-align: right;
235+
236+
width: 1%;
237+
white-space: nowrap;
238+
padding-right: 1em;
239+
}
240+
241+
table.details tr th, table.details tr td {
242+
padding-top: 0.1em;
243+
}
244+
245+
table.details tr:first-child th, table.details tr:first-child td {
246+
padding-top: 0;
247+
}
248+
249+
140250
footer {
141251
margin: 1.5rem 0;
142252
font-size: 0.9em;
@@ -161,6 +271,11 @@ footer a {
161271
}
162272

163273

274+
div.columns {
275+
display: block;
276+
}
277+
278+
164279
div.card {
165280
margin-left: 0.5em;
166281
margin-right: 0.5em;

src/assets.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ macro_rules! load_files {
5757
load_files! {
5858
templates: [
5959
"macros.html",
60-
6160
"layout.html",
62-
"queue.html",
61+
6362
"agents.html",
6463

64+
"queue.html",
65+
"experiment.html",
66+
6567
"404.html",
6668
"500.html",
6769

src/errors.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ error_chain! {
2828
}
2929

3030
errors {
31+
Error404 {
32+
description("not found")
33+
}
3134
Timeout(what: &'static str, when: u64) {
3235
description("the operation timed out")
3336
display("process killed after {} {}s", what, when)

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
extern crate base64;
66
extern crate bytes;
77
extern crate chrono;
8+
extern crate chrono_humanize;
89
extern crate crates_index;
910
extern crate crossbeam;
1011
#[macro_use]

src/server/experiments.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl ExperimentData {
164164
Ok(())
165165
}
166166

167-
pub fn progress(&self, db: &Database) -> Result<u8> {
167+
pub fn raw_progress(&self, db: &Database) -> Result<(u32, u32)> {
168168
let results_len: u32 = db
169169
.get_row(
170170
"SELECT COUNT(*) AS count FROM results WHERE experiment = ?1;",
@@ -173,18 +173,23 @@ impl ExperimentData {
173173
)?
174174
.unwrap();
175175

176-
// Avoid the second query if there are no results -- we already know the progress is 0%
177-
if results_len > 0 {
178-
let crates_len: u32 = db
179-
.get_row(
180-
"SELECT COUNT(*) AS count FROM experiment_crates \
181-
WHERE experiment = ?1 AND skipped = 0;",
182-
&[&self.experiment.name.as_str()],
183-
|r| r.get("count"),
184-
)?
185-
.unwrap();
176+
let crates_len: u32 = db
177+
.get_row(
178+
"SELECT COUNT(*) AS count FROM experiment_crates \
179+
WHERE experiment = ?1 AND skipped = 0;",
180+
&[&self.experiment.name.as_str()],
181+
|r| r.get("count"),
182+
)?
183+
.unwrap();
184+
185+
Ok((results_len, crates_len * 2))
186+
}
187+
188+
pub fn progress(&self, db: &Database) -> Result<u8> {
189+
let (results_len, crates_len) = self.raw_progress(db)?;
186190

187-
Ok((results_len as f32 * 50.0 / crates_len as f32).ceil() as u8)
191+
if crates_len != 0 {
192+
Ok((results_len as f32 * 100.0 / crates_len as f32).ceil() as u8)
188193
} else {
189194
Ok(0)
190195
}

0 commit comments

Comments
 (0)