dashboard.html 9.81 KB
Newer Older
1
{% extends "base.html" %}
2
{% load staticfiles %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
3
{% load i18n %}
4

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
5
{% block extrahead %}
6 7
    <link href="{% static 'b3theme/css/plugins/morris/morris-0.4.3.min.css' %}" rel="stylesheet">
    <link href="{% static 'b3theme/css/plugins/timeline/timeline.css' %}" rel="stylesheet">
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
8 9
    <style type="text/css">

10

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
	.dl-horizontal dt {
    width: 70px;
}
.dl-horizontal dd {
    margin-left: 90px;
}
</style>
{% endblock %}


{% block title %}{% trans "Dashboard" %}{% endblock %}
{% block contentplaceholder %}
{% csrf_token %}
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">{% trans "Dashboard" %}</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
<div class="row">
                <div class="col-lg-8">
                	<div class="panel panel-primary">
                        <div class="panel-heading">
                            <i class="fa fa-clock-o fa-fw"></i> {% trans "Timeline" %} - {% trans "Latest 10" %}
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
38
                            <div class=panel>{{message}}</div>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
39 40 41
                            <ul class="timeline">
                            	{% for route in routes %}
                                <li class="{% cycle '' 'timeline-inverted' %}">
42

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
                                    	{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}
											{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}
												<div class="timeline-badge"><i class="fa fa-adjust"></i></div>
											{% else %}
												{% if route.status == 'OUTOFSYNC' %}
													<div class="timeline-badge danger"><i class="fa fa-bug"></i></div>
												{% else %}
													<div class="timeline-badge danger"><i class="fa fa-exclamation"></i></div>
												{% endif %}
											{% endif %}
										{% else %}
											{% if route.status == 'ACTIVE' %}
												<div class="timeline-badge success"><i class="fa fa-shield"></i></div>
											{% else %}
												{% if route.status == 'PENDING' %}
													<div class="timeline-badge info"><i class="fa fa-spinner"></i></div>
												{% else %}
													<div class="timeline-badge warning"><i class="fa fa-exclamation"></i></div>
												{% endif %}
											{% endif %}
										{% endif %}

                                    <div class="timeline-panel">
                                        <div class="timeline-heading">
Stauros Kroustouris's avatar
Stauros Kroustouris committed
67
                                            <h4 class="timeline-title"><a href="{{ route.get_absolute_url }}">{{route.name}}</a></h4>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
                                            <p>
                                                <small class="text-muted"><i class="fa fa-pencil-square-o"></i> {% trans "Last update" %}: {{route.last_updated}} {% trans "by" %} {{route.applier}}</small>
                                            </p>
                                            <p>
                                                <small class="text-muted"><i class="fa fa-clock-o"></i> {% trans "Expires" %}: {{ route.expires|date:"d M y" }}</small>
                                            </p>
                                        </div>
                                        <div class="timeline-body">
										<small>
                                        		<p>
                                        			{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' or route.status == 'OUTOFSYNC'%}
														{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}
														<span class="label label-default">DEACTIVATED</span>
														{% else %}
															{% if route.status == 'OUTOFSYNC' %}
																<span class="label label-danger">ERROR</span>
															{% else %}
																<span class="label label-info">{{route.status}}</span>
															{% endif %}
														{% endif %}
													{% else %}
														{% if route.status == 'ACTIVE' %}
															<span class="label label-success">{{route.status}}</span>
														{% else %}
															{% if route.status == 'PENDING' %}
																<span class="label label-info">{{route.status}}</span>
															{% else %}
																<span class="label label-warning">{{route.status}}</span>
															{% endif %}
														{% endif %}
													{% endif %}
                                        		</p>

                                        	{{ route.get_match|safe|escape }}
102

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
103 104 105
                                        	<dl class="dl-horizontal">
                                        		<dt>Then</dt><dd>{{ route.get_then }}</dd>
                                        	</dl>
106

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
107 108 109
										</small>
										<div>
										{% ifequal route.status 'ACTIVE' %}
110
											<a href="{% url edit-route route.name %}" class="btn-info btn btn-xs btn-outline" id="edit_button_{{route.pk}}">{% trans "Edit" %}</a>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
											<button class="del_buttonpre btn-outline btn btn-xs btn-warning" id="{{route.name}}" data-routename="{{route.name}}">{% trans "Deactivate" %}</button>
										{% else %}
											{% if route.status == 'EXPIRED' or route.status == 'ADMININACTIVE' or route.status == 'INACTIVE' %}
												<a href="{% url edit-route route.name %}" class="btn-info btn btn-xs btn-outline" id="edit_button_{{route.pk}}" type="button">{% trans "Reactivate" %}</a>
											{% else %}
												{% ifequal route.status 'OUTOFSYNC' %}
													<a href="{% url edit-route route.name %}" class="btn-info btn btn-xs btn-outline" id="edit_button_{{route.pk}}">{% trans "ReSync" %}</a>
												{% else %}
													{% ifequal route.status 'ERROR' %}
														<a href="{% url edit-route route.name %}" class="btn-info btn btn-xs btn-outline" id="edit_button_{{route.pk}}">{% trans "Fix it!" %}</a>
													{% else %}
													-
													{% endifequal %}
												{% endifequal %}
											{% endif %}
										{% endifequal %}
										</div>
                                        </div>
                                    </div>
                                </li>

                                {% endfor %}
                            </ul>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                	</div>
                   <div class="col-lg-4">
                	<div class="panel panel-default">
                        <div class="panel-heading">
                            <i class="fa fa-tags"></i> {% trans "Shortcuts" %}
                        </div>
                        <!-- /.panel-heading -->
<div class="panel-body">
				<a class="btn btn-sm btn-outline btn-success" id="routebutton" href="{% url add-route %}"><i class="fa fa-plus-circle"></i> {% trans "Add Rule" %}</a>
				<a class="btn btn-sm btn-outline btn-primary"  href="{% url group-routes %}"><i class="fa fa-shield fa-fw"></i> {% trans "My Rules" %}</a>
				<a class="btn btn-sm btn-outline btn-info"  href="{% url user-profile %}"><i class="fa fa-user"></i> {% trans "My Profile" %}</a>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->

                	<div class="chat-panel panel panel-info">
                        <div class="panel-heading">
                            <i class="fa fa-circle-o"></i> Live status
                        </div>
                        <!-- /.panel-heading -->
<div class="panel-body">
	{% include "polldash.html" %}
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                	</div>
                	</div>




{% endblock %}
{% block pagejsbottom %}
{% if user.is_authenticated %}
<script type="text/javascript" src="{% url load-js 'pollerdash' %}"></script>
{% endif %}
<script type="text/javascript" src="{{STATIC_URL}}js/jquery.dataTables.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}js/datatables_bootstrap.js"></script>
<script>
var oldhtml;
var last_element = false;
var refreshUrl = "{% url group-routes-ajax %}";
	$(document).ready( function(){
		$('body').on('click', ".del_buttonpre", function(){
            	var my = $(this);
            	if (last_element != false){
            		last_element.html(oldhtml);
            	}
            	oldhtml = my.parent().html();
            	last_element = my.parent();
            	var routename = $(this).data("routename");
				var btn = '<a href="#" data-toggle="tooltip" title="This will deactivate your rule"  data-routename="'+routename+'" class="del_button btn btn-xs btn-warning"> {% trans "Deactivate" %}</a>'
				var back = '<a href="#" class="revertbutton btn btn-xs btn-info"><i class="fa fa-undo"></i></a>';
            	my.parent().html(back+" "+btn);
            	return false;
            });

            $('body').on('click', ".del_button", function(){
            	last_element = false;
            	var my = $(this);
            	my.html('Deactivating...')
				var routename = $(this).data("routename");
				var delurl = "{% url delete-route 'route_placeholder'%}".replace('route_placeholder', routename.toString());
				$.ajax({
        			type: 'POST',
        			url: delurl,
        			cache: false,
        			success: function(data) {
208

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
	        		}
	    		});
				return false;
			});
			$('body').on('click', '.revertbutton', function () {
            	var my = $(this);
            	my.parent().html(oldhtml);
            	last_element = false;
            	return false;
            });
			$("body").tooltip({ selector: '[data-toggle="tooltip"]' });

	});
</script>


225
{% endblock %}