Skip to content

Commit 58e0f4c

Browse files
UI improvements
1 parent f02b6f4 commit 58e0f4c

5 files changed

Lines changed: 192 additions & 105 deletions

File tree

src/routes/prometheus.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ def delete_file_path(id):
6161
flash('File path deleted successfully!', 'success')
6262
return redirect(url_for('external_monitoring'))
6363

64-
@app.route('/targets')
65-
def targets():
64+
@app.route('/configure_targets')
65+
def configure_targets():
6666
update_prometheus_config()
67-
# update_prometheus_container()
6867
targets_info = show_targets()
6968
return render_template('other/targets.html', targets_info=targets_info)
7069

@@ -73,7 +72,7 @@ def restart_prometheus():
7372
update_prometheus_config
7473
update_prometheus_container()
7574
flash('Prometheus container restarted successfully!', 'success')
76-
return redirect(url_for('dashboard_network'))
75+
return redirect(url_for('configure_targets'))
7776

7877
@app.route('/targets/add_target', methods=['POST'])
7978
def add_target():
@@ -85,7 +84,7 @@ def add_target():
8584
# new target should be <ip>:<port> check if it is in the correct format
8685
if ':' not in new_target:
8786
flash('Invalid target format. It should be in the format <ip>:<port>.', 'danger')
88-
return redirect(url_for('dashboard_network'))
87+
return redirect(url_for('configure_targets'))
8988

9089
for scrape_config in config['scrape_configs']:
9190
if scrape_config['job_name'] == job_name:
@@ -101,8 +100,8 @@ def add_target():
101100

102101
save_yaml(config, prometheus_yml_path)
103102
flash('Target added successfully!', 'success')
104-
update_prometheus_container()
105-
return redirect(url_for('dashboard_network'))
103+
# update_prometheus_container()
104+
return redirect(url_for('configure_targets'))
106105

107106
@app.route('/targets/remove_target', methods=['POST'])
108107
def remove_target():
@@ -128,8 +127,8 @@ def remove_target():
128127
flash(f'Job {job_name} not found.', 'warning')
129128

130129
save_yaml(config, prometheus_yml_path)
131-
update_prometheus_container()
132-
return redirect(url_for('dashboard_network'))
130+
# update_prometheus_container()
131+
return redirect(url_for('configure_targets'))
133132

134133
@app.route('/targets/change_interval', methods=['POST'])
135134
def change_interval():
@@ -144,5 +143,5 @@ def change_interval():
144143
break
145144

146145
save_yaml(config, prometheus_yml_path)
147-
update_prometheus_container()
148-
return redirect(url_for('targets'))
146+
# update_prometheus_container()
147+
return redirect(url_for('configure_targets'))

src/static/css/targets.css

Lines changed: 95 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,120 @@
1-
2-
3-
/* body {
4-
font-family: 'Arial', sans-serif;
5-
background-color: #f4f4f9;
6-
color: #333;
7-
line-height: 1.6;
1+
/* General page styles */
2+
.container {
3+
max-width: 1200px;
4+
margin: 20px auto;
85
padding: 20px;
9-
} */
6+
background-color: #f4f6f9;
7+
border-radius: 8px;
8+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
9+
}
1010

1111
h1, h2 {
12-
color: #4a4a4a;
12+
font-family: 'Roboto', sans-serif;
13+
color: #333;
1314
margin-bottom: 20px;
15+
text-align: center;
1416
}
1517

