Skip to content

Commit ddde207

Browse files
committed
working with new schema; modal dialogs
1 parent 2698c8b commit ddde207

File tree

6 files changed

+130
-37
lines changed

6 files changed

+130
-37
lines changed

assets/templates_src/index.html

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ <h1>Dashboard</h1>
99
{% endblock %}
1010

1111
{% block content%}
12+
1213
{% verbatim %}
1314
<div class="box">
1415
<div class="box-header">
@@ -20,7 +21,10 @@ <h3 class="box-title">Projects</h3>
2021
<tr>
2122
<th>Project</th>
2223
<th>Owner</th>
23-
<th width="350px">Last build</th>
24+
<th width="300px">Last build</th>
25+
{% if CurrentUser.IsSuperuser %}
26+
<th width="80px">-</th>
27+
{% endif %}
2428
</tr>
2529
{% for item in items %}
2630
<tr>
@@ -55,16 +59,58 @@ <h3 class="box-title">Projects</h3>
5559
{% endif %}
5660
{% endif %}
5761
</td>
62+
{% if CurrentUser.IsSuperuser %}
63+
<td>
64+
65+
<a href="#" data-toggle="modal" data-target="#confirmAction" data-action="/project/{{ item.ProjectID }}/delete/"><i class="fa fa-trash" aria-hidden="true"></i>delete</a>
66+
</td>
67+
{% endif %}
5868
</tr>
5969
{% endfor %}
6070
</tbody>
6171
</table>
6272
</div>
6373
{% if CurrentUser.IsSuperuser %}
6474
<div class="box-footer">
65-
<button type="submit" class="btn btn-primary">Add project</button>
75+
<button type="submit" data-toggle="modal" data-target="#addProject" class="btn btn-primary">Add project</button>
6676
</div>
6777
{% endif %}
6878
</div>
79+
{% if CurrentUser.IsSuperuser %}
80+
<div class="modal fade" id="addProject" tabindex="-1" role="dialog">
81+
<div class="modal-dialog" role="document">
82+
<div class="modal-content">
83+
<div class="modal-header">
84+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
85+
<h4 class="modal-title">Add project</h4>
86+
</div>
87+
<div class="modal-body">
88+
<div class="form-group">
89+
<label for="message-text" class="control-label">name:</label>
90+
<input type="text" name="name" class="form-control">
91+
</div>
92+
<div class="form-group">
93+
<label for="message-text" class="control-label">owner:</label>
94+
<select class="form-control" name="owner">
95+
<option>sdds</option>
96+
</select>
97+
</div>
98+
<div class="form-group">
99+
<label for="message-text" class="control-label">repository url</label>
100+
<input type="text" name="repository_url" class="form-control">
101+
</div>
102+
<div class="form-group">
103+
<label for="message-text" class="control-label">github secret</label>
104+
<input type="text" name="github_secret" class="form-control">
105+
</div>
106+
</div>
107+
<div class="modal-footer">
108+
<button type="button" class="btn btn-default" data-dismiss="modal">close</button>
109+
<button type="submit" class="btn btn-primary">add</button>
110+
</div>
111+
</div>
112+
</div>
113+
</div>
114+
{% endif %}
69115
{% endverbatim %}
70116
{% endblock %}

assets/templates_src/internal/layout/header.html

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<li class="dropdown">
1313
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{% verbatim %}{{ CurrentUser.Name }} {% endverbatim %} <span class="caret"></span></a>
1414
<ul class="dropdown-menu" role="menu">
15-
<li><a href="#">Change password</a></li>
15+
<li><a href="#" data-toggle="modal" data-target="#changePassword">Change password</a></li>
1616
<!--li class="divider"></li-->
1717
</ul>
1818
</li>
@@ -21,3 +21,31 @@
2121
</div>
2222
</nav>
2323
</header>
24+
<div class="modal fade" id="changePassword" tabindex="-1" role="dialog">
25+
<div class="modal-dialog" role="document">
26+
<div class="modal-content">
27+
<div class="modal-header">
28+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
29+
<h4 class="modal-title">Change password</h4>
30+
</div>
31+
<div class="modal-body">
32+
<div class="form-group">
33+
<label for="message-text" class="control-label">current password:</label>
34+
<input type="password" name="current_password" class="form-control">
35+
</div>
36+
<div class="form-group">
37+
<label for="message-text" class="control-label">new password:</label>
38+
<input type="password" name="new_password" class="form-control">
39+
</div>
40+
<div class="form-group">
41+
<label for="message-text" class="control-label">confirm password:</label>
42+
<input type="password" name="confirm_password" class="form-control">
43+
</div>
44+
</div>
45+
<div class="modal-footer">
46+
<button type="button" class="btn btn-default" data-dismiss="modal">close</button>
47+
<button type="submit" class="btn btn-primary">change</button>
48+
</div>
49+
</div>
50+
</div>
51+
</div>

assets/templates_src/project/view_build.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h3 class="box-title">Config</h3>
3434
<div class="box-header">
3535
<h3 class="box-title">
3636
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>
37-
Image: {{ part.DockerImage}}. Server version: {{ part.ServerVersion }}
37+
Image: {{ part.Image}}. Server version: {{ part.Version }}
3838
</h3>
3939
<div class="box-tools">
4040
<strong>Duration:</strong> {{ part.FinishedAt | duration:part.StartedAt }}
@@ -56,15 +56,15 @@ <h3 class="box-title">
5656
<td>
5757

