From e71f417aa2adc2e3c8dc0d5608eb0ac328e878fb Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 17 Sep 2015 10:16:42 +0200 Subject: [PATCH 1/3] refactor design --- public/app/css/app.css | 2 +- public/app/js/templates/dashboard.html | 128 +++++++------------------ 2 files changed, 37 insertions(+), 93 deletions(-) diff --git a/public/app/css/app.css b/public/app/css/app.css index 3f4165ef..46d0c30f 100644 --- a/public/app/css/app.css +++ b/public/app/css/app.css @@ -3,6 +3,6 @@ md-content table { max-width: 99%; width: 99%; margin: 0 0.5%; } - +md-card select { height: 100%; } .even{background-color:#ddd} .odd{background-color:#eee} diff --git a/public/app/js/templates/dashboard.html b/public/app/js/templates/dashboard.html index d2f5fd9e..520834f5 100644 --- a/public/app/js/templates/dashboard.html +++ b/public/app/js/templates/dashboard.html @@ -1,57 +1,43 @@ - - - + + + + + + + + + + - - - - - - - -

- - - {{period}} - - -

-
- - - -

{{account.account}} = {{account.amount | number:2}} €

- - + {{account.account}} = {{account.amount | number:2}} €
- - + + + + + - + @@ -96,46 +82,4 @@ - From dd3adadaee8324d3bb5bc657755eb930817c064a Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 17 Sep 2015 10:26:48 +0200 Subject: [PATCH 2/3] flex values --- public/app/js/templates/dashboard.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/app/js/templates/dashboard.html b/public/app/js/templates/dashboard.html index 520834f5..f1c81a65 100644 --- a/public/app/js/templates/dashboard.html +++ b/public/app/js/templates/dashboard.html @@ -1,11 +1,11 @@ - + - + {{account.account}} = {{account.amount | number:2}} € - +
From c0a109d56a79c2095eae46d59a2736d28cfb9b27 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Fri, 2 Oct 2015 15:02:02 +0200 Subject: [PATCH 3/3] small changes and refactoring --- public/app/js/controllers/DashboardCtrl.js | 50 +++++----------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/public/app/js/controllers/DashboardCtrl.js b/public/app/js/controllers/DashboardCtrl.js index 82bb33c5..123e7fc2 100644 --- a/public/app/js/controllers/DashboardCtrl.js +++ b/public/app/js/controllers/DashboardCtrl.js @@ -22,10 +22,8 @@ app.controller( 'DashboardCtrl', // compute an account's score: from 1 (good) to 10 (bad), 0 is neutral/undecided var score_account = function ( account ) { - if ( account.match( /^Income:(salaire|Sécu|Mutuelle)$/ ) ) { - return 11; - } else if ( account.match( /^Income:(Gift|Remboursement)$/ ) ) { - return 12; + if ( account.match( /^Income/ ) ) { + return -10; } else if ( account.match( /^Expenses:(courses|Hang)$/ ) ) { return 1; } else if ( account.match( /^Expenses:Home/ ) ) { @@ -41,9 +39,9 @@ app.controller( 'DashboardCtrl', } else if ( account.match( /^Expenses:Gadgets/ ) ) { return 10; } else if ( account.match( /^Liabilities/ ) ) { - return 1000; + return 0; } else if ( account.match( /^Assets/ ) ) { - return 100; + return -100; } else { return 0; } @@ -53,18 +51,14 @@ app.controller( 'DashboardCtrl', var adjusted_score = score; var color_scale = [ '#99f', '#0f0', '#3f0', '#6f0', '#9f0', '#cf0', '#fc0', '#f90', '#f60', '#f30', '#f00' ]; - if ( score >= 1000 ) { - // Liabilities - adjusted_score = score - 1000; - color_scale = [ '#0ff' ]; - } else if ( score >= 100 ) { + if ( score <= -100 ) { // Assets - adjusted_score = score - 100; + adjusted_score = ( score * -1 ) - 100; color_scale = [ '#f0f' ]; - } else if ( score >= 11 ) { + } else if ( score <= -10 ) { // Income - adjusted_score = score - 11; - color_scale = [ '#360', '#369' ]; + adjusted_score = ( score * -1 ) - 10; + color_scale = [ '#360' ]; } return color_scale[ adjusted_score ]; @@ -97,7 +91,7 @@ app.controller( 'DashboardCtrl', return memo + account.amount; }, 0 ); } ) - .value(); + .value(); bucket.total_detailed = _.chain(bucket.total_detailed) .keys() .map( function( key ) { @@ -109,12 +103,6 @@ app.controller( 'DashboardCtrl', } ); }; - $scope.select = { score_higher_than: function( bucket, score ) { - bucket.accounts_selected = _(bucket.raw_data).filter( function( account ) { - return account.score >= score; - } ); - }}; - var Bucket = function( categories, period ) { var _this = this; this.categories = categories; @@ -164,29 +152,11 @@ app.controller( 'DashboardCtrl', }, 0 ); bucket.accounts_selected = bucket.raw_data; - $scope.select.score_higher_than( bucket, bucket.score_threshold ); $scope.filter_data(); } ); } ); }; - // $scope.dates_salaries = []; - - // var retrieve_dates_salaries = function() { - // API.dates_salaries() - // .then( function ( response ) { - // $scope.dates_salaries = response.data; - // $scope.periods= []; - // for ( var i = 0 ; i < ( $scope.dates_salaries.length - 1 ) ; i++ ) { - // $scope.periods.push( 'from ' + $scope.dates_salaries[i] + ' to ' + $scope.dates_salaries[i+1] ); - // } - // $scope.periods.push( 'from ' + _($scope.dates_salaries).last() ); - // $scope.periods = _($scope.periods).reverse(); - // $scope.period = _($scope.periods).first(); - // } ); - // }; - //retrieve_dates_salaries(); - var retrieve_accounts = function() { API.accounts() .then( function ( response ) {