Compare commits
1 commit
live
...
wip/lagert
Author | SHA1 | Date | |
---|---|---|---|
d2a38b8327 |
49 changed files with 354 additions and 1163 deletions
|
@ -1,35 +0,0 @@
|
||||||
name: Bug Report
|
|
||||||
about: File a bug report
|
|
||||||
labels:
|
|
||||||
- Kind/Bug
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Thanks for taking the time to fill out this bug report!
|
|
||||||
- type: textarea
|
|
||||||
id: what-happened
|
|
||||||
attributes:
|
|
||||||
label: What happened?
|
|
||||||
description: Also tell us, what did you expect to happen?
|
|
||||||
placeholder: Tell us what you see!
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: dropdown
|
|
||||||
id: browsers
|
|
||||||
attributes:
|
|
||||||
label: What browsers are you seeing the problem on?
|
|
||||||
multiple: true
|
|
||||||
options:
|
|
||||||
- Firefox (Windows)
|
|
||||||
- Firefox (MacOS)
|
|
||||||
- Firefox (Linux)
|
|
||||||
- Firefox (Android)
|
|
||||||
- Firefox (iOS)
|
|
||||||
- Chrome (Windows)
|
|
||||||
- Chrome (MacOS)
|
|
||||||
- Chrome (Linux)
|
|
||||||
- Chrome (Android)
|
|
||||||
- Chrome (iOS)
|
|
||||||
- Safari
|
|
||||||
- Microsoft Edge
|
|
|
@ -1,27 +0,0 @@
|
||||||
name: 'New Feature'
|
|
||||||
about: 'This template is for new features'
|
|
||||||
labels:
|
|
||||||
- Kind/Feature
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Before creating a Feature Ticket, please check for duplicates.
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
### Implementation Checklist
|
|
||||||
- [ ] concept
|
|
||||||
- [ ] frontend
|
|
||||||
- [ ] backend
|
|
||||||
- [ ] unittests
|
|
||||||
- [ ] tested on staging
|
|
||||||
visible: [ content ]
|
|
||||||
- type: textarea
|
|
||||||
id: description
|
|
||||||
attributes:
|
|
||||||
label: 'Feature Description'
|
|
||||||
description: 'Explain the the feature.'
|
|
||||||
placeholder: Description
|
|
||||||
validations:
|
|
||||||
required: true
|
|
|
@ -1,20 +0,0 @@
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: ghcr.io/catthehacker/ubuntu:act-22.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
cache-dependency-path: '**/requirements.dev.txt'
|
|
||||||
- name: Install dependencies
|
|
||||||
working-directory: core
|
|
||||||
run: pip3 install -r requirements.dev.txt
|
|
||||||
- name: Run django tests
|
|
||||||
working-directory: core
|
|
||||||
run: python3 manage.py test
|
|
|
@ -1,60 +0,0 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: ghcr.io/catthehacker/ubuntu:act-22.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
cache-dependency-path: '**/requirements.dev.txt'
|
|
||||||
- name: Install dependencies
|
|
||||||
working-directory: core
|
|
||||||
run: pip3 install -r requirements.dev.txt
|
|
||||||
- name: Run django tests
|
|
||||||
working-directory: core
|
|
||||||
run: python3 manage.py test
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
needs: [test]
|
|
||||||
runs-on: docker
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Install ansible
|
|
||||||
run: |
|
|
||||||
apt update -y
|
|
||||||
apt install python3-pip -y
|
|
||||||
python3 -m pip install ansible
|
|
||||||
python3 -m pip install ansible-lint
|
|
||||||
|
|
||||||
- name: Populate relevant files
|
|
||||||
run: |
|
|
||||||
mkdir ~/.ssh
|
|
||||||
echo "${{ secrets.C3LF_SSH_TESTING }}" > ~/.ssh/id_ed25519
|
|
||||||
chmod 0600 ~/.ssh/id_ed25519
|
|
||||||
ls -lah ~/.ssh
|
|
||||||
command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )
|
|
||||||
eval $(ssh-agent -s)
|
|
||||||
ssh-add ~/.ssh/id_ed25519
|
|
||||||
echo "andromeda.lab.or.it ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDXPoO0PE+B9PYwbGaLo98zhbmjAkp6eBtVeZe43v/+T" >> ~/.ssh/known_hosts
|
|
||||||
mkdir /etc/ansible
|
|
||||||
echo "${{ secrets.C3LF_INVENTORY_TESTING }}" > /etc/ansible/hosts
|
|
||||||
|
|
||||||
- name: Check ansible version
|
|
||||||
run: |
|
|
||||||
ansible --version
|
|
||||||
|
|
||||||
- name: List ansible hosts
|
|
||||||
run: |
|
|
||||||
ansible -m ping Andromeda
|
|
||||||
|
|
||||||
- name: Deploy testing
|
|
||||||
run: |
|
|
||||||
cd deploy/ansible
|
|
||||||
ansible-playbook playbooks/deploy-c3lf-sys3.yml
|
|
|
@ -1,14 +0,0 @@
|
||||||
[run]
|
|
||||||
source = .
|
|
||||||
|
|
||||||
[report]
|
|
||||||
fail_under = 100
|
|
||||||
show_missing = True
|
|
||||||
skip_covered = True
|
|
||||||
omit =
|
|
||||||
*/tests/*
|
|
||||||
*/migrations/*
|
|
||||||
core/asgi.py
|
|
||||||
core/wsgi.py
|
|
||||||
core/settings.py
|
|
||||||
manage.py
|
|
|
@ -10,4 +10,4 @@ RUN apt update && apt install -y mariadb-client
|
||||||
RUN pip install -r requirements.dev.txt
|
RUN pip install -r requirements.dev.txt
|
||||||
RUN pip install -r requirements.prod.txt
|
RUN pip install -r requirements.prod.txt
|
||||||
RUN pip install mysqlclient
|
RUN pip install mysqlclient
|
||||||
COPY .. /code/
|
COPY . /code/
|
|
@ -15,9 +15,6 @@ import sys
|
||||||
import dotenv
|
import dotenv
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
def truthy_str(s):
|
|
||||||
return s.lower() in ['true', '1', 't', 'y', 'yes', 'yeah', 'yup', 'certainly', 'sure', 'positive', 'uh-huh', '👍']
|
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
@ -27,10 +24,10 @@ dotenv.load_dotenv(BASE_DIR / '.env')
|
||||||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY', 'django-insecure-tm*$w_14iqbiy-!7(8#ba7j+_@(7@rf2&a^!=shs&$03b%2*rv')
|
SECRET_KEY = 'django-insecure-tm*$w_14iqbiy-!7(8#ba7j+_@(7@rf2&a^!=shs&$03b%2*rv'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = truthy_str(os.getenv('DEBUG_MODE_ACTIVE', 'False'))
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = [os.getenv('HTTP_HOST', 'localhost')]
|
ALLOWED_HOSTS = [os.getenv('HTTP_HOST', 'localhost')]
|
||||||
|
|
||||||
|
@ -43,8 +40,6 @@ LEGACY_USER_PASSWORD = os.getenv('LEGACY_API_PASSWORD', 'legacy_password')
|
||||||
|
|
||||||
SYSTEM3_VERSION = "0.0.0-dev.0"
|
SYSTEM3_VERSION = "0.0.0-dev.0"
|
||||||
|
|
||||||
ACTIVE_SPAM_TRAINING = truthy_str(os.getenv('ACTIVE_SPAM_TRAINING', 'False'))
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
@ -55,7 +50,6 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'django_extensions',
|
'django_extensions',
|
||||||
'django_prometheus',
|
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
'knox',
|
'knox',
|
||||||
'drf_yasg',
|
'drf_yasg',
|
||||||
|
@ -91,7 +85,6 @@ SWAGGER_SETTINGS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django_prometheus.middleware.PrometheusBeforeMiddleware',
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
@ -99,7 +92,6 @@ MIDDLEWARE = [
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
'django_prometheus.middleware.PrometheusAfterMiddleware',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'core.urls'
|
ROOT_URLCONF = 'core.urls'
|
||||||
|
@ -212,12 +204,10 @@ CHANNEL_LAYERS = {
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'channels_redis.core.RedisChannelLayer',
|
'BACKEND': 'channels_redis.core.RedisChannelLayer',
|
||||||
'CONFIG': {
|
'CONFIG': {
|
||||||
'hosts': [(os.getenv('REDIS_HOST', 'localhost'), 6379)],
|
'hosts': [('localhost', 6379)],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PROMETHEUS_METRIC_NAMESPACE = 'c3lf'
|
|
||||||
|
|
||||||
TEST_RUNNER = 'core.test_runner.FastTestRunner'
|
TEST_RUNNER = 'core.test_runner.FastTestRunner'
|
||||||
|
|
|
@ -32,5 +32,4 @@ urlpatterns = [
|
||||||
path('api/2/', include('notify_sessions.api_v2')),
|
path('api/2/', include('notify_sessions.api_v2')),
|
||||||
path('api/2/', include('authentication.api_v2')),
|
path('api/2/', include('authentication.api_v2')),
|
||||||
path('api/', get_info),
|
path('api/', get_info),
|
||||||
path('', include('django_prometheus.urls')),
|
|
||||||
]
|
]
|
||||||
|
|
16
core/core/wsgi.py
Normal file
16
core/core/wsgi.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
WSGI config for core project.
|
||||||
|
|
||||||
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
|
@ -3,21 +3,12 @@ from rest_framework import serializers
|
||||||
|
|
||||||
from files.models import File
|
from files.models import File
|
||||||
from inventory.models import Event, Container, Item
|
from inventory.models import Event, Container, Item
|
||||||
from mail.models import EventAddress
|
|
||||||
|
|
||||||
|
|
||||||
class EventAdressSerializer(serializers.ModelSerializer):
|
|
||||||
class Meta:
|
|
||||||
model = EventAddress
|
|
||||||
fields = ['address']
|
|
||||||
|
|
||||||
|
|
||||||
class EventSerializer(serializers.ModelSerializer):
|
class EventSerializer(serializers.ModelSerializer):
|
||||||
addresses = EventAdressSerializer(many=True, required=False)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Event
|
model = Event
|
||||||
fields = ['eid', 'slug', 'name', 'start', 'end', 'pre_start', 'post_end', 'addresses']
|
fields = ['eid', 'slug', 'name', 'start', 'end', 'pre_start', 'post_end']
|
||||||
read_only_fields = ['eid']
|
read_only_fields = ['eid']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,15 +54,3 @@ class EventTestCase(TestCase):
|
||||||
response = client.delete(f'/api/2/events/{event.eid}/')
|
response = client.delete(f'/api/2/events/{event.eid}/')
|
||||||
self.assertEqual(response.status_code, 204)
|
self.assertEqual(response.status_code, 204)
|
||||||
self.assertEqual(len(Event.objects.all()), 1)
|
self.assertEqual(len(Event.objects.all()), 1)
|
||||||
|
|
||||||
def test_items2(self):
|
|
||||||
from mail.models import EventAddress
|
|
||||||
event1 = Event.objects.create(slug='TEST1', name='Event')
|
|
||||||
EventAddress.objects.create(event=Event.objects.get(slug='TEST1'), address='foo@bar.baz')
|
|
||||||
response = self.client.get('/api/2/events/')
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
self.assertEqual(1, len(response.json()))
|
|
||||||
self.assertEqual('TEST1', response.json()[0]['slug'])
|
|
||||||
self.assertEqual('Event', response.json()[0]['name'])
|
|
||||||
self.assertEqual(1, len(response.json()[0]['addresses']))
|
|
||||||
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
# Generated by Django 4.2.7 on 2024-11-03 18:30
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('inventory', '0004_alter_event_created_at_alter_item_created_at'),
|
|
||||||
('mail', '0004_alter_emailattachment_file'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='eventaddress',
|
|
||||||
name='event',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='addresses', to='inventory.event'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,36 +0,0 @@
|
||||||
# Generated by Django 4.2.7 on 2024-11-08 20:37
|
|
||||||
from django.core.files.base import ContentFile
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [
|
|
||||||
('mail', '0005_alter_eventaddress_event'),
|
|
||||||
]
|
|
||||||
|
|
||||||
def move_raw_mails_to_file(apps, schema_editor):
|
|
||||||
Email = apps.get_model('mail', 'Email')
|
|
||||||
for email in Email.objects.all():
|
|
||||||
raw_content = email.raw
|
|
||||||
path = "mail_{}".format(email.id)
|
|
||||||
if len(raw_content):
|
|
||||||
email.raw_file.save(path, ContentFile(raw_content))
|
|
||||||
email.save()
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='email',
|
|
||||||
name='raw_file',
|
|
||||||
field=models.FileField(null=True, upload_to='raw_mail/'),
|
|
||||||
),
|
|
||||||
migrations.RunPython(move_raw_mails_to_file),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='email',
|
|
||||||
name='raw',
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='email',
|
|
||||||
name='raw_file',
|
|
||||||
field=models.FileField(upload_to='raw_mail/'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -3,7 +3,7 @@ import random
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django_softdelete.models import SoftDeleteModel
|
from django_softdelete.models import SoftDeleteModel
|
||||||
|
|
||||||
from core.settings import MAIL_DOMAIN, ACTIVE_SPAM_TRAINING
|
from core.settings import MAIL_DOMAIN
|
||||||
from files.models import AbstractFile
|
from files.models import AbstractFile
|
||||||
from inventory.models import Event
|
from inventory.models import Event
|
||||||
from tickets.models import IssueThread
|
from tickets.models import IssueThread
|
||||||
|
@ -18,7 +18,7 @@ class Email(SoftDeleteModel):
|
||||||
recipient = models.CharField(max_length=255)
|
recipient = models.CharField(max_length=255)
|
||||||
reference = models.CharField(max_length=255, null=True, unique=True)
|
reference = models.CharField(max_length=255, null=True, unique=True)
|
||||||
in_reply_to = models.CharField(max_length=255, null=True)
|
in_reply_to = models.CharField(max_length=255, null=True)
|
||||||
raw_file = models.FileField(upload_to='raw_mail/')
|
raw = models.TextField()
|
||||||
issue_thread = models.ForeignKey(IssueThread, models.SET_NULL, null=True, related_name='emails')
|
issue_thread = models.ForeignKey(IssueThread, models.SET_NULL, null=True, related_name='emails')
|
||||||
event = models.ForeignKey(Event, models.SET_NULL, null=True)
|
event = models.ForeignKey(Event, models.SET_NULL, null=True)
|
||||||
|
|
||||||
|
@ -28,22 +28,10 @@ class Email(SoftDeleteModel):
|
||||||
self.reference = f'<{random.randint(0, 1000000000):09}@{MAIL_DOMAIN}>'
|
self.reference = f'<{random.randint(0, 1000000000):09}@{MAIL_DOMAIN}>'
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def train_spam(self):
|
|
||||||
if ACTIVE_SPAM_TRAINING and self.raw_file.path:
|
|
||||||
import subprocess
|
|
||||||
path = self.raw_file.path
|
|
||||||
subprocess.run(["rspamc", "learn_spam", path])
|
|
||||||
|
|
||||||
def train_ham(self):
|
|
||||||
if ACTIVE_SPAM_TRAINING and self.raw_file.path:
|
|
||||||
import subprocess
|
|
||||||
path = self.raw_file.path
|
|
||||||
subprocess.run(["rspamc", "learn_ham", path])
|
|
||||||
|
|
||||||
|
|
||||||
class EventAddress(models.Model):
|
class EventAddress(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
event = models.ForeignKey(Event, models.SET_NULL, null=True, related_name='addresses')
|
event = models.ForeignKey(Event, models.SET_NULL, null=True)
|
||||||
address = models.CharField(max_length=255)
|
address = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import logging
|
import logging
|
||||||
from re import match
|
|
||||||
|
|
||||||
import aiosmtplib
|
import aiosmtplib
|
||||||
from channels.layers import get_channel_layer
|
from channels.layers import get_channel_layer
|
||||||
|
@ -11,10 +10,6 @@ from notify_sessions.models import SystemEvent
|
||||||
from tickets.models import IssueThread
|
from tickets.models import IssueThread
|
||||||
|
|
||||||
|
|
||||||
class SpecialMailException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def find_quoted_printable(s, marker):
|
def find_quoted_printable(s, marker):
|
||||||
positions = [i for i in range(len(s)) if s.lower().startswith('=?utf-8?' + marker + '?', i)]
|
positions = [i for i in range(len(s)) if s.lower().startswith('=?utf-8?' + marker + '?', i)]
|
||||||
for pos in positions:
|
for pos in positions:
|
||||||
|
@ -91,7 +86,7 @@ async def send_smtp(message):
|
||||||
await aiosmtplib.send(message, hostname="127.0.0.1", port=25, use_tls=False, start_tls=False)
|
await aiosmtplib.send(message, hostname="127.0.0.1", port=25, use_tls=False, start_tls=False)
|
||||||
|
|
||||||
|
|
||||||
def find_active_issue_thread(in_reply_to, address, subject, event):
|
def find_active_issue_thread(in_reply_to, address, subject):
|
||||||
from re import match
|
from re import match
|
||||||
uuid_match = match(r'^ticket\+([a-f0-9-]{36})@', address)
|
uuid_match = match(r'^ticket\+([a-f0-9-]{36})@', address)
|
||||||
if uuid_match:
|
if uuid_match:
|
||||||
|
@ -102,7 +97,7 @@ def find_active_issue_thread(in_reply_to, address, subject, event):
|
||||||
if reply_to.exists():
|
if reply_to.exists():
|
||||||
return reply_to.first().issue_thread, False
|
return reply_to.first().issue_thread, False
|
||||||
else:
|
else:
|
||||||
issue = IssueThread.objects.create(name=subject, event=event)
|
issue = IssueThread.objects.create(name=subject)
|
||||||
return issue, True
|
return issue, True
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,13 +180,13 @@ def receive_email(envelope, log=None):
|
||||||
header_in_reply_to = parsed.get('In-Reply-To')
|
header_in_reply_to = parsed.get('In-Reply-To')
|
||||||
header_message_id = parsed.get('Message-ID')
|
header_message_id = parsed.get('Message-ID')
|
||||||
|
|
||||||
if match(r'^([a-zA-Z ]*<)?MAILER-DAEMON@', header_from) and envelope.mail_from.strip("<>") == "":
|
if header_from != envelope.mail_from:
|
||||||
log.warning("Ignoring mailer daemon")
|
log.warning("Header from does not match envelope from")
|
||||||
raise SpecialMailException("Ignoring mailer daemon")
|
log.info(f"Header from: {header_from}, envelope from: {envelope.mail_from}")
|
||||||
|
|
||||||
if Email.objects.filter(reference=header_message_id).exists(): # break before issue thread is created
|
if header_to != envelope.rcpt_tos[0]:
|
||||||
log.warning("Email already exists")
|
log.warning("Header to does not match envelope to")
|
||||||
raise Exception("Email already exists")
|
log.info(f"Header to: {header_to}, envelope to: {envelope.rcpt_tos[0]}")
|
||||||
|
|
||||||
recipient = envelope.rcpt_tos[0].lower() if envelope.rcpt_tos else header_to.lower()
|
recipient = envelope.rcpt_tos[0].lower() if envelope.rcpt_tos else header_to.lower()
|
||||||
sender = envelope.mail_from if envelope.mail_from else header_from
|
sender = envelope.mail_from if envelope.mail_from else header_from
|
||||||
|
@ -202,14 +197,11 @@ def receive_email(envelope, log=None):
|
||||||
subject = unescape_and_decode_base64(subject)
|
subject = unescape_and_decode_base64(subject)
|
||||||
target_event = find_target_event(recipient)
|
target_event = find_target_event(recipient)
|
||||||
|
|
||||||
active_issue_thread, new = find_active_issue_thread(header_in_reply_to, recipient, subject, target_event)
|
active_issue_thread, new = find_active_issue_thread(header_in_reply_to, recipient, subject)
|
||||||
|
|
||||||
from hashlib import sha256
|
|
||||||
random_filename = 'mail-' + sha256(envelope.content).hexdigest()
|
|
||||||
|
|
||||||
email = Email.objects.create(
|
email = Email.objects.create(
|
||||||
sender=sender, recipient=recipient, body=body, subject=subject, reference=header_message_id,
|
sender=sender, recipient=recipient, body=body, subject=subject, reference=header_message_id,
|
||||||
in_reply_to=header_in_reply_to, raw_file=ContentFile(envelope.content, name=random_filename), event=target_event,
|
in_reply_to=header_in_reply_to, raw=envelope.content, event=target_event,
|
||||||
issue_thread=active_issue_thread)
|
issue_thread=active_issue_thread)
|
||||||
for attachment in attachments:
|
for attachment in attachments:
|
||||||
email.attachments.add(attachment)
|
email.attachments.add(attachment)
|
||||||
|
@ -241,7 +233,7 @@ Your c3lf (Cloakroom + Lost&Found) Team'''.format(active_issue_thread.short_uuid
|
||||||
active_issue_thread.state = 'pending_open'
|
active_issue_thread.state = 'pending_open'
|
||||||
active_issue_thread.save()
|
active_issue_thread.save()
|
||||||
|
|
||||||
return email, new, reply, active_issue_thread
|
return email, new, reply
|
||||||
|
|
||||||
|
|
||||||
class LMTPHandler:
|
class LMTPHandler:
|
||||||
|
@ -263,7 +255,7 @@ class LMTPHandler:
|
||||||
content = None
|
content = None
|
||||||
try:
|
try:
|
||||||
content = envelope.content
|
content = envelope.content
|
||||||
email, new, reply, thread = await receive_email(envelope, log)
|
email, new, reply = await receive_email(envelope, log)
|
||||||
log.info(f"Created email {email.id}")
|
log.info(f"Created email {email.id}")
|
||||||
systemevent = await database_sync_to_async(SystemEvent.objects.create)(type='email received',
|
systemevent = await database_sync_to_async(SystemEvent.objects.create)(type='email received',
|
||||||
reference=email.id)
|
reference=email.id)
|
||||||
|
@ -271,20 +263,14 @@ class LMTPHandler:
|
||||||
channel_layer = get_channel_layer()
|
channel_layer = get_channel_layer()
|
||||||
await channel_layer.group_send(
|
await channel_layer.group_send(
|
||||||
'general', {"type": "generic.event", "name": "send_message_to_frontend", "event_id": systemevent.id,
|
'general', {"type": "generic.event", "name": "send_message_to_frontend", "event_id": systemevent.id,
|
||||||
"message": "email received"})
|
"message": "email received"}
|
||||||
|
)
|
||||||
log.info(f"Sent message to frontend")
|
log.info(f"Sent message to frontend")
|
||||||
if new and reply:
|
if new and reply:
|
||||||
log.info('Sending message to %s' % reply['To'])
|
log.info('Sending message to %s' % reply['To'])
|
||||||
await send_smtp(reply)
|
await send_smtp(reply)
|
||||||
log.info("Sent auto reply")
|
log.info("Sent auto reply")
|
||||||
|
|
||||||
return '250 Message accepted for delivery'
|
|
||||||
except SpecialMailException as e:
|
|
||||||
import uuid
|
|
||||||
random_filename = 'special-' + str(uuid.uuid4())
|
|
||||||
with open(random_filename, 'wb') as f:
|
|
||||||
f.write(content)
|
|
||||||
log.warning(f"Special mail exception: {e} saved to {random_filename}")
|
|
||||||
return '250 Message accepted for delivery'
|
return '250 Message accepted for delivery'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
|
|
|
@ -142,7 +142,6 @@ class LMTPHandlerTestCase(TestCase): # TODO replace with less hacky test
|
||||||
aiosmtplib.send.assert_called_once()
|
aiosmtplib.send.assert_called_once()
|
||||||
self.assertEqual('test ä', Email.objects.all()[0].subject)
|
self.assertEqual('test ä', Email.objects.all()[0].subject)
|
||||||
self.assertEqual('Text mit Quoted-Printable-Kodierung: äöüß', Email.objects.all()[0].body)
|
self.assertEqual('Text mit Quoted-Printable-Kodierung: äöüß', Email.objects.all()[0].body)
|
||||||
self.assertTrue( Email.objects.all()[0].raw_file.path)
|
|
||||||
|
|
||||||
def test_handle_quoted_printable_2(self):
|
def test_handle_quoted_printable_2(self):
|
||||||
from aiosmtpd.smtp import Envelope
|
from aiosmtpd.smtp import Envelope
|
||||||
|
@ -163,7 +162,6 @@ class LMTPHandlerTestCase(TestCase): # TODO replace with less hacky test
|
||||||
aiosmtplib.send.assert_called_once()
|
aiosmtplib.send.assert_called_once()
|
||||||
self.assertEqual('suche_Mütze', Email.objects.all()[0].subject)
|
self.assertEqual('suche_Mütze', Email.objects.all()[0].subject)
|
||||||
self.assertEqual('Text mit Quoted-Printable-Kodierung: äöüß', Email.objects.all()[0].body)
|
self.assertEqual('Text mit Quoted-Printable-Kodierung: äöüß', Email.objects.all()[0].body)
|
||||||
self.assertTrue( Email.objects.all()[0].raw_file.path)
|
|
||||||
|
|
||||||
def test_handle_base64(self):
|
def test_handle_base64(self):
|
||||||
from aiosmtpd.smtp import Envelope
|
from aiosmtpd.smtp import Envelope
|
||||||
|
@ -184,7 +182,6 @@ class LMTPHandlerTestCase(TestCase): # TODO replace with less hacky test
|
||||||
aiosmtplib.send.assert_called_once()
|
aiosmtplib.send.assert_called_once()
|
||||||
self.assertEqual('test', Email.objects.all()[0].subject)
|
self.assertEqual('test', Email.objects.all()[0].subject)
|
||||||
self.assertEqual('Text mit Base64-Kodierung: äöüß', Email.objects.all()[0].body)
|
self.assertEqual('Text mit Base64-Kodierung: äöüß', Email.objects.all()[0].body)
|
||||||
self.assertTrue( Email.objects.all()[0].raw_file.path)
|
|
||||||
|
|
||||||
def test_handle_client_reply(self):
|
def test_handle_client_reply(self):
|
||||||
issue_thread = IssueThread.objects.create(
|
issue_thread = IssueThread.objects.create(
|
||||||
|
@ -232,7 +229,6 @@ class LMTPHandlerTestCase(TestCase): # TODO replace with less hacky test
|
||||||
self.assertEqual(IssueThread.objects.all()[0].name, 'test')
|
self.assertEqual(IssueThread.objects.all()[0].name, 'test')
|
||||||
self.assertEqual(IssueThread.objects.all()[0].state, 'pending_new')
|
self.assertEqual(IssueThread.objects.all()[0].state, 'pending_new')
|
||||||
self.assertEqual(IssueThread.objects.all()[0].assigned_to, None)
|
self.assertEqual(IssueThread.objects.all()[0].assigned_to, None)
|
||||||
self.assertTrue( Email.objects.all()[2].raw_file.path)
|
|
||||||
|
|
||||||
def test_handle_client_reply_2(self):
|
def test_handle_client_reply_2(self):
|
||||||
issue_thread = IssueThread.objects.create(
|
issue_thread = IssueThread.objects.create(
|
||||||
|
@ -285,7 +281,6 @@ class LMTPHandlerTestCase(TestCase): # TODO replace with less hacky test
|
||||||
self.assertEqual(IssueThread.objects.all()[0].name, 'test')
|
self.assertEqual(IssueThread.objects.all()[0].name, 'test')
|
||||||
self.assertEqual(IssueThread.objects.all()[0].state, 'pending_open')
|
self.assertEqual(IssueThread.objects.all()[0].state, 'pending_open')
|
||||||
self.assertEqual(IssueThread.objects.all()[0].assigned_to, None)
|
self.assertEqual(IssueThread.objects.all()[0].assigned_to, None)
|
||||||
self.assertTrue( Email.objects.all()[2].raw_file.path)
|
|
||||||
|
|
||||||
def test_mail_reply(self):
|
def test_mail_reply(self):
|
||||||
issue_thread = IssueThread.objects.create(
|
issue_thread = IssueThread.objects.create(
|
||||||
|
@ -389,7 +384,6 @@ class LMTPHandlerTestCase(TestCase): # TODO replace with less hacky test
|
||||||
states = StateChange.objects.filter(issue_thread=IssueThread.objects.all()[0])
|
states = StateChange.objects.filter(issue_thread=IssueThread.objects.all()[0])
|
||||||
self.assertEqual(1, len(states))
|
self.assertEqual(1, len(states))
|
||||||
self.assertEqual('pending_new', states[0].state)
|
self.assertEqual('pending_new', states[0].state)
|
||||||
self.assertEqual(event, IssueThread.objects.all()[0].event)
|
|
||||||
|
|
||||||
def test_mail_html_body(self):
|
def test_mail_html_body(self):
|
||||||
from aiosmtpd.smtp import Envelope
|
from aiosmtpd.smtp import Envelope
|
||||||
|
@ -766,6 +760,7 @@ dGVzdGltYWdl
|
||||||
response = self.client.post(f'/api/2/tickets/{issue_thread.id}/reply/', {
|
response = self.client.post(f'/api/2/tickets/{issue_thread.id}/reply/', {
|
||||||
'message': 'test'
|
'message': 'test'
|
||||||
})
|
})
|
||||||
|
aiosmtplib.send.assert_called_once()
|
||||||
self.assertEqual(response.status_code, 201)
|
self.assertEqual(response.status_code, 201)
|
||||||
self.assertEqual(5, len(Email.objects.all()))
|
self.assertEqual(5, len(Email.objects.all()))
|
||||||
self.assertEqual(5, len(Email.objects.filter(issue_thread=issue_thread)))
|
self.assertEqual(5, len(Email.objects.filter(issue_thread=issue_thread)))
|
||||||
|
@ -781,7 +776,6 @@ dGVzdGltYWdl
|
||||||
self.assertEqual('test subject', IssueThread.objects.all()[0].name)
|
self.assertEqual('test subject', IssueThread.objects.all()[0].name)
|
||||||
self.assertEqual('pending_new', IssueThread.objects.all()[0].state)
|
self.assertEqual('pending_new', IssueThread.objects.all()[0].state)
|
||||||
self.assertEqual(None, IssueThread.objects.all()[0].assigned_to)
|
self.assertEqual(None, IssueThread.objects.all()[0].assigned_to)
|
||||||
aiosmtplib.send.assert_called_once()
|
|
||||||
|
|
||||||
def test_mail_4byte_unicode_emoji(self):
|
def test_mail_4byte_unicode_emoji(self):
|
||||||
from aiosmtpd.smtp import Envelope
|
from aiosmtpd.smtp import Envelope
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
aiodns==3.2.0
|
|
||||||
aiohttp==3.9.5
|
|
||||||
aiosignal==1.3.1
|
|
||||||
aiosmtpd==1.4.4.post2
|
aiosmtpd==1.4.4.post2
|
||||||
aiosmtplib==3.0.1
|
aiosmtplib==3.0.1
|
||||||
anyio==4.1.0
|
anyio==4.1.0
|
||||||
|
@ -31,7 +28,6 @@ django-rest-knox==4.2.0
|
||||||
django-soft-delete==0.9.21
|
django-soft-delete==0.9.21
|
||||||
djangorestframework==3.14.0
|
djangorestframework==3.14.0
|
||||||
drf-yasg==1.21.7
|
drf-yasg==1.21.7
|
||||||
frozenlist==1.4.1
|
|
||||||
h11==0.14.0
|
h11==0.14.0
|
||||||
hyperlink==21.0.0
|
hyperlink==21.0.0
|
||||||
idna==3.4
|
idna==3.4
|
||||||
|
@ -42,13 +38,11 @@ Jinja2==3.1.2
|
||||||
MarkupSafe==2.1.3
|
MarkupSafe==2.1.3
|
||||||
msgpack==1.0.7
|
msgpack==1.0.7
|
||||||
msgpack-python==0.5.6
|
msgpack-python==0.5.6
|
||||||
multidict==6.0.5
|
|
||||||
openapi-codec==1.3.2
|
openapi-codec==1.3.2
|
||||||
packaging==23.2
|
packaging==23.2
|
||||||
Pillow==10.1.0
|
Pillow==10.1.0
|
||||||
pyasn1==0.5.1
|
pyasn1==0.5.1
|
||||||
pyasn1-modules==0.3.0
|
pyasn1-modules==0.3.0
|
||||||
pycares==4.4.0
|
|
||||||
pycparser==2.21
|
pycparser==2.21
|
||||||
pyOpenSSL==23.3.0
|
pyOpenSSL==23.3.0
|
||||||
python-dotenv==1.0.0
|
python-dotenv==1.0.0
|
||||||
|
@ -71,7 +65,4 @@ urllib3==2.1.0
|
||||||
uvicorn==0.24.0.post1
|
uvicorn==0.24.0.post1
|
||||||
watchfiles==0.21.0
|
watchfiles==0.21.0
|
||||||
websockets==12.0
|
websockets==12.0
|
||||||
yarl==1.9.4
|
|
||||||
zope.interface==6.1
|
zope.interface==6.1
|
||||||
django-prometheus==2.3.1
|
|
||||||
prometheus_client==0.21.0
|
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
aiodns==3.2.0
|
|
||||||
aiohttp==3.9.5
|
|
||||||
aiosignal==1.3.1
|
|
||||||
aiosmtpd==1.4.4.post2
|
aiosmtpd==1.4.4.post2
|
||||||
aiosmtplib==3.0.1
|
aiosmtplib==3.0.1
|
||||||
asgiref==3.7.2
|
asgiref==3.7.2
|
||||||
|
@ -41,5 +38,3 @@ urllib3==2.1.0
|
||||||
uvicorn==0.24.0.post1
|
uvicorn==0.24.0.post1
|
||||||
watchfiles==0.21.0
|
watchfiles==0.21.0
|
||||||
websockets==12.0
|
websockets==12.0
|
||||||
django-prometheus==2.3.1
|
|
||||||
prometheus_client==0.21.0
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ from asgiref.sync import async_to_sync
|
||||||
from channels.layers import get_channel_layer
|
from channels.layers import get_channel_layer
|
||||||
|
|
||||||
from core.settings import MAIL_DOMAIN
|
from core.settings import MAIL_DOMAIN
|
||||||
from inventory.models import Event
|
|
||||||
from mail.models import Email
|
from mail.models import Email
|
||||||
from mail.protocol import send_smtp, make_reply, collect_references
|
from mail.protocol import send_smtp, make_reply, collect_references
|
||||||
from notify_sessions.models import SystemEvent
|
from notify_sessions.models import SystemEvent
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
# Generated by Django 4.2.7 on 2024-06-23 02:17
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [
|
|
||||||
('mail', '0006_email_raw_file'),
|
|
||||||
('tickets', '0010_issuethread_event_itemrelation_and_more'),
|
|
||||||
]
|
|
||||||
|
|
||||||
def train_old_mails(apps, schema_editor):
|
|
||||||
from tickets.models import IssueThread
|
|
||||||
for t in IssueThread.objects.all():
|
|
||||||
try:
|
|
||||||
state = t.state
|
|
||||||
i = 0
|
|
||||||
for e in t.emails.all():
|
|
||||||
if e.raw_file:
|
|
||||||
if state == 'closed_spam' and i == 0:
|
|
||||||
e.train_spam()
|
|
||||||
else:
|
|
||||||
e.train_ham()
|
|
||||||
i += 1
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(train_old_mails),
|
|
||||||
]
|
|
|
@ -60,8 +60,6 @@ class IssueThread(SoftDeleteModel):
|
||||||
if self.state == value:
|
if self.state == value:
|
||||||
return
|
return
|
||||||
self.state_changes.create(state=value)
|
self.state_changes.create(state=value)
|
||||||
if value == 'closed_spam' and self.emails.exists():
|
|
||||||
self.emails.first().train_spam()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def assigned_to(self):
|
def assigned_to(self):
|
||||||
|
|
|
@ -11,6 +11,4 @@ c3lf-nodes:
|
||||||
mail_domain: <mail_domain>
|
mail_domain: <mail_domain>
|
||||||
main_email: <main_email>
|
main_email: <main_email>
|
||||||
legacy_api_user: <legacy_api_user>
|
legacy_api_user: <legacy_api_user>
|
||||||
legacy_api_password: <legacy_api_password>
|
legacy_api_password: <legacy_api_password>
|
||||||
debug_mode_active: false
|
|
||||||
django_secret_key: 'django-insecure-tm*$w_14iqbiy-!7(8#ba7j+_@(7@rf2&a^!=shs&$03b%2*rv'
|
|
|
@ -1,4 +1,3 @@
|
||||||
REDIS_HOST=localhost
|
|
||||||
DB_HOST=localhost
|
DB_HOST=localhost
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
DB_NAME=c3lf_sys3
|
DB_NAME=c3lf_sys3
|
||||||
|
@ -10,6 +9,3 @@ LEGACY_API_USER={{ legacy_api_user }}
|
||||||
LEGACY_API_PASSWORD={{ legacy_api_password }}
|
LEGACY_API_PASSWORD={{ legacy_api_password }}
|
||||||
MEDIA_ROOT=/var/www/c3lf-sys3/userfiles
|
MEDIA_ROOT=/var/www/c3lf-sys3/userfiles
|
||||||
STATIC_ROOT=/var/www/c3lf-sys3/staticfiles
|
STATIC_ROOT=/var/www/c3lf-sys3/staticfiles
|
||||||
ACTIVE_SPAM_TRAINING=True
|
|
||||||
DEBUG_MODE_ACTIVE={{ debug_mode_active }}
|
|
||||||
DJANGO_SECRET_KEY={{ django_secret_key }}
|
|
||||||
|
|
|
@ -70,13 +70,6 @@ server {
|
||||||
alias /var/www/c3lf-sys3/staticfiles/;
|
alias /var/www/c3lf-sys3/staticfiles/;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /metrics {
|
|
||||||
allow 95.156.226.90;
|
|
||||||
allow 127.0.0.1;
|
|
||||||
allow ::1;
|
|
||||||
deny all;
|
|
||||||
}
|
|
||||||
|
|
||||||
listen 443 ssl http2; # managed by Certbot
|
listen 443 ssl http2; # managed by Certbot
|
||||||
ssl_certificate /etc/letsencrypt/live/{{ web_domain }}/fullchain.pem; # managed by Certbot
|
ssl_certificate /etc/letsencrypt/live/{{ web_domain }}/fullchain.pem; # managed by Certbot
|
||||||
ssl_certificate_key /etc/letsencrypt/live/{{ web_domain }}/privkey.pem; # managed by Certbot
|
ssl_certificate_key /etc/letsencrypt/live/{{ web_domain }}/privkey.pem; # managed by Certbot
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
services:
|
|
||||||
core:
|
|
||||||
build:
|
|
||||||
context: ../../core
|
|
||||||
dockerfile: ../deploy/dev/Dockerfile.backend
|
|
||||||
command: bash -c 'python manage.py migrate && python manage.py runserver 0.0.0.0:8000'
|
|
||||||
environment:
|
|
||||||
- HTTP_HOST=core
|
|
||||||
- DB_HOST=db
|
|
||||||
- DB_PORT=3306
|
|
||||||
- DB_NAME=system3
|
|
||||||
- DB_USER=system3
|
|
||||||
- DB_PASSWORD=system3
|
|
||||||
volumes:
|
|
||||||
- ../../core:/code
|
|
||||||
ports:
|
|
||||||
- "8000:8000"
|
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
|
|
||||||
frontend:
|
|
||||||
build:
|
|
||||||
context: ../../web
|
|
||||||
dockerfile: ../deploy/dev/Dockerfile.frontend
|
|
||||||
command: npm run serve
|
|
||||||
volumes:
|
|
||||||
- ../../web:/web:ro
|
|
||||||
- /web/node_modules
|
|
||||||
- ./vue.config.js:/web/vue.config.js
|
|
||||||
ports:
|
|
||||||
- "8080:8080"
|
|
||||||
depends_on:
|
|
||||||
- core
|
|
||||||
|
|
||||||
db:
|
|
||||||
image: mariadb
|
|
||||||
environment:
|
|
||||||
MARIADB_RANDOM_ROOT_PASSWORD: true
|
|
||||||
MARIADB_DATABASE: system3
|
|
||||||
MARIADB_USER: system3
|
|
||||||
MARIADB_PASSWORD: system3
|
|
||||||
volumes:
|
|
||||||
- mariadb_data:/var/lib/mysql
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
mariadb_data:
|
|
|
@ -1,27 +0,0 @@
|
||||||
// vue.config.js
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
devServer: {
|
|
||||||
headers: {
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
"Access-Control-Allow-Headers": "*",
|
|
||||||
"Access-Control-Allow-Methods": "*"
|
|
||||||
},
|
|
||||||
proxy: {
|
|
||||||
'^/media/2': {
|
|
||||||
target: 'http://core:8000/',
|
|
||||||
},
|
|
||||||
'^/api/2': {
|
|
||||||
target: 'http://core:8000/',
|
|
||||||
},
|
|
||||||
'^/api/1': {
|
|
||||||
target: 'http://core:8000/',
|
|
||||||
},
|
|
||||||
'^/ws/2': {
|
|
||||||
target: 'http://core:8000/',
|
|
||||||
ws: true,
|
|
||||||
logLevel: 'debug',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
FROM python:3.11-bookworm
|
|
||||||
LABEL authors="lagertonne"
|
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
|
||||||
RUN mkdir /code
|
|
||||||
WORKDIR /code
|
|
||||||
COPY requirements.prod.txt /code/
|
|
||||||
RUN apt update && apt install -y mariadb-client
|
|
||||||
RUN pip install -r requirements.prod.txt
|
|
||||||
RUN pip install mysqlclient
|
|
||||||
COPY .. /code/
|
|
|
@ -1,6 +0,0 @@
|
||||||
FROM docker.io/node:22
|
|
||||||
|
|
||||||
RUN mkdir /web
|
|
||||||
WORKDIR /web
|
|
||||||
COPY package.json /web/
|
|
||||||
RUN npm install
|
|
|
@ -1,55 +0,0 @@
|
||||||
services:
|
|
||||||
redis:
|
|
||||||
image: redis
|
|
||||||
ports:
|
|
||||||
- "6379:6379"
|
|
||||||
|
|
||||||
db:
|
|
||||||
image: mariadb
|
|
||||||
environment:
|
|
||||||
MARIADB_RANDOM_ROOT_PASSWORD: true
|
|
||||||
MARIADB_DATABASE: system3
|
|
||||||
MARIADB_USER: system3
|
|
||||||
MARIADB_PASSWORD: system3
|
|
||||||
volumes:
|
|
||||||
- mariadb_data:/var/lib/mysql
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
|
|
||||||
core:
|
|
||||||
build:
|
|
||||||
context: ../../core
|
|
||||||
dockerfile: ../deploy/testing/Dockerfile.backend
|
|
||||||
command: bash -c 'python manage.py migrate && python /code/server.py'
|
|
||||||
environment:
|
|
||||||
- HTTP_HOST=core
|
|
||||||
- REDIS_HOST=redis
|
|
||||||
- DB_HOST=db
|
|
||||||
- DB_PORT=3306
|
|
||||||
- DB_NAME=system3
|
|
||||||
- DB_USER=system3
|
|
||||||
- DB_PASSWORD=system3
|
|
||||||
volumes:
|
|
||||||
- ../../core:/code
|
|
||||||
ports:
|
|
||||||
- "8000:8000"
|
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
- redis
|
|
||||||
|
|
||||||
frontend:
|
|
||||||
build:
|
|
||||||
context: ../../web
|
|
||||||
dockerfile: ../deploy/testing/Dockerfile.frontend
|
|
||||||
command: npm run serve
|
|
||||||
volumes:
|
|
||||||
- ../../web:/web:ro
|
|
||||||
- /web/node_modules
|
|
||||||
- ./vue.config.js:/web/vue.config.js
|
|
||||||
ports:
|
|
||||||
- "8080:8080"
|
|
||||||
depends_on:
|
|
||||||
- core
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
mariadb_data:
|
|
|
@ -1,27 +0,0 @@
|
||||||
// vue.config.js
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
devServer: {
|
|
||||||
headers: {
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
"Access-Control-Allow-Headers": "*",
|
|
||||||
"Access-Control-Allow-Methods": "*"
|
|
||||||
},
|
|
||||||
proxy: {
|
|
||||||
'^/media/2': {
|
|
||||||
target: 'http://core:8000/',
|
|
||||||
},
|
|
||||||
'^/api/2': {
|
|
||||||
target: 'http://core:8000/',
|
|
||||||
},
|
|
||||||
'^/api/1': {
|
|
||||||
target: 'http://core:8000/',
|
|
||||||
},
|
|
||||||
'^/ws/2': {
|
|
||||||
target: 'http://core:8000/',
|
|
||||||
ws: true,
|
|
||||||
logLevel: 'debug',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
31
docker-compose.dev.yml
Normal file
31
docker-compose.dev.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
services:
|
||||||
|
core:
|
||||||
|
build:
|
||||||
|
context: ./core
|
||||||
|
dockerfile: Dockerfile.dev
|
||||||
|
command: python manage.py runserver 0.0.0.0:8000
|
||||||
|
#environment:
|
||||||
|
# - DATABASE_URL
|
||||||
|
volumes:
|
||||||
|
- ./core:/code
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: ./web
|
||||||
|
dockerfile: Dockerfile.dev
|
||||||
|
command: npm run serve
|
||||||
|
volumes:
|
||||||
|
- ./web:/web:ro
|
||||||
|
- /web/node_modules
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mariadb
|
||||||
|
environment:
|
||||||
|
MARIADB_RANDOM_ROOT_PASSWORD: true
|
||||||
|
MARIADB_DATABASE: system3
|
||||||
|
MARIADB_USER: system3
|
||||||
|
MARIADB_PASSWORD: system3
|
|
@ -1,11 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div style="min-height: 100vh; display: flex; flex-direction: column;">
|
<div id="app">
|
||||||
<AddItemModal v-if="addItemModalOpen && isLoggedIn" @close="closeAddItemModal()" isModal="true"/>
|
<AddItemModal v-if="addItemModalOpen && isLoggedIn" @close="closeAddItemModal()" isModal="true"/>
|
||||||
<AddTicketModal v-if="addTicketModalOpen && isLoggedIn" @close="closeAddTicketModal()" isModal="true"/>
|
<AddTicketModal v-if="addTicketModalOpen && isLoggedIn" @close="closeAddTicketModal()" isModal="true"/>
|
||||||
<AddBoxModal v-if="showAddBoxModal && isLoggedIn" @close="closeAddBoxModal()" isModal="true"/>
|
<AddBoxModal v-if="showAddBoxModal && isLoggedIn" @close="closeAddBoxModal()" isModal="true"/>
|
||||||
<AddEventModal v-if="showAddEventModal && isLoggedIn" @close="closeAddEventModal()" isModal="true"/>
|
|
||||||
<Navbar v-if="isLoggedIn" @addItemClicked="openAddItemModal()" @addTicketClicked="openAddTicketModal()"/>
|
<Navbar v-if="isLoggedIn" @addItemClicked="openAddItemModal()" @addTicketClicked="openAddTicketModal()"/>
|
||||||
<router-view style="flex: 1 1;"/>
|
<router-view/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -15,13 +14,12 @@ import AddItemModal from '@/components/AddItemModal';
|
||||||
import {mapState, mapMutations, mapActions, mapGetters} from 'vuex';
|
import {mapState, mapMutations, mapActions, mapGetters} from 'vuex';
|
||||||
import AddTicketModal from "@/components/AddTicketModal.vue";
|
import AddTicketModal from "@/components/AddTicketModal.vue";
|
||||||
import AddBoxModal from "@/components/AddBoxModal.vue";
|
import AddBoxModal from "@/components/AddBoxModal.vue";
|
||||||
import AddEventModal from "@/components/AddEventModal.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'app',
|
name: 'app',
|
||||||
components: {AddBoxModal, AddEventModal, Navbar, AddItemModal, AddTicketModal},
|
components: {AddBoxModal, Navbar, AddItemModal, AddTicketModal},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['loadedItems', 'layout', 'toasts', 'showAddBoxModal', 'showAddEventModal']),
|
...mapState(['loadedItems', 'layout', 'toasts', 'showAddBoxModal']),
|
||||||
...mapGetters(['isLoggedIn']),
|
...mapGetters(['isLoggedIn']),
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
|
@ -29,7 +27,7 @@ export default {
|
||||||
addTicketModalOpen: false
|
addTicketModalOpen: false
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['removeToast', 'createToast', 'closeAddBoxModal', 'openAddBoxModal', 'closeAddEventModal']),
|
...mapMutations(['removeToast', 'createToast', 'closeAddBoxModal', 'openAddBoxModal']),
|
||||||
...mapActions(['loadEvents', 'scheduleAfterInit']),
|
...mapActions(['loadEvents', 'scheduleAfterInit']),
|
||||||
openAddItemModal() {
|
openAddItemModal() {
|
||||||
this.addItemModalOpen = true;
|
this.addItemModalOpen = true;
|
||||||
|
|
|
@ -1,86 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<Modal v-if="isModal" title="Add Event" @close="$emit('close')">
|
|
||||||
<template #body>
|
|
||||||
<div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col">
|
|
||||||
<input type="text" class="form-control" placeholder="Event Title"
|
|
||||||
v-model="data.name">
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input type="text" class="form-control" placeholder="Event Slug" v-model="data.slug">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<input type="date" class="form-control" title="Buildup Start" v-model="data.pre_start"
|
|
||||||
:max="data.start" @focus="prepare_date_field">
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input type="date" class="form-control" title="Official Event Start" v-model="data.start"
|
|
||||||
:min="data.pre_start" :max="data.end" @focus="prepare_date_field">
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input type="date" class="form-control" title="Official Event End" v-model="data.end"
|
|
||||||
:min="data.start" :max="data.post_end" @focus="prepare_date_field">
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input type="date" class="form-control" title="Teardown End" v-model="data.post_end"
|
|
||||||
:min="data.end" @focus="prepare_date_field">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<small>The buildup and teardown dates only relate to the timeframe in which the c3lf team is
|
|
||||||
present.</small>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template #buttons>
|
|
||||||
<button type="button" class="btn btn-secondary" @click="$emit('close')">Cancel</button>
|
|
||||||
<button type="button" class="btn btn-success" @click="createEvent(data).then(()=>$emit('close'))">
|
|
||||||
Create
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Modal from '@/components/Modal';
|
|
||||||
import {mapActions} from "vuex";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'AddEventModal',
|
|
||||||
components: {Modal},
|
|
||||||
props: ['isModal'],
|
|
||||||
data: () => ({
|
|
||||||
data: {
|
|
||||||
name: '',
|
|
||||||
slug: '',
|
|
||||||
start: null,
|
|
||||||
end: null,
|
|
||||||
pre_start: null,
|
|
||||||
post_end: null,
|
|
||||||
},
|
|
||||||
errors: {},
|
|
||||||
}),
|
|
||||||
methods: {
|
|
||||||
...mapActions(['createEvent']),
|
|
||||||
validate_data() {
|
|
||||||
return this.pre_start <= this.start && this.start <= this.end && this.end <= this.post_end && !!this.slug && !!this.name;
|
|
||||||
},
|
|
||||||
prepare_date_field(e) {
|
|
||||||
if (!e.target.value) {
|
|
||||||
if (e.target.min) {
|
|
||||||
e.target.value = e.target.min
|
|
||||||
} else if (e.target.max) {
|
|
||||||
e.target.value = e.target.max
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
|
@ -1,133 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="async-wrapper" :class="{ 'loaded': loaded }">
|
|
||||||
<div class="deferred">
|
|
||||||
<slot></slot>
|
|
||||||
</div>
|
|
||||||
<div class="loader-wrapper">
|
|
||||||
<div class="loader-ellipsis">
|
|
||||||
<div></div>
|
|
||||||
<div></div>
|
|
||||||
<div></div>
|
|
||||||
<div></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'AsyncLoader',
|
|
||||||
props: {
|
|
||||||
loaded: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.async-wrapper {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper > .deferred {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper.loaded > .deferred {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper > .loader-wrapper {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper > .loader-wrapper > .loader-ellipsis {
|
|
||||||
color: #17a2b8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper.loaded > .loader-wrapper {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.async-wrapper > .loader-wrapper > .loader-ellipsis,
|
|
||||||
.async-wrapper > .loader-wrapper > .loader-ellipsis div {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper > .loader-wrapper > .loader-ellipsis {
|
|
||||||
display: inline-block;
|
|
||||||
position: relative;
|
|
||||||
width: 80px;
|
|
||||||
height: 80px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper > .loader-wrapper > .loader-ellipsis div {
|
|
||||||
position: absolute;
|
|
||||||
top: 33.33333px;
|
|
||||||
width: 13.33333px;
|
|
||||||
height: 13.33333px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: currentColor;
|
|
||||||
animation-timing-function: cubic-bezier(0, 1, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper > .loader-wrapper > .loader-ellipsis div:nth-child(1) {
|
|
||||||
left: 8px;
|
|
||||||
animation: loader-ellipsis1 0.6s infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper > .loader-wrapper > .loader-ellipsis div:nth-child(2) {
|
|
||||||
left: 8px;
|
|
||||||
animation: loader-ellipsis2 0.6s infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper > .loader-wrapper > .loader-ellipsis div:nth-child(3) {
|
|
||||||
left: 32px;
|
|
||||||
animation: loader-ellipsis2 0.6s infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.async-wrapper > .loader-wrapper > .loader-ellipsis div:nth-child(4) {
|
|
||||||
left: 56px;
|
|
||||||
animation: loader-ellipsis3 0.6s infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes loader-ellipsis1 {
|
|
||||||
0% {
|
|
||||||
transform: scale(0);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: scale(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes loader-ellipsis3 {
|
|
||||||
0% {
|
|
||||||
transform: scale(1);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: scale(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes loader-ellipsis2 {
|
|
||||||
0% {
|
|
||||||
transform: translate(0, 0);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: translate(24px, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -29,7 +29,16 @@
|
||||||
</router-link>
|
</router-link>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<SearchBox v-if="hasPermissions" class="mt-1 my-lg-auto my-xl-auto w-100 d-inline mr-1"/>
|
<form class="form-inline mt-1 my-lg-auto my-xl-auto w-100 d-inline mr-1" v-if="hasPermissions">
|
||||||
|
<input
|
||||||
|
class="form-control w-100"
|
||||||
|
type="search"
|
||||||
|
placeholder="Search"
|
||||||
|
aria-label="Search"
|
||||||
|
@input="searchEventItems($event.target.value)"
|
||||||
|
disabled
|
||||||
|
>
|
||||||
|
</form>
|
||||||
<div class="custom-control-inline mr-1" v-if="hasPermissions">
|
<div class="custom-control-inline mr-1" v-if="hasPermissions">
|
||||||
<div class="btn-group btn-group-toggle mr-1" v-if="isItemView()">
|
<div class="btn-group btn-group-toggle mr-1" v-if="isItemView()">
|
||||||
<button :class="['btn', 'btn-info', { active: layout === 'cards' }]" @click="setLayout('cards')">
|
<button :class="['btn', 'btn-info', { active: layout === 'cards' }]" @click="setLayout('cards')">
|
||||||
|
@ -94,13 +103,9 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapState, mapActions, mapMutations, mapGetters} from 'vuex';
|
import {mapState, mapActions, mapMutations, mapGetters} from 'vuex';
|
||||||
import SearchBox from "@/components/inputs/SearchBox.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Navbar',
|
name: 'Navbar',
|
||||||
components: {
|
|
||||||
SearchBox
|
|
||||||
},
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
views: [
|
views: [
|
||||||
{'title': 'items', 'path': 'items'},
|
{'title': 'items', 'path': 'items'},
|
||||||
|
@ -117,7 +122,7 @@ export default {
|
||||||
...mapGetters(['getEventSlug', 'getActiveView', "checkPermission", "hasPermissions", "layout", "route"]),
|
...mapGetters(['getEventSlug', 'getActiveView', "checkPermission", "hasPermissions", "layout", "route"]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['changeEvent', 'changeView']),
|
...mapActions(['changeEvent', 'changeView', 'searchEventItems']),
|
||||||
...mapMutations(['logout']),
|
...mapMutations(['logout']),
|
||||||
navigateTo(link) {
|
navigateTo(link) {
|
||||||
if (this.route.path !== link)
|
if (this.route.path !== link)
|
||||||
|
|
|
@ -40,10 +40,10 @@
|
||||||
<div class="">
|
<div class="">
|
||||||
<textarea placeholder="add comment..." v-model="newComment" class="form-control">
|
<textarea placeholder="add comment..." v-model="newComment" class="form-control">
|
||||||
</textarea>
|
</textarea>
|
||||||
<AsyncButton class="btn btn-primary float-right" :task="addCommentAndClear">
|
<button class="btn btn-primary float-right" @click="addCommentAndClear">
|
||||||
<font-awesome-icon icon="comment"/>
|
<font-awesome-icon icon="comment"/>
|
||||||
Save Comment
|
Save Comment
|
||||||
</AsyncButton>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -58,10 +58,10 @@
|
||||||
<div>
|
<div>
|
||||||
<textarea placeholder="reply mail..." v-model="newMail" class="form-control">
|
<textarea placeholder="reply mail..." v-model="newMail" class="form-control">
|
||||||
</textarea>
|
</textarea>
|
||||||
<AsyncButton class="btn btn-primary float-right" :task="sendMailAndClear">
|
<button class="btn btn-primary float-right" @click="sendMailAndClear">
|
||||||
<font-awesome-icon icon="envelope"/>
|
<font-awesome-icon icon="envelope"/>
|
||||||
Send Mail
|
Send Mail
|
||||||
</AsyncButton>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -77,12 +77,11 @@ import {mapActions, mapGetters} from "vuex";
|
||||||
import TimelineAssignment from "@/components/TimelineAssignment.vue";
|
import TimelineAssignment from "@/components/TimelineAssignment.vue";
|
||||||
import TimelineRelatedItem from "@/components/TimelineRelatedItem.vue";
|
import TimelineRelatedItem from "@/components/TimelineRelatedItem.vue";
|
||||||
import TimelineShippingVoucher from "@/components/TimelineShippingVoucher.vue";
|
import TimelineShippingVoucher from "@/components/TimelineShippingVoucher.vue";
|
||||||
import AsyncButton from "@/components/inputs/AsyncButton.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Timeline',
|
name: 'Timeline',
|
||||||
components: {
|
components: {
|
||||||
TimelineShippingVoucher, AsyncButton,
|
TimelineShippingVoucher,
|
||||||
TimelineRelatedItem, TimelineAssignment, TimelineStateChange, TimelineComment, TimelineMail
|
TimelineRelatedItem, TimelineAssignment, TimelineStateChange, TimelineComment, TimelineMail
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
@ -104,15 +103,18 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['sendMail', 'postComment']),
|
...mapActions(['fetchShippingVouchers']),
|
||||||
sendMailAndClear: async function () {
|
sendMailAndClear: function () {
|
||||||
await this.sendMail(this.newMail);
|
this.$emit('sendMail', this.newMail);
|
||||||
this.newMail = "";
|
this.newMail = "";
|
||||||
},
|
},
|
||||||
addCommentAndClear: async function () {
|
addCommentAndClear: function () {
|
||||||
await this.postComment(this.newComment);
|
this.$emit('addComment', this.newComment);
|
||||||
this.newComment = "";
|
this.newComment = "";
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.fetchShippingVouchers();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
<template>
|
|
||||||
<button @click.stop="handleClick" :disabled="disabled">
|
|
||||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"
|
|
||||||
:class="{'d-none': !disabled}"></span>
|
|
||||||
<span class="ml-2" :class="{'d-none': !disabled}">In Progress...</span>
|
|
||||||
<span :class="{'d-none': disabled}"><slot></slot></span>
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'AsyncButton',
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
disabled: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
task: {
|
|
||||||
type: Function,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async handleClick() {
|
|
||||||
console.log("AsyncButton.handleClick() called");
|
|
||||||
if (this.task && typeof this.task === 'function') {
|
|
||||||
this.disabled = true;
|
|
||||||
try {
|
|
||||||
await this.task();
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
} finally {
|
|
||||||
this.disabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.spinner-border {
|
|
||||||
vertical-align: -0.125em;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,43 +0,0 @@
|
||||||
<template>
|
|
||||||
<input
|
|
||||||
class="form-control w-100"
|
|
||||||
type="search"
|
|
||||||
placeholder="Search"
|
|
||||||
aria-label="Search"
|
|
||||||
v-model="search_query"
|
|
||||||
@keyup.enter="dispatchSearch"
|
|
||||||
>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
import {mapActions, mapGetters} from "vuex";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'SearchBox',
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
search_query: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters(['getActiveView'])
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
...mapActions(['searchEventItems', 'searchEventTickets']),
|
|
||||||
isItemView() {
|
|
||||||
return this.getActiveView === 'items' || this.getActiveView === 'item';
|
|
||||||
},
|
|
||||||
isTicketView() {
|
|
||||||
return this.getActiveView === 'tickets' || this.getActiveView === 'ticket';
|
|
||||||
},
|
|
||||||
dispatchSearch() {
|
|
||||||
if (this.isItemView()) {
|
|
||||||
this.searchEventItems(this.search_query);
|
|
||||||
} else if (this.isTicketView()) {
|
|
||||||
this.searchEventTickets(this.search_query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
|
@ -7,7 +7,7 @@ import Files from './views/Files';
|
||||||
import HowTo from './views/HowTo';
|
import HowTo from './views/HowTo';
|
||||||
import Login from '@/views/Login.vue';
|
import Login from '@/views/Login.vue';
|
||||||
import Register from '@/views/Register.vue';
|
import Register from '@/views/Register.vue';
|
||||||
import Dashboard from "@/views/admin/Dashboard.vue";
|
import Debug from "@/views/admin/Debug.vue";
|
||||||
import Tickets from "@/views/Tickets.vue";
|
import Tickets from "@/views/Tickets.vue";
|
||||||
import Ticket from "@/views/Ticket.vue";
|
import Ticket from "@/views/Ticket.vue";
|
||||||
import Admin from "@/views/admin/Admin.vue";
|
import Admin from "@/views/admin/Admin.vue";
|
||||||
|
@ -59,7 +59,7 @@ const routes = [
|
||||||
{requiresAuth: true, requiresPermission: 'delete_event'}
|
{requiresAuth: true, requiresPermission: 'delete_event'}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '', name: 'admin', component: Dashboard, meta:
|
path: '', name: 'admin', component: Debug, meta:
|
||||||
{requiresAuth: true, requiresPermission: 'delete_event'}
|
{requiresAuth: true, requiresPermission: 'delete_event'}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,6 @@ const store = createStore({
|
||||||
|
|
||||||
lastEvent: '37C3',
|
lastEvent: '37C3',
|
||||||
lastUsed: {},
|
lastUsed: {},
|
||||||
searchQuery: '',
|
|
||||||
remember: false,
|
remember: false,
|
||||||
user: {
|
user: {
|
||||||
username: null,
|
username: null,
|
||||||
|
@ -49,7 +48,6 @@ const store = createStore({
|
||||||
afterInitHandlers: [],
|
afterInitHandlers: [],
|
||||||
|
|
||||||
showAddBoxModal: false,
|
showAddBoxModal: false,
|
||||||
showAddEventModal: false,
|
|
||||||
|
|
||||||
shippingVoucherTypes: {
|
shippingVoucherTypes: {
|
||||||
'2kg-de': '2kg Paket (DE)',
|
'2kg-de': '2kg Paket (DE)',
|
||||||
|
@ -174,12 +172,6 @@ const store = createStore({
|
||||||
closeAddBoxModal(state) {
|
closeAddBoxModal(state) {
|
||||||
state.showAddBoxModal = false;
|
state.showAddBoxModal = false;
|
||||||
},
|
},
|
||||||
openAddEventModal(state) {
|
|
||||||
state.showAddEventModal = true;
|
|
||||||
},
|
|
||||||
closeAddEventModal(state) {
|
|
||||||
state.showAddEventModal = false;
|
|
||||||
},
|
|
||||||
createToast(state, {title, message, color}) {
|
createToast(state, {title, message, color}) {
|
||||||
var toast = {title, message, color, key: state.keyIncrement}
|
var toast = {title, message, color, key: state.keyIncrement}
|
||||||
state.toasts.push(toast);
|
state.toasts.push(toast);
|
||||||
|
@ -308,18 +300,6 @@ const store = createStore({
|
||||||
if (data && success)
|
if (data && success)
|
||||||
commit('replaceEvents', data);
|
commit('replaceEvents', data);
|
||||||
},
|
},
|
||||||
async createEvent({commit, dispatch, state}, event) {
|
|
||||||
const {data, success} = await http.post('/2/events/', event, state.user.token);
|
|
||||||
if (data && success)
|
|
||||||
commit('replaceEvents', [...state.events, data]);
|
|
||||||
},
|
|
||||||
async deleteEvent({commit, dispatch, state}, event_id) {
|
|
||||||
const {data, success} = await http.delete(`/2/events/${event_id}/`, state.user.token);
|
|
||||||
if (success) {
|
|
||||||
await dispatch('loadEvents')
|
|
||||||
commit('replaceEvents', [...state.events.filter(e => e.eid !== event_id)])
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async fetchTicketStates({commit, state}) {
|
async fetchTicketStates({commit, state}) {
|
||||||
if (!state.user.token) return;
|
if (!state.user.token) return;
|
||||||
if (state.fetchedData.states > Date.now() - 1000 * 60 * 60 * 24) return;
|
if (state.fetchedData.states > Date.now() - 1000 * 60 * 60 * 24) return;
|
||||||
|
@ -356,9 +336,10 @@ const store = createStore({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async searchEventItems({commit, getters, state}, query) {
|
async searchEventItems({commit, getters, state}, query) {
|
||||||
const encoded_query = base64.encode(utf8.encode(query));
|
const foo = utf8.encode(query);
|
||||||
|
const bar = base64.encode(foo);
|
||||||
|
|
||||||
const {data, success} = await http.get(`/2/${getters.getEventSlug}/items/${encoded_query}/`, state.user.token);
|
const {data, success} = await http.get(`/2/${getters.getEventSlug}/items/${bar}/`, state.user.token);
|
||||||
if (data && success)
|
if (data && success)
|
||||||
commit('replaceLoadedItems', data);
|
commit('replaceLoadedItems', data);
|
||||||
},
|
},
|
||||||
|
@ -407,13 +388,6 @@ const store = createStore({
|
||||||
if (data && success)
|
if (data && success)
|
||||||
commit('replaceTickets', data);
|
commit('replaceTickets', data);
|
||||||
},
|
},
|
||||||
async searchEventTickets({commit, getters, state}, query) {
|
|
||||||
const encoded_query = base64.encode(utf8.encode(query));
|
|
||||||
|
|
||||||
const {data, success} = await http.get(`/2/${getters.getEventSlug}/tickets/${encoded_query}/`, state.user.token);
|
|
||||||
if (data && success)
|
|
||||||
commit('replaceTickets', data);
|
|
||||||
},
|
|
||||||
async sendMail({commit, dispatch, state}, {id, message}) {
|
async sendMail({commit, dispatch, state}, {id, message}) {
|
||||||
const {data, success} = await http.post(`/2/tickets/${id}/reply/`, {message}, state.user.token);
|
const {data, success} = await http.post(`/2/tickets/${id}/reply/`, {message}, state.user.token);
|
||||||
if (data && success) {
|
if (data && success) {
|
||||||
|
|
|
@ -95,8 +95,8 @@ const http = {
|
||||||
"Authorization": `Token ${token}`,
|
"Authorization": `Token ${token}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const success = response.status === 204;
|
const success = response.status === 200 || response.status === 201;
|
||||||
return {data: await response.text() || {}, success};
|
return {data: await response.json() || {}, success};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,82 +1,77 @@
|
||||||
<template>
|
<template>
|
||||||
<AsyncLoader :loaded="loadedItems.length > 0">
|
<div class="container-fluid px-xl-5 mt-3">
|
||||||
<div class="container-fluid px-xl-5 mt-3">
|
<Modal title="Edit Item" v-if="editingItem" @close="closeEditingModal()">
|
||||||
<Modal title="Edit Item" v-if="editingItem" @close="closeEditingModal()">
|
<template #body>
|
||||||
<template #body>
|
<EditItem
|
||||||
<EditItem
|
:item="editingItem"
|
||||||
:item="editingItem"
|
badge="uid"
|
||||||
badge="uid"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #buttons>
|
|
||||||
<button type="button" class="btn btn-secondary" @click="closeEditingModal()">Cancel</button>
|
|
||||||
<button type="button" class="btn btn-success" @click="saveEditingItem()">Save Changes</button>
|
|
||||||
</template>
|
|
||||||
</Modal>
|
|
||||||
<Lightbox v-if="lightboxHash" :hash="lightboxHash" @close="closeLightboxModal()"/>
|
|
||||||
<div class="row" v-if="layout === 'table'">
|
|
||||||
<div class="col-xl-8 offset-xl-2">
|
|
||||||
<Table
|
|
||||||
:columns="['uid', 'description', 'box']"
|
|
||||||
:items="loadedItems"
|
|
||||||
:keyName="'uid'"
|
|
||||||
@itemActivated="openLightboxModalWith($event)"
|
|
||||||
>
|
|
||||||
<template #actions="{ item }">
|
|
||||||
<div class="btn-group">
|
|
||||||
<button class="btn btn-success"
|
|
||||||
@click.stop="confirm('return Item?') && markItemReturned(item)"
|
|
||||||
title="returned">
|
|
||||||
<font-awesome-icon icon="check"/>
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-secondary" @click.stop="openEditingModalWith(item)" title="edit">
|
|
||||||
<font-awesome-icon icon="edit"/>
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-danger" @click.stop="confirm('delete Item?') && deleteItem(item)"
|
|
||||||
title="delete">
|
|
||||||
<font-awesome-icon icon="trash"/>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</Table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Cards
|
|
||||||
v-if="layout === 'cards'"
|
|
||||||
:columns="['uid', 'description', 'box']"
|
|
||||||
:items="loadedItems"
|
|
||||||
:keyName="'uid'"
|
|
||||||
v-slot="{ item }"
|
|
||||||
@itemActivated="openLightboxModalWith($event)"
|
|
||||||
>
|
|
||||||
<AuthenticatedImage v-if="item.file" cached
|
|
||||||
:src="`/media/2/256/${item.file}/`"
|
|
||||||
class="card-img-top img-fluid"
|
|
||||||
/>
|
/>
|
||||||
<div class="card-body">
|
</template>
|
||||||
<h6 class="card-title">{{ item.description }}</h6>
|
<template #buttons>
|
||||||
<h6 class="card-subtitle text-secondary">uid: {{ item.uid }} box: {{ item.box }}</h6>
|
<button type="button" class="btn btn-secondary" @click="closeEditingModal()">Cancel</button>
|
||||||
<div class="row mx-auto mt-2">
|
<button type="button" class="btn btn-success" @click="saveEditingItem()">Save Changes</button>
|
||||||
|
</template>
|
||||||
|
</Modal>
|
||||||
|
<Lightbox v-if="lightboxHash" :hash="lightboxHash" @close="closeLightboxModal()"/>
|
||||||
|
<div class="row" v-if="layout === 'table'">
|
||||||
|
<div class="col-xl-8 offset-xl-2">
|
||||||
|
<Table
|
||||||
|
:columns="['uid', 'description', 'box']"
|
||||||
|
:items="loadedItems"
|
||||||
|
:keyName="'uid'"
|
||||||
|
@itemActivated="openLightboxModalWith($event)"
|
||||||
|
>
|
||||||
|
<template #actions="{ item }">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-outline-success"
|
<button class="btn btn-success"
|
||||||
@click.stop="confirm('return Item?') && markItemReturned(item)" title="returned">
|
@click.stop="confirm('return Item?') && markItemReturned(item)" title="returned">
|
||||||
<font-awesome-icon icon="check"/>
|
<font-awesome-icon icon="check"/>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-outline-secondary" @click.stop="openEditingModalWith(item)"
|
<button class="btn btn-secondary" @click.stop="openEditingModalWith(item)" title="edit">
|
||||||
title="edit">
|
|
||||||
<font-awesome-icon icon="edit"/>
|
<font-awesome-icon icon="edit"/>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-outline-danger"
|
<button class="btn btn-danger" @click.stop="confirm('delete Item?') && deleteItem(item)"
|
||||||
@click.stop="confirm('delete Item?') && deleteItem(item)"
|
|
||||||
title="delete">
|
title="delete">
|
||||||
<font-awesome-icon icon="trash"/>
|
<font-awesome-icon icon="trash"/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Cards
|
||||||
|
v-if="layout === 'cards'"
|
||||||
|
:columns="['uid', 'description', 'box']"
|
||||||
|
:items="loadedItems"
|
||||||
|
:keyName="'uid'"
|
||||||
|
v-slot="{ item }"
|
||||||
|
@itemActivated="openLightboxModalWith($event)"
|
||||||
|
>
|
||||||
|
<AuthenticatedImage v-if="item.file" cached
|
||||||
|
:src="`/media/2/256/${item.file}/`"
|
||||||
|
class="card-img-top img-fluid"
|
||||||
|
/>
|
||||||
|
<div class="card-body">
|
||||||
|
<h6 class="card-title">{{ item.description }}</h6>
|
||||||
|
<h6 class="card-subtitle text-secondary">uid: {{ item.uid }} box: {{ item.box }}</h6>
|
||||||
|
<div class="row mx-auto mt-2">
|
||||||
|
<div class="btn-group">
|
||||||
|
<button class="btn btn-outline-success"
|
||||||
|
@click.stop="confirm('return Item?') && markItemReturned(item)" title="returned">
|
||||||
|
<font-awesome-icon icon="check"/>
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-outline-secondary" @click.stop="openEditingModalWith(item)" title="edit">
|
||||||
|
<font-awesome-icon icon="edit"/>
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-outline-danger" @click.stop="confirm('delete Item?') && deleteItem(item)"
|
||||||
|
title="delete">
|
||||||
|
<font-awesome-icon icon="trash"/>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Cards>
|
</div>
|
||||||
</div>
|
</Cards>
|
||||||
</AsyncLoader>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -87,7 +82,6 @@ import EditItem from '@/components/EditItem';
|
||||||
import {mapActions, mapGetters, mapState} from 'vuex';
|
import {mapActions, mapGetters, mapState} from 'vuex';
|
||||||
import Lightbox from '../components/Lightbox';
|
import Lightbox from '../components/Lightbox';
|
||||||
import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
||||||
import AsyncLoader from "@/components/AsyncLoader.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Items',
|
name: 'Items',
|
||||||
|
@ -95,7 +89,7 @@ export default {
|
||||||
lightboxHash: null,
|
lightboxHash: null,
|
||||||
editingItem: null,
|
editingItem: null,
|
||||||
}),
|
}),
|
||||||
components: {AsyncLoader, AuthenticatedImage, Lightbox, Table, Cards, Modal, EditItem},
|
components: {AuthenticatedImage, Lightbox, Table, Cards, Modal, EditItem},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['loadedItems']),
|
...mapState(['loadedItems']),
|
||||||
...mapGetters(['layout']),
|
...mapGetters(['layout']),
|
||||||
|
|
|
@ -1,82 +1,70 @@
|
||||||
<template>
|
<template>
|
||||||
<AsyncLoader :loaded="ticket.id">
|
<div class="container-fluid px-xl-5 mt-3">
|
||||||
<div class="container-fluid px-xl-5 mt-3">
|
<div class="row">
|
||||||
<div class="row">
|
<div class="col-xl-8 offset-xl-2">
|
||||||
<div class="col-xl-8 offset-xl-2">
|
<div class="card bg-dark text-light mb-2" id="filters">
|
||||||
<div class="card bg-dark text-light mb-2" id="filters">
|
<div class="card-header">
|
||||||
<div class="card-header">
|
<h3>Ticket #{{ ticket.id }} - {{ ticket.name }}</h3>
|
||||||
<h3>Ticket #{{ ticket.id }} - {{ ticket.name }}</h3>
|
</div>
|
||||||
|
<Timeline :timeline="ticket.timeline" @sendMail="handleMail" @addComment="handleComment"/>
|
||||||
|
<div class="card-footer d-flex justify-content-between">
|
||||||
|
<button class="btn btn-secondary mr-2" @click="$router.go(-1)">Back</button>
|
||||||
|
<!--button class="btn btn-danger" @click="deleteItem({type: 'tickets', id: ticket.id})">
|
||||||
|
<font-awesome-icon icon="trash"/>
|
||||||
|
Delete
|
||||||
|
</button-->
|
||||||
|
<div class="btn-group">
|
||||||
|
<select class="form-control" v-model="ticket.assigned_to">
|
||||||
|
<option v-for="user in users" :value="user.username">{{ user.username }}</option>
|
||||||
|
</select>
|
||||||
|
<button class="form-control btn btn-success" @click="assigTicket(ticket)">
|
||||||
|
Assign Ticket
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<Timeline :timeline="ticket.timeline" @sendMail="handleMail" @addComment="handleComment"/>
|
<div class="btn-group">
|
||||||
<div class="card-footer d-flex justify-content-between">
|
<select class="form-control" v-model="ticket.state">
|
||||||
<button class="btn btn-secondary mr-2" @click="$router.go(-1)">Back</button>
|
<option v-for="status in state_options" :value="status.value">{{ status.text }}</option>
|
||||||
<!--button class="btn btn-danger" @click="deleteItem({type: 'tickets', id: ticket.id})">
|
</select>
|
||||||
<font-awesome-icon icon="trash"/>
|
<button class="form-control btn btn-success" @click="changeTicketStatus(ticket)">
|
||||||
Delete
|
Change Status
|
||||||
</button-->
|
</button>
|
||||||
<div class="btn-group">
|
|
||||||
<select class="form-control" v-model="selected_assignee">
|
|
||||||
<option v-for="user in users" :value="user.username">{{ user.username }}</option>
|
|
||||||
</select>
|
|
||||||
<button class="form-control btn btn-success"
|
|
||||||
@click="assignTicket(ticket)"
|
|
||||||
:disabled="!selected_assignee || (selected_assignee == ticket.assigned_to)">
|
|
||||||
Assign Ticket
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group">
|
|
||||||
<select class="form-control" v-model="selected_state">
|
|
||||||
<option v-for="status in state_options" :value="status.value">{{
|
|
||||||
status.text
|
|
||||||
}}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<button class="form-control btn btn-success"
|
|
||||||
@click="changeTicketStatus(ticket)"
|
|
||||||
:disabled="(selected_state == ticket.state)">
|
|
||||||
Change Status
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer d-flex justify-content-between">
|
</div>
|
||||||
<ClipboardButton :payload="shippingEmail" class="btn btn-primary">
|
<div class="card-footer d-flex justify-content-between">
|
||||||
<font-awesome-icon icon="clipboard"/>
|
<ClipboardButton :payload="shippingEmail" class="btn btn-primary">
|
||||||
Copy DHL contact to clipboard
|
<font-awesome-icon icon="clipboard"/>
|
||||||
</ClipboardButton>
|
Copy DHL contact to clipboard
|
||||||
<div class="btn-group">
|
</ClipboardButton>
|
||||||
<select class="form-control" v-model="shipping_voucher_type">
|
<div class="btn-group">
|
||||||
<option v-for="type in availableShippingVoucherTypes.filter(t=>t.count>0)"
|
<select class="form-control" v-model="shipping_voucher_type">
|
||||||
:value="type.id">{{ type.name }}
|
<option v-for="type in availableShippingVoucherTypes.filter(t=>t.count>0)"
|
||||||
</option>
|
:value="type.id">{{ type.name }}
|
||||||
</select>
|
</option>
|
||||||
<button class="form-control btn btn-success"
|
</select>
|
||||||
@click="claimShippingVoucher({ticket: ticket.id, shipping_voucher_type}).then(()=>shipping_voucher_type=null)"
|
<button class="form-control btn btn-success"
|
||||||
:disabled="!shipping_voucher_type">
|
@click="claimShippingVoucher({ticket: ticket.id, shipping_voucher_type}).then(()=>shipping_voucher_type=null)"
|
||||||
Claim Shipping Voucher
|
:disabled="!shipping_voucher_type">
|
||||||
</button>
|
Claim Shipping Voucher
|
||||||
</div>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</AsyncLoader>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapActions, mapGetters, mapState} from 'vuex';
|
import {mapActions, mapGetters, mapState} from 'vuex';
|
||||||
import Timeline from "@/components/Timeline.vue";
|
import Timeline from "@/components/Timeline.vue";
|
||||||
import ClipboardButton from "@/components/inputs/ClipboardButton.vue";
|
import ClipboardButton from "@/components/inputs/ClipboardButton.vue";
|
||||||
import AsyncLoader from "@/components/AsyncLoader.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Ticket',
|
name: 'Ticket',
|
||||||
components: {AsyncLoader, ClipboardButton, Timeline},
|
components: {ClipboardButton, Timeline},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selected_state: null,
|
shipping_voucher_type: null
|
||||||
selected_assignee: null,
|
|
||||||
shipping_voucher_type: null,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -95,7 +83,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['deleteItem', 'markItemReturned', 'sendMail', 'updateTicketPartial', 'postComment']),
|
...mapActions(['deleteItem', 'markItemReturned', 'sendMail', 'updateTicketPartial', 'postComment']),
|
||||||
...mapActions(['loadTickets', 'fetchTicketStates', 'loadUsers', 'scheduleAfterInit']),
|
...mapActions(['loadTickets', 'fetchTicketStates', 'loadUsers', 'scheduleAfterInit']),
|
||||||
...mapActions(['claimShippingVoucher', 'fetchShippingVouchers']),
|
...mapActions(['claimShippingVoucher']),
|
||||||
handleMail(mail) {
|
handleMail(mail) {
|
||||||
this.sendMail({
|
this.sendMail({
|
||||||
id: this.ticket.id,
|
id: this.ticket.id,
|
||||||
|
@ -109,33 +97,24 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
changeTicketStatus(ticket) {
|
changeTicketStatus(ticket) {
|
||||||
ticket.state = this.selected_state;
|
|
||||||
this.updateTicketPartial({
|
this.updateTicketPartial({
|
||||||
id: ticket.id,
|
id: ticket.id,
|
||||||
state: this.selected_state,
|
state: ticket.state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
assignTicket(ticket) {
|
assigTicket(ticket) {
|
||||||
ticket.assigned_to = this.selected_assignee;
|
|
||||||
this.updateTicketPartial({
|
this.updateTicketPartial({
|
||||||
id: ticket.id,
|
id: ticket.id,
|
||||||
assigned_to: this.selected_assignee
|
assigned_to: ticket.assigned_to
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.scheduleAfterInit(() => [Promise.all([this.fetchTicketStates(), this.loadTickets(), this.loadUsers(), this.fetchShippingVouchers()]).then(()=>{
|
this.scheduleAfterInit(() => [this.fetchTicketStates(), this.loadTickets(), this.loadUsers()]);
|
||||||
if (this.ticket.state == "pending_new"){
|
|
||||||
this.selected_state = "pending_open";
|
|
||||||
this.changeTicketStatus(this.ticket)
|
|
||||||
};
|
|
||||||
this.selected_state = this.ticket.state;
|
|
||||||
this.selected_assignee = this.ticket.assigned_to
|
|
||||||
})]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -1,53 +1,51 @@
|
||||||
<template>
|
<template>
|
||||||
<AsyncLoader :loaded="tickets.length > 0">
|
<div class="container-fluid px-xl-5 mt-3">
|
||||||
<div class="container-fluid px-xl-5 mt-3">
|
<div class="row">
|
||||||
<div class="row">
|
<div class="col-xl-8 offset-xl-2">
|
||||||
<div class="col-xl-8 offset-xl-2">
|
<Table
|
||||||
<Table
|
:columns="['id', 'name', 'state', 'last_activity', 'assigned_to']"
|
||||||
:columns="['id', 'name', 'state', 'last_activity', 'assigned_to', 'actions', 'actions2']"
|
:items="tickets"
|
||||||
:items="tickets.map(formatTicket)"
|
:keyName="'id'"
|
||||||
:keyName="'id'"
|
v-if="layout === 'table'"
|
||||||
v-if="layout === 'table'"
|
>
|
||||||
>
|
<template #actions="{ item }">
|
||||||
<template v-slot:actions="{item}">
|
<div class="btn-group">
|
||||||
<div class="btn-group">
|
<a class="btn btn-primary" :href="'/'+ getEventSlug + '/ticket/' + item.id" title="view"
|
||||||
<a class="btn btn-primary" :href="'/'+ getEventSlug + '/ticket/' + item.id" title="view"
|
@click.prevent="gotoDetail(item)">
|
||||||
@click.prevent="gotoDetail(item)">
|
<font-awesome-icon icon="eye"/>
|
||||||
<font-awesome-icon icon="eye"/>
|
View
|
||||||
View
|
</a>
|
||||||
</a>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
</Table>
|
||||||
</Table>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<CollapsableCards v-if="layout === 'tasks'" :items="tickets"
|
|
||||||
:columns="['id', 'name', 'last_activity', 'assigned_to']"
|
|
||||||
:keyName="'state'" :sections="['pending_new', 'pending_open','pending_shipping',
|
|
||||||
'pending_physical_confirmation','pending_return','pending_postponed'].map(stateInfo)">
|
|
||||||
<template #section_header="{index, section, count}">
|
|
||||||
{{ section.text }} <span class="badge badge-light ml-1">{{ count }}</span>
|
|
||||||
</template>
|
|
||||||
<template #section_body="{item}">
|
|
||||||
<tr>
|
|
||||||
<td>{{ item.id }}</td>
|
|
||||||
<td>{{ item.name }}</td>
|
|
||||||
<td>{{ item.last_activity }}</td>
|
|
||||||
<td>{{ item.assigned_to }}</td>
|
|
||||||
<td>
|
|
||||||
<div class="btn-group">
|
|
||||||
<a class="btn btn-primary" :href="'/'+ getEventSlug + '/ticket/' + item.id" title="view"
|
|
||||||
@click.prevent="gotoDetail(item)">
|
|
||||||
<font-awesome-icon icon="eye"/>
|
|
||||||
View
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</template>
|
|
||||||
</CollapsableCards>
|
|
||||||
</div>
|
</div>
|
||||||
</AsyncLoader>
|
<CollapsableCards v-if="layout === 'tasks'" :items="tickets"
|
||||||
|
:columns="['id', 'name', 'last_activity', 'assigned_to']"
|
||||||
|
:keyName="'state'" :sections="['pending_new', 'pending_open','pending_shipping',
|
||||||
|
'pending_physical_confirmation','pending_return','pending_postponed'].map(stateInfo)">
|
||||||
|
<template #section_header="{index, section, count}">
|
||||||
|
{{ section.text }} <span class="badge badge-light ml-1">{{ count }}</span>
|
||||||
|
</template>
|
||||||
|
<template #section_body="{item}">
|
||||||
|
<tr>
|
||||||
|
<td>{{ item.id }}</td>
|
||||||
|
<td>{{ item.name }}</td>
|
||||||
|
<td>{{ item.last_activity }}</td>
|
||||||
|
<td>{{ item.assigned_to }}</td>
|
||||||
|
<td>
|
||||||
|
<div class="btn-group">
|
||||||
|
<a class="btn btn-primary" :href="'/'+ getEventSlug + '/ticket/' + item.id" title="view"
|
||||||
|
@click.prevent="gotoDetail(item)">
|
||||||
|
<font-awesome-icon icon="eye"/>
|
||||||
|
View
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
</CollapsableCards>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -58,11 +56,10 @@ import {mapActions, mapGetters, mapState} from 'vuex';
|
||||||
import Lightbox from '../components/Lightbox';
|
import Lightbox from '../components/Lightbox';
|
||||||
import Table from '@/components/Table';
|
import Table from '@/components/Table';
|
||||||
import CollapsableCards from "@/components/CollapsableCards.vue";
|
import CollapsableCards from "@/components/CollapsableCards.vue";
|
||||||
import AsyncLoader from "@/components/AsyncLoader.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Tickets',
|
name: 'Tickets',
|
||||||
components: {AsyncLoader, Lightbox, Table, Cards, Modal, EditItem, CollapsableCards},
|
components: {Lightbox, Table, Cards, Modal, EditItem, CollapsableCards},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['tickets']),
|
...mapState(['tickets']),
|
||||||
...mapGetters(['stateInfo', 'getEventSlug', 'layout']),
|
...mapGetters(['stateInfo', 'getEventSlug', 'layout']),
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<h3 class="text-center">Events</h3>
|
|
||||||
<ul>
|
|
||||||
<li v-for="event in events" :key="event.id">
|
|
||||||
{{ event.slug }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import {mapActions, mapState} from 'vuex';
|
|
||||||
import Table from '@/components/Table';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'Dashboard',
|
|
||||||
components: {},
|
|
||||||
computed: {
|
|
||||||
...mapState(['events']),
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
...mapActions(['loadEvents']),
|
|
||||||
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.loadEvents();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
</style>
|
|
62
web/src/views/admin/Debug.vue
Normal file
62
web/src/views/admin/Debug.vue
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!--qr-code :text="qr_url" color="#000" bg-color="#fff" error-level="H" class="qr-code"></qr-code-->
|
||||||
|
<h3 class="text-center">Events</h3>
|
||||||
|
<!--p>{{ events }}</p-->
|
||||||
|
<ul>
|
||||||
|
<li v-for="event in events" :key="event.id">
|
||||||
|
{{ event.slug }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h3 class="text-center">Items</h3>
|
||||||
|
<!--p>{{ loadedItems }}</p-->
|
||||||
|
<ul>
|
||||||
|
<li v-for="item in loadedItems" :key="item.id">
|
||||||
|
{{ item.description }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h3 class="text-center">Boxes</h3>
|
||||||
|
<!--p>{{ loadedBoxes }}</p-->
|
||||||
|
<ul>
|
||||||
|
<li v-for="box in loadedBoxes" :key="box.id">
|
||||||
|
{{ box.name }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h3 class="text-center">Issues</h3>
|
||||||
|
<!--p>{{ issues }}</p-->
|
||||||
|
<ul>
|
||||||
|
<li v-for="issue in tickets" :key="issue.id">
|
||||||
|
{{ issue.id }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {mapActions, mapState} from 'vuex';
|
||||||
|
import Table from '@/components/Table';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Debug',
|
||||||
|
components: {Table},
|
||||||
|
computed: {
|
||||||
|
...mapState(['events', 'loadedItems', 'loadedBoxes', 'tickets']),
|
||||||
|
qr_url() {
|
||||||
|
return window.location.href;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions(['changeEvent', 'loadTickets']),
|
||||||
|
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.loadTickets();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.qr-code img {
|
||||||
|
border: #fff solid 7px
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -4,19 +4,13 @@
|
||||||
:items="events"
|
:items="events"
|
||||||
:keyName="'slug'"
|
:keyName="'slug'"
|
||||||
>
|
>
|
||||||
<template v-slot:header_actions>
|
<template #actions="{ item }">
|
||||||
<button class="btn btn-success" @click.prevent="openAddEventModal">
|
|
||||||
<font-awesome-icon icon="plus"/>
|
|
||||||
Create Event
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
<template v-slot:actions="{ item }">
|
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-secondary" @click.stop="changeEvent(item)">
|
<button class="btn btn-secondary" @click.stop="changeEvent(item)">
|
||||||
<font-awesome-icon icon="archive"/>
|
<font-awesome-icon icon="archive"/>
|
||||||
use
|
use
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-danger" @click.stop="safeDeleteEvent(item.eid)">
|
<button class="btn btn-danger" @click.stop="">
|
||||||
<font-awesome-icon icon="trash"/>
|
<font-awesome-icon icon="trash"/>
|
||||||
delete
|
delete
|
||||||
</button>
|
</button>
|
||||||
|
@ -26,22 +20,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapActions, mapMutations, mapState} from 'vuex';
|
import {mapActions, mapState} from 'vuex';
|
||||||
import Table from '@/components/Table';
|
import Table from '@/components/Table';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Events',
|
name: 'Events',
|
||||||
components: {Table},
|
components: {Table},
|
||||||
computed: mapState(['events']),
|
computed: mapState(['events']),
|
||||||
methods: {
|
methods: mapActions(['changeEvent']),
|
||||||
...mapActions(['changeEvent', 'deleteEvent']),
|
|
||||||
...mapMutations(['openAddEventModal']),
|
|
||||||
safeDeleteEvent(id) {
|
|
||||||
if (confirm('do you want to completely delete this event and related data?')) {
|
|
||||||
this.deleteEvent(id)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -7,25 +7,25 @@ module.exports = {
|
||||||
"Access-Control-Allow-Headers": "*",
|
"Access-Control-Allow-Headers": "*",
|
||||||
"Access-Control-Allow-Methods": "*"
|
"Access-Control-Allow-Methods": "*"
|
||||||
},
|
},
|
||||||
proxy: {
|
//proxy: {
|
||||||
'^/media/2': {
|
// '^/media/2': {
|
||||||
target: 'https://staging.c3lf.de/',
|
// target: 'https://staging.c3lf.de/',
|
||||||
changeOrigin: true
|
// changeOrigin: true
|
||||||
},
|
// },
|
||||||
'^/api/2': {
|
// '^/api/2': {
|
||||||
target: 'https://staging.c3lf.de/',
|
// target: 'https://staging.c3lf.de/',
|
||||||
changeOrigin: true,
|
// changeOrigin: true,
|
||||||
},
|
// },
|
||||||
'^/api/1': {
|
// '^/api/1': {
|
||||||
target: 'https://staging.c3lf.de/',
|
// target: 'https://staging.c3lf.de/',
|
||||||
changeOrigin: true,
|
// changeOrigin: true,
|
||||||
},
|
// },
|
||||||
'^/ws/2': {
|
// '^/ws/2': {
|
||||||
target: 'http://127.0.0.1:8082/',
|
// target: 'http://127.0.0.1:8082/',
|
||||||
//changeOrigin: true,
|
// //changeOrigin: true,
|
||||||
ws: true,
|
// ws: true,
|
||||||
logLevel: 'debug',
|
// logLevel: 'debug',
|
||||||
},
|
// },
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue