{% extends "base.html" %}
{% load static %}
{% block head %}
    <meta name="nonfiction" content="true">
    <script type="text/javascript" src="{% static "javascript/loader.js" %}"></script>
{% endblock %}
{% block title %}Networks{% endblock %}
{% block description %}Configred networks{% endblock %}
{% block keywords %}irc networks{% endblock %}
{% block keywords-not %}{% endblock %}
{% block content %}
    <article class="ui text container">
        <header class="ui four statistics">
            <div class="statistic">
                <div class="value">
                    <i class="sitemap icon"></i> {{ networks|length }}
                </div>
                <div class="label">
                    Networks
                </div>
            </div>
            <div class="statistic">
                <div class="value">
                    <i class="hashtag icon"></i> {{ channels|length }}
                </div>
                <div class="label">
                    Channels
                </div>
            </div>
            <div class="statistic">
                <div class="value">
                    <i class="users icon"></i> {{ users|length }}
                </div>
                <div class="label">
                    Users
                </div>
            </div>
            <div class="statistic">
                <div class="value">
                    <i class="comments outline icon"></i> {{ totalmessages }}
                </div>
                <div class="label">
                    Messages
                </div>
            </div>
        </header>
        <section class="ui basic segment container">
            <div class="ui basic segment">
                <div class="ui celled selection link list">
                    {% for network in networks %}
                        <a class="item" href="{% url 'stats:network' network.name %}">
                            <div class="right floated content">
                                {% if network.password %}<i class="privacy icon" alt="NickServ password saved"></i>{% endif %}
                                {% if network.use_ssl %}<i class="protect icon" title="Encrypted connection"></i>{% endif %}
                                </div>
                            <i class="middle aligned server icon"></i>
                            <div class="content">
                                <div class="header">
                                    <div class="content" href="{% url 'stats:network' network.name %}">{{ network.name }}</div>
                                </div>
                                <div class="description">
                                    {{ network.host }}:{{ network.port }}
                                </div>
                            </div>
                        </a>
                    {% endfor %}
                </div>
            </div>
        </section>
    </article>
    <section class="ui container">
        <div class="ui stackable cards">
            <script type="text/javascript">
                google.charts.load("current", {packages:["corechart"]});
                google.charts.setOnLoadCallback(drawChart0);
                function drawChart0() {
                    var data = google.visualization.arrayToDataTable([
                        ['Network', 'Messages'],
                        {% for network in networklist.items %}
                            ['{{ network.0 }}',     {{ network.1.messages }}],
                        {% endfor %}
                    ]);
                    var options = {
                        legend: 'none',
                        pieSliceText: 'label',
                        height: '275',
                        pieHole: 0.1,
                        'chartArea': {'width': '95%', 'height': '100%'},
                        pieSliceText: 'label',
                    };
                    var chart = new google.visualization.PieChart(document.getElementById('messageschart'));
                    chart.draw(data, options);
                }
            </script>
            <div class="ui card">
                <div class="content">
                    <div class="header">
                        <div>
                            <i class="ui users icon"></i>
                            /
                            <i class="ui sitemap icon"></i>
                        </div>
                    </div>
                </div>
                <div class="content">
                    <div id="messageschart"></div>
                </div>
            </div>
            <script type="text/javascript">
                google.charts.load("current", {packages:["corechart"]});
                google.charts.setOnLoadCallback(drawChart);
                function drawChart() {
                    var data = google.visualization.arrayToDataTable([
                        ['Network', 'Users'],
                            {% for network in networklist.items %}
                                ['{{ network.0 }}',     {{ network.1.users }}],
                            {% endfor %}
                        ]);
                    var options = {
                        legend: 'none',
                        pieSliceText: 'label',
                        height: '275',
                        pieHole: 0.1,
                        'chartArea': {'width': '95%', 'height': '100%'},
                    };
                    var chart = new google.visualization.PieChart(document.getElementById('userschart'));
                    chart.draw(data, options);
                }
            </script>
            <div class="ui card">
                <div class="content">
                    <div class="header">
                    <div>
                        <i class="ui users icon"></i>
                        /
                        <i class="ui sitemap icon"></i>
                    </div>
                    </div>
                </div>
                <div class="content">
                    <div id="userschart"></div>
                </div>
            </div>
            <script type="text/javascript">
                google.charts.load("current", {packages:["corechart"]});
                google.charts.setOnLoadCallback(drawChart1);
                function drawChart1() {
                    var data = google.visualization.arrayToDataTable([
                        ['Network', 'Channels'],
                            {% for network in networklist.items %}
                                ['{{ network.0 }}',     {{ network.1.channels }}],
                            {% endfor %}
                        ]);
                    var options = {
                        legend: 'none',
                        pieSliceText: 'label',
                        height: '275',
                        pieHole: 0.1,
                        'chartArea': {'width': '95%', 'height': '100%'},
                    };
                    var chart = new google.visualization.PieChart(document.getElementById('networkschart'));
                    chart.draw(data, options);
                }
            </script>
            <div class="ui card">
                <div class="content">
                    <div class="header">
                    <div>
                        <i class="ui hashtag icon"></i>
                        /
                        <i class="ui sitemap icon"></i>
                    </div>
                    </div>
                </div>
                <div class="content">
                    <div id="networkschart"></div>
                </div>
            </div>
        </div>
    </section>
{% endblock content %}
{% block breadcrumbs %}
    <i class="sitemap icon"></i>
    <div class="active section">Networks</div>
{% endblock %}
