From 37e8224369ec70fde4d852dc723bf30692819e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20P=C5=82aczek?= Date: Wed, 21 Mar 2018 11:36:47 +0100 Subject: [PATCH 1/2] Instrukcja uruchomienia. --- README.md | 6 ++++++ index.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3863662..af03832 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # docker_flask + +## Run + `set FLASK_APP=index.py + set FLASK_DEBUG=1 + set + flask run -p 5001` \ No newline at end of file diff --git a/index.py b/index.py index 01b7ced..9731a96 100644 --- a/index.py +++ b/index.py @@ -380,5 +380,6 @@ def slugify(text): app.secret_key = b'\xd7:o\\\xaayFe\x1ey\x08m9\xe4\xbc!\xee\x0e>\xd1Z\x99-\xbb' +#http://flask.pocoo.org/snippets/133/ @TODO if __name__ == "__main__": - app.run(host="0.0.0.0", port=5002, debug=True, threaded=True) + app.run(host="0.0.0.0", port=5001, debug=True, threaded=True) -- 2.52.0 From a26863e74f1e25e351fc72db7638c67b5cb70c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20P=C5=82aczek?= Date: Thu, 22 Mar 2018 10:46:55 +0100 Subject: [PATCH 2/2] Displaying port mappings on container lists. Neater json formatting. --- index.py | 10 +++++++-- static/style.css | 16 ++++++++++++- templates/container.html | 12 +++++----- templates/containers.html | 47 ++++++++++++--------------------------- 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/index.py b/index.py index 9731a96..c0f03d4 100644 --- a/index.py +++ b/index.py @@ -5,6 +5,7 @@ import re import unidecode import datetime import base64 +import json # # from flask_wtf import FlaskForm @@ -184,7 +185,12 @@ def containers_all_action(client_name): def container_action(client_name, short_id=None): if client_name in clients: container = clients[client_name].containers.get(short_id) - return render_template('container.html', container=container, client_name=client_name) + # parsed = json.loads(container.attrs) + + # print() + + return render_template('container.html', container=container, client_name=client_name, + container_attributes=json.dumps(container.attrs, indent=4)) else: flash('Client name \'%s\' not found' % client_name) return redirect(url_for('index')) @@ -380,6 +386,6 @@ def slugify(text): app.secret_key = b'\xd7:o\\\xaayFe\x1ey\x08m9\xe4\xbc!\xee\x0e>\xd1Z\x99-\xbb' -#http://flask.pocoo.org/snippets/133/ @TODO +# http://flask.pocoo.org/snippets/133/ @TODO if __name__ == "__main__": app.run(host="0.0.0.0", port=5001, debug=True, threaded=True) diff --git a/static/style.css b/static/style.css index 58bc3e3..24267a8 100644 --- a/static/style.css +++ b/static/style.css @@ -110,4 +110,18 @@ padding: 5px 15px; .details__entrypoint { display: inline-block; width: 210px; } .details__image { display: inline-block; } -.details__more-info {display: none; } \ No newline at end of file +.details__more-info { margin: 5px 10px; } +.more-info__ports { } +.more-info__ports--line { +display: list-item; +list-style-position: inside; +margin: 8px 8px; +} + +.container_attribute { + +} +.container_attribute-details { + white-space: pre; + line-height: 1.1em; +} \ No newline at end of file diff --git a/templates/container.html b/templates/container.html index 69af4fa..b906315 100644 --- a/templates/container.html +++ b/templates/container.html @@ -1,17 +1,17 @@ {% extends "layout.html" %} {% block body %} -

Dashboard » {{ client_name }} » Containers » {{ container.name }}

+

Dashboard » {{ client_name }} » Containers + » {{ container.name }}

-

Details

-
-{{ container.attrs|pprint }}
-
-
+
+
{{ container_attributes }}
+
{% endblock %} \ No newline at end of file diff --git a/templates/containers.html b/templates/containers.html index c23c7ff..e2c42ab 100644 --- a/templates/containers.html +++ b/templates/containers.html @@ -28,26 +28,11 @@ container.attrs.Config.Labels['com.docker.compose.project'] }} {% endif%} - - - - - - - - - - - - - - - -
-
{{ container.status }}
- @@ -61,17 +46,15 @@
{% for port in container.attrs['NetworkSettings']['Ports'] %} - {{ port }} {% if container.attrs['NetworkSettings']['Ports'][port] is not none %} - {% if container.attrs['NetworkSettings']['Ports'][port] is not none and container.attrs['NetworkSettings']['Ports'][port]|length > 0 %} {% for port_exposed in container.attrs['NetworkSettings']['Ports'][port] %} - ->{{ port_exposed['HostIp'] }}:{{ port_exposed['HostPort'] }} - + {{ port }} -> {{ port_exposed['HostIp'] }}:{{ port_exposed['HostPort'] }} {% endfor %} {% endif %} {% endif %} + {% endfor %}
@@ -80,17 +63,15 @@
- log - export - {% if (container.status == 'exited') or (container.status == 'created') %} - start - remove - {% endif %} - - {% if container.status == 'running' %} - stop - restart - top + log + export + {% if (container.status == 'exited') or (container.status == 'created') %}start + remove + {% endif %}{% if container.status == 'running' %} + stop + restart + top {% endif %}
-- 2.52.0