2786 |
rexy |
1 |
/***************************************************************************
|
|
|
2 |
* Copyright (C) 2008 by phpSysInfo - A PHP System Information Script *
|
|
|
3 |
* http://phpsysinfo.sourceforge.net/ *
|
|
|
4 |
* *
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify *
|
|
|
6 |
* it under the terms of the GNU General Public License as published by *
|
|
|
7 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
8 |
* (at your option) any later version. *
|
|
|
9 |
* *
|
|
|
10 |
* This program is distributed in the hope that it will be useful, *
|
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
13 |
* GNU General Public License for more details. *
|
|
|
14 |
* *
|
|
|
15 |
* You should have received a copy of the GNU General Public License *
|
|
|
16 |
* along with this program; if not, write to the *
|
|
|
17 |
* Free Software Foundation, Inc., *
|
|
|
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
19 |
***************************************************************************/
|
|
|
20 |
|
|
|
21 |
//$Id: docker.js 661 2014-01-08 11:26:39 aolah76 $
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang, createBar */
|
|
|
25 |
|
|
|
26 |
"use strict";
|
|
|
27 |
|
|
|
28 |
var docker_show = false, docker_table;
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* insert content into table
|
|
|
32 |
* @param {jQuery} xml plugin-XML
|
|
|
33 |
*/
|
|
|
34 |
|
|
|
35 |
function docker_populate(xml) {
|
|
|
36 |
|
|
|
37 |
var html = "";
|
|
|
38 |
|
|
|
39 |
docker_table.fnClearTable();
|
|
|
40 |
|
|
|
41 |
$("Plugins Plugin_Docker Docker Item", xml).each(function docker_getitem(id) {
|
|
|
42 |
var name = "", cpuu= 0, memu = 0, used = 0, limit = 0, netio = "", blockio = "", pids = 0;
|
|
|
43 |
name = $(this).attr("Name");
|
|
|
44 |
cpuu = parseInt($(this).attr("CPUUsage"), 10);
|
|
|
45 |
memu = parseInt($(this).attr("MemoryUsage"), 10);
|
|
|
46 |
used = parseInt($(this).attr("MemoryUsed"), 10);
|
|
|
47 |
limit = parseInt($(this).attr("MemoryLimit"), 10);
|
|
|
48 |
netio = $(this).attr("NetIO");
|
|
|
49 |
blockio = $(this).attr("BlockIO");
|
|
|
50 |
pids = parseInt($(this).attr("PIDs"), 10);
|
|
|
51 |
|
|
|
52 |
docker_table.fnAddData(["<span style=\"display:none;\">" + name + "</span>" + name, "<span style=\"display:none;\">" + cpuu + "</span>" + createBar(cpuu), "<span style=\"display:none;\">" + memu + "</span>" + createBar(memu), "<span style=\"display:none;\">" + used + "</span>" + formatBytes(used, xml), "<span style=\"display:none;\">" + limit + "</span>" + formatBytes(limit, xml), "<span style=\"display:none;\">" + netio + "</span>" + netio, "<span style=\"display:none;\">" + blockio + "</span>" + blockio, "<span style=\"display:none;\">" + pids + "</span>" + pids]);
|
|
|
53 |
docker_show = true;
|
|
|
54 |
});
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
function docker_buildTable() {
|
|
|
58 |
var html = "";
|
|
|
59 |
|
|
|
60 |
html += "<div style=\"overflow-x:auto;\">\n";
|
|
|
61 |
html += " <table id=\"Plugin_DockerTable\" class=\"stripeMe\" style=\"border-collapse:collapse;\">\n";
|
|
|
62 |
html += " <thead>\n";
|
|
|
63 |
html += " <tr>\n";
|
|
|
64 |
html += " <th>" + genlang(101, "docker") + "</th>\n";
|
|
|
65 |
html += " <th>" + genlang(102, "docker") + "</th>\n";
|
|
|
66 |
html += " <th>" + genlang(103, "docker") + "</th>\n";
|
|
|
67 |
html += " <th class=\"right\">" + genlang(104, "docker") + "</th>\n";
|
|
|
68 |
html += " <th class=\"right\">" + genlang(105, "docker") + "</th>\n";
|
|
|
69 |
html += " <th class=\"right\">" + genlang(106, "docker") + "</th>\n";
|
|
|
70 |
html += " <th class=\"right\">" + genlang(107, "docker") + "</th>\n";
|
|
|
71 |
html += " <th class=\"right\">" + genlang(108, "docker") + "</th>\n";
|
|
|
72 |
html += " </tr>\n";
|
|
|
73 |
html += " </thead>\n";
|
|
|
74 |
html += " <tbody id=\"Plugin_DockerTable-tbody\">\n";
|
|
|
75 |
html += " </tbody>\n";
|
|
|
76 |
html += " </table>\n";
|
|
|
77 |
html += "</div>\n";
|
|
|
78 |
$("#Plugin_Docker").append(html);
|
|
|
79 |
|
|
|
80 |
docker_table = $("#Plugin_DockerTable").dataTable({
|
|
|
81 |
"bPaginate": false,
|
|
|
82 |
"bLengthChange": false,
|
|
|
83 |
"bFilter": false,
|
|
|
84 |
"bSort": true,
|
|
|
85 |
"bInfo": false,
|
|
|
86 |
"bProcessing": true,
|
|
|
87 |
"bAutoWidth": false,
|
|
|
88 |
"bStateSave": true,
|
|
|
89 |
"aoColumns": [{
|
|
|
90 |
"sType": 'span-string'
|
|
|
91 |
}, {
|
|
|
92 |
"sType": 'span-number'
|
|
|
93 |
}, {
|
|
|
94 |
"sType": 'span-number'
|
|
|
95 |
}, {
|
|
|
96 |
"sType": 'span-number',
|
|
|
97 |
"sClass": "right"
|
|
|
98 |
}, {
|
|
|
99 |
"sType": 'span-number',
|
|
|
100 |
"sClass": "right"
|
|
|
101 |
}, {
|
|
|
102 |
"sType": 'span-string',
|
|
|
103 |
"sClass": "right"
|
|
|
104 |
}, {
|
|
|
105 |
"sType": 'span-string',
|
|
|
106 |
"sClass": "right"
|
|
|
107 |
}, {
|
|
|
108 |
"sType": 'span-number',
|
|
|
109 |
"sClass": "right"
|
|
|
110 |
}]
|
|
|
111 |
});
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
/**
|
|
|
115 |
* load the xml via ajax
|
|
|
116 |
*/
|
|
|
117 |
|
|
|
118 |
function docker_request() {
|
|
|
119 |
$("#Reload_DockerTable").attr("title", "reload");
|
|
|
120 |
$.ajax({
|
|
|
121 |
url: "xml.php?plugin=docker",
|
|
|
122 |
dataType: "xml",
|
|
|
123 |
error: function docker_error() {
|
|
|
124 |
$.jGrowl("Error loading XML document for Plugin docker!");
|
|
|
125 |
},
|
|
|
126 |
success: function docker_buildblock(xml) {
|
|
|
127 |
populateErrors(xml);
|
|
|
128 |
docker_populate(xml);
|
|
|
129 |
if (docker_show) {
|
|
|
130 |
plugin_translate("Docker");
|
|
|
131 |
$("#Plugin_Docker").show();
|
|
|
132 |
}
|
|
|
133 |
}
|
|
|
134 |
});
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
$(document).ready(function docker_buildpage() {
|
|
|
138 |
$("#footer").before(buildBlock("Docker", 1, true));
|
|
|
139 |
$("#Plugin_Docker").css("width", "915px");
|
|
|
140 |
|
|
|
141 |
docker_buildTable();
|
|
|
142 |
|
|
|
143 |
docker_request();
|
|
|
144 |
|
|
|
145 |
$("#Reload_DockerTable").click(function docker_reload(id) {
|
|
|
146 |
docker_request();
|
|
|
147 |
$(this).attr("title", datetime());
|
|
|
148 |
});
|
|
|
149 |
});
|