Youen
2 years ago
13 changed files with 140 additions and 36 deletions
@ -0,0 +1,8 @@
|
||||
var confirm_elements = document.querySelectorAll('a[data-confirm]'); |
||||
for (let elt of confirm_elements) |
||||
{ |
||||
elt.addEventListener('click', (e) => { |
||||
if(!confirm(elt.getAttribute('data-confirm'))) |
||||
e.preventDefault(); |
||||
}, false); |
||||
} |
@ -0,0 +1,8 @@
|
||||
{% extends 'base.html' %} |
||||
|
||||
{% block title %}Exécution...{% endblock %} |
||||
|
||||
{% block content %} |
||||
<pre>{{ output }}</pre> |
||||
<a href="{{ next }}" class="button">OK</a> |
||||
{% endblock %} |
@ -0,0 +1,11 @@
|
||||
{% extends 'base.html' %} |
||||
|
||||
{% block title %}{{ doc.doc_name }} / {{ doc.branch }} (admin){% endblock %} |
||||
|
||||
{% block content %} |
||||
<h1>Gestion de {{ doc.doc_name }} / {{ doc.branch }}</h1> |
||||
<a href="{{doc.get_url()}}" class="button">Consulter</a><br/> |
||||
<a href="{{ url_for('api_document.build', doc = doc.doc_name, branch = doc.branch) }}" class="button">Compiler</a><br/> |
||||
<br/> |
||||
<a href="{{ url_for('admin_document.delete', doc_name = doc.doc_name, branch = doc.branch) }}" class="button danger" data-confirm="Êtes-vous sûr de vouloir supprimer le document {{ doc.doc_name }} / {{ doc.branch }} ?">Supprimer</a> |
||||
{% endblock %} |
@ -0,0 +1,14 @@
|
||||
{% extends 'base.html' %} |
||||
|
||||
{% block title %}Nouveau document{% endblock %} |
||||
|
||||
{% block content %} |
||||
<form method="POST"> |
||||
<label for="repo">Dépôt git :</label> <input type="text" id="repo" name="repo"><br/> |
||||
<label for="branch">Branche :</label> <input type="text" id="branch" name="branch" value="master"><br/> |
||||
<label for="doc">Nom :</label> <input type="text" id="doc" name="doc"> (laisser vide pour utiliser le nom du dépôt)<br/> |
||||
<label for="source">Dossier source :</label> <input type="text" id="source" name="source" value="source"> (chemin dans le dépôt du dossier contenant les sources du document)<br/> |
||||
|
||||
<input type="submit" value="Créer le document"/> |
||||
</form> |
||||
{% endblock %} |
@ -0,0 +1,22 @@
|
||||
{% extends 'base.html' %} |
||||
|
||||
{% block title %}Documentation (admin){% endblock %} |
||||
|
||||
{% block content %} |
||||
<h1>Administration des documents</h1> |
||||
<a href="{{ url_for('admin_document.new') }}">Nouveau document...</a> |
||||
<h2>Liste des documents</h2> |
||||
{% if documents|length > 0 %} |
||||
<ul> |
||||
{% for doc in documents %} |
||||
{% if doc.valid %} |
||||
<li>{{ doc.doc_name }} / {{ doc.branch }} <a href="{{ doc.get_url() }}">Consulter</a> <a href="{{ url_for('admin_document.manage', doc_name = doc.doc_name, branch = doc.branch) }}" class="button">Gérer</a></li> |
||||
{% else %} |
||||
<li>{{ doc.doc_name }} / {{ doc.branch }} (document invalide) <a href="{{ url_for('admin_document.delete_invalid', doc_name = doc.doc_name, branch = doc.branch) }}" class="confirm danger">Supprimer le dossier</a></li> |
||||
{% endif %} |
||||
{% endfor %} |
||||
</ul> |
||||
{% else %} |
||||
<p>Aucun document</p> |
||||
{% endif %} |
||||
{% endblock %} |
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html> |
||||
<html lang="fr"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<title>{% block title %}{% endblock %}</title> |
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> |
||||
</head> |
||||
|
||||
<body> |
||||
{% block content %}{% endblock %} |
||||
|
||||
<script type="text/javascript" src="{{ url_for('static', filename='app.js') }}"></script> |
||||
</body> |
@ -1,24 +0,0 @@
|
||||
<!DOCTYPE html> |
||||
<html lang="fr"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<title>Documentation (admin)</title> |
||||
</head> |
||||
|
||||
<body> |
||||
<h1>Administration des documents</h1> |
||||
<a href="">Nouveau document...</a> |
||||
<h2>Liste des documents</h2> |
||||
<ul> |
||||
{% for doc in documents %} |
||||
{% if doc.valid %} |
||||
<li>{{ doc.doc_name }} / {{ doc.branch }} <a href="{{ doc.get_url() }}">Consulter</a></li> |
||||
{% else %} |
||||
<li>{{ doc.doc_name }} / {{ doc.branch }} (document invalide)</li> |
||||
{% endif %} |
||||
{% endfor %} |
||||
</ul> |
||||
|
||||
<script type="text/javascript" src="/static/index.js"></script> |
||||
</body> |
@ -0,0 +1,9 @@
|
||||
from flask import Blueprint, render_template |
||||
|
||||
from data.document import Document |
||||
|
||||
bp = Blueprint('admin', __name__, url_prefix='/admin') |
||||
|
||||
@bp.route('/') |
||||
def index(): |
||||
return render_template("admin/index.html", documents=Document.list()) |
@ -0,0 +1,41 @@
|
||||
import os |
||||
from flask import Blueprint, render_template, redirect, url_for, request |
||||
|
||||
from web_utils.get_arg import get_arg |
||||
|
||||
from data.document import Document |
||||
|
||||
bp = Blueprint('admin_document', __name__, url_prefix='/admin/doc') |
||||
|
||||
@bp.route('/new', methods=['GET', 'POST']) |
||||
def new(): |
||||
if request.method == 'POST': |
||||
repo = request.form.get('repo') |
||||
doc_name = request.form.get('doc') |
||||
branch = request.form.get('branch') |
||||
source_dir = request.form.get('source') |
||||
|
||||
if doc_name == "": |
||||
doc_name = os.path.splitext(os.path.basename(repo))[0] |
||||
|
||||
output = Document.clone(repo, branch, doc_name, source_dir) |
||||
|
||||
return render_template("admin/command_output.html", output = output, next = url_for('admin_document.manage', doc_name = doc_name, branch = branch)) |
||||
else: |
||||
return render_template("admin/document/new.html") |
||||
|
||||
@bp.route('/manage/<doc_name>/<branch>') |
||||
def manage(doc_name, branch): |
||||
return render_template("admin/document/manage.html", doc=Document(doc_name, branch)) |
||||
|
||||
@bp.route('/delete/<doc_name>/<branch>') |
||||
def delete(doc_name, branch): |
||||
doc = Document(doc_name, branch) |
||||
doc.delete() |
||||
return redirect(url_for('admin.index'), code=302) |
||||
|
||||
@bp.route('/delete_invalid/<doc_name>/<branch>') |
||||
def delete_invalid(doc_name, branch): |
||||
doc = Document(doc_name, branch, allow_invalid = True) |
||||
doc.delete_folder() |
||||
return redirect(url_for('admin.index'), code=302) |
Loading…
Reference in new issue