diff options
Diffstat (limited to 'js/script.js')
-rw-r--r-- | js/script.js | 229 |
1 files changed, 143 insertions, 86 deletions
diff --git a/js/script.js b/js/script.js index 87e1acf..5367cfe 100644 --- a/js/script.js +++ b/js/script.js @@ -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'); @@ -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')+")"); @@ -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(); @@ -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 + } + }] + } + } }); } @@ -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 + } + }] + } + } }); } } @@ -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); |