diff --git a/src/app/components/module-parts/module-detail-data.service.ts b/src/app/components/module-parts/module-detail-data.service.ts index d4db05f0..d99ce3d3 100644 --- a/src/app/components/module-parts/module-detail-data.service.ts +++ b/src/app/components/module-parts/module-detail-data.service.ts @@ -17,7 +17,7 @@ import { tap, withLatestFrom } from 'rxjs/operators'; -import { RackModuleAdderComponent } from 'src/app/components/rack-parts/rack-module-adder/rack-module-adder.component'; +import { RackModuleAdderDialogComponent } from 'src/app/components/rack-parts/rack-module-adder/rack-module-adder-dialog.component'; import { UserManagementService } from '../../features/backbone/login/user-management.service'; import { SupabaseService } from '../../features/backend/supabase.service'; import { DbModule } from '../../models/module'; @@ -151,7 +151,7 @@ export class ModuleDetailDataService { this.requestAddModuleToRack$ .pipe( - switchMap(x => RackModuleAdderComponent.open(this.dialog, {module: x}) + switchMap(x => RackModuleAdderDialogComponent.open(this.dialog, {module: x}) .afterClosed()), withLatestFrom(this.updateSingleModuleData$), takeUntil(this.destroyEvent$) diff --git a/src/app/components/rack-parts/rack-module-adder/rack-module-adder.component.html b/src/app/components/rack-parts/rack-module-adder/rack-module-adder-dialog.component.html similarity index 100% rename from src/app/components/rack-parts/rack-module-adder/rack-module-adder.component.html rename to src/app/components/rack-parts/rack-module-adder/rack-module-adder-dialog.component.html diff --git a/src/app/components/rack-parts/rack-module-adder/rack-module-adder.component.scss b/src/app/components/rack-parts/rack-module-adder/rack-module-adder-dialog.component.scss similarity index 100% rename from src/app/components/rack-parts/rack-module-adder/rack-module-adder.component.scss rename to src/app/components/rack-parts/rack-module-adder/rack-module-adder-dialog.component.scss diff --git a/src/app/components/rack-parts/rack-module-adder/rack-module-adder.component.ts b/src/app/components/rack-parts/rack-module-adder/rack-module-adder-dialog.component.ts similarity index 65% rename from src/app/components/rack-parts/rack-module-adder/rack-module-adder.component.ts rename to src/app/components/rack-parts/rack-module-adder/rack-module-adder-dialog.component.ts index f254cbaf..2525192a 100644 --- a/src/app/components/rack-parts/rack-module-adder/rack-module-adder.component.ts +++ b/src/app/components/rack-parts/rack-module-adder/rack-module-adder-dialog.component.ts @@ -1,10 +1,31 @@ -import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormControl, Validators } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { + ChangeDetectionStrategy, + Component, + Inject, + OnInit +} from '@angular/core'; +import { + UntypedFormControl, + Validators +} from '@angular/forms'; +import { + MAT_DIALOG_DATA, + MatDialog, + MatDialogRef +} from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; import { TimeagoPipe } from 'ngx-timeago'; -import { BehaviorSubject, Subject } from 'rxjs'; -import { filter, map, share, startWith, switchMap } from 'rxjs/operators'; +import { + BehaviorSubject, + Subject +} from 'rxjs'; +import { + filter, + map, + share, + startWith, + switchMap +} from 'rxjs/operators'; import { SupabaseService } from 'src/app/features/backend/supabase.service'; import { UserAreaDataService } from 'src/app/features/user-area/user-area-data.service'; import { DbModule } from 'src/app/models/module'; @@ -13,6 +34,7 @@ import { SubManager } from 'src/app/shared-interproject/directives/subscription- import { SharedConstants } from 'src/app/shared-interproject/SharedConstants'; import { RackDetailDataService } from '../rack-detail-data.service'; + export interface RackModuleAdderOutModel { } @@ -22,15 +44,15 @@ export interface RackModuleAdderInModel { @Component({ selector: 'app-rack-module-adder', - templateUrl: './rack-module-adder.component.html', - styleUrls: ['./rack-module-adder.component.scss'], + templateUrl: './rack-module-adder-dialog.component.html', + styleUrls: ['./rack-module-adder-dialog.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, providers: [ UserAreaDataService, TimeagoPipe ] }) -export class RackModuleAdderComponent extends SubManager implements OnInit { +export class RackModuleAdderDialogComponent extends SubManager implements OnInit { readonly saveRackedModule$ = new Subject(); data$ = new BehaviorSubject<[]>([]); @@ -47,8 +69,8 @@ export class RackModuleAdderComponent extends SubManager implements OnInit { } }; - static open(dialog: MatDialog, data: RackModuleAdderInModel): MatDialogRef { - return dialog.open(RackModuleAdderComponent, { + static open(dialog: MatDialog, data: RackModuleAdderInModel): MatDialogRef { + return dialog.open(RackModuleAdderDialogComponent, { data, width: '70%', maxWidth: '40rem' @@ -60,7 +82,7 @@ export class RackModuleAdderComponent extends SubManager implements OnInit { public backend: SupabaseService, public timeagoPipe: TimeagoPipe, public userAreaDataService: UserAreaDataService, - public dialogRef: MatDialogRef, + public dialogRef: MatDialogRef, public rackDetailDataService: RackDetailDataService, @Inject(MAT_DIALOG_DATA) public data: RackModuleAdderInModel ) { @@ -68,17 +90,17 @@ export class RackModuleAdderComponent extends SubManager implements OnInit { this.manageSub( this.saveRackedModule$ - .pipe( - switchMap(x => this.backend.add.rackModule( - this.data.module.id, - this.fields.rack.control.value.id - )) - ) - .subscribe(value => { - SharedConstants.successSave(this.snackBar); - - this.dialogRef.close(); - }) + .pipe( + switchMap(x => this.backend.add.rackModule( + this.data.module.id, + this.fields.rack.control.value.id + )) + ) + .subscribe(value => { + SharedConstants.successSave(this.snackBar); + + this.dialogRef.close(); + }) ); this.userAreaDataService.updateRackData$.next(undefined); @@ -92,7 +114,10 @@ export class RackModuleAdderComponent extends SubManager implements OnInit { return this.userAreaDataService.rackData$.pipe( filter(x => !!x), map(x => { - const mapFunction: (row) => { name: string; id: string } = row => { + const mapFunction: (row) => { + name: string; + id: string + } = row => { const name = `${ row.name } ( ${ row.hp } HP , ${ row.rows } row(s) , ${ this.timeagoPipe.transform(new Date(row.updated)) } )`; return { @@ -100,14 +125,20 @@ export class RackModuleAdderComponent extends SubManager implements OnInit { name }; }; - const options: { name: string; id: string }[] = x.map(mapFunction); + const options: { + name: string; + id: string + }[] = x.map(mapFunction); // add lastly updated rack if not already empty if (options.length > 0) { const lastUpdatedRack = x.sort((a, b) => new Date(b.updated).getTime() - new Date(a.updated).getTime())[0]; - const firstRackAsOption: { name: string; id: string } = [lastUpdatedRack].map(mapFunction)[0]; + const firstRackAsOption: { + name: string; + id: string + } = [lastUpdatedRack].map(mapFunction)[0]; this.fields.rack.control.patchValue(firstRackAsOption); } @@ -119,4 +150,4 @@ export class RackModuleAdderComponent extends SubManager implements OnInit { share() ); } -} +} \ No newline at end of file diff --git a/src/app/components/rack-parts/rack.module.ts b/src/app/components/rack-parts/rack.module.ts index 6461d2ce..b8074604 100644 --- a/src/app/components/rack-parts/rack.module.ts +++ b/src/app/components/rack-parts/rack.module.ts @@ -15,7 +15,7 @@ import { RackDetailDataService } from 'src/app/components/rack-parts/rack-detail import { RackDetailsComponent } from 'src/app/components/rack-parts/rack-details/rack-details.component'; import { RackEditorComponent } from 'src/app/components/rack-parts/rack-editor/rack-editor.component'; import { RackMinimalComponent } from 'src/app/components/rack-parts/rack-minimal/rack-minimal.component'; -import { RackModuleAdderComponent } from 'src/app/components/rack-parts/rack-module-adder/rack-module-adder.component'; +import { RackModuleAdderDialogComponent } from 'src/app/components/rack-parts/rack-module-adder/rack-module-adder-dialog.component'; import { SharedAtomsModule } from 'src/app/components/shared-atoms/shared-atoms.module'; import { ModuleBrowserModule } from 'src/app/features/module-browser/module-browser.module'; import { MatFormEntityModule } from 'src/app/shared-interproject/components/@smart/mat-form-entity/mat-form-entity.module'; @@ -48,7 +48,7 @@ import { StatisticsModule } from "src/app/components/shared-atoms/statistics/sta RackEditorComponent, RackMinimalComponent, RackCreatorComponent, - RackModuleAdderComponent, + RackModuleAdderDialogComponent, RackDetailsComponent, TotalHpOfModulesPipe, RackDetailsRemainingIndicatorComponent, @@ -63,7 +63,7 @@ import { StatisticsModule } from "src/app/components/shared-atoms/statistics/sta RackMinimalComponent, RackEditorComponent, RackCreatorComponent, - RackModuleAdderComponent, + RackModuleAdderDialogComponent, RackDetailsComponent, RackDetailsRemainingIndicatorComponent, RackVisualModelComponent diff --git a/src/build.ts b/src/build.ts index 31ac55f6..50dcd377 100644 --- a/src/build.ts +++ b/src/build.ts @@ -1,13 +1,13 @@ // Build information, automatically generated by `ng-info` const build = { version: "4.2.3", - timestamp: "Fri Feb 09 2024 11:07:51 GMT+0100 (Ora standard dell’Europa centrale)", + timestamp: "Fri Feb 09 2024 11:53:26 GMT+0100 (Ora standard dell’Europa centrale)", message: null, git: { user: "Polyterative", branch: "develop", - hash: "a811c2", - fullHash: "a811c286e2afd507b7d44b545065627f451f75c4" + hash: "228029", + fullHash: "2280297164013d554e69b322dae22aaac8d3f231" } };