From b848fb2bb2ed396cfb59bb3a76e35628da24c1dc Mon Sep 17 00:00:00 2001 From: Senyoret1 <34079003+Senyoret1@users.noreply.github.com> Date: Mon, 27 Feb 2023 15:04:36 -0400 Subject: [PATCH] Improvements for the UI code --- .../layout/button/button.component.scss | 2 +- .../initial-setup.component.html | 8 +- .../initial-setup/initial-setup.component.ts | 5 + .../pages/node-list/node-list.component.ts | 21 +- .../skysocks-client-settings.component.html | 7 +- .../pages/node/charts/charts.component.html | 16 +- .../pages/node/charts/charts.component.ts | 25 +- .../node-info-content.component.html | 2 +- .../node-info-content.component.ts | 3 + .../node/node-info/node-info.component.html | 2 +- .../node/node-info/node-info.component.ts | 15 +- .../components/pages/node/node.component.html | 2 +- .../components/pages/node/node.component.ts | 40 +- .../settings/password/password.component.ts | 9 +- .../services/multiple-node-data.service.ts | 141 ++++++ .../src/app/services/node.service.ts | 433 +----------------- .../app/services/single-node-data.service.ts | 360 +++++++++++++++ 17 files changed, 600 insertions(+), 491 deletions(-) create mode 100644 static/skywire-manager-src/src/app/services/multiple-node-data.service.ts create mode 100644 static/skywire-manager-src/src/app/services/single-node-data.service.ts diff --git a/static/skywire-manager-src/src/app/components/layout/button/button.component.scss b/static/skywire-manager-src/src/app/components/layout/button/button.component.scss index 97a9c8ce3e..0da36d1fe0 100644 --- a/static/skywire-manager-src/src/app/components/layout/button/button.component.scss +++ b/static/skywire-manager-src/src/app/components/layout/button/button.component.scss @@ -11,7 +11,7 @@ button { } } -mat-icon { +mat-icon, mat-spinner { display: inline-block; margin-right: 15px; } diff --git a/static/skywire-manager-src/src/app/components/pages/login/initial-setup/initial-setup.component.html b/static/skywire-manager-src/src/app/components/pages/login/initial-setup/initial-setup.component.html index 9eea902cfc..f8a81befa1 100644 --- a/static/skywire-manager-src/src/app/components/pages/login/initial-setup/initial-setup.component.html +++ b/static/skywire-manager-src/src/app/components/pages/login/initial-setup/initial-setup.component.html @@ -1,3 +1,7 @@ - - + + diff --git a/static/skywire-manager-src/src/app/components/pages/login/initial-setup/initial-setup.component.ts b/static/skywire-manager-src/src/app/components/pages/login/initial-setup/initial-setup.component.ts index e92434192f..bd566e3968 100644 --- a/static/skywire-manager-src/src/app/components/pages/login/initial-setup/initial-setup.component.ts +++ b/static/skywire-manager-src/src/app/components/pages/login/initial-setup/initial-setup.component.ts @@ -13,6 +13,11 @@ import { AppConfig } from 'src/app/app.config'; }) export class InitialSetupComponent { + /** + * If true, all the ways provided by default by the UI for closing the modal window are disabled. + */ + disableDismiss = false; + /** * Opens the modal window. Please use this function instead of opening the window "by hand". */ diff --git a/static/skywire-manager-src/src/app/components/pages/node-list/node-list.component.ts b/static/skywire-manager-src/src/app/components/pages/node-list/node-list.component.ts index f84389ca2d..1985675820 100644 --- a/static/skywire-manager-src/src/app/components/pages/node-list/node-list.component.ts +++ b/static/skywire-manager-src/src/app/components/pages/node-list/node-list.component.ts @@ -5,7 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router'; import { catchError, mergeMap } from 'rxjs/operators'; import { TranslateService } from '@ngx-translate/core'; -import { NodeService, BackendData, KnownHealthStatuses } from '../../../services/node.service'; +import { NodeService, KnownHealthStatuses } from '../../../services/node.service'; import { Node } from '../../../app.datatypes'; import { AuthService, AuthStates } from '../../../services/auth.service'; import { EditLabelComponent } from '../../layout/edit-label/edit-label.component'; @@ -22,6 +22,7 @@ import { SortingModes, SortingColumn, DataSorter } from 'src/app/utils/lists/dat import { DataFilterer } from 'src/app/utils/lists/data-filterer'; import { NodeData, UpdateAllComponent } from '../../layout/update-all/update-all.component'; import { BulkRewardAddressChangerComponent, BulkRewardAddressParams, NodeToEditData } from '../../layout/bulk-reward-address-changer/bulk-reward-address-changer.component'; +import { MultipleNodeDataService, MultipleNodesBackendData } from 'src/app/services/multiple-node-data.service'; /** * Page for showing the node list. @@ -129,6 +130,7 @@ export class NodeListComponent implements OnInit, OnDestroy { constructor( private nodeService: NodeService, + private multipleNodeDataService: MultipleNodeDataService, private router: Router, private dialog: MatDialog, private authService: AuthService, @@ -228,7 +230,7 @@ export class NodeListComponent implements OnInit, OnDestroy { // Refresh the data after languaje changes, to ensure the labels used for filtering // are updated. this.languageSubscription = this.translateService.onLangChange.subscribe(() => { - this.nodeService.forceNodeListRefresh(); + this.multipleNodeDataService.forceRefresh(); }); } @@ -263,7 +265,6 @@ export class NodeListComponent implements OnInit, OnDestroy { ngOnInit() { // Load the data. - this.nodeService.startRequestingNodeList(); this.startGettingData(); // Procedure to keep updated the variable that indicates how long ago the data was updated. @@ -276,7 +277,6 @@ export class NodeListComponent implements OnInit, OnDestroy { } ngOnDestroy() { - this.nodeService.stopRequestingNodeList(); this.authVerificationSubscription.unsubscribe(); this.dataSubscription.unsubscribe(); this.updateTimeSubscription.unsubscribe(); @@ -358,21 +358,20 @@ export class NodeListComponent implements OnInit, OnDestroy { this.lastUpdateRequestedManually = true; } - this.nodeService.forceNodeListRefresh(); + this.multipleNodeDataService.forceRefresh(); } /** * Starts getting the data from the backend. */ private startGettingData() { - // Detect when the service is updating the data. - this.dataSubscription = this.nodeService.updatingNodeList.subscribe(val => this.updating = val); - this.ngZone.runOutsideAngular(() => { // Get the node list. - this.dataSubscription.add(this.nodeService.nodeList.subscribe((result: BackendData) => { + this.dataSubscription = this.multipleNodeDataService.startRequestingData().subscribe((result: MultipleNodesBackendData) => { this.ngZone.run(() => { - if (result) { + this.updating = result ? result.updating : true; + + if (result && !result.updating) { // If the data was obtained. if (result.data && !result.error) { this.allNodes = result.data as Node[]; @@ -416,7 +415,7 @@ export class NodeListComponent implements OnInit, OnDestroy { } } }); - })); + }); }); } diff --git a/static/skywire-manager-src/src/app/components/pages/node/apps/node-apps/skysocks-client-settings/skysocks-client-settings.component.html b/static/skywire-manager-src/src/app/components/pages/node/apps/node-apps/skysocks-client-settings/skysocks-client-settings.component.html index 33303987c6..8b10fff89b 100644 --- a/static/skywire-manager-src/src/app/components/pages/node/apps/node-apps/skysocks-client-settings/skysocks-client-settings.component.html +++ b/static/skywire-manager-src/src/app/components/pages/node/apps/node-apps/skysocks-client-settings/skysocks-client-settings.component.html @@ -104,6 +104,7 @@