diff --git a/hledger-api/client/hledger-client.css b/hledger-api/client/hledger-client.css deleted file mode 100644 index 046e00407..000000000 --- a/hledger-api/client/hledger-client.css +++ /dev/null @@ -1,7 +0,0 @@ -ul.accounts, ul.accounts ul { - list-style-type: none; - padding-left: 0; -} -ul.accounts ul { - margin-left: 15px; -} diff --git a/hledger-api/examples/01.html b/hledger-api/examples/01.html deleted file mode 100644 index 00d16a60c..000000000 --- a/hledger-api/examples/01.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - hledger-api example 01 - - - -

-Account names: - -


-
-
-
-
-
diff --git a/hledger-api/examples/02.html b/hledger-api/examples/02.html
deleted file mode 100644
index 0306d5887..000000000
--- a/hledger-api/examples/02.html
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-  
-  hledger-api example 01
-  
-
-  
-    
-      
-      
-    
-  
- -

Commodities

-

-
-        

Market Prices

-

-
-        

Account names

-

-
-      
- -

Transactions

-

-
-      
- - - - - diff --git a/hledger-api/static/README.txt b/hledger-api/static/README.txt deleted file mode 100644 index 2b8913edb..000000000 --- a/hledger-api/static/README.txt +++ /dev/null @@ -1 +0,0 @@ -Files under this directory are served by hledger-api when no other API route is matched. diff --git a/hledger-api/client/accounts/view.html b/hledger-api/static/accounts/view.html similarity index 100% rename from hledger-api/client/accounts/view.html rename to hledger-api/static/accounts/view.html diff --git a/hledger-api/client/help/index.html b/hledger-api/static/help/index.html similarity index 100% rename from hledger-api/client/help/index.html rename to hledger-api/static/help/index.html diff --git a/hledger-api/static/hledger-client.css b/hledger-api/static/hledger-client.css new file mode 100644 index 000000000..5c5680700 --- /dev/null +++ b/hledger-api/static/hledger-client.css @@ -0,0 +1,22 @@ +ul.accounts, ul.accounts ul { + list-style-type: none; + padding-left: 0; +} +ul.accounts ul { + margin-left: 15px; +} +ul.accounts li { + clear: both; + border-top: 1px dotted #888; +} +ul.accounts .balances { + display: block; + float: right; + text-align: right; +} +ul.accounts .balance { + display: block; +} +ul.accounts .balance .commodity-side-L { + float: left; +} diff --git a/hledger-api/client/hledger-client.js b/hledger-api/static/hledger-client.js similarity index 61% rename from hledger-api/client/hledger-client.js rename to hledger-api/static/hledger-client.js index a3fb8965a..a80adb554 100644 --- a/hledger-api/client/hledger-client.js +++ b/hledger-api/static/hledger-client.js @@ -2,12 +2,26 @@ var hledger = angular.module('hledger', [ 'ui.router', 'ngResource' ]) +function listToTree(list, id_field, parent_field) { + children = function(list, parent_id) { + return $.grep(list, + function(element) { + return element[parent_field] === parent_id + }); + } + $.map(list, function(element) { + element.children = children(list, element[id_field]) + }); + root = children(list, ''); + return root; +} + hledger.config(function($stateProvider, $urlRouterProvider) { $urlRouterProvider.otherwise("/accounts"); $stateProvider .state('accounts', { url: "/accounts", - templateUrl: "accounts/view.html", + templateUrl: "accounts/index.html", controller: 'AccountsController' }) .state('help', { @@ -22,7 +36,7 @@ hledger.factory('Journal', function($resource) { hledger.controller("JournalController", function($scope, Journal) { Journal.query(function(data) { - $scope.journal = data; + $scope.journal = data; }); }); @@ -32,6 +46,6 @@ hledger.factory('Account', function($resource) { hledger.controller("AccountsController", function($scope, Account) { Account.query(function(data) { - $scope.accounts = data; + $scope.accounts = listToTree(data, 'aname', 'aparentname')[0].children; }); }); diff --git a/hledger-api/client/index.html b/hledger-api/static/index.html similarity index 100% rename from hledger-api/client/index.html rename to hledger-api/static/index.html diff --git a/hledger-api/client/journal/index.html b/hledger-api/static/journal/index.html similarity index 100% rename from hledger-api/client/journal/index.html rename to hledger-api/static/journal/index.html diff --git a/hledger-api/client/libraries/angular-resource.min.js b/hledger-api/static/libraries/angular-resource.min.js similarity index 100% rename from hledger-api/client/libraries/angular-resource.min.js rename to hledger-api/static/libraries/angular-resource.min.js diff --git a/hledger-api/client/libraries/angular-ui-router.min.js b/hledger-api/static/libraries/angular-ui-router.min.js similarity index 100% rename from hledger-api/client/libraries/angular-ui-router.min.js rename to hledger-api/static/libraries/angular-ui-router.min.js diff --git a/hledger-api/client/libraries/angular.min.js b/hledger-api/static/libraries/angular.min.js similarity index 100% rename from hledger-api/client/libraries/angular.min.js rename to hledger-api/static/libraries/angular.min.js diff --git a/hledger-api/client/libraries/bootstrap/css/bootstrap.css b/hledger-api/static/libraries/bootstrap/css/bootstrap.css similarity index 100% rename from hledger-api/client/libraries/bootstrap/css/bootstrap.css rename to hledger-api/static/libraries/bootstrap/css/bootstrap.css diff --git a/hledger-api/client/libraries/jquery-2.2.0.min.js b/hledger-api/static/libraries/jquery-2.2.0.min.js similarity index 100% rename from hledger-api/client/libraries/jquery-2.2.0.min.js rename to hledger-api/static/libraries/jquery-2.2.0.min.js