Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
.barchart {
max-width: 700px;
max-height: 350px;
}
}

.clipboardButton {
display: inline-block;
position: relative;
top: 2px;
margin-left: 5px;
}

#ocsEndPoint {
margin-bottom: 10px;
}
229 changes: 143 additions & 86 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
setHumanReadableSizeToElement("phpMemLimit");
setHumanReadableSizeToElement("phpUploadMaxSize");

initMonitoringLinkToClipboard();
$("#monitoring-endpoint-url").on('click', function() {
$(this).select();
});

function updateInfo() {
var url = OC.generateUrl('/apps/serverinfo/update');

Expand All @@ -62,14 +67,14 @@
if (typeof cpuLoadChart === 'undefined') {
cpuLoadChart = new SmoothieChart(
{
millisPerPixel:250,
minValue:0,
grid:{fillStyle:'rgba(0,0,0,0.03)',strokeStyle:'transparent'},
labels:{fillStyle:'rgba(0,0,0,0.4)', fontSize:12}
millisPerPixel: 250,
minValue: 0,
grid: { fillStyle: 'rgba(0,0,0,0.03)', strokeStyle: 'transparent' },
labels: { fillStyle: 'rgba(0,0,0,0.4)', fontSize: 12 }
});
cpuLoadChart.streamTo(document.getElementById("cpuloadcanvas"), 1000/*delay*/);
cpuLoadLine = new TimeSeries();
cpuLoadChart.addTimeSeries(cpuLoadLine, {lineWidth:1, strokeStyle:'rgb(0, 0, 255)', fillStyle:'rgba(0, 0, 255, 0.2)'});
cpuLoadChart.addTimeSeries(cpuLoadLine, { lineWidth: 1, strokeStyle: 'rgb(0, 0, 255)', fillStyle: 'rgba(0, 0, 255, 0.2)' });
}

$('#cpuFooterInfo').text(t('serverinfo', 'Load average')+": "+cpu1+" ("+t('serverinfo', 'Last minute')+")");
Expand Down Expand Up @@ -102,11 +107,11 @@
if (typeof memoryUsageChart === 'undefined') {
memoryUsageChart = new SmoothieChart(
{
millisPerPixel:250,
maxValue:maxValueOfChart,
minValue:0,
grid:{fillStyle:'rgba(0,0,0,0.03)',strokeStyle:'transparent'},
labels:{fillStyle:'rgba(0,0,0,0.4)', fontSize:12}
millisPerPixel: 250,
maxValue: maxValueOfChart,
minValue: 0,
grid: { fillStyle: 'rgba(0,0,0,0.03)', strokeStyle: 'transparent' },
labels: { fillStyle: 'rgba(0,0,0,0.4)', fontSize: 12 }
});
memoryUsageChart.streamTo(document.getElementById("memorycanvas"), 1000/*delay*/);
memoryUsageLine = new TimeSeries();
Expand All @@ -127,50 +132,54 @@
shares_data = [shares.num_shares_user, shares.num_shares_groups, shares.num_shares_link, shares.num_fed_shares_sent, shares.num_fed_shares_received],
stepSize = 0;

if (Math.max.apply(null, shares_data) < 10) {stepSize = 1;}
if (Math.max.apply(null, shares_data) < 10) {
stepSize = 1;
}

if (typeof sharesChart === 'undefined') {
var ctx = document.getElementById("sharecanvas");

sharesChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [t('serverinfo', 'Users'),
t('serverinfo', 'Groups'),
t('serverinfo', 'Links'),
t('serverinfo', 'Federated sent'),
t('serverinfo', 'Federated received')],
datasets: [{
label: " ",
data: shares_data,
backgroundColor: [
'rgba(0, 0, 255, 0.2)',
'rgba(0, 255, 0, 0.2)',
'rgba(255, 0, 0, 0.2)',
'rgba(0, 255, 255, 0.2)',
'rgba(255, 0, 255, 0.2)'
],
borderColor: [
'rgba(0, 0, 255, 1)',
'rgba(0, 255, 0, 1)',
'rgba(255, 0, 0, 1)',
'rgba(0, 255, 255, 1)',
'rgba(255, 0, 255, 1)'
],
borderWidth: 1
}]
},
options: {
legend: {display:false},
scales: {
yAxes: [{
ticks: {
min: 0,
stepSize: stepSize
}
}]
}
}
type: 'bar',
data: {
labels: [
t('serverinfo', 'Users'),
t('serverinfo', 'Groups'),
t('serverinfo', 'Links'),
t('serverinfo', 'Federated sent'),
t('serverinfo', 'Federated received')
],
datasets: [{
label: " ",
data: shares_data,
backgroundColor: [
'rgba(0, 0, 255, 0.2)',
'rgba(0, 255, 0, 0.2)',
'rgba(255, 0, 0, 0.2)',
'rgba(0, 255, 255, 0.2)',
'rgba(255, 0, 255, 0.2)'
],
borderColor: [
'rgba(0, 0, 255, 1)',
'rgba(0, 255, 0, 1)',
'rgba(255, 0, 0, 1)',
'rgba(0, 255, 255, 1)',
'rgba(255, 0, 255, 1)'
],
borderWidth: 1
}]
},
options: {
legend: { display:false },
scales: {
yAxes: [{
ticks: {
min: 0,
stepSize: stepSize
}
}]
}
}
});
}

