Skip to content
Closed
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
TT-71 fix: spinner for loading (advances)
  • Loading branch information
Guido Quezada committed Jan 4, 2021
commit 0d0f8825f28eae315ed1b20e9aaf0c7d107c78c7
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"ngx-mask": "^9.1.2",
"ngx-material-timepicker": "^5.5.3",
"ngx-pagination": "^5.0.0",
"ngx-spinner": "^10.0.1",
"ngx-toastr": "^12.0.1",
"rxjs": "~6.6.3",
"tslib": "^1.10.0",
Expand Down
5 changes: 4 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';
import { CommonModule, DatePipe } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Component } from '@angular/core';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { DataTablesModule } from 'angular-datatables';
Expand All @@ -13,6 +13,7 @@ import { StoreDevtoolsModule } from '@ngrx/store-devtools';

import { NgxPaginationModule } from 'ngx-pagination';
import { AutocompleteLibModule } from 'angular-ng-autocomplete';
import { NgxSpinnerModule } from "ngx-spinner";

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
Expand Down Expand Up @@ -139,6 +140,7 @@ const maskConfig: Partial<IConfig> = {
ReactiveFormsModule,
HttpClientModule,
NgxPaginationModule,
NgxSpinnerModule,
DataTablesModule,
AutocompleteLibModule,
NgxMaterialTimepickerModule,
Expand Down Expand Up @@ -171,5 +173,6 @@ const maskConfig: Partial<IConfig> = {
CookieService,
],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export class EntryFieldsComponent implements OnInit {
this.store.dispatch(new entryActions.LoadEntriesSummary());
} else {
this.store.dispatch(new entryActions.UpdateEntryRunning({ ...this.newData, ...this.entryForm.value }));
this.store.dispatch(new LoadActiveEntry());
this.store.dispatch(new entryActions.LoadEntriesSummary());
}
});
Expand Down
10 changes: 9 additions & 1 deletion src/app/modules/time-clock/pages/time-clock.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<app-time-entries-summary></app-time-entries-summary>
<ngx-spinner
bdColor = "rgba(0, 0, 0, 0.7)"
size = "default"
type = "pacman"
[fullScreen] = "true"
>
<p style="color: #ffff" > Loading... </p>
</ngx-spinner>

<div class="col-12 col-md-9 px-0">

Expand All @@ -15,7 +23,7 @@
</div>

<app-project-list-hover></app-project-list-hover>
<div *ngIf="areFieldsVisible">
<div *ngIf="areFieldsVisible"> <!-- no recomendable-->
<app-entry-fields></app-entry-fields>
</div>

Expand Down
14 changes: 12 additions & 2 deletions src/app/modules/time-clock/pages/time-clock.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { AzureAdB2CService } from '../../login/services/azure.ad.b2c.service';
import { EntryFieldsComponent } from '../components/entry-fields/entry-fields.component';
import { Entry } from './../../shared/models/entry.model';
import { EntryActionTypes, LoadEntriesSummary, StopTimeEntryRunning } from './../store/entry.actions';
import { getActiveTimeEntry } from './../store/entry.selectors';
import { getActiveTimeEntry, getIsLoading } from './../store/entry.selectors';
import { NgxSpinnerService } from "ngx-spinner";
@Component({
selector: 'app-time-clock',
templateUrl: './time-clock.component.html',
Expand All @@ -26,7 +27,8 @@ export class TimeClockComponent implements OnInit, OnDestroy {
private azureAdB2CService: AzureAdB2CService,
private store: Store<Entry>,
private toastrService: ToastrService,
private actionsSubject$: ActionsSubject
private actionsSubject$: ActionsSubject,
private spinner: NgxSpinnerService,
) {}

ngOnDestroy(): void {
Expand All @@ -44,6 +46,14 @@ export class TimeClockComponent implements OnInit, OnDestroy {
}
});

this.store.pipe(select(getIsLoading)).subscribe((isLoading) => {
if (isLoading) {
this.spinner.show();
} else {
this.spinner.hide();
}
});

this.reloadSummariesOnClockOut();

}
Expand Down
37 changes: 36 additions & 1 deletion src/app/modules/time-clock/store/entry.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { EntryActions, EntryActionTypes } from './entry.actions';
export interface EntryState {
active: Entry;
isLoading: boolean;
isLoading2: boolean;
message: string;
createError: boolean;
updateError: boolean;
Expand All @@ -20,6 +21,7 @@ const emptyTimeEntriesSummary: TimeEntriesSummary = { day: emptyTimeDetails, wee
export const initialState = {
active: null,
isLoading: false,
isLoading2: false,
message: '',
createError: null,
updateError: null,
Expand Down Expand Up @@ -56,19 +58,24 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi
return {
...state,
isLoading: true,
isLoading2: true,
};
}
case EntryActionTypes.LOAD_ACTIVE_ENTRY_SUCCESS:
return {
...state,
active: action.payload,
isLoading: false,
isLoading2: false,
};
case EntryActionTypes.LOAD_ACTIVE_ENTRY_FAIL: {
console.log('jjsjd');

return {
...state,
active: null,
isLoading: false,
isLoading2: false,
message: 'Something went wrong fetching active entry!',
};
}
Expand All @@ -93,6 +100,8 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi
};

case EntryActionTypes.LOAD_ENTRIES_FAIL: {
console.log('here');

return {
...state,
message: 'Something went wrong fetching entries!',
Expand Down Expand Up @@ -210,6 +219,7 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi
return {
...state,
isLoading: true,
isLoading2: true,
};
}

Expand All @@ -221,10 +231,27 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi
};
}

case EntryActionTypes.UPDATE_ENTRY_RUNNING: {
console.log('UPDATE_ENTRY_RUNNING ');

return {
...state,
isLoading2: true,
};
}

case EntryActionTypes.SWITCH_TIME_ENTRY: {
return {
...state,
isLoading2: true,
};
}

case EntryActionTypes.STOP_TIME_ENTRY_RUNNING: {
return {
...state,
isLoading: true,
isLoading2: true,
};
}

Expand All @@ -233,7 +260,15 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi
...state,
active: null,
isLoading: false,
message: 'You clocked-out successfully',
isLoading2: false,
message: 'You clocked-out successfullys',
};
}

case EntryActionTypes.CLOCK_IN: {
return {
...state,
isLoading2: true,
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/app/modules/time-clock/store/entry.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const getActiveTimeEntry = createSelector(getEntryState, (state: EntrySta

export const getCreateError = createSelector(getEntryState, (state: EntryState) => state?.createError);

export const getIsLoading = createSelector(getEntryState, (state: EntryState) => state?.isLoading2);

export const getUpdateError = createSelector(getEntryState, (state: EntryState) => state?.updateError);

export const getStatusMessage = createSelector(getEntryState, (state: EntryState) => state?.message);
Expand Down