Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ActivityEffects {
private actions$: Actions,
private activityService: ActivityService,
private toastrService: ToastrService
) {}
) { }

@Effect()
getActivities$: Observable<Action> = this.actions$.pipe(
Expand All @@ -26,7 +26,10 @@ export class ActivityEffects {
map((activities: Activity[]) => {
return new actions.LoadActivitiesSuccess(activities);
}),
catchError((error) => of(new actions.LoadActivitiesFail(error)))
catchError((error) => {
this.toastrService.error(error.error.message);
return of(new actions.LoadActivitiesFail(error));
})
)
)
);
Expand All @@ -42,7 +45,7 @@ export class ActivityEffects {
return new actions.CreateActivitySuccess(activityData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.CreateActivityFail(error));
})
)
Expand All @@ -60,7 +63,7 @@ export class ActivityEffects {
return new actions.DeleteActivitySuccess(activityId);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.DeleteActivityFail(error));
})
)
Expand All @@ -78,7 +81,7 @@ export class ActivityEffects {
return new actions.UpdateActivitySuccess(activityData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.UpdateActivityFail(error));
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ProjectTypeEffects {
private actions$: Actions,
private projectTypeService: ProjectTypeService,
private toastrService: ToastrService
) {}
) { }

@Effect()
getProjectTypes$: Observable<Action> = this.actions$.pipe(
Expand All @@ -26,7 +26,10 @@ export class ProjectTypeEffects {
map((projectTypes: ProjectType[]) => {
return new actions.LoadProjectTypesSuccess(projectTypes);
}),
catchError((error) => of(new actions.LoadProjectTypesFail(error)))
catchError((error) => {
this.toastrService.error(error.error.message);
return of(new actions.LoadProjectTypesFail(error));
})
)
)
);
Expand All @@ -42,7 +45,7 @@ export class ProjectTypeEffects {
return new actions.CreateProjectTypeSuccess(projectTypeData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.CreateProjectTypeFail(error));
})
)
Expand All @@ -60,7 +63,7 @@ export class ProjectTypeEffects {
return new actions.DeleteProjectTypeSuccess(protectTypeId);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.DeleteProjectTypeFail(error));
})
)
Expand All @@ -78,7 +81,7 @@ export class ProjectTypeEffects {
return new actions.UpdateProjectTypeSuccess(projectTypeData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.UpdateProjectTypeFail(error));
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ProjectEffects {
private actions$: Actions,
private projectService: ProjectService,
private toastrService: ToastrService
) {}
) { }

@Effect()
loadProjects$: Observable<Action> = this.actions$.pipe(
Expand All @@ -25,6 +25,7 @@ export class ProjectEffects {
return new actions.LoadProjectsSuccess(projects);
}),
catchError((error) => {
this.toastrService.error(error.error.message);
return of(new actions.LoadProjectsFail(error));
})
)
Expand All @@ -39,7 +40,10 @@ export class ProjectEffects {
map((project) => {
return new actions.LoadCustomerProjectsSuccess(project);
}),
catchError((error) => of(new actions.LoadCustomerProjectsFail(error)))
catchError((error) => {
this.toastrService.error(error.error.message);
return of(new actions.LoadCustomerProjectsFail(error));
})
)
)
);
Expand All @@ -55,7 +59,7 @@ export class ProjectEffects {
return new actions.CreateProjectSuccess(projectData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.CreateProjectFail(error));
})
)
Expand All @@ -73,7 +77,7 @@ export class ProjectEffects {
return new actions.UpdateProjectSuccess(projectData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.UpdateProjectFail(error));
})
)
Expand All @@ -91,7 +95,7 @@ export class ProjectEffects {
return new actions.DeleteProjectSuccess(projectId);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.DeleteProjectFail(error));
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CustomerEffects {
private actions$: Actions,
private customerService: CustomerService,
private toastrService: ToastrService
) {}
) { }

