Skip to content

Commit

Permalink
better code organization
Browse files Browse the repository at this point in the history
  • Loading branch information
Pop John committed Jul 12, 2024
1 parent 82056cc commit 2eb1a98
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 23 deletions.
6 changes: 4 additions & 2 deletions frontend/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { provideClientHydration } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
import { provideCore } from './modules/core/core.provide';
import { provideCoreServices } from './modules/core/core-services.provide';
import { provideCustomMaterialConfigs } from './modules/shared/material.providers';
import { provideBEServices } from './services/be-services.provide';
import { provideInterceptors } from './services/interceptors.provide';
import { provideGlobalStore } from './state/global-store.providers';

Expand All @@ -15,7 +16,8 @@ export const appConfig: ApplicationConfig = {
provideRouter(routes),
provideCustomMaterialConfigs(),
provideGlobalStore(),
provideCore(),
provideBEServices(),
provideCoreServices(),
provideInterceptors(),
provideClientHydration(),
provideHttpClient(withInterceptorsFromDi())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { HttpClient } from '@angular/common/http';
import { ENVIRONMENT_INITIALIZER, inject, Provider } from '@angular/core';
import { MatIconRegistry } from '@angular/material/icon';
import { CLIENT } from '../../app.tokens';
import { ClientBackend } from '../../services/client/client-backend';
import { ScriptActions } from '../../state/core/script';
import { AuthGuard } from './guards/auth.guard';
import { ModeSelectGuard } from './guards/mode-select.guard';
Expand All @@ -23,7 +20,7 @@ import {
import { ModelsFacadeService } from './services/models-facade.service';
import { PageRunningScriptSpiningIndicatorService } from './services/page-running-script-spinning-indicator.service';

export function provideCore(): Provider[] {
export function provideCoreServices(): Provider[] {
return [
WebsocketService,
AuthGuard,
Expand All @@ -41,13 +38,6 @@ export function provideCore(): Provider[] {
StatisticsFacadeService,
PageRunningScriptSpiningIndicatorService,
ModelsFacadeService,
{
provide: CLIENT,
useFactory: (httpClient: HttpClient) => {
return new ClientBackend(httpClient);
},
deps: [HttpClient]
},
{
provide: ENVIRONMENT_INITIALIZER,
multi: true,
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/app/services/be-services.provide.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { HttpClient } from '@angular/common/http';
import { Provider } from '@angular/core';
import { ClientBackend } from './client/client-backend';
import { CLIENT } from './services.tokens';

export function provideBEServices(): Provider[] {
return [
{
provide: CLIENT,
useFactory: (httpClient: HttpClient) => {
return new ClientBackend(httpClient);
},
deps: [HttpClient]
}
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
// SPDX-License-Identifier: Apache-2.0

import { InjectionToken } from '@angular/core';
import { Client } from './services/client/client';
import { Client } from './client/client';

export const CLIENT = new InjectionToken<Client>('CLIENT');
2 changes: 1 addition & 1 deletion frontend/src/app/state/core/auth/auth.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import { Router } from '@angular/router';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { catchError, filter, map, mergeMap, tap, withLatestFrom } from 'rxjs/operators';
import { CLIENT } from '../../../app.tokens';
import { RoutesList } from '../../../modules/core/models/enums/routes-list.enum';
import { Client } from '../../../services/client/client';
import { PostLogin } from '../../../services/client/serviceCalls/authenticate/post-login';
import { PostLogout } from '../../../services/client/serviceCalls/user/post-logout';
import { CLIENT } from '../../../services/services.tokens';
import { AuthActions } from './auth.actions';
import { selectIsAuthenticated } from './auth.selector';
import { AuthState } from './auth.state';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/state/core/charts/charts.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import { Inject, Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { catchError, map, of, switchMap } from 'rxjs';
import { CLIENT } from '../../../app.tokens';
import { Client } from '../../../services/client/client';
import { GetChartConfigurationSettings } from '../../../services/client/serviceCalls/charts/get-chart-configuration-settings';
import { GetCurrentMachineUnlearningChartData } from '../../../services/client/serviceCalls/charts/get-current-machine-unlearning-chart-data copy';
import { GetCurrentPruningChartData } from '../../../services/client/serviceCalls/charts/get-current-pruning-chart-data';
import { GetCurrentQuantizationChartData } from '../../../services/client/serviceCalls/charts/get-current-quantization-chart-data';
import { CLIENT } from '../../../services/services.tokens';
import { ChartActions } from './charts.actions';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/state/core/file/file.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { Inject, Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { of } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators';
import { CLIENT } from '../../../app.tokens';
import { BannerService } from '../../../modules/shared/components/ms-banner/services/banner.service';
import { Client } from '../../../services/client/client';
import { PostUploadModel } from '../../../services/client/serviceCalls/upload-file/post-upload-file';
import { CLIENT } from '../../../services/services.tokens';
import { ScriptActions } from '../script/script.actions';
import { FileActions } from './file.actions';

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/state/core/models/models.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import { Inject, Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { of } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators';
import { CLIENT } from '../../../app.tokens';
import { Client } from '../../../services/client/client';
import { GetCurrentOrPreviousSelectedModel } from '../../../services/client/serviceCalls/models/get-current-or-previous-selected-model';
import { GetModelMetadata } from '../../../services/client/serviceCalls/models/get-model-metadata';
import { GetModelsList } from '../../../services/client/serviceCalls/models/get-models-list';
import { CLIENT } from '../../../services/services.tokens';
import { ModelsActions } from './models.actions';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import { Inject, Injectable } from '@angular/core';

import { Actions, createEffect, ofType } from '@ngrx/effects';
import { catchError, map, of, switchMap } from 'rxjs';
import { CLIENT } from '../../../app.tokens';
import { Client } from '../../../services/client/client';
import { GetParameters } from '../../../services/client/serviceCalls/parameters/get-parameters';
import { CLIENT } from '../../../services/services.tokens';
import { ParameterActions } from './parameters.actions';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/state/core/script/script.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import { Inject, Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { catchError, map, of, switchMap } from 'rxjs';
import { CLIENT } from '../../../app.tokens';
import { Client } from '../../../services/client/client';
import { GetCurrentOrLastActiveScriptDetails } from '../../../services/client/serviceCalls/script/get-current-or-last-active-script-details';
import { GetScriptStatus } from '../../../services/client/serviceCalls/script/get-script-status';
import { PostRunScript } from '../../../services/client/serviceCalls/script/post-run-script';
import { PostStopScript } from '../../../services/client/serviceCalls/script/post-stop-script';
import { CLIENT } from '../../../services/services.tokens';
import { ScriptActions } from './script.actions';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import { Inject, Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { catchError, map, of, switchMap } from 'rxjs';
import { CLIENT } from '../../../app.tokens';
import { Client } from '../../../services/client/client';
import { GetStatistics } from '../../../services/client/serviceCalls/statistics/get-statistics';
import { CLIENT } from '../../../services/services.tokens';
import { StatisticsActions } from './statistics.actions';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/state/core/terminal/terminal.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import { Inject, Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { catchError, map, of, switchMap } from 'rxjs';
import { CLIENT } from '../../../app.tokens';
import { Client } from '../../../services/client/client';
import { GetLatestMessages } from '../../../services/client/serviceCalls/terminal/get-latest-messages';
import { PostClearHistory } from '../../../services/client/serviceCalls/terminal/post-clear-history';
import { CLIENT } from '../../../services/services.tokens';
import { TerminalActions } from './terminal.actions';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import { Inject, Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { catchError, map, of, switchMap } from 'rxjs';
import { CLIENT } from '../../../app.tokens';
import { Client } from '../../../services/client/client';
import { GetRunRecordsFilenames } from '../../../services/client/serviceCalls/run-records/get-run-records-filenames';
import { GetRunRecordsSummarizedData } from '../../../services/client/serviceCalls/run-records/get-run-records-summarized-data';
import { CLIENT } from '../../../services/services.tokens';
import { RunRecordsActions } from './records.actions';

@Injectable()
Expand Down

0 comments on commit 2eb1a98

Please sign in to comment.