1201 |
1201 |
});
|
1202 |
1202 |
return false;
|
1203 |
1203 |
}
|
|
1204 |
var test=[];
|
|
1205 |
// get stats
|
|
1206 |
function get_server_stats(serverID) {
|
|
1207 |
$.ajax({
|
|
1208 |
url: API_URL + '/servers/' + serverID + '/stats',
|
|
1209 |
cache: false,
|
|
1210 |
type: "GET",
|
|
1211 |
//async: false,
|
|
1212 |
dataType: "json",
|
|
1213 |
timeout: TIMEOUT,
|
|
1214 |
error: function(jqXHR, textStatus, errorThrown) {
|
|
1215 |
try {
|
|
1216 |
ajax_error(jqXHR.status, undefined, 'Get stats', jqXHR.responseText);
|
|
1217 |
} catch (err) {
|
|
1218 |
ajax_error(err);
|
|
1219 |
}
|
|
1220 |
},
|
|
1221 |
success: function(data, textStatus, jqXHR) {
|
|
1222 |
// in icon view
|
|
1223 |
if ( $.cookie('view') == 0 ) {
|
|
1224 |
$('#' + serverID + ' img.cpu').attr("src", data.stats.cpuBar);
|
|
1225 |
$('#' + serverID + ' img.net').attr("src", data.stats.netBar);
|
|
1226 |
}
|
|
1227 |
// in single view
|
|
1228 |
else if ( $.cookie('view') == 2 ) {
|
|
1229 |
$('#' + serverID + ' div.cpu-graph img.stats').attr("src", data.stats.cpuTimeSeries);
|
|
1230 |
$('#' + serverID + ' div.net-graph img.stats').attr("src", data.stats.netTimeSeries);
|
|
1231 |
}
|
|
1232 |
}
|
|
1233 |
});
|
|
1234 |
return false;
|
|
1235 |
}
|
1204 |
1236 |
|
1205 |
1237 |
// create network
|
1206 |
1238 |
function create_network(networkName){
|
... | ... | |
1622 |
1654 |
return;
|
1623 |
1655 |
}
|
1624 |
1656 |
window.ACTION_ICON_HANDLERS[machines_view] = 1;
|
1625 |
|
|
|
1657 |
|
1626 |
1658 |
if (machines_view == "list")
|
1627 |
|
{
|
|
1659 |
{
|
1628 |
1660 |
// totally different logic for list view
|
1629 |
1661 |
init_action_indicator_list_handlers();
|
1630 |
1662 |
return;
|
1631 |
1663 |
}
|
1632 |
|
|
|
1664 |
|
1633 |
1665 |
function update_action_icon_indicators(force)
|
1634 |
|
{
|
|
1666 |
{
|
1635 |
1667 |
function show(el, action) {
|
1636 |
1668 |
$(".action-indicator", $(el)).attr("class", "action-indicator " + action);
|
1637 |
1669 |
$(".action-indicator", $(el)).show();
|
1638 |
1670 |
}
|
1639 |
1671 |
|
1640 |
|
function hide(el) {
|
|
1672 |
function hide(el) {
|
1641 |
1673 |
$(".action-indicator", $(el)).hide();
|
1642 |
1674 |
}
|
1643 |
|
|
|
1675 |
|
1644 |
1676 |
function get_pending_actions(el) {
|
1645 |
1677 |
return $(".confirm_single:visible", $(el));
|
1646 |
1678 |
}
|
1647 |
|
|
|
1679 |
|
1648 |
1680 |
function other_indicators(el) {
|
1649 |
1681 |
return $("img.wave:visible, img.spinner:visible", $(el))
|
1650 |
1682 |
}
|
1651 |
|
|
|
1683 |
|
1652 |
1684 |
$("div.machine:visible, div.single-container").each(function(index, el){
|
1653 |
1685 |
var el = $(el);
|
1654 |
1686 |
var pending = get_pending_actions(el);
|
... | ... | |
1662 |
1694 |
// skipping force action
|
1663 |
1695 |
force_action = undefined;
|
1664 |
1696 |
}
|
1665 |
|
|
|
1697 |
|
1666 |
1698 |
if (force_action !==undefined && force_action.el === el[0]) {
|
1667 |
1699 |
action = force_action.action;
|
1668 |
1700 |
}
|
... | ... | |
1671 |
1703 |
return;
|
1672 |
1704 |
}
|
1673 |
1705 |
|
1674 |
|
if (pending.length >= 1 && force_action === undefined) {
|
|
1706 |
if (pending.length >= 1 && force_action === undefined) {
|
1675 |
1707 |
action = $(pending.parent()).attr("class").replace("action-container","");
|
1676 |
1708 |
}
|
1677 |
|
|
|
1709 |
|
1678 |
1710 |
if (action in {'console':''}) {
|
1679 |
1711 |
return;
|
1680 |
1712 |
}
|
1681 |
|
|
|
1713 |
|
1682 |
1714 |
if (action !== undefined) {
|
1683 |
1715 |
show(el, action);
|
1684 |
1716 |
} else {
|
1685 |
|
try {
|
|
1717 |
try {
|
1686 |
1718 |
if (el.attr('id') == pending_actions[0][1])
|
1687 |
1719 |
{
|
1688 |
|
return;
|
|
1720 |
return;
|
1689 |
1721 |
}
|
1690 |
1722 |
} catch (err) {
|
1691 |
1723 |
}
|
... | ... | |
1738 |
1770 |
}
|
1739 |
1771 |
|
1740 |
1772 |
function init_action_indicator_list_handlers()
|
1741 |
|
{
|
|
1773 |
{
|
1742 |
1774 |
var skip_actions = { 'console':'','connect':'','details':'' };
|
1743 |
1775 |
|
1744 |
1776 |
var has_pending_confirmation = function()
|
1745 |
1777 |
{
|
1746 |
1778 |
return $(".confirm_multiple:visible").length >= 1
|
1747 |
1779 |
}
|
1748 |
|
|
|
1780 |
|
1749 |
1781 |
function update_action_indicator_icons(force_action, skip_pending)
|
1750 |
|
{
|
|
1782 |
{
|
1751 |
1783 |
// pending action based on the element class
|
1752 |
1784 |
var pending_action = $(".selected", $(".actions"))[0];
|
1753 |
1785 |
var selected = get_list_view_selected_machine_rows();
|
1754 |
1786 |
|
1755 |
1787 |
// reset previous state
|
1756 |
1788 |
list_view_hide_action_indicators();
|
1757 |
|
|
|
1789 |
|
1758 |
1790 |
if (pending_action == undefined && !force_action)
|
1759 |
1791 |
{
|
1760 |
1792 |
// no action selected
|
1761 |
1793 |
return;
|
1762 |
1794 |
}
|
1763 |
|
|
|
1795 |
|
1764 |
1796 |
if (force_action != undefined)
|
1765 |
1797 |
{
|
1766 |
1798 |
// user forced action choice
|
... | ... | |
1784 |
1816 |
// hide os logo
|
1785 |
1817 |
$("img.list-logo", el).hide();
|
1786 |
1818 |
});
|
1787 |
|
}
|
1788 |
|
|
|
1819 |
}
|
|
1820 |
|
1789 |
1821 |
// on mouseover we force the images to the hovered action
|
1790 |
1822 |
$(".actions a").live("mouseover", function(evn) {
|
1791 |
1823 |
var el = $(evn.currentTarget);
|
1792 |
1824 |
if (!el.hasClass("enabled"))
|
1793 |
|
{
|
|
1825 |
{
|
1794 |
1826 |
return;
|
1795 |
1827 |
}
|
1796 |
1828 |
var action_class = el.attr("id").replace("action-","");
|
... | ... | |
1800 |
1832 |
}
|
1801 |
1833 |
update_action_indicator_icons(action_class, false);
|
1802 |
1834 |
});
|
1803 |
|
|
|
1835 |
|
1804 |
1836 |
|
1805 |
1837 |
// register events where icons should get updated
|
1806 |
1838 |
$(".actions a.enabled").live("click", function(evn) {
|
... | ... | |
1815 |
1847 |
$(".actions a").live("mouseout", function(evn) {
|
1816 |
1848 |
update_action_indicator_icons(undefined, false);
|
1817 |
1849 |
});
|
1818 |
|
|
|
1850 |
|
1819 |
1851 |
$(".confirm_multiple button.no").click(function(){
|
1820 |
1852 |
list_view_hide_action_indicators();
|
1821 |
1853 |
});
|
... | ... | |
1823 |
1855 |
$(".confirm_multiple button.yes").click(function(){
|
1824 |
1856 |
list_view_hide_action_indicators();
|
1825 |
1857 |
});
|
1826 |
|
|
|
1858 |
|
1827 |
1859 |
$("input[type=checkbox]").live('change', function(){
|
1828 |
1860 |
// pending_actions will become empty on every checkbox click/change
|
1829 |
1861 |
// line 154 machines_list.html
|
... | ... | |
1831 |
1863 |
if (pending_actions.length == 0)
|
1832 |
1864 |
{
|
1833 |
1865 |
$(".confirm_multiple").hide();
|
1834 |
|
$("a.selected").each(function(index, el){$(el).removeClass("selected")});
|
|
1866 |
$("a.selected").each(function(index, el){$(el).removeClass("selected")});
|
1835 |
1867 |
}
|
1836 |
1868 |
update_action_indicator_icons(undefined, false);
|
1837 |
1869 |
});
|
1838 |
|
|
|
1870 |
|
1839 |
1871 |
}
|
1840 |
1872 |
|
1841 |
1873 |
function list_view_hide_action_indicators()
|
... | ... | |
1845 |
1877 |
}
|
1846 |
1878 |
|
1847 |
1879 |
function get_list_view_selected_machine_rows()
|
1848 |
|
{
|
|
1880 |
{
|
1849 |
1881 |
var table = $("table.list-machines");
|
1850 |
1882 |
var rows = $("tr:has(input[type=checkbox]:checked)",table);
|
1851 |
1883 |
return rows;
|
1852 |
1884 |
}
|
1853 |
|
|