Expand All @@ -183,48 +192,52 @@
activeUsers_data = [activeUsers.last24hours, activeUsers.last1hour, activeUsers.last5minutes],
stepSize = 0;

if (Math.max.apply(null, activeUsers_data) < 10) {stepSize = 1;}
if (Math.max.apply(null, activeUsers_data) < 10) {
stepSize = 1;
}

if (typeof activeusersChart === 'undefined') {
var ctx = document.getElementById("activeuserscanvas");

activeusersChart = new Chart(ctx, {
type: 'line',
data: {
labels: [t('serverinfo', 'Last 24 hours'),
t('serverinfo', 'Last 1 hour'),
t('serverinfo', 'Last 5 mins')],
datasets: [{
label: " ",
data: activeUsers_data,
fill: false,
borderColor: ['rgba(0, 0, 255, 1)'],
borderWidth: 1,
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: 'rgba(0, 0, 255, 1)',
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "rgba(0,0,255,0.6)",
pointHoverBorderColor: "rgba(0, 0, 255, 1)",
pointHoverBorderWidth: 1,
pointRadius: 5,
pointHitRadius: 10,
lineTension:0
}]
},
options: {
legend: {display:false},
scales: {
yAxes: [{
ticks: {
min: 0,
stepSize: stepSize
}
}]
}
}
type: 'line',
data: {
labels: [
t('serverinfo', 'Last 24 hours'),
t('serverinfo', 'Last 1 hour'),
t('serverinfo', 'Last 5 mins')
],
datasets: [{
label: " ",
data: activeUsers_data,
fill: false,
borderColor: [ 'rgba(0, 0, 255, 1)' ],
borderWidth: 1,
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: 'rgba(0, 0, 255, 1)',
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "rgba(0,0,255,0.6)",
pointHoverBorderColor: "rgba(0, 0, 255, 1)",
pointHoverBorderWidth: 1,
pointRadius: 5,
pointHitRadius: 10,
lineTension: 0
}]
},
options: {
legend: { display:false },
scales: {
yAxes: [{
ticks: {
min: 0,
stepSize: stepSize
}
}]
}
}
});
}
}
Expand Down Expand Up @@ -255,4 +268,48 @@
mem_canvas.height = newHeight;
}

function initMonitoringLinkToClipboard() {
var monAPIBox = $("#ocsEndPoint");
/* reused from settings/js/authtoken_view.js */
monAPIBox.find('.clipboardButton').tooltip({placement: 'bottom', title: t('core', 'Copy'), trigger: 'hover'});

// Clipboard!
var clipboard = new Clipboard('.clipboardButton');
clipboard.on('success', function(e) {
var $input = $(e.trigger);
$input.tooltip('hide')
.attr('data-original-title', t('core', 'Copied!'))
.tooltip('fixTitle')
.tooltip({placement: 'bottom', trigger: 'manual'})
.tooltip('show');
_.delay(function() {
$input.tooltip('hide')
.attr('data-original-title', t('core', 'Copy'))
.tooltip('fixTitle');
}, 3000);
});
clipboard.on('error', function (e) {
var $input = $(e.trigger);
var actionMsg = '';
if (/iPhone|iPad/i.test(navigator.userAgent)) {
actionMsg = t('core', 'Not supported!');
} else if (/Mac/i.test(navigator.userAgent)) {
actionMsg = t('core', 'Press ⌘-C to copy.');
} else {
actionMsg = t('core', 'Press Ctrl-C to copy.');
}

$input.tooltip('hide')
.attr('data-original-title', actionMsg)
.tooltip('fixTitle')
.tooltip({placement: 'bottom', trigger: 'manual'})
.tooltip('show');
_.delay(function () {
$input.tooltip('hide')
.attr('data-original-title', t('core', 'Copy'))
.tooltip('fixTitle');
}, 3000);
});
}

})(jQuery, OC);
8 changes: 7 additions & 1 deletion templates/settings-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
script('serverinfo', 'Chart.min');

style('serverinfo', 'style');

?>

<div class="section" id="cpuSection">
Expand Down Expand Up @@ -70,5 +71,10 @@
<div class="section" id="ocsEndPoint">
<h2><?php p($l->t('External monitoring tool'));?></h2>
<p>
<?php p($l->t('You can connect an external monitoring tool by using this end point: ') . $_['ocs']);?>
<?php p($l->t('You can connect an external monitoring tool by using this end point:')); ?>
</p>
<div>
<input type="text" readonly="readonly" style="width: 415px;" id="monitoring-endpoint-url" value="<?php echo p($_['ocs']); ?>" />
Copy link
Member

@Noodlesalat Noodlesalat Jul 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style="width: 415px;"
This style tag breaks on mobile devices. I think a value in percent (e.g. 70%) is better. In addition we could move this into the style.css file for better overview.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good points, thanks! 80% works out great on a few tests, I think it's a good value IMO.

<a class="clipboardButton icon icon-clippy" data-clipboard-target="#monitoring-endpoint-url"></a>
</div>
</div>