Skip to content

Commit

Permalink
Merge pull request #1007 from gisaia/feature/optimizeCollectionList
Browse files Browse the repository at this point in the history
Feat: remove useless collection list call
  • Loading branch information
mbarbet authored Nov 6, 2024
2 parents c10798d + a824afc commit 31b2389
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build an image from Dockerfile
run: |
docker build -t docker.io/gisaia/arlas-wui-builder:${{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
with:
image-ref: "docker.io/gisaia/arlas-wui-builder:${{ github.sha }}"
format: "table"
Expand Down
14 changes: 7 additions & 7 deletions src/app/components/landing-page/landing-page-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export class LandingPageDialogComponent implements OnInit, OnDestroy {
private http: HttpClient,
private logger: NGXLogger,
public startupService: StartupService,
private configDescritor: ArlasConfigurationDescriptor,
private translate: TranslateService,
private mainFormManager: MainFormManagerService,
private collectionService: CollectionService,
Expand Down Expand Up @@ -129,11 +128,12 @@ export class LandingPageDialogComponent implements OnInit, OnDestroy {
() => {
this.landingPageService.getServerCollections(url).then(
() => {
this.urlCollectionsSubscription = this.configDescritor.getAllCollections().subscribe(
collections => {
this.availablesCollections = collections;
this.collectionService.setCollections(collections);
this.collectionService.getCollectionsReferenceDescription().subscribe(cdrs => this.collectionService.setCollectionsRef(cdrs));
this.urlCollectionsSubscription = this.collectionService.getCollectionsReferenceDescription().subscribe(
cdrs => {
const collectionsNames = cdrs.map(c => c.collection_name);
this.availablesCollections = collectionsNames;
this.collectionService.setCollections(collectionsNames);
this.collectionService.setCollectionsRef(cdrs);
},
error => {
this.logger.error(this.translate.instant('Unable to access the server. Please, verify the url.'));
Expand Down Expand Up @@ -180,7 +180,7 @@ export class LandingPageDialogComponent implements OnInit, OnDestroy {
]).then(values => {
const configJson = values[0] as Config;
// Delete existing previewID to avoid right access problem on erase existing resource
if(!!configJson.resources?.previewId){
if (!!configJson.resources?.previewId) {
delete configJson.resources.previewId;
}
const configMapJson = values[1] as MapConfig;
Expand Down
80 changes: 39 additions & 41 deletions src/app/services/landing-page/landing-page.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ArlasConfigService, ArlasConfigurationDescriptor, ArlasSettingsService
import { NGXLogger } from 'ngx-logger';
import { NgxSpinnerService } from 'ngx-spinner';
import { Observable, Subject, Subscription, takeUntil } from 'rxjs';
import { CollectionReferenceDescription } from 'arlas-api';


@Injectable({
Expand All @@ -48,7 +49,6 @@ export class LandingPageService implements OnDestroy {
private logger: NGXLogger,
private translate: TranslateService,
private configService: ArlasConfigService,
private configDescritor: ArlasConfigurationDescriptor,
private defaultValuesService: DefaultValuesService,
private collectionService: CollectionService,
private arlasSettingsService: ArlasSettingsService,
Expand All @@ -69,9 +69,9 @@ export class LandingPageService implements OnDestroy {
public initWithConfig(configJson: Config, configMapJson: MapConfig, configId?: string, configName?: string, isRetry?: boolean) {
this.spinner.show('importconfig');
this.getServerCollections(configJson.arlas.server.url).then(() => {
this.configDescritor.getAllCollections().pipe(takeUntil(this._onDestroy$)).subscribe({
next: collections => {
this.initCollections(collections, configJson, configMapJson, configId, configName);
this.collectionService.getCollectionsReferenceDescription().pipe(takeUntil(this._onDestroy$)).subscribe({
next: cdrs => {
this.initCollections(cdrs, configJson, configMapJson, configId, configName);
},
error: () => {
this.spinner.hide('importconfig');
Expand All @@ -89,46 +89,44 @@ export class LandingPageService implements OnDestroy {
});
}

public initCollections(collections: string[], configJson: Config, configMapJson: MapConfig, configId?: string, configName?: string) {
private initCollections(cdrs: CollectionReferenceDescription[], configJson: Config,
configMapJson: MapConfig, configId?: string, configName?: string) {
const collections = cdrs.map(c => c.collection_name);
this.collectionService.setCollections(collections);
this.collectionService.getCollectionsReferenceDescription().subscribe(cdrs => {
this.collectionService.setCollectionsRef(cdrs);
const collection = (collections.find(c => c === configJson.arlas.server.collection.name));
if (!collection) {
this.spinner.hide('importconfig');
this.logger.error(
this.translate.instant('Collection ')
+ configJson.arlas.server.collection.name
+ this.translate.instant(' unknown. Available collections: ')
+ collections.join(', '));

this.collectionService.setCollectionsRef(cdrs);
const collection = (collections.find(c => c === configJson.arlas.server.collection.name));
if (!collection) {
this.spinner.hide('importconfig');
this.logger.error(
this.translate.instant('Collection ')
+ configJson.arlas.server.collection.name
+ this.translate.instant(' unknown. Available collections: ')
+ collections.join(', '));
} else {
if (this.arlasSettingsService.settings['use_time_filter']) {
this.startupService.getTimeFilter(collection, configJson.arlas.server.url, this.collectionService, this.arlasSettingsService)
.subscribe(timeFilter => {
this.startupService.applyArlasInterceptor(collection, timeFilter);
setTimeout(() => {
this.mainFormManager.doImport(configJson, configMapJson);
this.startEventSource.next(null);
this.spinner.hide('importconfig');
}, 100);
});
/** hack in order to trigger the spinner 'importconfig'
* otherwise, we will think the application is not loading
*/
} else {
if (this.arlasSettingsService.settings['use_time_filter']) {
this.startupService.getTimeFilter(collection, configJson.arlas.server.url, this.collectionService, this.arlasSettingsService)
.subscribe(timeFilter => {
this.startupService.applyArlasInterceptor(collection, timeFilter);
setTimeout(() => {
this.mainFormManager.doImport(configJson, configMapJson);
this.startEventSource.next(null);
this.spinner.hide('importconfig');
}, 100);
});
/** hack in order to trigger the spinner 'importconfig'
* otherwise, we will think the application is not loading
*/
} else {
setTimeout(() => {
this.mainFormManager.doImport(configJson, configMapJson);
this.startEventSource.next(null);
this.spinner.hide('importconfig');
}, 100);
}

}
if (!!configId && !!configName) {
this.mainFormService.configChange.next({ id: configId, name: configName });
setTimeout(() => {
this.mainFormManager.doImport(configJson, configMapJson);
this.startEventSource.next(null);
this.spinner.hide('importconfig');
}, 100);
}
});
}
if (!!configId && !!configName) {
this.mainFormService.configChange.next({ id: configId, name: configName });
}
}

public getServerCollections(serverUrl: string) {
Expand Down
8 changes: 4 additions & 4 deletions src/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
############ AUTHENTICATION SETTINGS ###############
########################################################
authentication:
use_authent: false
use_authent: true
auth_mode: iam
url: http://localhost/arlas_iam_server
url: 'https://localhost/arlas_iam_server'
force_connect: true
threshold: 60000
use_discovery: false
Expand All @@ -26,12 +26,12 @@ authentication:
sign_up_enabled: true

persistence:
url: 'http://localhost:81/persist'
url: 'https://localhost/persist'
########################################################
############ Permissions SETTINGS ##################
########################################################
permission:
url: http://localhost:81/permissions
url: 'https://localhost/arlas_permissions_server'
########################################################
############ URLs to WUI app #######################
########################################################
Expand Down

0 comments on commit 31b2389

Please sign in to comment.