Skip to content

Commit

Permalink
Merge pull request #1013 from gisaia/fix/orglessCollection
Browse files Browse the repository at this point in the history
fix: allow dashboard building for orgless collections without authent
  • Loading branch information
QuCMGisaia authored Nov 22, 2024
2 parents 9d634fd + 1e82014 commit 723bbaf
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 152 deletions.
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
ArlasStartupService, ArlasWalkthroughService, AuthentificationService, ConfigMenuModule, configUpdaterFactory,
CONFIG_UPDATER, FETCH_OPTIONS, getOptionsFactory,
iamServiceFactory, PaginatorI18n, UserInfosComponent,
GET_OPTIONS, ArlasToolkitSharedModule, ArlasSettingsService, ArlasConfigService, ArlasCollectionService,
GET_OPTIONS, ArlasToolkitSharedModule, ArlasSettingsService
} from 'arlas-wui-toolkit';
import { environment } from 'environments/environment';
import { LoggerModule } from 'ngx-logger';
Expand Down
16 changes: 8 additions & 8 deletions src/app/components/collection/collection.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ <h3 class="form-control-title">{{'Explore collections' | translate}}</h3>
</div>
<div class="params">
<div class="value"><span class="label">{{'Id path' | translate}} :</span>
{{def.collection.params.id_path }}</div>
{{ def.collection.params.id_path }}</div>
<div class="value"><span class="label">{{'Centroid path' | translate}} :</span>
{{def.collection.params.centroid_path }}</div>
<div class="value"><span class="label">{{'Geometry path' | translate}} :
</span>{{def.collection.params.geometry_path}}</div>
<div class="value"><span class="label">{{'Timestamp path' | translate}} :
</span>{{def.collection.params.timestamp_path}}</div>
<div class="value"><span class="label">{{'Index name' | translate}} :
</span>{{def.collection.params.index_name}}</div>
{{ def.collection.params.centroid_path }}</div>
<div class="value"><span class="label">{{'Geometry path' | translate}} :</span>
{{ def.collection.params.geometry_path }}</div>
<div class="value"><span class="label">{{'Timestamp path' | translate}} :</span>
{{ def.collection.params.timestamp_path }}</div>
<div class="value"><span class="label">{{'Index name' | translate}} :</span>
{{ def.collection.params.index_name }}</div>
<div class="value" *ngIf="def.collection.params.taggable_fields"><span class="label">{{'Taggable fields' | translate}} :
</span>{{def.collection.params.taggable_fields}}</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
</ngx-spinner>
<h2 mat-dialog-title>{{'New dashboard' | translate}}</h2>
<mat-dialog-content class="new-config-content">
<div [formGroup]="this.mainFormService.startingConfig.getFg()">
<div [formGroup]="mainFormService.startingConfig.getFg()">
<arlas-config-element [fullSize]="true">
<div form-fields class="server-url">
<mat-form-field>
<mat-label>{{'Server URL' | translate}}</mat-label>
<input matInput (keyup)="onKeyUp($event)"
(change)="this.mainFormService.startingConfig.getFg().get('serverUrl').valid ? checkUrl() : false"
(change)="mainFormService.startingConfig.getFg().get('serverUrl').valid ? checkUrl() : false"
formControlName="serverUrl" type="url">
</mat-form-field>
<button
(click)="this.mainFormService.startingConfig.getFg().get('serverUrl').valid ? checkUrl() : false"
[disabled]="this.mainFormService.startingConfig.getFg().get('serverUrl').invalid"
(click)="mainFormService.startingConfig.getFg().get('serverUrl').valid ? checkUrl() : false"
[disabled]="mainFormService.startingConfig.getFg().get('serverUrl').invalid"
mat-stroked-button color="accent">{{'Show collections' | translate}}</button>
<mat-checkbox [disabled]="this.mainFormService.startingConfig.getFg().get('serverUrl').invalid" *ngIf="data.authentMode === 'iam'" (change)="toggleDisplayPublic($event)" class="include-public">{{'Include public collections' |
translate}}</mat-checkbox>
<mat-checkbox [disabled]="mainFormService.startingConfig.getFg().get('serverUrl').invalid"
*ngIf="data.isAuthentActivated && data.authentMode === 'iam'" (change)="toggleDisplayPublic($event)" class="include-public">
{{'Include public collections' | translate}}</mat-checkbox>
</div>
</arlas-config-element>
<arlas-config-element *ngIf="isServerReady">
Expand Down
18 changes: 8 additions & 10 deletions src/app/components/landing-page/landing-page-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class LandingPageDialogComponent implements OnInit, OnDestroy {
public displayedColumns: string[] = ['id', 'creation', 'detail'];
public includePublicCollection = false;


private subscription: Subscription;
private urlSubscription: Subscription;
private urlCollectionsSubscription: Subscription;
Expand All @@ -75,9 +74,7 @@ export class LandingPageDialogComponent implements OnInit, OnDestroy {
private router: Router,
private menu: MenuService,
private landingPageService: LandingPageService
) {

}
) { }

