readme, json formatting, port mapping is now displayed. #2
10
index.py
10
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)
|
||||
|
||||
@@ -110,4 +110,18 @@ padding: 5px 15px;
|
||||
.details__entrypoint { display: inline-block; width: 210px; }
|
||||
.details__image { display: inline-block; }
|
||||
|
||||
.details__more-info {display: none; }
|
||||
.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;
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
|
||||
<h1><a href="/">Dashboard</a> » {{ client_name }} » <a href="/{{ client_name }}/containers">Containers</a> » {{ container.name }}</h1>
|
||||
<h1><a href="/">Dashboard</a> » {{ client_name }} » <a href="/{{ client_name }}/containers">Containers</a>
|
||||
» {{ container.name }}</h1>
|
||||
|
||||
<form action="{{ url_for('rename_container', client_name=client_name) }}" method="post">
|
||||
<p><input type="text" name="name" size="60" value="{{ container.name }}"><!--
|
||||
<p><input type="text" name="name" size="60" value="{{ container.name }}"><!--
|
||||
--><input type="hidden" name="short_id" value="{{ container.short_id }}"><!--
|
||||
--><input type="submit" value="rename">
|
||||
</form>
|
||||
|
||||
<h2>Details</h2>
|
||||
<pre>
|
||||
{{ container.attrs|pprint }}
|
||||
|
||||
</pre>
|
||||
<div class="container_attribute">
|
||||
<div class="container_attribute-details">{{ container_attributes }}</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -28,26 +28,11 @@
|
||||
container.attrs.Config.Labels['com.docker.compose.project'] }}</a></h2>
|
||||
{% endif%}
|
||||
|
||||
<!--<table>-->
|
||||
<!--<thead>-->
|
||||
<!--<tr>-->
|
||||
<!--<th>COMPOSE PROJECT</th>-->
|
||||
<!--<th>CONTAINER ID</th>-->
|
||||
<!--<th>NAME</th>-->
|
||||
<!--<th>COMMAND</th>-->
|
||||
<!--<th>CREATED</th>-->
|
||||
<!--<th>STATUS</th>-->
|
||||
<!--<th>PORTS</th>-->
|
||||
<!--<th>IMAGE</th>-->
|
||||
<!--</tr>-->
|
||||
<!--</thead>-->
|
||||
<!--<tbody>-->
|
||||
|
||||
|
||||
<div class="details">
|
||||
<div>
|
||||
<div class="details__status details__status--{{ container.status }}">{{ container.status }}</div>
|
||||
<div class="details__name"><a class="button--link"
|
||||
<div class="details__status details__status--{{ container.status }}">{{ container.status }}
|
||||
</div><div
|
||||
class="details__name"><a class="button--link"
|
||||
href="/{{ client_name }}/containers/id/{{ container.short_id }}">{{
|
||||
container.name
|
||||
}}</a></div>
|
||||
@@ -61,17 +46,15 @@
|
||||
<div class="details__more-info">
|
||||
<div class="more-info__ports">
|
||||
{% 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'] }}
|
||||
|
||||
<span class="more-info__ports--line">{{ port }} -> {{ port_exposed['HostIp'] }}:{{ port_exposed['HostPort'] }}</span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -80,17 +63,15 @@
|
||||
|
||||
</div>
|
||||
<div class="details__controll">
|
||||
<a class="button--link" href="/{{ client_name }}/containers/log/{{ container.short_id }}">log</a>
|
||||
<a class="button--link" href="/{{ client_name }}/containers/export/{{ container.short_id }}">export</a>
|
||||
{% if (container.status == 'exited') or (container.status == 'created') %}
|
||||
<a class="button--link" href="/{{ client_name }}/containers/start/{{ container.short_id }}">start</a>
|
||||
<a class="button--link" href="/{{ client_name }}/containers/remove/{{ container.short_id }}">remove</a>
|
||||
{% endif %}
|
||||
|
||||
{% if container.status == 'running' %}
|
||||
<a class="button--link" href="/{{ client_name }}/containers/stop/{{ container.short_id }}">stop</a>
|
||||
<a class="button--link" href="/{{ client_name }}/containers/restart/{{ container.short_id }}">restart</a>
|
||||
<a class="button--link" href="/{{ client_name }}/containers/top/{{ container.short_id }}">top</a>
|
||||
<a class="button--link" href="/{{ client_name }}/containers/log/{{ container.short_id }}">log
|
||||
</a><a class="button--link" href="/{{ client_name }}/containers/export/{{ container.short_id }}">export
|
||||
</a>{% if (container.status == 'exited') or (container.status == 'created') %}<a class="button--link"
|
||||
href="/{{ client_name }}/containers/start/{{ container.short_id }}">start
|
||||
</a><a class="button--link" href="/{{ client_name }}/containers/remove/{{ container.short_id }}">remove</a>
|
||||
{% endif %}{% if container.status == 'running' %}
|
||||
<a class="button--link" href="/{{ client_name }}/containers/stop/{{ container.short_id }}">stop
|
||||
</a><a class="button--link" href="/{{ client_name }}/containers/restart/{{ container.short_id }}">restart
|
||||
</a><a class="button--link" href="/{{ client_name }}/containers/top/{{ container.short_id }}">top</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user