Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #40 from arnovr/activity_charts
Browse files Browse the repository at this point in the history
Activity charts
  • Loading branch information
arnovr committed Oct 6, 2014
2 parents 8eda7c3 + 189ab85 commit f50fce0
Show file tree
Hide file tree
Showing 76 changed files with 3,136 additions and 382 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
js/c3
js/d3
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ script:
# Create coverage report
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

# try in future
#after_success:
# - coveralls
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@ ocUsageCharts
=============
ocUsageCharts is created due to the fact that the original usage_charts is no longer updated to work properly with owncloud 7.
This application is from the base up designed for Owncloud 7.
ocUsageCharts uses C3.js for rendering the charts on the dashboard.
ocUsageCharts gives the ability to display various statistics about your users within owncloud.
These statistics include storage usage charts and activities charts.

The master branch is always stable, however i would suggest running the latest tag for production worthy statistics.

Features
========
- ocUsageCharts stores the disk space used by each user of ownCloud.
- Graphs available:
- User mode:
- A pie chart showing space used / free space
- A graph with data used over the course of the last month
- A Bar chart with average data used in the last months
- Admin mode
- A pie chart showing space used by all users
- A graph with data used over the course of the last month for all users
- A Bar chart with average data used in the last months for all users
Graphs
======
- User mode:
- A pie chart showing space used / free space
- A graph with data used over the course of the last month
- A Bar chart with average data used in the last months
- An Activity chart over the last month
- An Activity chart with activities over the last months
- Admin mode:
- A pie chart showing space used by all users
- A graph with data used over the course of the last month for all users
- A Bar chart with average data used in the last months for all users
- An Activity chart over the last month for all users
- An Activity chart with activities over the last months for all users

Future ideas
============
- Improve User Interface to handle a lot of users
- Graphs:
- Files downloaded
- Activity tracking
- Option to use alternative for C3.js
- Configure your own graphs through personal page, technically ready ( default configs )

Requirements
============
- Cronjobs must run every day!
- For activity charts, the activity app needs to be enabled
- Owncloud 7.0.1 ( untested with versions before 7.0.1 )

Install
Expand All @@ -43,6 +44,7 @@ Install

Product reference
=================
- ocUsagechart official release channel: http://apps.owncloud.com/content/show.php/Usage+Charts+%28+owncloud+7+%29?content=166746
- C3.js: http://c3js.org/ - https://github.com/masayuki0812/c3
- usage_charts: http://apps.owncloud.com/content/show.php/Usage+Charts?content=164956 - https://github.com/alanv72/usage_charts ( a fork from StorageCharts/ocStorage )

