Skip to content

Commit

Permalink
refactor action buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
bai1024 committed Jul 24, 2024
1 parent e7c897e commit c9696a5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 73 deletions.
28 changes: 0 additions & 28 deletions promgen/templates/promgen/service_action_button.html

This file was deleted.

48 changes: 48 additions & 0 deletions promgen/templates/promgen/service_action_button_group.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% load i18n %}
{% load promgen %}


<div style="display: inline-block;">
<div class="btn-group btn-group-sm" role="group" aria-label="...">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{% translate "Actions" %} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li role="presentation"><a href="{% urlqs 'audit-list' service=service.id %}">{% translate "Edit History" %}</a></li>
<li role="presentation"><a href="{% urlqs 'alert-list' service=service.name %}">{% translate "Alert History" %}</a></li>

<hr>

<li role="presentation"><a href="{% url 'api:service-rules' name=service.name %}">{% translate "Export Rules" %}</a></li>
<li role="presentation"><a href="{% url 'api:service-targets' name=service.name %}">{% translate "Export Service" %}</a></li>

<hr>

<li role="presentation">
<a href="">
<form method="post" action="{% url 'service-delete' service.id %}" onsubmit="return confirm('{% translate "Delete this service?" %}')" style="display: inline">
{% csrf_token %}
<button style="background:none;border: none;padding: 0;">{% translate "Delete Service" %}</button>
</form>
</a>
</li>

<hr>

<li>
<a href="">
<form action="{% url 'service-notifier' service.id %}" style="display:inline" method="post" v-pre>{% csrf_token %}
<input type="hidden" name="sender" value="promgen.notification.user">
<input type="hidden" name="value" value="{{request.user.username}}" />
<button style="background:none;border: none;padding: 0;">{% translate "Subscribe to Notifications" %}</button>
</form>
</a>
</li>

</ul>
</div>
<a @click="setSilenceDataset" data-service="{{service.name}}" class="btn btn-warning btn-sm ml-2 mr-2">{% translate "Silence" %}</a>

<a href="{% url 'service-update' service.id %}" class="btn btn-warning btn-sm">{% translate "Edit Service" %}</a>

</div>
45 changes: 7 additions & 38 deletions promgen/templates/promgen/service_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,19 @@

<div class="panel panel-default">
<div class="panel-body">
<div class="btn-group btn-group-sm" role="group" aria-label="...">
<div class="btn-group btn-group-sm mr-2" role="group" aria-label="...">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{% trans "Register" %} <span class="caret"></span>
{% translate "Register" %} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li role="presentation"><a href="{% url 'project-new' service.id %}">{% trans "Register Project" %}</a></li>
<li role="presentation"><a href="{% url 'rule-new' 'service' service.id %}">{% trans "Register Rule" %}</a></li>
<li role="presentation"><a href="{% url 'service-notifier' service.id %}">{% trans "Register Notifier" %}</a></li>
<li role="presentation"><a href="{% url 'project-new' service.id %}">{% translate "Register Project" %}</a></li>
<li role="presentation"><a href="{% url 'rule-new' 'service' service.id %}">{% translate "Register Rule" %}</a></li>
<li role="presentation"><a href="{% url 'service-notifier' service.id %}">{% translate "Register Notifier" %}</a></li>
</ul>
</div>

<form action="{% url 'service-notifier' service.id %}" style="display:inline" method="post" v-pre>{% csrf_token %}
<input type="hidden" name="sender" value="promgen.notification.user">
<input type="hidden" name="value" value="{{request.user.username}}" />
<button class="btn btn-primary btn-sm">{% trans "Subscribe to Notifications" %}</button>
</form>
{% include "promgen/service_action_button_group.html" %}

<div class="btn-group btn-group-sm" role="group" aria-label="...">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{% trans "Change History" %} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li role="presentation"><a href="{% urlqs 'audit-list' service=service.id %}">{% trans "Edit History" %}</a></li>
<li role="presentation"><a href="{% urlqs 'alert-list' service=service.name %}">{% trans "Alert History" %}</a></li>
</ul>
</div>

<a href="{% url 'service-update' service.id %}" class="btn btn-warning btn-sm">{% trans "Edit Service" %}</a>
<a @click="setSilenceDataset" data-service="{{service.name}}" class="btn btn-warning btn-sm">{% trans "Silence" %}</a>

<div class="btn-group btn-group-sm" role="group" aria-label="...">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Export <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li role="presentation"><a href="{% url 'api:service-rules' name=service.name %}">{% trans "Export Rules" %}</a></li>
<li role="presentation"><a href="{% url 'api:service-targets' name=service.name %}">{% trans "Export Service" %}</a></li>
</ul>
</div>

<form method="post" action="{% url 'service-delete' service.id %}" onsubmit="return confirm('{% trans "Delete this service?" %}')" style="display: inline">
{% csrf_token %}
<button class="btn btn-danger btn-sm pull-right">{% trans "Delete Service" %}</button>
</form>
</div>
</div>

Expand All @@ -89,7 +58,7 @@
</table>
<div class="panel-footer">
<a class="btn btn-default btn-xs" role="button" data-toggle="collapse" href=".service-site-rules-{{service.id}}" aria-expanded="false" aria-controls="collapseExample">
{% trans 'Show Site Rules' %}
{% translate 'Show Site Rules' %}
</a>
</div>
</div>
Expand Down
8 changes: 1 addition & 7 deletions promgen/templates/promgen/service_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@ <h1>Service: {{ service.name }}</h1>
{% endif %}
</div>

<div>

{% include "promgen/service_action_button.html" %}

<a @click="setSilenceDataset" data-service="{{service.name}}" class="btn btn-warning btn-sm ml-2 mr-2">{% translate "Silence" %}</a>
{% include "promgen/service_action_button_group.html" %}

<a href="{% url 'service-update' service.id %}" class="btn btn-warning btn-sm">{% translate "Edit Service" %}</a>

</div>
</div>

{% breadcrumb service %}
Expand Down

0 comments on commit c9696a5

Please sign in to comment.