From 3459de36f35839e98e894ae3b58c4f4374d90913 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Wed, 31 Aug 2022 17:45:20 +0200 Subject: Add Servers section In Servers section/view, users can add or delete ogServers from ogCP configuration file. Replaces Repositories views and recycle some of its code. --- ogcp/forms/action_forms.py | 6 +- ogcp/templates/actions/add_repository.html | 17 --- ogcp/templates/actions/add_server.html | 17 +++ ogcp/templates/actions/delete_repository.html | 23 ---- ogcp/templates/actions/delete_server.html | 23 ++++ ogcp/templates/base.html | 4 +- ogcp/templates/repositories.html | 37 ------ ogcp/templates/servers.html | 38 ++++++ ogcp/views.py | 171 +++++++++++++++++--------- 9 files changed, 197 insertions(+), 139 deletions(-) delete mode 100644 ogcp/templates/actions/add_repository.html create mode 100644 ogcp/templates/actions/add_server.html delete mode 100644 ogcp/templates/actions/delete_repository.html create mode 100644 ogcp/templates/actions/delete_server.html delete mode 100644 ogcp/templates/repositories.html create mode 100644 ogcp/templates/servers.html (limited to 'ogcp') diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py index dcf4965..d1789a7 100644 --- a/ogcp/forms/action_forms.py +++ b/ogcp/forms/action_forms.py @@ -194,11 +194,15 @@ class ImageDetailsForm(FlaskForm): permissions = StringField(label=_l('Permissions')) software_id = StringField(label=_l('Software id')) -class RepositoryForm(FlaskForm): +class ServerForm(FlaskForm): name = StringField(label=_l('Name'), validators=[InputRequired()]) ip = StringField(label=_l('IP'), validators=[InputRequired()]) + port = StringField(label=_l('Port'), + validators=[InputRequired()]) + api_token = StringField(label=_l('API token'), + validators=[InputRequired()]) submit = SubmitField(label=_l('Submit')) class DeleteRepositoryForm(FlaskForm): diff --git a/ogcp/templates/actions/add_repository.html b/ogcp/templates/actions/add_repository.html deleted file mode 100644 index e7c50fa..0000000 --- a/ogcp/templates/actions/add_repository.html +++ /dev/null @@ -1,17 +0,0 @@ -{% extends 'repositories.html' %} -{% import "bootstrap/wtf.html" as wtf %} - -{% set sidebar_state = 'disabled' %} -{% set btn_back = true %} - -{% block nav_repository_add %}active{% endblock %} -{% block content %} - -

{{_('Add a repository')}}

- -{{ wtf.quick_form(form, - action=url_for('repository_add_post'), - method='post', - button_map={'submit_btn':'primary'}) }} - -{% endblock %} diff --git a/ogcp/templates/actions/add_server.html b/ogcp/templates/actions/add_server.html new file mode 100644 index 0000000..c86dcba --- /dev/null +++ b/ogcp/templates/actions/add_server.html @@ -0,0 +1,17 @@ +{% extends 'servers.html' %} +{% import "bootstrap/wtf.html" as wtf %} + +{% set sidebar_state = 'disabled' %} +{% set btn_back = true %} + +{% block nav_server_add %}active{% endblock %} +{% block content %} + +

{{_('Add a server')}}

+ +{{ wtf.quick_form(form, + action=url_for('server_add_post'), + method='post', + button_map={'submit_btn':'primary'}) }} + +{% endblock %} diff --git a/ogcp/templates/actions/delete_repository.html b/ogcp/templates/actions/delete_repository.html deleted file mode 100644 index 82177a3..0000000 --- a/ogcp/templates/actions/delete_repository.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends 'repositories.html' %} -{% import "bootstrap/wtf.html" as wtf %} - -{% set sidebar_state = 'disabled' %} -{% set btn_back = true %} - -{% block content %} - -{{ args }} - -

- {{ _('Delete repository %(repo_name)s', repo_name=repo_name) }} -

- -{{ wtf.quick_form(form, - action=url_for('repository_delete_post'), - method='post', - button_map={'submit': 'primary'}, - extra_classes="mx-5") }} - -{% endblock %} - - diff --git a/ogcp/templates/actions/delete_server.html b/ogcp/templates/actions/delete_server.html new file mode 100644 index 0000000..8f9417e --- /dev/null +++ b/ogcp/templates/actions/delete_server.html @@ -0,0 +1,23 @@ +{% extends 'servers.html' %} +{% import "bootstrap/wtf.html" as wtf %} + +{% set sidebar_state = 'disabled' %} +{% set btn_back = true %} + +{% block content %} + +{{ args }} + +

+{{ _('Delete server %(server_name)s', server_name=form.name.data) }} +

+ +{{ wtf.quick_form(form, + action=url_for('server_delete_post'), + method='post', + button_map={'submit': 'primary'}, + extra_classes="mx-5") }} + +{% endblock %} + + diff --git a/ogcp/templates/base.html b/ogcp/templates/base.html index dca6fda..da5f1db 100644 --- a/ogcp/templates/base.html +++ b/ogcp/templates/base.html @@ -36,8 +36,8 @@ - {% if current_user.admin %}