Expand Down
26 changes: 16 additions & 10 deletions appinfo/chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
use OCA\ocUsageCharts\Controller\ChartApiController;
use OCA\ocUsageCharts\Controller\ChartController;
use OCA\ocUsageCharts\DataProviderFactory;
use OCA\ocUsageCharts\DataProviders\ChartUsageHelper;
use OCA\ocUsageCharts\Entity\Activity\ActivityUsageRepository;
use OCA\ocUsageCharts\Entity\ChartConfigRepository;
use OCA\ocUsageCharts\Entity\StorageUsageRepository;
use OCA\ocUsageCharts\Entity\Storage\StorageUsageRepository;
use OCA\ocUsageCharts\Owncloud\Storage;
use OCA\ocUsageCharts\Owncloud\User;
use OCA\ocUsageCharts\Service\AppConfigService;
use OCA\ocUsageCharts\Service\ChartConfigService;
use OCA\ocUsageCharts\Service\ChartDataProvider;
use OCA\ocUsageCharts\Service\ChartService;
Expand Down Expand Up @@ -79,6 +80,12 @@ private function registerOwncloudDependencies()
*/
private function registerRepositories()
{
$this->container->registerService('ActivityUsageRepository', function($c) {
return new ActivityUsageRepository(
$c->query('ServerContainer')->getDb()
);
});

$this->container->registerService('StorageUsageRepository', function($c) {
return new StorageUsageRepository(
$c->query('ServerContainer')->getDb()
Expand Down Expand Up @@ -118,10 +125,16 @@ private function registerVarious()
$this->container->registerService('DataProviderFactory', function($c) {
return new DataProviderFactory(
$c->query('StorageUsageRepository'),
$c->query('ActivityUsageRepository'),
$c->query('OwncloudUser'),
$c->query('OwncloudStorage')
$c->query('OwncloudStorage'),
$c->query('ChartUsageHelper')
);
});
$this->container->registerService('ChartUsageHelper', function() {
return new ChartUsageHelper();
});

}

/**
Expand All @@ -137,13 +150,6 @@ private function registerServices()
$c->query('OwncloudUser')
);
});
$this->container->registerService('AppConfigService', function($c) {
return new AppConfigService(
$c->query('ServerContainer')->getConfig(),
$c->query('AppName'),
$c->query('OwncloudUser')
);
});
$this->container->registerService('ChartConfigService', function($c) {
return new ChartConfigService(
$c->query('ChartConfigRepository'),
Expand Down
15 changes: 14 additions & 1 deletion changelog
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
- Moved Gigabyte / Megabyte selector to personal page, reason, it was cluttering interface
0.3:
- Added activity graph: Activities over the last month, and activities per month
- Appending byte size to tooltip values
- Added numeric values above bar's within bar charts
- Technical improvements ( bower for javascript, travis CI implementation, unit tests, code improvements )
- Moved Gigabyte / Megabyte selector to personal page, because it is cluttering the interface

0.2:
- The same cron job command existed twice, one with capitalized, one without. This gives problems on windows machines.
- Fix error:
"Argument 1 passed to OCA\ocUsageCharts\Service\ChartService::getUsage() must be an instance of OCA\ocUsageCharts\ChartType\ChartTypeViewInterface........."

0.1:
- Initial release
7 changes: 2 additions & 5 deletions controller/chartcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ public function __construct($appName, IRequest $request, ChartService $chartServ
*/
public function frontpage()
{
$this->configService->setDefaultConfigs();

$charts = $this->configService->getCharts();
if ( count($charts) == 0 )
{
$this->configService->createDefaultConfig();
$charts = $this->configService->getCharts();
}
$id = $charts[0]->getId();
$url = \OCP\Util::linkToRoute('ocusagecharts.chart.display_chart', array('id' => $id));
return new RedirectResponse($url);
Expand Down
19 changes: 19 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,23 @@
#app-content .chart
{
margin-top: 50px;
}
#app-navigation .menu-title
{
display: block;
width: 100%;
line-height: 44px;
padding: 0 12px;
overflow: hidden;
-moz-box-sizing: border-box;
box-sizing: border-box;
white-space: nowrap;
text-overflow: ellipsis;
color: #333;
}

#app-navigation .menu-title h2
{
font-size: 14px;
font-weight: bold;
}
41 changes: 36 additions & 5 deletions js/c3_initGraphs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
function loadGraph(url, yLabel, graphType, format)
function loadGraph(url, yLabel, shortLable, graphType, format, appendLabel)
{
if ( format == undefined )
{
format = '%Y-%m-%d';
}
var appendLabelContent = '';
if ( appendLabel )
{
appendLabelContent = ({
format: {
y: function (value) {
return value;
}
}
});
}

c3.generate({
bindto: '#chart',
Expand All @@ -14,7 +25,8 @@ function loadGraph(url, yLabel, graphType, format)
x: 'x',
mimeType: 'json',
url: url ,
type: graphType
type: graphType,
labels: appendLabelContent
},
axis: {
x: {
Expand All @@ -26,6 +38,13 @@ function loadGraph(url, yLabel, graphType, format)
y: {
label: yLabel
}
},
tooltip: {
format: {
value: function (value) {
return value + ' ' + shortLable;
}
}
}
});
}
Expand All @@ -50,15 +69,27 @@ $( document ).ready(function() {
loadGraph(
$(".defaultChart").data("url"),
$(".defaultChart").data("label"),
$(".defaultChart").data("shortlabel"),
$(".defaultChart").data("type"),
$(".defaultChart").data("format")
$(".defaultChart").data("format"),
false
);
}

if ($(".defaultBar").length > 0 )
{
loadGraph(
$(".defaultBar").data("url"),
$(".defaultBar").data("label"),
$(".defaultBar").data("shortlabel"),
$(".defaultBar").data("type"),
$(".defaultBar").data("format"),
true
);
}
if ($(".defaultPie").length > 0 )
{
loadPie(
$(".defaultBar").data("url")
$(".defaultPie").data("url")
);
}
});
8 changes: 7 additions & 1 deletion l10n/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
"sizes_kb" => "Kilobytes",
"sizes_mb" => "Megabytes",
"sizes_gb" => "Gigabytes",
"sizes_tb" => "Terabytes"
"sizes_tb" => "Terabytes",

"ActivityUsageLastMonth"=> "Activities over the last month",
"activities" => "Activities",
"ActivityUsagePerMonth" => "Activities per month",
"Storage_title" => "Storage Usage",
"Activity_title" => "Activities"
);
8 changes: 7 additions & 1 deletion l10n/nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
"sizes_kb" => "Kilobytes",
"sizes_mb" => "Megabytes",
"sizes_gb" => "Gigabytes",
"sizes_tb" => "Terabytes"
"sizes_tb" => "Terabytes",

"ActivityUsageLastMonth"=> "Activiteiten over de afgelopen maand",
"activities" => "Activiteiten",
"ActivityUsagePerMonth" => "Activiteiten per maand",
"Storage_title" => "Data verbruik",
"Activity_title" => "Activiteiten"
);
Loading

0 comments on commit f50fce0

Please sign in to comment.