diff --git a/app/urls.py b/app/urls.py index 91e2ef0..b03cb93 100644 --- a/app/urls.py +++ b/app/urls.py @@ -24,6 +24,8 @@ from core.api.views.threshold import ThresholdChans, ThresholdOnline, ThresholdU from core.views import Billing, Cancel, Home, Order, Portal, Signup from core.views.callbacks import Callback from core.views.manage.threshold.irc import ( + ThresholdIRCActions, + ThresholdIRCActionsAddNetwork, ThresholdIRCAliases, ThresholdIRCAliasesEdit, ThresholdIRCNetworkActions, @@ -102,6 +104,16 @@ urlpatterns = [ ThresholdIRCNetworks.as_view(), name="threshold_irc_networks", ), + path( + "manage/threshold/irc/overview/actions/", + ThresholdIRCActions.as_view(), + name="threshold_irc_actions", + ), + path( + "manage/threshold/irc/overview/actions/add-network/", + ThresholdIRCActionsAddNetwork.as_view(), + name="threshold_irc_actions_add-network", + ), path( "manage/threshold/irc/network//", ThresholdIRCNetwork.as_view(), diff --git a/core/lib/manage/threshold.py b/core/lib/manage/threshold.py index 2b2f483..826dc6c 100644 --- a/core/lib/manage/threshold.py +++ b/core/lib/manage/threshold.py @@ -125,3 +125,10 @@ def run_list(net): payload = {} ran = threshold_request(url, payload, method="POST") return ran + + +def create_network(data): + url = "irc/network/create" + payload = data + ran = threshold_request(url, payload, method="PUT") + return ran diff --git a/core/lib/threshold.py b/core/lib/threshold.py index a885ddb..4c1cfdc 100644 --- a/core/lib/threshold.py +++ b/core/lib/threshold.py @@ -71,7 +71,6 @@ def threshold_request(url, data, method="POST", esc=False): else: logger.error("Invalid method specified") method = requests.get - print("SENDING TO", url) r = method( f"{settings.THRESHOLD_ENDPOINT}/{url}/", data=dumps(data), headers=headers diff --git a/core/templates/manage/threshold/irc/network/actions.html b/core/templates/manage/threshold/irc/network/actions.html index 6154f80..accd20e 100644 --- a/core/templates/manage/threshold/irc/network/actions.html +++ b/core/templates/manage/threshold/irc/network/actions.html @@ -1,9 +1,5 @@
- {% if message is not None %} -
- {{ message }} -
- {% endif %} + {% include 'manage/threshold/partials/notify.html' %}
-
diff --git a/core/templates/manage/threshold/irc/network/channels.html b/core/templates/manage/threshold/irc/network/channels.html index 32d751c..1096b62 100644 --- a/core/templates/manage/threshold/irc/network/channels.html +++ b/core/templates/manage/threshold/irc/network/channels.html @@ -1,9 +1,5 @@
- {% if message is not None %} -
- {{ message }} -
- {% endif %} + {% include 'manage/threshold/partials/notify.html' %} {% if channels is not None %}
diff --git a/core/templates/manage/threshold/irc/network/edit-network.html b/core/templates/manage/threshold/irc/network/edit-network.html index e88daf4..ce8eb25 100644 --- a/core/templates/manage/threshold/irc/network/edit-network.html +++ b/core/templates/manage/threshold/irc/network/edit-network.html @@ -63,12 +63,13 @@ - + +
diff --git a/core/templates/manage/threshold/irc/network/info.html b/core/templates/manage/threshold/irc/network/info.html index 2737842..14bbea8 100644 --- a/core/templates/manage/threshold/irc/network/info.html +++ b/core/templates/manage/threshold/irc/network/info.html @@ -1,9 +1,5 @@
- {% if message is not None %} -
- {{ message }} -
- {% endif %} + {% include 'manage/threshold/partials/notify.html' %} {% if network is not None %}
diff --git a/core/templates/manage/threshold/irc/network/relays.html b/core/templates/manage/threshold/irc/network/relays.html index ff55933..79188e0 100644 --- a/core/templates/manage/threshold/irc/network/relays.html +++ b/core/templates/manage/threshold/irc/network/relays.html @@ -1,10 +1,6 @@ {% load index %}
- {% if message is not None %} -
- {{ message }} -
- {% endif %} + {% include 'manage/threshold/partials/notify.html' %} {% if relays is not None %}
diff --git a/core/templates/manage/threshold/irc/overview/actions.html b/core/templates/manage/threshold/irc/overview/actions.html new file mode 100644 index 0000000..b71b875 --- /dev/null +++ b/core/templates/manage/threshold/irc/overview/actions.html @@ -0,0 +1,42 @@ +
+ {% include 'manage/threshold/partials/notify.html' %} +
+ + + +
+
\ No newline at end of file diff --git a/core/templates/manage/threshold/irc/overview/aliases.html b/core/templates/manage/threshold/irc/overview/aliases.html index 8bd9752..45fc8b2 100644 --- a/core/templates/manage/threshold/irc/overview/aliases.html +++ b/core/templates/manage/threshold/irc/overview/aliases.html @@ -1,11 +1,7 @@ {% load joinsep %}
- {% if message is not None %} -
- {{ message }} -
- {% endif %} + {% include 'manage/threshold/partials/notify.html' %} {% if aliases is not None %}
diff --git a/core/templates/manage/threshold/irc/overview/modals/add-network.html b/core/templates/manage/threshold/irc/overview/modals/add-network.html new file mode 100644 index 0000000..4d7d9ff --- /dev/null +++ b/core/templates/manage/threshold/irc/overview/modals/add-network.html @@ -0,0 +1,85 @@ +{% load index %} +{% load static %} + + + +
+
+
@@ -53,8 +62,20 @@
+ Alerts here
+ +
+
+
+
+
+
+
+
+
+ {% endblock %} diff --git a/core/templates/manage/threshold/partials/notify.html b/core/templates/manage/threshold/partials/notify.html new file mode 100644 index 0000000..6cdaccb --- /dev/null +++ b/core/templates/manage/threshold/partials/notify.html @@ -0,0 +1,5 @@ +{% if message is not None %} +
+ {{ message }} +
+{% endif %} \ No newline at end of file diff --git a/core/views/manage/threshold/irc.py b/core/views/manage/threshold/irc.py index b5b27b5..a5dfaa1 100644 --- a/core/views/manage/threshold/irc.py +++ b/core/views/manage/threshold/irc.py @@ -215,6 +215,49 @@ class ThresholdIRCAliases(SuperUserRequiredMixin, APIView): return render(request, self.template_name, context) +class ThresholdIRCActions(SuperUserRequiredMixin, APIView): + template_name = "manage/threshold/irc/overview/actions.html" + + def get(self, request): + """ + Get actions pane. + """ + return render(request, self.template_name) + + +class ThresholdIRCActionsAddNetwork(SuperUserRequiredMixin, APIView): + template_name = "manage/threshold/irc/overview/modals/add-network.html" + parser_classes = [FormParser] + + def get(self, request): + """ + Get actions pane. + """ + return render(request, self.template_name) + + def put(self, request): + """ + Create a network. + """ + template_name = "manage/threshold/irc/overview/networks.html" + created = threshold.create_network(request.data) + + message = "Network created successfully." + message_class = "success" + + if not created["success"]: + message = created["reason"] + message_class = "danger" + + networks = threshold.get_irc_networks() + context = { + "networks": networks, + "message": message, + "class": message_class, + } + return render(request, template_name, context) + + class ThresholdIRCAliasesEdit(SuperUserRequiredMixin, APIView): template_name = "manage/threshold/irc/overview/modals/edit-aliases.html" parser_classes = [FormParser]