diff --git a/app/db.sqlite3 b/app/db.sqlite3 index 41b7c20c..5fc2ac29 100644 Binary files a/app/db.sqlite3 and b/app/db.sqlite3 differ diff --git a/app/server/static/js/label.js b/app/server/static/js/label.js new file mode 100644 index 00000000..b3882133 --- /dev/null +++ b/app/server/static/js/label.js @@ -0,0 +1,51 @@ +axios.defaults.xsrfCookieName = 'csrftoken'; +axios.defaults.xsrfHeaderName = 'X-CSRFToken'; +var base_url = window.location.href.split('/').slice(3, 5).join('/'); +const HTTP = axios.create({ + baseURL: `/api/${base_url}/`, +}) + +var vm = new Vue({ + el: '#mail-app', + delimiters: ['[[', ']]'], + data: { + labels: [], + labelText: '', + selectedShortkey: '', + backgroundColor: '#209cee', + textColor: '#ffffff', + }, + + methods: { + addLabel: function () { + var payload = { + text: this.labelText, + shortcut: this.selectedShortkey, + background_color: this.backgroundColor, + text_color: this.textColor + }; + HTTP.post('labels/', payload).then(response => { + this.reset(); + this.labels.push(response.data); + }) + }, + removeLabel: function (label) { + var label_id = label.id; + HTTP.delete(`labels/${label_id}`).then(response => { + var index = this.labels.indexOf(label) + this.labels.splice(index, 1) + }) + }, + reset: function () { + this.labelText = ''; + this.selectedShortkey = ''; + this.backgroundColor = '#209cee'; + this.textColor = '#ffffff'; + } + }, + created: function () { + HTTP.get('labels').then(response => { + this.labels = response.data + }) + } +}) \ No newline at end of file diff --git a/app/server/templates/admin/label.html b/app/server/templates/admin/label.html new file mode 100644 index 00000000..337e246f --- /dev/null +++ b/app/server/templates/admin/label.html @@ -0,0 +1,96 @@ +{% extends "admin/admin_base.html" %} {% load static %} {% block content-area %} +