@Effect()
loadCustomers$: Observable<Action> = this.actions$.pipe(
Expand All @@ -25,7 +25,11 @@ export class CustomerEffects {
map((customers) => {
return new actions.LoadCustomersSuccess(customers);
}),
catchError((error) => of(new actions.LoadCustomersFail(error)))
catchError((error) => {
this.toastrService.error(error.error.message);
return of(new actions.LoadCustomersFail(error));
}
)
)
)
);
Expand All @@ -41,7 +45,7 @@ export class CustomerEffects {
return new actions.CreateCustomerSuccess(customerData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.CreateCustomerFail(error));
})
)
Expand All @@ -59,7 +63,7 @@ export class CustomerEffects {
return new actions.DeleteCustomerSuccesss(customerId);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.DeleteCustomerFail(error));
})
)
Expand All @@ -77,7 +81,7 @@ export class CustomerEffects {
return new actions.UpdateCustomerSuccess(customerData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.UpdateCustomerFail(error));
})
)
Expand Down
9 changes: 7 additions & 2 deletions src/app/modules/shared/store/technology.effects.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ToastrService } from 'ngx-toastr';
import { Injectable } from '@angular/core';
import { ofType, Actions, Effect } from '@ngrx/effects';
import { Action } from '@ngrx/store';
Expand All @@ -8,7 +9,8 @@ import * as actions from './technology.actions';

@Injectable()
export class TechnologyEffects {
constructor(private actions$: Actions, private technologyService: TechnologyService) {}

constructor(private toastrService: ToastrService, private actions$: Actions, private technologyService: TechnologyService) { }

@Effect()
findTechnology$: Observable<Action> = this.actions$.pipe(
Expand All @@ -19,7 +21,10 @@ export class TechnologyEffects {
map((technology) => {
return new actions.FindTechnologySuccess(technology);
}),
catchError((error) => of(new actions.FindTechnologyFail(error)))
catchError((error) => {
this.toastrService.error(error.error.message);
return of(new actions.FindTechnologyFail(error));
})
)
)
);
Expand Down
28 changes: 20 additions & 8 deletions src/app/modules/time-clock/store/entry.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as actions from './entry.actions';

@Injectable()
export class EntryEffects {
constructor(private actions$: Actions, private entryService: EntryService, private toastrService: ToastrService) {}
constructor(private actions$: Actions, private entryService: EntryService, private toastrService: ToastrService) { }

@Effect()
loadEntriesSummary$: Observable<Action> = this.actions$.pipe(
Expand All @@ -20,7 +20,10 @@ export class EntryEffects {
map((response) => {
return new actions.LoadEntriesSummarySuccess(response);
}),
catchError((error) => of(new actions.LoadEntriesSummaryFail()))
catchError((error) => {
this.toastrService.success(error);
return of(new actions.LoadEntriesSummaryFail());
})
)
)
);
Expand All @@ -33,7 +36,10 @@ export class EntryEffects {
map((activeEntry) => {
return new actions.LoadActiveEntrySuccess(activeEntry);
}),
catchError((error) => of(new actions.LoadActiveEntryFail(error)))
catchError((error) => {
this.toastrService.success(error);
return of(new actions.LoadActiveEntryFail(error));
})
)
)
);
Expand All @@ -44,7 +50,10 @@ export class EntryEffects {
mergeMap(() =>
this.entryService.loadEntries().pipe(
map((entries) => new actions.LoadEntriesSuccess(entries)),
catchError((error) => of(new actions.LoadEntriesFail(error)))
catchError((error) => {
this.toastrService.success(error);
return of(new actions.LoadEntriesFail(error));
})
)
)
);
Expand All @@ -64,7 +73,7 @@ export class EntryEffects {
return new actions.CreateEntrySuccess(entryData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.CreateEntryFail(error.error.message));
})
)
Expand All @@ -82,7 +91,7 @@ export class EntryEffects {
return new actions.DeleteEntrySuccess(entryId);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.DeleteEntryFail(error));
})
)
Expand All @@ -99,7 +108,7 @@ export class EntryEffects {
return new actions.UpdateActiveEntrySuccess(projectData);
}),
catchError((error) => {
this.toastrService.error(UNEXPECTED_ERROR);
this.toastrService.error(error.error.message);
return of(new actions.UpdateActiveEntryFail(error));
})
)
Expand All @@ -116,7 +125,10 @@ export class EntryEffects {
this.toastrService.success('You clocked-out successfully');
return new actions.StopTimeEntryRunningSuccess(timeEntryId);
}),
catchError((error) => of(new actions.StopTimeEntryRunningFail(error.error.message)))
catchError((error) => {
this.toastrService.error(error.error.message);
return of(new actions.StopTimeEntryRunningFail(error.error.message));
})
)
)
);
Expand Down