diff --git a/apprise_api/api/templates/base.html b/apprise_api/api/templates/base.html index dee0a6b..60fe6d7 100644 --- a/apprise_api/api/templates/base.html +++ b/apprise_api/api/templates/base.html @@ -7,21 +7,23 @@ + - + + + - - - + + {% block title %}{% trans "Apprise API" %}{% endblock %} diff --git a/apprise_api/api/templates/config.html b/apprise_api/api/templates/config.html index c91ed27..7b56991 100644 --- a/apprise_api/api/templates/config.html +++ b/apprise_api/api/templates/config.html @@ -2,15 +2,17 @@ {% load i18n %} {% block body %} {% if STATEFUL_MODE != 'disabled' %} -

{% trans "Management for Config ID:" %} {{ key }}

+

{% trans "Management for Config ID:" %} {{ key }}

@@ -105,31 +107,24 @@
{% trans "Using CURL" %}

{% blocktrans %}The following command would cause the apprise api to notify all of your services:{% endblocktrans %}

curl -X POST \
-     -F "body=Test Message" \
-     -F "tags=all" \
-     http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}}
+     -F "body=Test Message" \
+     -F "tags=all" \
+     http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}} {% blocktrans %}Send one or more attachments like this:{% endblocktrans %}
curl -X POST \
-     -F "tags=all" \
-     -F "body=Test Message" \
-     -F attach1=@Screenshot-1.png \
-     -F attach2=@/my/path/to/Apprise.doc \
-     http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}}
+     -F "tags=all" \
+     -F "body=Test Message" \
+     -F attach1=@Screenshot-1.png \
+     -F attach2=@/my/path/to/Apprise.doc \
+     http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}} {% blocktrans %}Sends a notification to our endpoints with an attachment{% endblocktrans %} -

+         

         curl -X POST \
    -F "tag=all" \
    -F "attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png" \
    "{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}}"

-
-
{% trans "Loaded Configuration" %}
-
-
-
-
-
@@ -150,6 +145,24 @@
{% trans "Your Configuration Is Locked" %}
{% endif %}
+
+ {% if not CONFIG_LOCK %} +

+ {% blocktrans %}The following URLs have been detected:{% endblocktrans %} +

+
+
{% trans "Loaded Configuration" %}
+
+
+
+
+
+ {% else %} +
{% trans "Your Configuration Is Locked" %}
+

{% blocktrans %}Access to your configuration has been disabled by your administrator.{% endblocktrans %} + {% endif %} +

+

{% blocktrans %} @@ -201,10 +214,16 @@

{% trans "Persistent Store Endpoints" %}

let jsonResponse = await fetch('{% url "json_urls" key %}/?privacy=1', { method: 'GET', }) - if(jsonResponse.status != 200) { + if(jsonResponse.status == 204) { // Take an early exit document.querySelector('#url-list-progress').style.display = 'none'; - document.querySelector('#url-list').textContent = '{% trans "An error occurred retrieving the list of loaded Apprise URL(s)" %}' + document.querySelector('#url-list').textContent = '{% trans "There are no URLs defined. Click on the ⚙️ Configuration tab and define some." %}' + return; + + } else if(jsonResponse.status != 200) { + // Take an early exit + document.querySelector('#url-list-progress').style.display = 'none'; + document.querySelector('#url-list').textContent = '{% trans "💣 An error occurred retrieving the list of loaded Apprise URL(s)" %}' return; } @@ -212,12 +231,13 @@

{% trans "Persistent Store Endpoints" %}

// choose from. Tags are based off ones found in the saved // configuration. const data = await jsonResponse.json(); - let external_data = tags.concat(data.tags).reduce(function(result, item) { + const external_data = tags.concat(data.tags).reduce(function(result, item) { result[item] = null; return result; }, {}) - M.Chips.init(document.querySelectorAll('.chips'), { + const chipElement = document.querySelector('.chips'); + M.Chips.init(chipElement, { placeholder: 'Optional Tag', secondaryPlaceholder: 'Another Tag', autocompleteOptions: { @@ -233,6 +253,23 @@

{% trans "Persistent Store Endpoints" %}

} }); + // our GET parameters to be treated as template values + var tagRe = new RegExp('[^[A-Za-z0-9_-]+'); + const params = new Proxy(new URLSearchParams(window.location.search), { + get: (searchParams, prop) => searchParams.get(prop), + }); + if (params.tag) { + params.tag.split(tagRe).forEach(function (tag, index) { + M.Chips.getInstance(chipElement).addChip({tag: tag, image: ''}); + }); + } + if (params.title) { + document.querySelector('#id_title').value = params.title; + } + if (params.body) { + document.querySelector('#id_body').value = params.body; + } + // Now build our our loaded list of configuration for our welcome page let urlList = document.createElement('ul'); @@ -248,8 +285,19 @@

{% trans "Persistent Store Endpoints" %}

entry.tags.forEach(function (tag) { let chip = document.createElement('div'); chip.setAttribute('class', 'chip'); + chip.setAttribute('name', tag); + chip.setAttribute('href', `?tag=${tag}#notify`); chip.textContent = `🏷️ ${tag}`; li.appendChild(chip); + + chip.addEventListener('click', function(e) { + e.preventDefault(); + window.history.pushState(null, null, this.getAttribute('href')); + document.querySelector('.config-overview li a[href="#notify"]').click() + + const chipElement = document.querySelector('.chips'); + M.Chips.getInstance(chipElement).addChip({tag: this.getAttribute('name'), image: ''}); + }, false); }); urlList.appendChild(li); @@ -396,14 +444,47 @@

{% trans "Persistent Store Endpoints" %}

} } +function form_file_input_hack() { + /* + A small hack to remformat all `` upload options to a more cleaner + and presentable look by wrapping it like this: + + + cloud_upload + Browse + + */ + document.querySelectorAll('input[type=file]').forEach(function (entry) { + const div = document.createElement('div'); + const selected = document.createElement('div'); + selected.style.display = 'none'; + selected.setAttribute('class', 'file-selected'); + const span = document.createElement('span') + span.setAttribute('class', 'btn btn-file waves-effect waves-light'); + const i = document.createElement('i') + span.textContent = '{% trans "Browse" %}'; + i.setAttribute('class', 'material-icons right'); + i.textContent = 'folder'; + div.appendChild(span); + span.appendChild(i); + entry.before(div) + span.appendChild(entry); + span.after(selected); + + entry.addEventListener('change', function(e){ + const selected = this.parentNode.nextElementSibling; + const file = e.target.files[0]; + selected.style.display = 'block' + selected.textContent = file.name; + }); + }); + } function notify_init() { // over-ride manual submit for a nicer user experience document.querySelector('#donotify').onsubmit = function(event) { event.preventDefault(); const chipElement = document.querySelector('.chips'); - - chipElement.querySelector('.chips'); const chipInput = document.querySelector('.chips > input'); if(chipInput.value) { // This code just handles text typed in the tag section that was @@ -496,8 +577,10 @@

{% trans "Persistent Store Endpoints" %}

{% if not CONFIG_LOCK %} /* Initialze our configuration */ config_init(); + {% endif %} notify_init(); +form_file_input_hack(); {% endif %} {% endblock %} diff --git a/apprise_api/api/templates/details.html b/apprise_api/api/templates/details.html index 3985eea..0ea969a 100644 --- a/apprise_api/api/templates/details.html +++ b/apprise_api/api/templates/details.html @@ -40,12 +40,12 @@
{{ entry.service_name }}