mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
All kinds of fixes and things. I should really start organizing.
This commit is contained in:
@@ -1,145 +1,20 @@
|
||||
$(function () {
|
||||
|
||||
if (typeof(googleLineChart) == "function") {
|
||||
if (typeof(googleLineChart) == "function" && typeof accountID != 'undefined') {
|
||||
googleLineChart('chart/account/' + accountID, 'overview-chart');
|
||||
}
|
||||
//
|
||||
if(typeof(googleSankeyChart) == 'function') {
|
||||
googleSankeyChart('chart/sankey/' + accountID + '/out','account-out-sankey');
|
||||
googleSankeyChart('chart/sankey/' + accountID + '/in','account-in-sankey');
|
||||
if (typeof(googleSankeyChart) == 'function' && typeof accountID != 'undefined') {
|
||||
googleSankeyChart('chart/sankey/' + accountID + '/out', 'account-out-sankey');
|
||||
googleSankeyChart('chart/sankey/' + accountID + '/in', 'account-in-sankey');
|
||||
}
|
||||
if(typeof(googleTable) == 'function') {
|
||||
googleTable('table/account/' + accountID + '/transactions','account-transactions');
|
||||
if (typeof(googleTable) == 'function') {
|
||||
if (typeof accountID != 'undefined') {
|
||||
googleTable('table/account/' + accountID + '/transactions', 'account-transactions');
|
||||
}
|
||||
if (typeof what != 'undefined') {
|
||||
googleTable('table/accounts/' + what, 'account-list');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($('#accountTable').length == 1) {
|
||||
drawDatatable();
|
||||
}
|
||||
//if ($('#overviewChart').length == 1) {
|
||||
// drawOverviewChart();
|
||||
//}
|
||||
|
||||
});
|
||||
|
||||
function drawDatatable() {
|
||||
var opt = {
|
||||
serverSide: true,
|
||||
ajax: URL,
|
||||
paging: true,
|
||||
processing: true,
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
data: 'name',
|
||||
searchable: true,
|
||||
render: function (data) {
|
||||
return '<a href="' + data.url + '">' + data.name + '</a>';
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
name: 'balance',
|
||||
data: 'balance',
|
||||
title: 'Amount (\u20AC)',
|
||||
searchable: false,
|
||||
sortable: true,
|
||||
render: function (data) {
|
||||
var amount = parseInt(data);
|
||||
if (amount < 0) {
|
||||
'<span class="text-danger">\u20AC ' + data.toFixed(2) + '</span>'
|
||||
}
|
||||
if (amount > 0) {
|
||||
'<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>'
|
||||
}
|
||||
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'id',
|
||||
data: 'id',
|
||||
title: '',
|
||||
render: function (data) {
|
||||
return '<div class="btn-group btn-group-xs">' +
|
||||
'<a class="btn btn-default btn-xs" href="' + data.edit + '">' +
|
||||
'<span class="glyphicon glyphicon-pencil"</a>' +
|
||||
'<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +
|
||||
'<span class="glyphicon glyphicon-trash"</a>' +
|
||||
'</a></div>';
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
$('#accountTable').DataTable(opt);
|
||||
}
|
||||
|
||||
|
||||
function drawOverviewChart() {
|
||||
$.getJSON('chart/home/account/' + accountID).success(function (data) {
|
||||
var options = {
|
||||
chart: {
|
||||
renderTo: 'overviewChart',
|
||||
type: 'spline'
|
||||
},
|
||||
|
||||
series: data.series,
|
||||
title: {
|
||||
text: null
|
||||
},
|
||||
yAxis: {
|
||||
allowDecimals: false,
|
||||
labels: {
|
||||
formatter: function () {
|
||||
if (this.value >= 1000 || this.value <= -1000) {
|
||||
return '\u20AC ' + (this.value / 1000) + 'k';
|
||||
}
|
||||
return '\u20AC ' + this.value;
|
||||
|
||||
}
|
||||
},
|
||||
title: {text: null}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'datetime',
|
||||
dateTimeLabelFormats: {
|
||||
day: '%e %b',
|
||||
week: '%e %b'
|
||||
},
|
||||
title: {
|
||||
text: null
|
||||
}
|
||||
},
|
||||
legend: {enabled: false},
|
||||
tooltip: {
|
||||
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: 0
|
||||
},
|
||||
point: {
|
||||
events: {
|
||||
click: function (e) {
|
||||
alert('click!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
credits: {
|
||||
enabled: false
|
||||
}
|
||||
};
|
||||
$('#overviewChart').highcharts(options);
|
||||
});
|
||||
}
|
||||
});
|
@@ -1,4 +1,4 @@
|
||||
google.load('visualization', '1.1', {'packages': ['corechart', 'bar','sankey', 'table']});
|
||||
google.load('visualization', '1.1', {'packages': ['corechart', 'bar', 'sankey', 'table']});
|
||||
|
||||
function googleLineChart(URL, container) {
|
||||
$.getJSON(URL).success(function (data) {
|
||||
@@ -187,24 +187,24 @@ function googleTable(URL, container) {
|
||||
/*
|
||||
Format a string using the previous column as URL.
|
||||
*/
|
||||
if (label == 'Description' || label == 'From' || label == 'To' || label == 'Budget' || label == 'Category') {
|
||||
if (label == 'Description' || label == 'From' || label == 'Name' || label == 'To' || label == 'Budget' || label == 'Category') {
|
||||
URLFormatter.format(gdata, [i - 1, i], i);
|
||||
columnsToHide.push(i - 1);
|
||||
}
|
||||
if(label == 'ID') {
|
||||
EditButtonFormatter.format(gdata, [i+1,i+2],i);
|
||||
columnsToHide.push(i+1,i+2);
|
||||
if (label == 'ID') {
|
||||
EditButtonFormatter.format(gdata, [i + 1, i + 2], i);
|
||||
columnsToHide.push(i + 1, i + 2);
|
||||
}
|
||||
|
||||
/*
|
||||
Format with buttons:
|
||||
Format with buttons:
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Format as money
|
||||
*/
|
||||
if (label == 'Amount') {
|
||||
if (label == 'Amount' || label == 'Balance') {
|
||||
money.format(gdata, i);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user