16-
table {
18+
.section {
19+
margin-top: 30px;
20+
text-align: center;
21+
}
22+
23+
/* Table styles */
24+
.table-wrapper {
25+
overflow-x: auto;
26+
}
27+
28+
.modern-table {
1729
width: 100%;
1830
border-collapse: collapse;
19-
margin-bottom: 20px;
31+
font-family: 'Roboto', sans-serif;
2032
}
2133

22-
th, td {
23-
padding: 12px;
34+
.modern-table th, .modern-table td {
35+
padding: 12px 15px;
2436
text-align: left;
25-
border-bottom: 1px solid #ccc;
37+
border-bottom: 1px solid #ddd;
2638
}
2739

28-
th {
40+
.modern-table th {
2941
background-color: #007bff;
30-
color: white;
42+
color: #fff;
43+
text-transform: uppercase;
44+
letter-spacing: 0.03em;
45+
}
46+
47+
.modern-table tr:nth-child(even) {
48+
background-color: #f9f9f9;
3149
}
3250

33-
tr:hover {
51+
.modern-table tr:hover {
3452
background-color: #f1f1f1;
3553
}
3654

37-
form {
55+
.target-list {
56+
list-style-type: none;
57+
padding-left: 0;
58+
}
59+
60+
.target-list li {
61+
margin-bottom: 8px;
62+
}
63+
64+
/* Form styles */
65+
form.inline-form {
3866
display: inline;
3967
}
4068

41-
input[type="text"], input[type="submit"] {
42-
padding: 10px;
69+
.input-field {
70+
padding: 8px;
4371
margin: 5px;
4472
border: 1px solid #ccc;
4573
border-radius: 4px;
46-
transition: border 0.3s ease;
74+
width: 200px;
4775
}
4876

49-
input[type="text"]:focus {
50-
border: 1px solid #007bff;
77+
.input-field:focus {
78+
border-color: #007bff;
5179
outline: none;
80+
transition: border 0.2s;
5281
}
5382

54-
input[type="submit"] {
55-
background-color: #007bff;
83+
/* Button styles */
84+
.btn-primary, .btn-danger, .btn-warning {
85+
padding: 10px 15px;
86+
border: none;
87+
border-radius: 4px;
5688
color: white;
5789
cursor: pointer;
90+
transition: background-color 0.3s ease;
5891
}
5992

60-
input[type="submit"]:hover {
93+
.btn-primary {
94+
background-color: #007bff;
95+
}
96+
97+
.btn-primary:hover {
6198
background-color: #0056b3;
6299
}
63100

101+
.btn-danger {
102+
background-color: #dc3545;
103+
}
104+
105+
.btn-danger:hover {
106+
background-color: #c82333;
107+
}
108+
109+
.btn-warning {
110+
background-color: #ffc107;
111+
}
112+
113+
.btn-warning:hover {
114+
background-color: #e0a800;
115+
}
116+
117+
/* Messages */
64118
.flash {
65119
padding: 10px;
66120
margin: 10px 0;
@@ -76,3 +130,18 @@ input[type="submit"]:hover {
76130
background-color: #f8d7da;
77131
color: #721c24;
78132
}
133+
134+
/* Add New Target Form */
135+
.add-target-form {
136+
margin: 0 auto;
137+
max-width: 600px;
138+
text-align: center;
139+
}
140+
141+
.add-target-form .input-field {
142+
width: 70%;
143+
}
144+
145+
.add-target-form input[type="submit"] {
146+
width: 150px;
147+
}

src/static/js/targets.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,22 @@ async function fetchTargetData() {
7373
jobNameInput.value = target.labels.job;
7474
removeForm.appendChild(jobNameInput);
7575

76-
const targetToRemoveInput = document.createElement('input');
77-
targetToRemoveInput.type = 'hidden';
78-
targetToRemoveInput.name = 'target_to_remove';
79-
targetToRemoveInput.value = target.labels.instance;
80-
removeForm.appendChild(targetToRemoveInput);
81-
82-
const submitButton = document.createElement('input');
83-
submitButton.type = 'submit';
84-
submitButton.value = 'Remove';
85-
submitButton.onclick = function () {
86-
return confirm('Are you sure you want to remove this target?');
87-
};
88-
removeForm.appendChild(submitButton);
89-
90-
removeCell.appendChild(removeForm);
91-
row.appendChild(removeCell);
92-
93-
// Append the row to the table body
94-
targetTableBody.appendChild(row);
76+
// const targetToRemoveInput = document.createElement('input');
77+
// targetToRemoveInput.type = 'hidden';
78+
// targetToRemoveInput.name = 'target_to_remove';
79+
// targetToRemoveInput.value = target.labels.instance;
80+
// removeForm.appendChild(targetToRemoveInput);
81+
82+
// const submitButton = document.createElement('input');
83+
// submitButton.type = 'submit';
84+
// submitButton.value = 'Remove';
85+
// submitButton.onclick = function () {
86+
// return confirm('Are you sure you want to remove this target?');
87+
// };
88+
// removeForm.appendChild(submitButton);
89+
90+
// removeCell.appendChild(removeForm);
91+
// row.appendChild(removeCell);
9592

9693
// Append the row to the table body
9794
targetTableBody.appendChild(row);

src/templates/network/dashboard_network.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ <h1>SystemGuard Active Targets</h1>
2020
<th>Scrape Duration (s)</th>
2121
<th>Scrape Interval</th>
2222
<th>Go to Dashboard</th>
23-
<th>Remove Target</th>
2423
</tr>
2524
</thead>
2625
<tbody id="target-table-body">
@@ -29,8 +28,7 @@ <h1>SystemGuard Active Targets</h1>
2928
</table>
3029
</div>
3130

32-
33-
<div class="text-center">
31+
<!-- <div class="text-center">
3432
<h2>Restart Prometheus Docker Service</h2>
3533
<form action="{{ url_for('restart_prometheus') }}">
3634
<input type="submit" value="Restart Prometheus">
@@ -40,12 +38,11 @@ <h2>Restart Prometheus Docker Service</h2>
4038
<div class="text-center">
4139
<h2>Add New Target</h2>
4240
<form action="{{ url_for('add_target') }}" method="post">
43-
<input type="text" name="job_name" placeholder="Job Name" required>
4441
<input type="text" name="new_target" placeholder="New Instance" required>
4542
<input type="text" name="scrape_interval" placeholder="Scrape Interval" required>
4643
<input type="submit" value="Add Target">
4744
</form>
48-
</div>
45+
</div> -->
4946
{% endblock %}
5047
{% block extra_scripts %}
5148
<script src="{{ url_for('static', filename='js/targets.js') }}"></script>

0 commit comments

Comments
 (0)