Skip to content

Commit 9e2d5d7

Browse files
committed
update
1 parent 4b816bd commit 9e2d5d7

32 files changed

Lines changed: 201 additions & 326 deletions

src/app/auto-save.service.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Injectable, OnDestroy, NgZone, signal } from '@angular/core';
2-
import { toObservable } from '@angular/core/rxjs-interop';
32

43
@Injectable({
54
providedIn: 'root'
@@ -14,11 +13,9 @@ export class AutoSaveService implements OnDestroy {
1413

1514
private readonly _autoSaveTrigger = signal(0);
1615
readonly autoSaveTrigger = this._autoSaveTrigger.asReadonly();
17-
readonly autoSaveTrigger$ = toObservable(this._autoSaveTrigger);
1816

1917
private readonly _settingsChanged = signal(0);
2018
readonly settingsChanged = this._settingsChanged.asReadonly();
21-
readonly settingsChanged$ = toObservable(this._settingsChanged);
2219

2320
constructor(private ngZone: NgZone) {
2421
this.tabId = this.generateTabId();

src/app/components/bar-chart/bar-chart.component.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import {ChangeDetectionStrategy, Component, DestroyRef, effect, inject, input, OnInit, signal} from '@angular/core';
1+
import {ChangeDetectionStrategy, Component, effect, input, OnInit, signal} from '@angular/core';
22
import {DataService} from "../../data.service";
33
import {Series} from "data-forge";
44
import {UniprotService} from "../../uniprot.service";
55
import {WebService} from "../../web.service";
66
import {StatsService} from "../../stats.service";
77
import {SettingsService} from "../../settings.service";
8-
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
98
import {PlotlyThemeService} from "../../plotly-theme.service";
109
import {ThemeService} from "../../theme.service";
1110

@@ -17,7 +16,6 @@ import {ThemeService} from "../../theme.service";
1716
changeDetection: ChangeDetectionStrategy.OnPush
1817
})
1918
export class BarChartComponent implements OnInit {
20-
private destroyRef = inject(DestroyRef)
2119

2220
data = input<any>()
2321

@@ -203,15 +201,17 @@ export class BarChartComponent implements OnInit {
203201
}
204202
})
205203

206-
this.themeService.theme$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
204+
effect(() => {
205+
this.themeService.mode();
207206
this.drawBarChart();
208207
this.drawAverageBarChart();
209208
this.graphLayout = this.plotlyTheme.applyThemeToLayout(this.graphLayout);
210209
this.graphLayoutAverage = this.plotlyTheme.applyThemeToLayout(this.graphLayoutAverage);
211210
this.graphLayoutViolin = this.plotlyTheme.applyThemeToLayout(this.graphLayoutViolin);
212211
});
213212

214-
this.dataService.barChartDownloadTrigger$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(trigger => {
213+
effect(() => {
214+
const trigger = this.dataService.barChartDownloadTrigger();
215215
if (trigger) {
216216
const rawData = this._data()
217217
for (const i of ["bar", "average", "violin"]) {
@@ -243,7 +243,8 @@ export class BarChartComponent implements OnInit {
243243
}
244244
})
245245

246-
this.dataService.redrawTrigger$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(data => {
246+
effect(() => {
247+
const data = this.dataService.redrawTrigger();
247248
if (data) {
248249
this.enableImputation = this.settings.settings.enableImputation
249250
this.volcanoConditionLeft = this.settings.settings.volcanoConditionLabels.leftCondition

src/app/components/batch-upload-modal/batch-upload-modal.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, Component } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, effect } from '@angular/core';
22
import {Settings} from "../../classes/settings";
33
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule} from "@angular/forms";
44
import {DataFrame, fromCSV} from "data-forge";
@@ -78,7 +78,8 @@ export class BatchUploadModalComponent {
7878
}[] = [];
7979
allTasksFinished = false
8080
constructor(private toasts: ToastService, private fb: FormBuilder, private dialogRef: NgbActiveModal, private batchService: BatchUploadServiceService) {
81-
this.batchService.taskStart$.subscribe((index) => {
81+
effect(() => {
82+
const index = this.batchService.taskStartIndex();
8283
if (index >= 0) {
8384
this.toasts.show("Task started", `Start processing task ${index}`).then()
8485
}
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import { Injectable, signal } from '@angular/core';
2-
import { toObservable } from '@angular/core/rxjs-interop';
32

43
@Injectable({
54
providedIn: 'root'
65
})
76
export class BatchUploadServiceService {
8-
readonly taskStartIndex = signal(-1);
9-
readonly taskStart$ = toObservable(this.taskStartIndex);
7+
private readonly _taskStartIndex = signal(-1);
8+
readonly taskStartIndex = this._taskStartIndex.asReadonly();
109

11-
readonly resetCounter = signal(0);
12-
readonly reset$ = toObservable(this.resetCounter);
10+
private readonly _resetCounter = signal(0);
11+
readonly resetCounter = this._resetCounter.asReadonly();
1312

1413
triggerTaskStart(index: number): void {
15-
this.taskStartIndex.set(index);
14+
this._taskStartIndex.set(index);
1615
}
1716

1817
triggerReset(): void {
19-
this.resetCounter.update(v => v + 1);
18+
this._resetCounter.update(v => v + 1);
2019
}
2120
}

src/app/components/batch-upload-modal/individual-session/individual-session.component.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnDestroy, Output, SimpleChanges} from '@angular/core';
1+
import {AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, effect, EventEmitter, Input, OnChanges, OnDestroy, Output, SimpleChanges} from '@angular/core';
22
import { InputFile } from 'src/app/classes/input-file';
33
import { Raw } from 'src/app/classes/raw';
44
import {Differential} from "../../../classes/differential";
@@ -16,7 +16,6 @@ import {ToastService} from "../../../toast.service";
1616
import {QuillEditorComponent} from "ngx-quill";
1717
import {NgClass} from "@angular/common";
1818
import {ColorPickerDirective} from "ngx-color-picker";
19-
import {Subject, takeUntil} from "rxjs";
2019

2120
@Component({
2221
selector: 'app-individual-session',
@@ -40,7 +39,6 @@ import {Subject, takeUntil} from "rxjs";
4039
changeDetection: ChangeDetectionStrategy.OnPush
4140
})
4241
export class IndividualSessionComponent implements OnChanges, AfterViewInit, OnDestroy {
43-
private destroy$ = new Subject<void>();
4442
@Input() sessionId: number = -1;
4543
private _session: {data: {
4644
raw: InputFile,
@@ -139,12 +137,14 @@ export class IndividualSessionComponent implements OnChanges, AfterViewInit, OnD
139137
loadingCollections: boolean = false
140138
isCreatingCollection: boolean = false
141139
constructor(private fb: FormBuilder, private toast: ToastService, public accounts: AccountsService, private batchService: BatchUploadServiceService, private data: DataService, private uniprot: UniprotService, private cd: ChangeDetectorRef, public settings: SettingsService) {
142-
this.batchService.taskStart$.pipe(takeUntil(this.destroy$)).subscribe((taskId: number) => {
140+
effect(() => {
141+
const taskId = this.batchService.taskStartIndex();
143142
if (taskId === this.sessionId) {
144143
this.startWork().then(() => this.cd.markForCheck())
145144
}
146145
})
147-
this.batchService.reset$.pipe(takeUntil(this.destroy$)).subscribe((counter) => {
146+
effect(() => {
147+
const counter = this.batchService.resetCounter();
148148
if (counter > 0) {
149149
this.data.reset()
150150
this.uniprot.reset()
@@ -155,8 +155,6 @@ export class IndividualSessionComponent implements OnChanges, AfterViewInit, OnD
155155
}
156156

157157
ngOnDestroy() {
158-
this.destroy$.next();
159-
this.destroy$.complete();
160158
}
161159

162160
ngAfterViewInit() {

src/app/components/correlation-matrix/correlation-matrix.component.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
1+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, effect, OnInit } from '@angular/core';
22
import { DataService } from "../../data.service";
33
import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
44
import { ToastService } from "../../toast.service";
55
import { WebService } from "../../web.service";
66
import { SettingsService } from "../../settings.service";
77
import { PlotlyThemeService } from "../../plotly-theme.service";
88
import { ThemeService } from "../../theme.service";
9-
import { Subject, takeUntil } from "rxjs";
109

1110
interface CorrelationResult {
1211
column_x: string;
@@ -30,8 +29,7 @@ type ColorScalePreset = 'default' | 'viridis' | 'plasma' | 'bluered' | 'rdylbu';
3029
standalone: false,
3130
changeDetection: ChangeDetectionStrategy.OnPush
3231
})
33-
export class CorrelationMatrixComponent implements OnInit, OnDestroy {
34-
private destroy$ = new Subject<void>();
32+
export class CorrelationMatrixComponent implements OnInit {
3533
revision = 0;
3634
graphData: any[] = [];
3735
graphLayout: any = {};
@@ -115,21 +113,16 @@ export class CorrelationMatrixComponent implements OnInit, OnDestroy {
115113
private cdr: ChangeDetectorRef
116114
) {
117115
this.initializeSamples();
118-
}
119-
120-
ngOnInit(): void {
121-
this.themeService.theme$.pipe(takeUntil(this.destroy$)).subscribe(() => {
116+
effect(() => {
117+
this.themeService.mode();
122118
this.updateLayout();
123119
this.revision++;
124120
this.cdr.markForCheck();
125121
});
126-
127-
this.calculateAndRender();
128122
}
129123

130-
ngOnDestroy(): void {
131-
this.destroy$.next();
132-
this.destroy$.complete();
124+
ngOnInit(): void {
125+
this.calculateAndRender();
133126
}
134127

135128
private initializeSamples(): void {

src/app/components/curtain-stats-summary/curtain-stats-summary.component.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core';
1+
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, effect, OnInit} from '@angular/core';
22
import {AccountsService} from "../../accounts/accounts.service";
33
import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap";
44
import {PlotlyThemeService} from "../../plotly-theme.service";
55
import {ThemeService} from "../../theme.service";
6-
import {Subject, takeUntil} from "rxjs";
76

87
@Component({
98
selector: 'app-curtain-stats-summary',
@@ -12,8 +11,7 @@ import {Subject, takeUntil} from "rxjs";
1211
standalone: false,
1312
changeDetection: ChangeDetectionStrategy.OnPush
1413
})
15-
export class CurtainStatsSummaryComponent implements OnInit, OnDestroy {
16-
private destroy$ = new Subject<void>();
14+
export class CurtainStatsSummaryComponent implements OnInit {
1715
revisionDownload = 0;
1816
revisionCreated = 0;
1917
graphDataDownload: any[] = []
@@ -86,17 +84,13 @@ export class CurtainStatsSummaryComponent implements OnInit, OnDestroy {
8684
}
8785

8886
ngOnInit(): void {
89-
this.themeService.theme$.pipe(takeUntil(this.destroy$)).subscribe(() => {
87+
effect(() => {
88+
this.themeService.mode();
9089
this.graphLayoutDownload = this.plotlyTheme.applyThemeToLayout(this.graphLayoutDownload);
9190
this.graphLayoutCreated = this.plotlyTheme.applyThemeToLayout(this.graphLayoutCreated);
9291
this.revisionDownload++;
9392
this.revisionCreated++;
9493
this.cdr.markForCheck();
9594
});
9695
}
97-
98-
ngOnDestroy(): void {
99-
this.destroy$.next();
100-
this.destroy$.complete();
101-
}
10296
}

src/app/components/cytoplot/cytoplot.component.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import {AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
1+
import {AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, effect, EventEmitter, Input, OnDestroy, Output} from '@angular/core';
22
import cytoscape from "cytoscape";
33
import fcose from "cytoscape-fcose";
44
import {saveAs} from "file-saver";
55
import {SettingsService} from "../../settings.service";
66
import {ThemeService} from "../../theme.service";
7-
import {Subject, takeUntil} from "rxjs";
87

98
cytoscape.use(fcose);
109

@@ -15,8 +14,7 @@ cytoscape.use(fcose);
1514
standalone: false,
1615
changeDetection: ChangeDetectionStrategy.OnPush
1716
})
18-
export class CytoplotComponent implements OnInit, AfterViewInit, OnDestroy {
19-
private destroy$ = new Subject<void>();
17+
export class CytoplotComponent implements AfterViewInit, OnDestroy {
2018
private _dimensions = {width: 700, height: 700}
2119
@Output() clickedID = new EventEmitter<string>()
2220
@Output() ready = new EventEmitter<boolean>()
@@ -37,29 +35,30 @@ export class CytoplotComponent implements OnInit, AfterViewInit, OnDestroy {
3735
if(this._drawData) {
3836
if (this._drawData.data.length > 2) {
3937
this.componentID = this._drawData.id
38+
this.hidden = false
39+
this.cdr.markForCheck()
4040
setTimeout(() => {
4141
this.draw()
4242
}, 3000)
4343
}
4444
}
4545
}
4646

47-
constructor(private settings: SettingsService, private themeService: ThemeService, private cdr: ChangeDetectorRef) { }
48-
49-
ngOnInit(): void {
50-
this.themeService.beforeThemeChange$.pipe(takeUntil(this.destroy$)).subscribe(() => {
51-
this.hidden = true;
52-
if (this.cy) {
53-
this.cy.destroy();
54-
this.cy = null;
47+
constructor(private settings: SettingsService, private themeService: ThemeService, private cdr: ChangeDetectorRef) {
48+
effect(() => {
49+
const counter = this.themeService.beforeThemeChange();
50+
if (counter > 0) {
51+
this.hidden = true;
52+
if (this.cy) {
53+
this.cy.destroy();
54+
this.cy = null;
55+
}
56+
this.cdr.markForCheck();
5557
}
56-
this.cdr.markForCheck();
5758
});
5859
}
5960

6061
ngOnDestroy(): void {
61-
this.destroy$.next();
62-
this.destroy$.complete();
6362
if (this.cy) {
6463
this.cy.destroy();
6564
this.cy = null;
@@ -70,11 +69,12 @@ export class CytoplotComponent implements OnInit, AfterViewInit, OnDestroy {
7069
}
7170

7271
draw() {
73-
console.log(this._drawData)
7472
const container = document.getElementById(this._drawData.id)
75-
container?.style.setProperty("width", this._dimensions.width+"px")
76-
container?.style.setProperty("height", this._dimensions.height+"px")
77-
console.log(container)
73+
if (!container) {
74+
return
75+
}
76+
container.style.setProperty("width", this._dimensions.width+"px")
77+
container.style.setProperty("height", this._dimensions.height+"px")
7878
const ad = this
7979
if (!this.cy) {
8080
this.cy = cytoscape(

src/app/components/file-form/file-form.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, OnDestroy, OnInit, Output} from '@angular/core';
1+
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, effect, EventEmitter, OnDestroy, OnInit, Output} from '@angular/core';
22
import { InputFile } from "../../classes/input-file";
33
import { DataService } from "../../data.service";
44
import { DataFrame, fromJSON, IDataFrame, Series } from "data-forge";
@@ -37,13 +37,15 @@ export class FileFormComponent implements OnInit, OnDestroy {
3737
private toast: ToastService,
3838
private cdr: ChangeDetectorRef
3939
) {
40-
this.uniprot.progressBar$.pipe(takeUntil(this.destroy$)).subscribe(data => {
40+
effect(() => {
41+
const data = this.uniprot.progressBar();
4142
this.progressBar.value = data.value;
4243
this.progressBar.text = data.text;
4344
this.cdr.markForCheck();
4445
});
4546

46-
this.data.restoreTrigger$.pipe(takeUntil(this.destroy$)).subscribe(data => {
47+
effect(() => {
48+
const data = this.data.restoreTrigger();
4749
if (data) {
4850
this.updateProgressBar(100, "Restoring session...");
4951
if (!this.clicked) {

0 commit comments

Comments
 (0)