1 <%doc>Copyright (C) 2009 HDE, Inc.</%doc>
2 <%inherit file="../include/common.part" />
5 from karesansui.lib.template import img_status, str_status, clipping
6 from karesansui.lib.const import MACHINE_NAME_CLIPPING_RANGE
8 <script type="text/javascript">
10 $(document).ready(function(){
13 function guest_location(id){
14 var uri = "${ctx.homepath}${ctx.path}".replace(".part", "");
15 location.href = uri + "/" + id + ".html";
17 function get_target_id(){
19 $("#guests div").each(function(){
20 if($(this).hasClass("active") == true){
21 target_id = $(this).attr("id").replace("guest_", "");
30 $("#guests div").each(function(){
32 $(this).click(function(){
33 past_active_id = active_id
34 active_id = $(this).attr("id").replace("guest_", "")
36 if($(this).hasClass("active") == true){
37 guest_location(active_id);
40 if($(this).hasClass("passive") == true){
41 uri = "${ctx.homepath}${ctx.path}".replace(".part", "");
44 uri + "/" + active_id + ".json",
46 function(data, status) {
47 var _s = "<table class='detail-contents'>";
50 var _g = "<table cellspacing='0' cellpadding='0' class='detail-sub-contents'>";
51 _g += make_tr("${_('Name')}", data.model.name);
52 _g += make_tr("${_('State')}", str_status(data.virt.state));
53 _g += make_tr("${_('Unique Key')}", data.model.uniq_key);
54 _g += make_tr("${_('Domain Name')}", data.virt.name);
57 if(data.autostart == true){
58 autostart = "${_('ON')}";
60 autostart = "${_('OFF')}";
62 _g += make_tr("${_('Autostart')}", autostart);
65 if(data.info["os"] != null){
68 os = "${_('Unknown')}";
70 _g += make_tr("${_('OS Type')}", os);
73 if(data.model.tags.length > 0){
74 for(var i = 0; i < data.model.tags.length; i++){
75 tags += data.model.tags[i].name + ", ";
77 tags = tags.slice(0, tags.length - 2)
79 tags = "${_('No tag')}"
81 _g += make_tr("${_('Tag Name')}", tags);
84 _s += make_tr("${_('General Information')}", _g, true);
89 var _n = "<table cellspacing='0' cellpadding='0' class='detail-sub-contents'>";
90 var notebook_title = ""
91 if(data.model.notebook.title != ""){
92 notebook_title = data.model.notebook.title
94 notebook_title = "${_('No title')}"
96 _n += make_tr("${_('Title')}", notebook_title);
98 var notebook_value = ""
99 if(data.model.notebook.value != ""){
100 notebook_value = data.model.notebook.value
102 notebook_value = "${_('N/A')}"
104 _n += make_tr("${_('Note')}", notebook_value);
107 _s += make_tr("${_('Notebook')}", _n, true);
112 var _d = "<table cellspacing='0' cellpadding='0' class='detail-sub-contents'>";
113 _d += make_tr("${_('CPU Time (seconds)')}", format_cputime(data.info["cpu"] / (1000.00 * 1000.00 * 1000.00)));
114 _d += make_tr("${_('Memory Size (MB)')}", Math.floor(data.info["memory"] / 1024));
117 if(data.diskinfo.length > 0){
118 disks = join_comma(data.diskinfo)
120 disks = "${_('No Disk')}"
122 _d += make_tr("${_('Disk Info')}", disks);
125 if(data.interfaceinfo.length > 0){
126 inters = join_comma(data.interfaceinfo)
128 inters = "${_('No interface')}"
130 _d += make_tr("${_('Interface Info')}", inters);
133 if(data.netinfo.length > 0){
134 nets = join_comma(data.netinfo)
136 nets = "${_('No network')}"
138 _d += make_tr("${_('Network Info')}", nets);
141 _s += make_tr("${_('Device')}", _d, true);
146 var _a = "<table cellspacing='0' cellpadding='0' class='detail-sub-contents'>";
147 _a += make_tr("${_('Created User')}", data.model.created_user.nickname);
148 _a += make_tr("${_('Modified User')}", data.model.modified_user.nickname);
149 _a += make_tr("${_('Date Created')}", data.model.created);
150 _a += make_tr("${_('Date Modified')}", data.model.modified);
152 _s += make_tr("${_('Audit')}", _a, true);
155 $("#detail_value").html(_s);
160 // privent illegal error by assign class complete ajax communication
161 $("#guests div").each(function() {
162 $(this).removeClass("active").addClass("passive")
164 $(this).removeClass("passive").addClass("active")
165 if(typeof(past_active_id) != "undefined"){
166 $("#guest_" + past_active_id).unbind("click.active");
173 $(this).one("click.once", function(){
175 $("#edit_guest").click(function(){
176 var target_id = get_target_id();
177 if(target_id != null){
179 "${ctx.homepath}/grayout.part",
182 uri + "/" + target_id + ".part?mode=input",
183 "${_('Guest Settings')}",
184 "${ctx.homepath}${ctx.path}");
186 alert_on(".alert", "ERROR", "${_('Please select a target.')}");
189 tool_reset("#edit_guest");
192 $("#replicate_guest").click(function(){
193 var target_id = get_target_id();
194 if(target_id != null){
196 "${ctx.homepath}/grayout.part",
199 uri + "/replicate?mode=input&src_id=" + target_id,
200 "${_('Guest Settings')}",
201 "${ctx.homepath}${ctx.path}");
203 alert_on(".alert", "ERROR", "${_('Please select a target.')}");
206 tool_reset("#replicate_guest");
209 $("#delete_guest").click(function(){
210 var target_id = get_target_id();
211 if(target_id != null){
212 url = uri + "/" + target_id + ".part";
213 reflush = "${ctx.homepath}${ctx.path}"
215 delete_dialog("#dialog", url, param, reflush, "#delete_guest");
217 alert_on(".alert", "ERROR", "${_('Please select a target.')}");
220 tool_reset("#delete_guest");
222 $("#guests div").each(function(){
223 $(this).unbind("click.once");
226 renew_main_event("#tool_renew", "${ctx.homepath}${ctx.path}");
230 $("#create_guest").click(function(){
232 "${ctx.homepath}/grayout.part",
236 "${ctx.homepath}${ctx.path}?mode=input",
237 "${_('Guest Settings')}",
238 "${ctx.homepath}${ctx.path}");
247 "${ctx.homepath}${ctx.path}".replace(".part", "") + "/tag.part"
250 $("#action>a").hover(
251 function(){tool_over(this);},
252 function(){tool_over(this);}
253 ).mousedown(function(){
254 var id = $(this).attr("id");
257 tool_invalid("#edit_guest");
258 tool_invalid("#replicate_guest");
259 tool_invalid("#delete_guest");
264 <div class="alert"></div>
265 <div id="dialog"></div>
267 <div class="left"></div>
269 <a href="#" class="tool-link" name="create_guest" id="create_guest">
270 <div class="tool-mid">
271 <div class="tool-left"></div>
272 <div class="tool-img">
273 <img src="${ctx.homepath}/static/images/tool-add.png" alt="" />
275 <div class="tool-right">
276 <div class="tool-text">${_('Create')}</div>
280 <a href="#" class="tool-link" id="edit_guest">
281 <div class="tool-mid">
282 <div class="tool-left"></div>
283 <div class="tool-img">
284 <img src="${ctx.homepath}/static/images/tool-edit.png" alt="" />
286 <div class="tool-right">
287 <div class="tool-text">${_('Edit')}</div>
291 <a href="#" class="tool-link" name="" id="replicate_guest">
292 <div class="tool-mid">
293 <div class="tool-left"></div>
294 <div class="tool-img">
295 <img src="${ctx.homepath}/static/images/tool-copy.png" alt="" />
297 <div class="tool-right">
298 <div class="tool-text">${_('Copy')}</div>
302 <a href="#" class="tool-link" name="delete_guest" id="delete_guest">
303 <div class="tool-mid">
304 <div class="tool-left"></div>
305 <div class="tool-img">
306 <img src="${ctx.homepath}/static/images/tool-trash.png" alt="" />
308 <div class="tool-right">
309 <div class="tool-text">${_('Delete')}</div>
315 <a href="#" class="tool-link" >
316 <div class="tool-mid">
317 <img src="${ctx.homepath}/static/images/reload.gif" alt="renew" id="tool_renew"/>
322 <br style="clear: both;"/>
323 <div class="space"></div>
327 <div class="left"></div>
328 <div class="right"></div>
333 <div class="text">${_('Now loading')}</div>
338 <div id="tag-progress"></div>
340 <br style="clear: both;"/>
348 % for guest in guests:
349 <div id="guest_${guest.info['model'].id}" class="passive">
350 <span class="status-b">
351 ${img_status(guest.info['virt'].status())}
353 % if guest.info['model'].webicon() is None:
354 <img src="${ctx.homepath}/static/images/notos.png" alt="" />
356 <img src="${guest.info['model'].webicon()}" alt="" width="124px" height="124px" />
359 ${clipping(guest.info['model'].name, MACHINE_NAME_CLIPPING_RANGE) | h}
361 <span class="status">
362 (${str_status(guest.info['virt'].status(), _)})
370 <br style="clear: both;"/>
371 <div class="space"></div>
375 <span class="title"> </span>
376 <p class="point"> </p>
379 <img src="${ctx.homepath}/static/images/tree-open.gif" alt="" id="show_detail_switch" class="tree-toggle-button"/><span class="msg-title">${_('Details')}</span><br />
380 <span id="detail_value">--</span>
384 <dl><dt> </dt></dl>
388 <br style="clear: both;"/>