Commit 9e4feb07 authored by Julian Bigge's avatar Julian Bigge

Merge branch 'develop' into 'master'

Version 0.1.1

See merge request !1
parents ef42b469 bfa1a324
Pipeline #45283 passed with stage
in 7 minutes and 43 seconds
......@@ -22,4 +22,7 @@
// navigation or on the settings page
'name' => 'Sccuot'
];
});
\ No newline at end of file
}
);
$app = new OCA\Sccuot\AppInfo\Application();
......@@ -12,24 +12,46 @@
namespace OCA\Sccuot\AppInfo;
use \OCP\AppFramework\App;
use \OCA\Sccuot\Db\SnapshotMapper;
use \OCA\Sccuot\Controller\PageController;
use \OCA\Sccuot\Controller\FilesController;
use \OCA\Sccuot\Controller\MetricsController;
use \OCA\Sccuot\Controller\UserStorageController;
use \OCA\Sccuot\Controller\QuotaController;
use \OCA\Sccuot\Service\ConfigService;
use \OCA\Sccuot\Service\SccuotService;
use \OCA\Sccuot\Service\SnapshotDbService;
use \OCA\Sccuot\Storage\CacheStorage;
use \OCA\Sccuot\Command\SnapshotCommand;
class Application extends App
{
public function __construct(array $urlParams=array()) {
parent::__construct('sccuot', $urlParams);
$container = $this->getContainer();
$container->registerService('AppStorage', function ($c) {
return $c->query('ServerContainer')->getAppFolder();
});
$container = $this->getContainer();
$container->registerService('CacheStorage', function ($c) {
return new CacheStorage(
$c->query('AppStorage')
);
});
$container->registerService('SnapshotMapper', function ($c) {
return new SnapshotMapper(
$c->query('ServerContainer')->getDb()
);
});
$container->registerService('ConfigService', function ($c) {
return new ConfigService(
$c->query('Config'),
$c->query('AppName'),
$c->query('UserId')
$c->query('AppName')
);
});
......@@ -39,14 +61,20 @@ class Application extends App
$container->registerService('SccuotService', function($c) {
return new SccuotService(
$c->query('ConfigService')
$c->query('ConfigService'),
$c->query('CacheStorage')
);
});
});
$container->registerService('SnapshotDbService', function ($c) {
return new SnapshotDbService(
$c->query('SnapshotMapper')
);
});
$container->registerService('PageController', function ($c) {
return new PageController(
$c->query('AppName'),
"0.1.0",
$c->query('AppName'),
$c->query('Request'),
$c->query('ConfigService'),
$c->query('SccuotService')
......@@ -57,9 +85,45 @@ class Application extends App
$c->query('AppName'),
$c->query('Request'),
$c->query('SccuotService'),
$c->query('ConfigService')
$c->query('ConfigService'),
$c->query('SnapshotDbService')
);
});
$container->registerService('UserStorageController', function ($c) {
return new UserStorageController(
$c->query('AppName'),
$c->query('Request'),
$c->query('SccuotService'),
$c->query('ConfigService'),
$c->query('SnapshotDbService')
);
});
$container->registerService('FilesController', function ($c) {
return new FilesController(
$c->query('AppName'),
$c->query('Request'),
$c->query('SccuotService'),
$c->query('SnapshotDbService')
);
});
$container->registerService('QuotaController', function ($c) {
return new QuotaController(
$c->query('AppName'),
$c->query('Request'),
$c->query('SccuotService'),
$c->query('ConfigService'),
$c->query('SnapshotDbService')
);
});
$container->registerService(
SnapshotCommand::class,
function ($c) {
return new SnapshotCommand(
$c->query('SccuotService')
);
});
}
}
......@@ -5,7 +5,7 @@
<description>Sccuot test app</description>
<licence>AGPL</licence>
<author>Julian Bigge</author>
<version>0.1.0</version>
<version>0.1.1</version>
<namespace>Sccuot</namespace>
<category>tools</category>
<dependencies>
......@@ -18,4 +18,7 @@
<website>https://zivgitlab.uni-muenster.de/j_bigg01/sccuot-owncloud</website>
<repository type="git">https://zivgitlab.uni-muenster.de/j_bigg01/sccuot-owncloud</repository>
<bugs>https://zivgitlab.uni-muenster.de/j_bigg01/sccuot-owncloud/issues</bugs>
</info>
\ No newline at end of file
<commands>
<command>OCA\Sccuot\Command\SnapshotCommand</command>
</commands>
</info>
......@@ -24,18 +24,29 @@ $application = new Application();
$application->registerRoutes($this, [
'routes' => [
['name' => 'page#settings', 'url' => '/settings', 'verb' => 'GET'],
['name' => 'page#save_settings', 'url' => '/save_settings', 'verb' => 'POST'],
['name' => 'page#reset_settings', 'url' => '/reset_settings', 'verb' => 'GET'],
['name' => 'page#load_settings', 'url' => '/load_settings', 'verb' => 'GET'],
['name' => 'page#save_settings', 'url' => '/save-settings', 'verb' => 'POST'],
['name' => 'page#reset_settings', 'url' => '/reset-settings', 'verb' => 'GET'],
['name' => 'page#load_settings', 'url' => '/load-settings', 'verb' => 'GET'],
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#snapshot_settings', 'url' => '/snapshot-settings', 'verb' => 'GET'],
['name' => 'page#find_sccuot_binary', 'url' => '/find-sccuot', 'verb' => 'GET'],
['name' => 'page#check_sccuot_binary', 'url' => '/check-sccuot', 'verb' => 'POST'],
['name' => 'page#get_snapshot_file_types', 'url' => '/snapshot-settings/get-file-types', 'verb' => 'GET'],
['name' => 'page#save_snapshot_file_types', 'url' => '/snapshot-settings/save-file-types', 'verb' => 'POST'],
['name' => 'metrics#metrics', 'url' => '/metrics', 'verb' => 'GET'],
['name' => 'metrics#get_for_date', 'url' => '/metrics/get', 'verb' => 'GET'],
['name' => 'metrics#raw_metrics', 'url' => '/metrics/raw', 'verb' => 'GET'],
['name' => 'metrics#raw_histogram', 'url' => '/metrics/raw_histogram', 'verb' => 'GET'],
['name' => 'metrics#metrics_query', 'url' => '/metrics/query', 'verb' => 'POST'],
['name' => 'metrics#metrics_query_save', 'url' => '/metrics/query-save', 'verb' => 'POST'],
['name' => 'metrics#metrics_query_histogram', 'url' => '/metrics/query-histogram', 'verb' => 'POST'],
['name' => 'metrics#quota', 'url' => '/quota', 'verb' => 'GET'],
['name' => 'metrics#files', 'url' => '/files', 'verb' => 'GET'],
['name' => 'metrics#files_query', 'url' => '/files/query', 'verb' => 'POST']
['name' => 'user_storage#user_storage', 'url' => '/user-storage', 'verb' => 'GET'],
['name' => 'user_storage#get_histogram', 'url' => '/user-storage/get-histogram', 'verb' => 'GET'],
['name' => 'user_storage#raw_histogram', 'url' => '/user-storage/raw-histogram', 'verb' => 'GET'],
['name' => 'quota#quota', 'url' => '/quota', 'verb' => 'GET'],
['name' => 'quota#get_histogram', 'url' => '/quota/get-histogram', 'verb' => 'GET'],
['name' => 'files#files', 'url' => '/files', 'verb' => 'GET'],
['name' => 'files#get', 'url' => '/files/get', 'verb' => 'GET'],
['name' => 'files#get_live', 'url' => '/files/get-live', 'verb' => 'POST']
]
]);
......@@ -4,6 +4,7 @@
list-style-type: square;
list-style-position: inside;
padding: 10px;
display: none;
}
.errormsg {
color: #fff;
......@@ -18,6 +19,28 @@
display: none;
}
@keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.blinking {
-webkit-transition:all 1s ease-in-out;
-o-transition:all 1s ease-in-out;
-ms-transition:all 1s ease-in-out;
transition:all 1s ease-in-out;
-webkit-animation:blink normal 2s infinite ease-in-out;
-ms-animation:blink normal 2s infinite ease-in-out;
animation:blink normal 2s infinite ease-in-out;
}
.welcomescreen {
position: absolute;
text-align:center;
......@@ -48,6 +71,24 @@
padding-left: 10px;
}
.row {
display: flex;
flex-flow: row;
}
.half-width {
width: 50%;
}
.column {
display:flex;
flex-flow: column;
}
.flex {
flex: auto;
}
#footer {
position: absolute;
width: 200px;
......@@ -57,4 +98,4 @@
margin-left: -100px;
font-weight: 300;
font-family: "Open Sans", Frutiger, Calibri, "Myriad Pro", Myriad, sans-serif;
}
\ No newline at end of file
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32"
height="32"
viewBox="0 0 8.4666665 8.4666669"
version="1.1"
id="svg8"
inkscape:version="0.92.4 (unknown)"
sodipodi:docname="on_air.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="15.839192"
inkscape:cx="31.652141"
inkscape:cy="10.317175"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1050"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-288.53332)">
<rect
style="fill:#ff0000;stroke:#ffffff;stroke-width:0.5291667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1"
id="rect10"
width="7.8902526"
height="6.6145964"
x="0.28348213"
y="289.46411" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.23538733px;line-height:1.25;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.08088516"
x="1.0324318"
y="191.86105"
id="text4522"
transform="scale(0.65144681,1.5350447)"><tspan
sodipodi:role="line"
id="tspan4520"
x="1.0324318"
y="191.86105"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.23538733px;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke-width:0.08088516">ON AIR</tspan></text>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333335"
version="1.1"
id="svg8"
inkscape:version="0.92.4 (unknown)"
sodipodi:docname="rec.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="15.839192"
inkscape:cx="15.665877"
inkscape:cy="12.185404"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1050"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<ellipse
transform="translate(0,4.6807091e-6)"
id="path3713"
cx="2.1202102"
cy="294.87869"
rx="2.1202102"
ry="2.1171088"
style="stroke-width:0.2634168;fill:#ff0000" />
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333335"
version="1.1"
id="svg8"
inkscape:version="0.92.4 (unknown)"
sodipodi:docname="rec_text.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="31.678384"
inkscape:cx="8.819729"
inkscape:cy="9.923183"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1050"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:snap-text-baseline="true"
showguides="true"
inkscape:guide-bbox="true">
<sodipodi:guide
position="2.6977517,2.121452"
orientation="0,1"
id="guide3769"
inkscape:locked="false" />
<sodipodi:guide
position="2.1130996,4.2763126"
orientation="1,0"
id="guide3771"
inkscape:locked="false" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-292.76665)">
<ellipse
id="path3713"
cx="2.1234319"
cy="294.88193"
rx="2.1169884"
ry="2.1138918"
style="fill:#ff0000;stroke-width:0.26301652" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.89699292px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.35568616;"
x="0.20287837"
y="295.61502"
id="text3767"><tspan
sodipodi:role="line"
id="tspan3765"
x="0.20287837"
y="295.61502"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:1.89699292px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.35568616;fill:#ffffff;">REC</tspan></text>
</g>
</svg>
var DATE = '';
var callback = null;
function setDateChangedCallback(cb) {
callback = cb;
}
(function($, OC) {
$(document).ready(function() {
$("#date-select").change(function() {
var value = $(this).val();
DATE = value;
Cookies.set('date-selection', DATE);
if (callback !== null) {
callback(value);
}
});
var savedDate = Cookies.get('date-selection');
if (savedDate != null) {
DATE = savedDate;
$('#date-select').val(DATE);
if (callback !== null) {
callback(savedDate);
}
} else {
DATE = $('#date-select').val();
}
});
})(jQuery, OC);
(function($, OC) {
$(document).ready(function() {
var chart = null;
var chartScreen = $("#file-types-chart");
var loadingScreen = $("#file-types-chart-loading-screen");
var noDataScreen = $("#file-types-chart-no-data-screen");
var file_types = {
var fileTypes = {
"pdf": {'n': 0, 'enabled': true},
"doc": {'n': 0, 'enabled': true},
"docx": {'n': 0, 'enabled': true},
......@@ -42,7 +45,8 @@
};
$("#file-types-refresh-button").click(function() {
getFreshData();
$('#on-air-sign').addClass('blinking');
getLiveData();
});
$("#custom-file-type-add-button").click(function() {
......@@ -54,30 +58,29 @@
var savedTypes = Cookies.get('file-type-selection');
if (savedTypes != null) {
file_types = JSON.parse(savedTypes);
fileTypes = JSON.parse(savedTypes);
}
var canvas = $('#file-types-chart')[0];
addLoadingListener(canvas);
getFreshData();
getData();
drawFileTypeSelection();
function drawFileTypeSelection() {
$('#file-type-selection tr').remove();
var strideSize = 4;
var fileTypeTable = $('#file-type-selection');
for (var i = 0; i < Object.keys(file_types).length; i += strideSize) {
for (var i = 0; i < Object.keys(fileTypes).length; i += strideSize) {
fileTypeTable.append('<tr>');
Object.keys(file_types).slice(i, i + strideSize).forEach(function (key) {
Object.keys(fileTypes).slice(i, i + strideSize).forEach(function (key) {
$("#file-type-selection tr:last").append($('<td>').attr('style', 'vertical-align:middle;')
.append($('<input>').attr('id', key).attr('type', 'checkbox').attr('value', key)
.attr("checked", file_types[key]['enabled'])
.attr("checked", fileTypes[key]['enabled'])
)
.append($('<label>').attr('for', key).text(key)
)
);
if (file_types[key]['custom']) {
if (fileTypes[key]['custom']) {
var button = $('<button/>',
{
click: function() {removeFileType(key);}
......@@ -91,23 +94,23 @@
}
function addFileType(fileType) {
file_types[fileType] = {'n': 0, 'enabled': true, 'custom': true};
fileTypes[fileType] = {'n': 0, 'enabled': true, 'custom': true};
// Update table
drawFileTypeSelection();
updateSelectedTypes();
}
function removeFileType(fileType) {
delete file_types[fileType];
delete fileTypes[fileType];
drawFileTypeSelection();
updateSelectedTypes();
}
function updateSelectedTypes() {
$("#file-type-selection input").each(function() {
file_types[$(this).attr('id')]['enabled'] = $(this).is(':checked');
fileTypes[$(this).attr('id')]['enabled'] = $(this).is(':checked');
});
Cookies.set('file-type-selection', file_types, { path: ''});
Cookies.set('file-type-selection', fileTypes, { path: ''});
}
function drawTable(ftypes) {
......@@ -132,48 +135,77 @@
+ (((tuples[i][1]/sum)*100).toFixed(2)) + " %</td></tr>");
}
}
function getFreshData() {
loading = true;
canvas.dispatchEvent(loadingEvent);
function getData() {
chartScreen.css('display', 'none');
loadingScreen.css('display', 'flex');
noDataScreen.css('display', 'none');
var url = OC.generateUrl('/apps/sccuot/files/get');
$.get(url)
.done(function(response) {
var data = [];
var labels = [];
for (var key in response) {
fileTypes[key]['enabled'] = true;
fileTypes[key]['n'] = response[key];
labels.push(key);
data.push(response[key]);
}
if (chart != null) {
chart.destroy();
<