0001-Feature-764-Add-enable-disable-support-for-templates.patch
src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb | ||
---|---|---|
44 | 44 |
rc = case action_hash['perform'] |
45 | 45 |
when "publish" then self.publish |
46 | 46 |
when "unpublish" then self.unpublish |
47 |
when "enable" then self.enable |
|
48 |
when "disable" then self.disable |
|
47 | 49 |
when "update" then self.update(action_hash['params']) |
48 | 50 |
when "chown" then self.chown(action_hash['params']) |
49 | 51 |
when "instantiate" then self.instantiate(action_hash['params']) |
src/sunstone/public/js/opennebula.js | ||
---|---|---|
2498 | 2498 |
} |
2499 | 2499 |
}); |
2500 | 2500 |
}, |
2501 | ||
2502 |
"enable" : function(params) |
|
2503 |
{ |
|
2504 |
var callback = params.success; |
|
2505 |
var callback_error = params.error; |
|
2506 |
var id = params.data.id; |
|
2507 | ||
2508 |
var method = "enable"; |
|
2509 |
var action = OpenNebula.Helper.action(method); |
|
2510 |
var resource = OpenNebula.Template.resource; |
|
2511 |
var request = OpenNebula.Helper.request(resource,method, id); |
|
2512 | ||
2513 |
$.ajax({ |
|
2514 |
url: "template/" + id + "/action", |
|
2515 |
type: "POST", |
|
2516 |
data: JSON.stringify(action), |
|
2517 |
success: function() |
|
2518 |
{ |
|
2519 |
if (callback) |
|
2520 |
{ |
|
2521 |
callback(request); |
|
2522 |
} |
|
2523 |
}, |
|
2524 |
error: function(response) |
|
2525 |
{ |
|
2526 |
if(callback_error) |
|
2527 |
{ |
|
2528 |
callback_error(request, OpenNebula.Error(response)); |
|
2529 |
} |
|
2530 |
} |
|
2531 |
}); |
|
2532 |
}, |
|
2533 |
"disable" : function(params) |
|
2534 |
{ |
|
2535 |
var callback = params.success; |
|
2536 |
var callback_error = params.error; |
|
2537 |
var id = params.data.id; |
|
2538 | ||
2539 |
var method = "disable"; |
|
2540 |
var action = OpenNebula.Helper.action(method); |
|
2541 |
var resource = OpenNebula.Template.resource; |
|
2542 |
var request = OpenNebula.Helper.request(resource,method, id); |
|
2543 | ||
2544 |
$.ajax({ |
|
2545 |
url: "template/" + id + "/action", |
|
2546 |
type: "POST", |
|
2547 |
data: JSON.stringify(action), |
|
2548 |
success: function() |
|
2549 |
{ |
|
2550 |
if (callback) |
|
2551 |
{ |
|
2552 |
callback(request); |
|
2553 |
} |
|
2554 |
}, |
|
2555 |
error: function(response) |
|
2556 |
{ |
|
2557 |
if(callback_error) |
|
2558 |
{ |
|
2559 |
callback_error(request, OpenNebula.Error(response)); |
|
2560 |
} |
|
2561 |
} |
|
2562 |
}); |
|
2563 |
}, |
|
2564 | ||
2565 | ||
2501 | 2566 |
"list" : function(params) |
2502 | 2567 |
{ |
2503 | 2568 |
var callback = params.success; |
src/sunstone/public/js/plugins/templates-tab.js | ||
---|---|---|
30 | 30 |
<th>Name</th>\ |
31 | 31 |
<th>Registration time</th>\ |
32 | 32 |
<th>Public</th>\ |
33 |
<th>Enabled</th>\ |
|
33 | 34 |
</tr>\ |
34 | 35 |
</thead>\ |
35 | 36 |
<tbody id="tbodytemplates">\ |
... | ... | |
678 | 679 |
notify: true |
679 | 680 |
}, |
680 | 681 | |
682 |
"Template.enable" : { |
|
683 |
type: "multiple", |
|
684 |
call: OpenNebula.Template.enable, |
|
685 |
callback: templateShow, |
|
686 |
elements: templateElements, |
|
687 |
error: onError, |
|
688 |
notify: true |
|
689 |
}, |
|
690 | ||
691 |
"Template.disable" : { |
|
692 |
type: "multiple", |
|
693 |
call: OpenNebula.Template.disable, |
|
694 |
callback: templateShow, |
|
695 |
elements: templateElements, |
|
696 |
error: onError, |
|
697 |
notify: true |
|
698 |
}, |
|
699 | ||
681 | 700 |
"Template.delete" : { |
682 | 701 |
type: "multiple", |
683 | 702 |
call: OpenNebula.Template.delete, |
... | ... | |
766 | 785 |
type: "action", |
767 | 786 |
text: "Unpublish" |
768 | 787 |
}, |
788 |
"Template.enable" : { |
|
789 |
type: "action", |
|
790 |
text: "Enable" |
|
791 |
}, |
|
792 |
"Template.disable" : { |
|
793 |
type: "action", |
|
794 |
text: "Disable" |
|
795 |
}, |
|
769 | 796 |
} |
770 | 797 |
}, |
771 | 798 |
"Template.delete" : { |
... | ... | |
812 | 839 |
template.GNAME, |
813 | 840 |
template.NAME, |
814 | 841 |
pretty_time(template.REGTIME), |
815 |
parseInt(template.PUBLIC) ? "yes" : "no" |
|
842 |
parseInt(template.PUBLIC,10) ? "yes" : "no", |
|
843 |
parseInt(template.ENABLED,10) ? "yes" : "no" |
|
816 | 844 |
]; |
817 | 845 |
} |
818 | 846 | |
... | ... | |
909 | 937 |
</tr>\ |
910 | 938 |
<tr>\ |
911 | 939 |
<td class="key_td">Public</td>\ |
912 |
<td class="value_td">'+(parseInt(template_info.PUBLIC) ? "yes" : "no")+'</td>\ |
|
940 |
<td class="value_td">'+(parseInt(template_info.PUBLIC,10) ? "yes" : "no")+'</td>\ |
|
941 |
</tr>\ |
|
942 |
<tr>\ |
|
943 |
<td class="key_td">Enabled</td>\ |
|
944 |
<td class="value_td">'+(parseInt(template_info.ENABLED,10) ? "yes" : "no")+'</td>\ |
|
913 | 945 |
</tr>\ |
914 | 946 |
</table>' |
915 | 947 |
}; |
... | ... | |
1964 | 1996 |
{ "bSortable": false, "aTargets": ["check"] }, |
1965 | 1997 |
{ "sWidth": "60px", "aTargets": [0] }, |
1966 | 1998 |
{ "sWidth": "35px", "aTargets": [1] }, |
1967 |
{ "sWidth": "100px", "aTargets": [2,3,4] } |
|
1999 |
{ "sWidth": "100px", "aTargets": [2,3,4,6,7] }
|
|
1968 | 2000 |
] |
1969 | 2001 |
}); |
1970 | 2002 | |
1971 | 2003 |
dataTable_templates.fnClearTable(); |
1972 | 2004 |
addElement([ |
1973 | 2005 |
spinner, |
1974 |
'','','','','',''],dataTable_templates); |
|
2006 |
'','','','','','',''],dataTable_templates);
|
|
1975 | 2007 |
Sunstone.runAction("Template.list"); |
1976 | 2008 | |
1977 | 2009 |
setupCreateTemplateDialog(); |
1978 |
- |