5858
{% if test.Errors %}
59-
<span class="label label-danger">{{ test.Namespace }}.{{ test.Procedure }}</span><br>
59+
<span class="label label-danger">{{ test.Function }}</span><br>
6060
{% for error in test.Errors %}
6161
{{ error.Message }} {{ error.Comment }} <br>
6262
{% endfor %}
6363
{% else %}
64-
{{ test.Namespace }}.{{ test.Procedure }}
64+
{{ test.Function }}
6565
{% endif %}
6666
</td>
67-
<td>{{ test.FinishedAt | duration_seconds:test.StartedAt }}</td>
67+
<td>{{ test.Duration | floatformat:4 }}s</td>
6868
</tr>
6969
{% endfor %}
7070
</tbody>

assets/templates_src/users/index.html

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,45 @@ <h3 class="box-title">Users</h3>
5252
</div>
5353
<div class="box-footer clearfix">
5454
{% if CurrentUser.IsSuperuser %}
55-
<button type="submit" class="btn btn-primary">Add user</button>
55+
<button type="submit" data-toggle="modal" data-target="#addUser" class="btn btn-primary">Add user</button>
5656
{% endif %} {% endverbatim %} {% include "../internal/pagination.html" %}
5757
</div>
58+
{% verbatim %} {% if CurrentUser.IsSuperuser %}
59+
<div class="modal fade" id="addUser" tabindex="-1" role="dialog">
60+
<div class="modal-dialog" role="document">
61+
<div class="modal-content">
62+
<div class="modal-header">
63+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
64+
<h4 class="modal-title">Add user</h4>
65+
</div>
66+
<div class="modal-body">
67+
<div class="form-group">
68+
<label for="message-text" class="control-label">user name:</label>
69+
<input type="text" name="user_name" class="form-control">
70+
</div>
71+
<div class="form-group">
72+
<label for="message-text" class="control-label">email:</label>
73+
<input type="email" name="email" class="form-control">
74+
</div>
75+
<div class="form-group">
76+
<label for="message-text" class="control-label">login:</label>
77+
<input type="text" name="login" class="form-control">
78+
</div>
79+
<div class="form-group">
80+
<label for="message-text" class="control-label">password:</label>
81+
<input type="password" name="password" class="form-control" id="password">
82+
</div>
83+
<div class="form-group">
84+
<label><input type="checkbox" name="is_superuser"> superuser</label>
85+
</div>
86+
</div>
87+
<div class="modal-footer">
88+
<button type="button" class="btn btn-default" data-dismiss="modal">close</button>
89+
<button type="submit" class="btn btn-primary">add</button>
90+
</div>
91+
</div>
92+
</div>
93+
</div>
94+
{% endif %} {% endverbatim %}
5895
</div>
5996
{% endblock %}

src/app/models/build/view.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ type build struct {
2828
}
2929

3030
type Part struct {
31-
PartID int32 `json:"part_id"`
32-
DockerImage string `json:"docker_image"`
33-
ServerVersion string `json:"server_version"`
34-
Output string `json:"output"`
35-
Success bool `json:"success"`
36-
StartedAt time.Time `json:"started_at"`
37-
FinishedAt time.Time `json:"finished_at"`
38-
Tests []Test `json:"tests"`
31+
PartID int32 `json:"part_id"`
32+
Image string `json:"image"`
33+
Version string `json:"version"`
34+
Output string `json:"output"`
35+
Success bool `json:"success"`
36+
StartedAt time.Time `json:"started_at"`
37+
FinishedAt time.Time `json:"finished_at"`
38+
Tests []Test `json:"tests"`
3939
}
4040

4141
type Parts []Part
@@ -57,11 +57,9 @@ func (p *Parts) Scan(src interface{}) error {
5757
}
5858

5959
type Test struct {
60-
Namespace string `json:"namespace"`
61-
Procedure string `json:"procedure"`
62-
Errors []Error `json:"errors"`
63-
StartedAt time.Time `json:"started_at"`
64-
FinishedAt time.Time `json:"finished_at"`
60+
Function string `json:"function"`
61+
Errors []Error `json:"errors"`
62+
Duration float64 `json:"duration"`
6563
}
6664

6765
type Error struct {

src/tools/render/filters/time.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
func init() {
1111
pongo2.RegisterFilter("duration", durationFilter)
12-
pongo2.RegisterFilter("duration_seconds", durationSecondsFilter)
1312
pongo2.RegisterFilter("naturaltime", naturaltimeFilter)
1413
}
1514

@@ -28,21 +27,6 @@ func durationFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pong
2827
return pongo2.AsValue(duration(diff)), nil
2928
}
3029

31-
func durationSecondsFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
32-
33-
diff, err := timeDiff(in, param)
34-
35-
if err != nil {
36-
37-
return nil, &pongo2.Error{
38-
Sender: "filter:duration_seconds",
39-
ErrorMsg: err.Error(),
40-
}
41-
}
42-
43-
return pongo2.AsValue(fmt.Sprintf("%.4fs", diff.Seconds())), nil
44-
}
45-
4630
func naturaltimeFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
4731

4832
diff, err := timeDiff(in, param)

0 commit comments

Comments
 (0)