Skip to content

Firefly III: a personal finances manager

Reversed from flot/plot back to high charts. Cleaned up the index.

James Cole5788db9f07b1
diff --git a/app/assets/javascripts/firefly/index.js b/app/assets/javascripts/firefly/index.js
index 212508dc7f..bb0e9b202b 100644
--- a/app/assets/javascripts/firefly/index.js
+++ b/app/assets/javascripts/firefly/index.js
@@ -6,9 +6,218 @@ $(function () {
*/
$.getJSON('chart/home/account').success(function (data) {
var options = {
+ chart: {
+ renderTo: 'accounts-chart',
+ type: 'line'
+ },
+ series: data.series,
+ title: {
+ text: null
+ },
+ yAxis: {
+ allowDecimals: false,
+ alternateGridColor: true,
+ labels: {
+ formatter: function () {
+ return '€ ' + this.value;
+ }
+ },
+ title: {text: null}
+ },
+ xAxis: {
+ floor: 0,
+ type: 'datetime',
+ dateTimeLabelFormats: {
+ day: '%e %b',
+ year: '%b'
+ },
+ title: {
+ text: null
+ }
+ },
+ legend: {enabled:false},
+ tooltip: {
+
+ shared: false,
+ crosshairs: false,
+ formatter: function () {
+ return this.series.name + ': \u20AC ' + Highcharts.numberFormat(this.y,2);
+ }
+ },
+ plotOptions: {
+ line: {
+ shadow: true
+ },
+ series: {
+ cursor: 'pointer',
+ negativeColor: '#FF0000',
+ threshold: 0,
+ lineWidth: 1,
+ marker: {
+ radius: 2
+ },
+ point: {
+ events: {
+ click: function (e) {
+ hs.htmlExpand(null, {
+ src: 'chart/home/info/' + this.series.name + '/' + Highcharts.dateFormat("%d/%m/%Y", this.x),
+ pageOrigin: {
+ x: e.pageX,
+ y: e.pageY
+ },
+ objectType: 'ajax',
+ headingText: '<a href="accounts/show/' + this.series.id + '">' + this.series.name + '</a>',
+ width: 250
+ }
+ )
+ ;
+ }
+ }
+ }
+ }
+ },
+ credits: {
+ enabled: false
+ }
};
- $.plot("#flot-chart-accounts", data, options);
+ $('#accounts-chart').highcharts(options);
+ });
+
+ /**
+ * Get chart data for categories chart:
+ */
+ $.getJSON('chart/home/categories').success(function (data) {
+ $('#categories').highcharts({
+ chart: {
+ type: 'column'
+ },
+ title: {
+ text: null
+ },
+ credits: {
+ enabled: false
+ },
+ xAxis: {
+ type: 'category',
+ labels: {
+ rotation: -45,
+ style: {
+ fontSize: '12px',
+ fontFamily: 'Verdana, sans-serif'
+ }
+ }
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'Expense (€)'
+ }
+ },
+ legend: {
+ enabled: false
+ },
+ tooltip: {
+ pointFormat: 'Total expense: <strong>€ {point.y:.2f}</strong>',
+ },
+ plotOptions: {
+ column: {
+ cursor: 'pointer'
+ }
+ },
+ series: [
+ {
+ name: 'Population',
+ data: data,
+
+ events: {
+ click: function (e) {
+ alert('klik!');
+ }
+ },
+ dataLabels: {
+ enabled: false
+ }
+ }
+ ]
+ });
+ });
+
+ /**
+ * Get chart data for budget charts.
+ */
+ $.getJSON('chart/home/budgets').success(function (data) {
+ $('#budgets').highcharts({
+ chart: {
+ type: 'bar'
+ },
+ title: {
+ text: null
+ },
+ subtitle: {
+ text: null
+ },
+ xAxis: {
+ categories: data.labels,
+ title: {
+ text: null
+ },
+ labels: {
+ style: {
+ fontSize: '11px',
+ fontFamily: 'Verdana, sans-serif'
+ }
+ }
+ },
+ yAxis: {
+ min: 0,
+ title: {
+ text: 'Amount (€)',
+ align: 'high'
+ },
+ labels: {
+ overflow: 'justify'
+ }
+ },
+ tooltip: {
+ formatter: function () {
+ return false;
+ return '€ ' + Highcharts.numberFormat(this.y, 2);
+ }
+ },
+ plotOptions: {
+ bar: {
+ cursor: 'pointer',
+ events: {
+ click: function (e) {
+ alert('klik!!');
+ }
+ },
+ dataLabels: {
+ enabled: true,
+ formatter: function () {
+ return '€ ' + Highcharts.numberFormat(this.y, 2);
+ }
+ }
+ }
+ },
+ legend: {
+ enabled: false,
+ layout: 'vertical',
+ align: 'right',
+ verticalAlign: 'top',
+ x: -40,
+ y: 100,
+ floating: true,
+ borderWidth: 1,
+ backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor || '#FFFFFF'),
+ shadow: true
+ },
+ credits: {
+ enabled: false
+ },
+ series: data.series
+ });
});
diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js
index b8f964051b..22aa60bc7c 100644
--- a/app/assets/javascripts/index.js
+++ b/app/assets/javascripts/index.js
@@ -10,5 +10,7 @@
//
// The available directives right now are require, require_directory, and require_tree
//
-//= require flot/jquery.flot.min
+//= require highslide/highslide-full.min
+//= require highslide/highslide.config
+//= require_tree highcharts
//= require firefly/index
diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php
index ec28946115..d1f09bdc05 100644
--- a/app/controllers/HomeController.php
+++ b/app/controllers/HomeController.php
@@ -71,14 +71,6 @@ class HomeController extends BaseController
}
}
- if (count($transactions) % 2 == 0) {
- $transactions = array_chunk($transactions, 2);
- } elseif (count($transactions) == 1) {
- $transactions = array_chunk($transactions, 3);
- } else {
- $transactions = array_chunk($transactions, 3);
- }
-
// build the home screen:
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with('title', 'Firefly')
->with('subTitle', 'What\'s playing?');
diff --git a/app/views/index.blade.php b/app/views/index.blade.php
index 5dc2083368..39ab8bac1a 100644
--- a/app/views/index.blade.php
+++ b/app/views/index.blade.php
@@ -33,7 +33,7 @@
<div class="col-lg-8 col-md-12 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
- <i class="fa fa-credit-card fa-fw"></i> Your accounts
+ <i class="fa fa-credit-card fa-fw"></i> <a href="#">Your accounts</a>
<div class="pull-right">
<div class="btn-group">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
@@ -55,56 +55,84 @@
</div>
</div>
<div class="panel-body">
- <div id="flot-chart-accounts" style="height:300px;"></div>
+ <div id="accounts-chart" style="height:300px;"></div>
</div>
</div>
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-tasks fa-fw"></i> <a href="{{route('budgets.index')}}">Budgets and spending</a>
+ <div class="pull-right">
+ <div class="btn-group">
+ <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
+ Actions
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu pull-right" role="menu">
+ <li><a href="#">Action</a>
+ </li>
+ <li><a href="#">Another action</a>
+ </li>
+ <li><a href="#">Something else here</a>
+ </li>
+ <li class="divider"></li>
+ <li><a href="#">Separated link</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ <div class="panel-body">
+ <div id="budgets"></div>
+ </div>
+ </div>
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-bar-chart fa-fw"></i> <a href="{{route('categories.index')}}">Categories</a>
+ <div class="pull-right">
+ <div class="btn-group">
+ <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
+ Actions
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu pull-right" role="menu">
+ <li><a href="#">Action</a>
+ </li>
+ <li><a href="#">Another action</a>
+ </li>
+ <li><a href="#">Something else here</a>
+ </li>
+ <li class="divider"></li>
+ <li><a href="#">Separated link</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ <div class="panel-body">
+ <div id="categories"></div>
+ </div>
- </div>
- </div>
-
- <!-- TRANSACTIONS -->
- @if(count($transactions) > 0)
- @foreach($transactions as $set)
- <div class="row">
- <?php $split = 12 / count($set); ?>
- @foreach($set as $data)
- <div class="col-lg-{{$split}} col-md-{{$split}}">
- <h4>
- <a href="{{route('accounts.show',$data[1]->id)}}">{{{$data[1]->name}}}</a>
- </h4>
-
- @include('transactions.journals-small',['transactions' => $data[0],'account' => $data[1]])
- <div class="btn-group btn-group-xs">
- <a class="btn btn-default"
- href="{{route('transactions.create','withdrawal')}}?account_id={{$data[1]->id}}"><span
- class="glyphicon glyphicon-arrow-left" title="Withdrawal"></span> Add withdrawal</a>
- <a class="btn btn-default"
- href="{{route('transactions.create','deposit')}}?account_id={{$data[1]->id}}"><span
- class="glyphicon glyphicon-arrow-right" title="Deposit"></span> Add deposit</a>
- <a class="btn btn-default"
- href="{{route('transactions.create','transfer')}}?account_from_id={{$data[1]->id}}"><span
- class="glyphicon glyphicon-resize-full" title="Transfer"></span> Add transfer</a>
</div>
- </div>
- @endforeach
- </div>
- @endforeach
- @endif
- <div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- <div id="budgets"></div>
- </div>
- </div>
- <div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- <div id="categories"></div>
+ </div>
+ <div class="col-lg-4 col-md-6 col-sm-12">
+ <!-- TRANSACTIONS -->
+ @foreach($transactions as $data)
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-money fa-fw"></i>
+ <a href="{{route('accounts.show',$data[1]->id)}}">{{{$data[1]->name}}}</a>
+ </div>
+ <div class="panel-body">
+ @include('transactions.journals-small-index',['transactions' => $data[0],'account' => $data[1]])
+ </div>
+ </div>
+ @endforeach
</div>
</div>
-
@endif
@stop
diff --git a/app/views/transactions/journals-small-index.blade.php b/app/views/transactions/journals-small-index.blade.php
new file mode 100644
index 0000000000..78f84a1d09
--- /dev/null
+++ b/app/views/transactions/journals-small-index.blade.php
@@ -0,0 +1,27 @@
+<div class="list-group">
+@foreach($transactions as $journal)
+<a class="list-group-item" href="{{route('transactions.show',$journal->id)}}">
+
+ @if($journal->transactiontype->type == 'Withdrawal')
+ <i class="fa fa-long-arrow-left fa-fw" title="Withdrawal"></i>
+ @endif
+ @if($journal->transactiontype->type == 'Deposit')
+ <i class="fa fa-long-arrow-right fa-fw" title="Deposit"></i>
+ @endif
+ @if($journal->transactiontype->type == 'Transfer')
+ <i class="fa fa-arrows-h fa-fw" title="Transfer"></i>
+ @endif
+
+ {{{$journal->description}}}
+
+<span class="pull-right small">
+ @foreach($journal->transactions as $t)
+ @if($t->account_id == $account->id)
+ {{mf($t->amount)}}
+ @endif
+ @endforeach
+</span>
+
+</a>
+@endforeach
+</div>
\ No newline at end of file