Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor (overview component): remove unnecessary code and tests #1286

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import { map, take, takeLast } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { Location } from '@angular/common';
import { UserStateModel } from '@dasch-swiss/vre/shared/app-state';
import { LoadProjectsAction, UserStateModel } from '@dasch-swiss/vre/shared/app-state';
import { Store } from '@ngxs/store';

@Component({
selector: 'app-login-form',
Expand Down Expand Up @@ -105,9 +106,9 @@ export class LoginFormComponent implements OnInit {
required: 'password is required',
},
};

returnUrl: string;

constructor(
private _componentCommsService: ComponentCommunicationEventService,
private _fb: UntypedFormBuilder,
Expand Down Expand Up @@ -161,7 +162,7 @@ export class LoginFormComponent implements OnInit {
this._componentCommsService.emit(
new EmitEvent(Events.loginSuccess, true)
);

return this._authService.loadUser(identifier)
.pipe(take(1))
.pipe(map((result: any) => result.user))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class="settings">
<button color="primary" class="settings-button"
mat-icon-button
(click)="emitButtonClicked(project.id, 'settings')"
(click)="navigateToSettings(project.id)"
>
<mat-icon>settings</mat-icon>
</button>
Expand All @@ -39,7 +39,7 @@
class="workspace-button"
mat-flat-button
[color]="'primary'"
(click)="emitButtonClicked(project.id, 'workspace')">
(click)="navigateToProject(project.id)">
Browse Data
</button>
</div>
Expand Down

This file was deleted.

25 changes: 18 additions & 7 deletions apps/dsp-app/src/app/system/project-tile/project-tile.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, Input } from '@angular/core';
import { StoredProject } from '@dasch-swiss/dsp-js';
import { TileLinks, routeParams } from '@dsp-app/src/app/user/overview/overview.component';
import { RouteConstants } from '@dasch-swiss/vre/shared/app-config';
import { Router } from '@angular/router';
import { ProjectService } from '@dsp-app/src/app/workspace/resource/services/project.service';

@Component({
selector: 'app-project-tile',
Expand All @@ -10,12 +12,21 @@ import { TileLinks, routeParams } from '@dsp-app/src/app/user/overview/overview.
export class ProjectTileComponent {
@Input() project: StoredProject;
@Input() sysAdmin: boolean; // used to show settings button
@Output() buttonClicked = new EventEmitter<routeParams>();

constructor() {}
constructor(
private _router: Router,
private _projectService: ProjectService,
) {}

emitButtonClicked(id: string, path: TileLinks) {
const params: routeParams = { id, path };
this.buttonClicked.emit(params);
navigateToProject(id: string) {
const uuid = this._projectService.iriToUuid(id);
this._router.navigate([RouteConstants.project, uuid]);
}

navigateToSettings(id: string) {
const uuid = this._projectService.iriToUuid(id);
this._router.navigate([
RouteConstants.project, uuid, RouteConstants.settings, RouteConstants.collaboration
]);
}
}
8 changes: 2 additions & 6 deletions apps/dsp-app/src/app/user/overview/overview.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@
<app-project-tile
[project]="proj"
[sysAdmin]="true"
(buttonClicked)="navigateTo($event)"
></app-project-tile>
</div>
</div>
</div>
<!-- user is logged in and not a system admin -->
<div *ngIf="(isSysAdmin$ | async) === false && (isLoggedIn$ | async) === true">
<div *ngIf="(isSysAdmin$ | async) === false && !!(user$ | async)">
<div class="title-bar">
<div class="title">
<p>My Projects</p>
Expand All @@ -48,7 +47,6 @@
<app-project-tile
[project]="userProj"
[sysAdmin]="false"
(buttonClicked)="navigateTo($event)"
></app-project-tile>
</div>
</div>
Expand All @@ -65,14 +63,13 @@
<app-project-tile
[project]="otherProj"
[sysAdmin]="false"
(buttonClicked)="navigateTo($event)"
></app-project-tile>
</div>
</div>
</div>

<!-- user is not logged in -->
<div *ngIf="((isProjectsLoading$ | async) === false) && ((isLoggedIn$ | async) === false)">
<div *ngIf="((isProjectsLoading$ | async) === false) && !((user$ | async))">
<!-- list all projects -->
<div class="title-bar admin">
<div class="title">
Expand All @@ -87,7 +84,6 @@
<app-project-tile
[project]="proj"
[sysAdmin]="false"
(buttonClicked)="navigateTo($event)"
></app-project-tile>
</div>
</div>
Expand Down
Loading
Loading