Ticket #3957 (partial) - ganeti_webmgr uses ganeti python namespace:
[ganeti_webmgr.git] / ganeti_web / templates / search / search.html
blob36e2c974802230184cc51112a6f79d79880d345f
1 {% extends 'menu_base.html' %}
2 {% load webmgr_tags %}
3 {% block content %}
5 <style>
6 #search_result_title{
7 margin-bottom: 20px;
10 #search_results li{
11 margin-left: 20px;
12 margin-top: 20px;
13 margin-bottom: 10px;
16 #search_results p{
17 margin-top: 5px;
18 margin-bottom: 5px;
21 .result_title{
22 font-size: 1.5em;
25 .result_title .highlight{
26 font-size: 1em;
27 font-weight: bold;
29 </style>
31 {# If there was a query... #}
32 {% if query %}
34 <script type="text/javascript">
36 // Grab the actual search query
37 TERM = '{{ query }}';
39 // Highlight the matched terms in the results
40 $(function(){
41 $('.result_title').each(function(){
42 var ORIG_TEXT = $(this).text();
43 var INDEX_OF_TERM = ORIG_TEXT.indexOf(TERM);
44 var BEFORE_TERM = ORIG_TEXT.substring(0, INDEX_OF_TERM);
45 var AFTER_TERM = ORIG_TEXT.substring(
46 INDEX_OF_TERM+TERM.length, ORIG_TEXT.length);
47 $(this).html(
48 BEFORE_TERM +
49 "<span class='highlight'>" + TERM + "</span>" +
50 AFTER_TERM
52 });
53 });
54 </script>
56 <h1 id='search_result_title'>Search results</h1>
58 {# If there were results, list them #}
59 {% if page.object_list %}
60 <ul id='search_results'>
61 {% for result in page.object_list %}
62 <li>
63 {# If the result was a VirtualMachine #}
64 {% if result.model_name == 'virtualmachine' %}
65 {% with result.object as vm %}
66 <a href='{% url instance-detail vm.cluster.slug result.object.hostname %}'>
67 <div class='result_title'>{{vm.hostname}}</div>
68 </a>
69 <p>
70 <b>Virtual Machine</b> on cluster
71 <a href='{% url cluster-detail vm.cluster.slug %}'>
72 {{ vm.cluster|abbreviate_fqdn }}
73 </a> |
74 {{vm.operating_system|render_os}} |
75 {{vm.virtual_cpus}} CPUs |
76 {{vm.ram|render_storage}} RAM |
77 {{vm.disk_size|render_storage}} disk
78 </p>
79 {% endwith %}
81 {# Otherwise, if the result is a Cluster #}
82 {% else %}{% if result.model_name == 'cluster' %}
83 {% with result.object as cluster %}
84 <a href='{% url cluster-detail cluster.slug %}'>
85 <div class='result_title'>{{cluster.hostname}}</div>
86 </a>
87 <p>
88 <b>Cluster</b> on master node
89 <a href='{% url node-detail cluster.slug cluster.info.master %}'>
90 {{cluster.info.master|abbreviate_fqdn}}
91 </a> |
92 {% if cluster.description %}
93 {{cluster.description}} |
94 {% endif %}
95 v{{cluster.info.software_version}} |
96 {{cluster.info.default_hypervisor}} hypervisor |
98 {% if cluster.nodes.count == 1 %}
99 1 node
100 {% else %}
101 {{cluster.nodes.count}} nodes
102 {% endif %} |
104 {% if cluster.virtual_machines.count == 1 %}
105 1 virtual machine
106 {% else %}
107 {{cluster.virtual_machines.count}} virtual machines
108 {% endif %}
109 </p>
110 {% endwith %}
112 {# Otherwise, if the result is a Node #}
113 {% else %}{% if result.model_name == 'node' %}
114 {% with result.object as node %}
115 <a href='{% url node-detail node.cluster.slug node.hostname %}'>
116 <div class='result_title'>{{ node.hostname }}</div>
117 </a>
118 <b>Node</b> |
119 {% node_memory node %} GiB RAM |
120 {% node_disk node %} GiB disk |
121 {{ node.info.pinst_cnt }} / {{ node.info.sinst_cnt }} instances (P/S)
122 {% endwith %}
123 {% endif %}{% endif %}{% endif %}
124 </li>
125 {% endfor %}
126 </ul>
128 {# Otherwise, no results were found #}
129 {% else %}{% if query|length < 2 %}
130 <h2>Search query too short!</h2>
131 <p>Please make your search query at least two characters long.</p>
132 {% else %}
133 <h2>No results</h2>
134 <p>No results matching "{{query}}".</p>
135 {% endif %}{% endif %}
137 {# Paging stuffs #}
138 {% if page.has_previous or page.has_next %}
139 <div>
140 {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %}
142 {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %}
143 </div>
144 {% endif %}
146 {# If no query was entered... #}
147 {% else %}
148 <h1>Not sure which <del>droids</del> virtual machines you're looking for...</h1>
150 Please enter a query in the search box in the sidebar.
151 </p>
152 {% endif %}
154 {% endblock %}