public ngOnInit(): void {
if (!!this.data.configChoice) {
Expand Down Expand Up @@ -132,19 +129,20 @@ export class LandingPageDialogComponent implements OnInit, OnDestroy {
() => {
this.urlCollectionsSubscription = this.collectionService.getCollectionsReferenceDescription().subscribe(
cdrs => {
const collectionsItems = cdrs
const collectionsItems: Array<CollectionItem> = cdrs
.filter(c => {
if (this.includePublicCollection) {
// If there is no authentication, then we want all the collections
if (this.includePublicCollection || !this.data?.isAuthentActivated) {
return true;
} else {
return (c.params.organisations as any).public === false;
return (c.params.organisations as any)?.public === false;
}
})
.map(c => ({
name: c.collection_name,
isPublic: (c.params.organisations as any).public,
sharedWith: c.params.organisations.shared,
owner: c.params.organisations.owner
isPublic: !this.data.isAuthentActivated ? true : (c.params.organisations as any)?.public === true,
sharedWith: c.params.organisations?.shared,
owner: c.params.organisations?.owner
}));
this.availablesCollections = this.collectionService.buildGroupCollectionItems(collectionsItems, this.data.currentOrga);
this.collectionService.setGroupCollectionItems(this.availablesCollections);
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/landing-page/landing-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ export class LandingPageComponent implements OnInit, AfterViewInit, OnDestroy {
if (configChoice) {
this.dialogRef = this.dialog.open(LandingPageDialogComponent, {
disableClose: true, data:
{ message: this.confId, configChoice, authentMode: this.authentMode, currentOrga: this.currentOrga }
{ message: this.confId, configChoice, authentMode: this.authentMode,
currentOrga: this.currentOrga, isAuthentActivated: this.isAuthentActivated }
});
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/modules/analytics-config/analytics-config.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { EditHistogramLabelComponent } from './components/edit-histogram-label/e
import { MetricsTableDataComponent } from './components/metrics-table-data/metrics-table-data.component';
import { AddSubtableDialogComponent } from './components/add-subtable-dialog/add-subtable-dialog.component';
import { MatExpansionModule } from '@angular/material/expansion';
import { GetCollectionDisplayModule } from 'arlas-web-components';
import { GetCollectionDisplayModule, GetFieldDisplayModule } from 'arlas-web-components';

@NgModule({
entryComponents: [
Expand Down Expand Up @@ -70,7 +70,8 @@ import { GetCollectionDisplayModule } from 'arlas-web-components';
AnalyticsConfigRoutingModule,
IconPickerModule,
MatExpansionModule,
GetCollectionDisplayModule
GetCollectionDisplayModule,
GetFieldDisplayModule
]
})
export class AnalyticsConfigModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
(click)="setSort(c, c.get('sort').value,subTable.controls.collection.value,subTable.controls.aggregationField.value, c.get('metricCollectFunction').value, c.get('metricCollectField').value )"
[matTooltip]="'Not sorted' | translate">sync_alt</mat-icon>
<span
*ngIf="!c.get('metricCollectField').value">{{c.get("metricCollectFunction").value}}</span>
*ngIf="!c.get('metricCollectField').value">{{c.get("metricCollectFunction").value | translate}}</span>
<span *ngIf="c.get('metricCollectField').value">
{{ 'metric of field' | translate : {metric: c.get("metricCollectFunction").value, field:
c.get("metricCollectField").value} }}</span>
{{ 'metric of field' | translate : {metric: c.get("metricCollectFunction").value | translate, field:
c.get("metricCollectField").value | getFieldDisplayName | translate} }}</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ export class TabsComponent implements OnDestroy {
if (otherTabNames.indexOf(newTabName) >= 0) {
const dialogRef = this.dialog.open(InputModalComponent, {
data: {
title: 'Tab name',
message: 'Another tab already exists with the same name, please choose another one',
title: marker('Tab name'),
message: marker('Another tab already exists with the same name, please choose another one'),
initialValue: newTabName,
noCancel: true
}
Expand Down Expand Up @@ -179,8 +179,8 @@ export class TabsComponent implements OnDestroy {
if (otherTabNames.indexOf(newTabName) >= 0) {
const dialogRef = this.dialog.open(InputModalComponent, {
data: {
title: 'Tab name',
message: 'Another tab already exists with the same name, please choose another one',
title: marker('Tab name'),
message: marker('Another tab already exists with the same name, please choose another one'),
initialValue: newTabName,
noCancel: true
}
Expand Down
1 change: 0 additions & 1 deletion src/app/services/collection-service/collection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ export class CollectionService {
).finally(() => this.spinner.hide()));
}

// eslint-disable-next-line max-len
public buildGroupCollectionItems(items: CollectionItem[], currentOrg: string): GroupCollectionItem {
const groupCollection = items.reduce((acc, item) => {
if (!!currentOrg && currentOrg.length > 0) {
Expand Down
12 changes: 8 additions & 4 deletions src/app/services/landing-page/landing-page.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class LandingPageService implements OnDestroy {
public startEventSource: Subject<boolean> = new Subject<boolean>();
public startEvent$: Observable<boolean> = this.startEventSource.asObservable();

private isAuthentActivated: boolean;

private _onDestroy$ = new Subject<boolean>();

public constructor(
Expand All @@ -54,7 +56,9 @@ export class LandingPageService implements OnDestroy {
private arlasSettingsService: ArlasSettingsService,
private mainFormManager: MainFormManagerService,
public mainFormService: MainFormService,
private arlasIamService: ArlasIamService) {
private arlasIamService: ArlasIamService
) {
this.isAuthentActivated = !!this.arlasSettingsService.getAuthentSettings()?.use_authent === true;
}

public ngOnDestroy() {
Expand All @@ -76,9 +80,9 @@ export class LandingPageService implements OnDestroy {
const collectionsItems = cdrs
.map(c => ({
name: c.collection_name,
isPublic: (c.params.organisations as any).public,
sharedWith: c.params.organisations.shared,
owner: c.params.organisations.owner
isPublic: !this.isAuthentActivated ? true : (c.params.organisations as any)?.public === true,
sharedWith: c.params.organisations?.shared,
owner: c.params.organisations?.owner
}));
const groupCollectionItems = this.collectionService.buildGroupCollectionItems(collectionsItems, this.arlasIamService.getOrganisation());
this.collectionService.setGroupCollectionItems(groupCollectionItems);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { Observable, catchError, map, of, tap } from 'rxjs';
import { DataWithLinks } from 'arlas-persistence-api';
import { ResourcesConfigFormGroup } from '@services/resources-form-builder/resources-config-form-builder.service';
import { NgxSpinnerService } from 'ngx-spinner';
import { marker } from '@biesbjerg/ngx-translate-extract-marker';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -351,8 +352,8 @@ export class MainFormManagerService {
// Open a modal to explain that a dashboard with this name already exists
const dialogRef = this.dialog.open(InputModalComponent, {
data: {
title: 'Invalid dashboard name',
message: 'Another dashboad already exists with the same name, please choose another one',
title: marker('Invalid dashboard name'),
message: marker('Another dashboad already exists with the same name, please choose another one'),
initialValue: this.mainFormService.configurationName,
noCancel: true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface DialogData {
initialValue?: string;
noCancel?: boolean;
authentMode?: string;
isAuthentActivated?: string;
currentOrga?: string;
}

Expand Down
Loading

0 comments on commit 723bbaf

Please sign in to comment.