mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-28 21:02:04 +03:00
0ab008ed5e
- api routes (but not /swagger.json) are now under /api/v1 - the api has changed a bit, more to come - files are served from the current directory by default, simplifying naming - the startup message is more informative - added some startup hints for the angular client
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
var hledger = angular.module('hledger', [
|
|
'ui.router',
|
|
'ngResource'
|
|
])
|
|
hledger.api_root = '/api/v1';
|
|
|
|
hledger.config(function($stateProvider, $urlRouterProvider) {
|
|
//$urlRouterProvider.otherwise("/");
|
|
$stateProvider
|
|
.state('dashboard', {
|
|
url: ""
|
|
})
|
|
.state('accounts', {
|
|
abstract: true,
|
|
url: "/accounts",
|
|
templateUrl: "accounts/index.html"
|
|
})
|
|
.state('accounts.show', {
|
|
url: "/:id",
|
|
templateUrl: 'accounts/show.html',
|
|
resolve: {
|
|
Account: 'Account',
|
|
account: function(Account, $stateParams) {
|
|
return Account.get($stateParams);
|
|
}
|
|
}
|
|
})
|
|
.state('help', {
|
|
url: "/help",
|
|
templateUrl: "help/index.html"
|
|
});
|
|
});
|
|
|
|
hledger.factory('Journal', function($resource) {
|
|
return($resource(hledger.api_root + "/journals/:id"));
|
|
});
|
|
|
|
hledger.controller("JournalController", function($scope, Journal) {
|
|
Journal.query(function(data) {
|
|
$scope.journal = data;
|
|
});
|
|
});
|
|
|
|
hledger.factory('Account', function($resource) {
|
|
return($resource(hledger.api_root + "/accounts/:id"));
|
|
});
|
|
|
|
hledger.controller("AccountsController", function($scope, Account) {
|
|
Account.query(function(data) {
|
|
$scope.accounts = data;
|
|
});
|
|
});
|
|
|
|
hledger.filter("accountNameNode", function() {
|
|
return function(account) {
|
|
return account.replace(/^.*:/, '');
|
|
};
|
|
});
|
|
|