Merge branch 'bug/13917' into release/0.10.2
[ganeti_webmgr.git] / ganeti_web / templates / search / search.html
blob3e4176f731d1c3e6e9e5c3a4898ad63936c6b007
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>
89 {% if cluster.info.master %}
90 on master node
91 <a href='{% url node-detail cluster.slug cluster.info.master %}'>
92 {{cluster.info.master|abbreviate_fqdn}}
93 </a> |
94 {% endif %}
95 {% if cluster.description %}
96 {{cluster.description}} |
97 {% endif %}
98 {% if cluster.info %}
99 v{{cluster.info.software_version}} |
100 {{cluster.info.default_hypervisor}} hypervisor |
101 {% endif %}
102 {% if cluster.nodes.count == 1 %}
103 1 node
104 {% else %}
105 {{cluster.nodes.count}} nodes
106 {% endif %} |
108 {% if cluster.virtual_machines.count == 1 %}
109 1 virtual machine
110 {% else %}
111 {{cluster.virtual_machines.count}} virtual machines
112 {% endif %}
113 </p>
114 {% endwith %}
116 {# Otherwise, if the result is a Node #}
117 {% else %}{% if result.model_name == 'node' %}
118 {% with result.object as node %}
119 <a href='{% url node-detail node.cluster.slug node.hostname %}'>
120 <div class='result_title'>{{ node.hostname }}</div>
121 </a>
122 <b>Node</b> |
123 {% node_memory node %} GiB RAM |
124 {% node_disk node %} GiB disk |
125 {{ node.info.pinst_cnt }} / {{ node.info.sinst_cnt }} instances (P/S)
126 {% endwith %}
127 {% endif %}{% endif %}{% endif %}
128 </li>
129 {% endfor %}
130 </ul>
132 {# Otherwise, no results were found #}
133 {% else %}{% if query|length < 2 %}
134 <h2>Search query too short!</h2>
135 <p>Please make your search query at least two characters long.</p>
136 {% else %}
137 <h2>No results</h2>
138 <p>No results matching "{{query}}".</p>
139 {% endif %}{% endif %}
141 {# Paging stuffs #}
142 {% if page.has_previous or page.has_next %}
143 <div>
144 {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %}
146 {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %}
147 </div>
148 {% endif %}
150 {# If no query was entered... #}
151 {% else %}
152 <h1>Not sure which <del>droids</del> virtual machines you're looking for...</h1>
154 Please enter a query in the search box in the sidebar.
155 </p>
156 {% endif %}
158 {% endblock %}