From 0fe8aa61c7d235b5b610632e363be40d6eef2805 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 28 Jun 2021 15:16:42 +0200 Subject: [PATCH] Deploy new admin interface. --- doc/manual_installation/webserver.rst | 15 +++++++++++++-- modoboa/core/commands/deploy.py | 13 ++++++++++++- modoboa/templates/nlayout.html | 7 +++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/doc/manual_installation/webserver.rst b/doc/manual_installation/webserver.rst index 648f4bb38..947193577 100644 --- a/doc/manual_installation/webserver.rst +++ b/doc/manual_installation/webserver.rst @@ -4,7 +4,7 @@ Web server ########## -.. note:: +.. note:: The following instructions are meant to help you get your site up and running quickly. However it is not possible for the people @@ -128,6 +128,17 @@ following configuration:: autoindex on; } + location ^~ /new-admin { + alias /frontend/; + index index.html; + + expires -1; + add_header Pragma "no-cache"; + add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"; + + try_files $uri $uri/ /index.html = 404; + } + location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; @@ -166,7 +177,7 @@ optimize their configuration for your site. The Django documentation includes the following warning regarding uwsgi: -.. warning:: +.. warning:: Use uwsgi 1.2.6 or newer. If you do not, you *will* run into problems. Modoboa will fail in obscure ways. diff --git a/modoboa/core/commands/deploy.py b/modoboa/core/commands/deploy.py index d22ce1573..e2e78092f 100644 --- a/modoboa/core/commands/deploy.py +++ b/modoboa/core/commands/deploy.py @@ -2,10 +2,10 @@ import getpass import os +from os.path import isfile import shutil import subprocess import sys -from os.path import isfile import dj_database_url @@ -267,3 +267,14 @@ class DeployCommand(Command): self._exec_django_command( "set_default_site", parsed_args.name, allowed_host ) + + base_frontend_dir = os.path.join( + os.path.dirname(__file__), "../../../frontend/dist/") + frontend_target_dir = "{}/frontend".format(parsed_args.name) + shutil.copytree(base_frontend_dir, frontend_target_dir) + + with open("{}/config.json".format(frontend_target_dir), "w") as fp: + fp.write("""{ + "API_BASE_URL": "https://%s/api/v2" +} +""" % allowed_host) diff --git a/modoboa/templates/nlayout.html b/modoboa/templates/nlayout.html index 386f610ed..2c94c30a4 100644 --- a/modoboa/templates/nlayout.html +++ b/modoboa/templates/nlayout.html @@ -51,6 +51,13 @@ {% endif %} {% load_optionalmenu user %}
  • + {% if user.is_admin %} +
  • + + {% trans "New admin" %} + +
  • + {% endif %}