Use new Logger in account module.

This commit is contained in:
Alexis Lahouze 2017-07-16 22:25:50 +02:00
parent de945cd16c
commit 3e6b1ecccc
2 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,7 @@
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { Logger } from '@nsalaun/ng-logger';
var accountFormTmpl = require('./account.form.tmpl.html'), var accountFormTmpl = require('./account.form.tmpl.html'),
accountDeleteTmpl = require('./account.delete.tmpl.html'); accountDeleteTmpl = require('./account.delete.tmpl.html');
@ -9,7 +11,7 @@ import { AccountService } from './account.service';
import { AccountBalancesService } from './accountBalances.service'; import { AccountBalancesService } from './accountBalances.service';
export class AccountComponent { export class AccountComponent {
static $inject = ['AccountService', 'AccountBalancesService', 'Notification', '$log', '$modal']; static $inject = ['AccountService', 'AccountBalancesService', 'Notification', 'Logger', '$modal'];
accounts: Account[]; accounts: Account[];
@ -17,7 +19,7 @@ export class AccountComponent {
private AccountService: AccountService, private AccountService: AccountService,
private AccountBalancesService: AccountBalancesService, private AccountBalancesService: AccountBalancesService,
private Notification, private Notification,
private $log, private Logger: Logger,
private $modal private $modal
) { ) {
// Load accounts. // Load accounts.
@ -61,6 +63,7 @@ export class AccountComponent {
load() { load() {
this.AccountService.query().subscribe(accounts => { this.AccountService.query().subscribe(accounts => {
this.accounts = accounts.map((account: Account) => { this.accounts = accounts.map((account: Account) => {
this.Logger.log(account);
this.AccountBalancesService this.AccountBalancesService
.get(account.id) .get(account.id)
.subscribe((accountBalances: AccountBalances) => { .subscribe((accountBalances: AccountBalances) => {
@ -95,7 +98,7 @@ export class AccountComponent {
this.load(); this.load();
}, result => { }, result => {
this.$log.error('Error while saving account', account, result); this.Logger.error('Error while saving account', account, result);
this.Notification.error( this.Notification.error(
'Error while saving account: ' + result.message 'Error while saving account: ' + result.message
@ -157,7 +160,7 @@ export class AccountComponent {
this.$modal({ this.$modal({
templateUrl: accountFormTmpl, templateUrl: accountFormTmpl,
controller: function($log, $scope, title, account, $save) { controller: function($scope, title, account, $save) {
$scope.title = title; $scope.title = title;
$scope.account = account; $scope.account = account;
$scope.account.authorized_overdraft *= -1; $scope.account.authorized_overdraft *= -1;

View File

@ -27,6 +27,8 @@ var ngResource = require('angular-resource'),
ngUiNotification = require('angular-ui-notification'), ngUiNotification = require('angular-ui-notification'),
ngStrap = require('angular-strap'); ngStrap = require('angular-strap');
import { Logger } from '@nsalaun/ng-logger';
var accountsTmpl = require('./accounts.html'); var accountsTmpl = require('./accounts.html');
import { AccountBalancesService } from './accountBalances.service'; import { AccountBalancesService } from './accountBalances.service';
@ -40,6 +42,8 @@ export default angular.module('accountant.accounts', [
ngStrap, ngStrap,
]) ])
.factory('Logger', downgradeInjectable(Logger))
.factory('AccountBalancesService', downgradeInjectable(AccountBalancesService)) .factory('AccountBalancesService', downgradeInjectable(AccountBalancesService))
.factory('AccountService', downgradeInjectable(AccountService)) .factory('AccountService', downgradeInjectable(AccountService))