Skip to content

Commit

Permalink
* Update Collaborate and Annotate pages to given design.
Browse files Browse the repository at this point in the history
* Combine ExploreCompilationDialog and ExploreEntityDialog into one ViewerDialog
* Apply centering to ProfilePage, AdminPage, ContactPage, and ConsortiumPage
  • Loading branch information
HeyItsBATMAN committed Aug 24, 2023
1 parent 3c52765 commit 92b811b
Show file tree
Hide file tree
Showing 34 changed files with 411 additions and 312 deletions.
18 changes: 11 additions & 7 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ import {
EntityComponent,
EntityDetailComponent,
FooterComponent,
GridComponent,
GridElementComponent,
GroupElementComponent,
InstitutionComponent,
NavbarComponent,
PersonComponent,
Expand Down Expand Up @@ -87,23 +89,23 @@ import {

// Pipes
import { FilesizePipe, ReplayHasValuePipe, SafePipe } from './pipes';
import { CountUniqueGroupMembersPipe } from './components/elements/group-element/count-unique-group-members.pipe';

// Dialogs
import {
ConfirmationDialogComponent,
EditEntityDialogComponent,
EntityRightsDialogComponent,
EntitySettingsDialogComponent,
ExploreCompilationDialogComponent,
ExploreEntityDialogComponent,
ForgotPasswordDialogComponent,
ForgotUsernameDialogComponent,
GroupMemberDialogComponent,
PasswordProtectedDialogComponent,
RegisterDialogComponent,
ResetPasswordDialogComponent,
UploadApplicationDialogComponent,
ViewerDialogComponent,
} from './dialogs';
import { ResetPasswordDialogComponent } from './dialogs/reset-password-dialog/reset-password-dialog.component';
import { ForgotUsernameDialogComponent } from './dialogs/forgot-username-dialog/forgot-username-dialog.component';
import { ForgotPasswordDialogComponent } from './dialogs/forgot-password-dialog/forgot-password-dialog.component';

// Interceptors
import { HttpOptionsInterceptor } from './services/interceptors/http-options-interceptor';
Expand Down Expand Up @@ -148,12 +150,10 @@ const INTERCEPTORS: Provider[] = [
AnnotateComponent,
CollaborateComponent,
AboutComponent,
ExploreEntityDialogComponent,
UploadApplicationDialogComponent,
ProfilePageHelpComponent,
ActionbarComponent,
AnimatedImageComponent,
ExploreCompilationDialogComponent,
EditEntityDialogComponent,
AdminPageComponent,
CompilationDetailComponent,
Expand All @@ -170,6 +170,10 @@ const INTERCEPTORS: Provider[] = [
ForgotUsernameDialogComponent,
ForgotPasswordDialogComponent,
ReplayHasValuePipe,
GroupElementComponent,
CountUniqueGroupMembersPipe,
GridComponent,
ViewerDialogComponent,
],
imports: [
CommonModule,
Expand Down
1 change: 1 addition & 0 deletions src/app/components/elements/grid/grid.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ng-content></ng-content>
5 changes: 5 additions & 0 deletions src/app/components/elements/grid/grid.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:host {
display: grid;
grid-template-columns: repeat(var(--items-per-row, 4), 1fr);
gap: var(--gap-size, 8px);
}
20 changes: 20 additions & 0 deletions src/app/components/elements/grid/grid.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component, HostBinding, Input } from '@angular/core';

@Component({
selector: 'app-grid',
templateUrl: './grid.component.html',
styleUrls: ['./grid.component.scss'],
})
export class GridComponent {
@Input('itemsPerRow') itemsPerRow = 4;

@Input('gapSizePx') gapSizePx = 8;

@HostBinding('style.--items-per-row') get itemsPerRowStyle() {
return this.itemsPerRow;
}

@HostBinding('style.--gap-size') get gapSizeStyle() {
return this.gapSizePx + 'px';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Pipe, PipeTransform } from '@angular/core';
import { IGroup } from '~common/interfaces';

@Pipe({
name: 'countUniqueGroupMembers',
})
export class CountUniqueGroupMembersPipe implements PipeTransform {
transform({ members, owners }: IGroup): unknown {
const uniqueIds = new Set([...members, ...owners].map(({ _id }) => _id));
return Array.from(uniqueIds).length;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<ng-container *ngIf="group$ | async as group">
<p>
<span><b>{{group.name}}</b></span><br>
<small>by {{group.creator.fullname}}</small>
</p>

<button mat-flat-button color="primary" class="rounded" (click)="openMemberList(group)">
<mat-icon>groups</mat-icon>
<span>View members ({{ group | countUniqueGroupMembers }})</span>
</button>
</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
:host {
display: inline-flex;
flex-direction: column;
padding: 24px;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.2);
border-radius: 4px;
gap: 16px;
min-width: 240px;

* {
margin: 0;
}

button {
align-self: flex-start;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Component, Input } from '@angular/core';
import { IGroup } from '~common/interfaces';
import { combineLatest, map, ReplaySubject } from 'rxjs';
import { AccountService } from '~services';
import { GroupMemberDialogComponent } from '~dialogs';
import { MatDialog } from '@angular/material/dialog';

@Component({
selector: 'app-group-element',
templateUrl: './group-element.component.html',
styleUrls: ['./group-element.component.scss'],
})
export class GroupElementComponent {
@Input('group') set group(group: IGroup) {
this.group$.next(group);
}

public group$ = new ReplaySubject<IGroup>(1);
public isUserOwner$ = combineLatest([this.group$, this.account.user$]).pipe(
map(([group, user]) => group?.creator._id === user._id),
);

public openMemberList(group: IGroup) {
this.dialog.open(GroupMemberDialogComponent, { data: group });
}

constructor(private account: AccountService, private dialog: MatDialog) {}
}
39 changes: 16 additions & 23 deletions src/app/components/grid-element/grid-element.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatMenu } from '@angular/material/menu';
import { MatDialog } from '@angular/material/dialog';

import {
ICompilation,
IEntity,
isAnnotation,
isCompilation,
isEntity,
isResolvedEntity,
ICompilation,
IEntity,
ObjectId,
} from 'src/common';
import { environment } from 'src/environments/environment';
import { ExploreEntityDialogComponent, ExploreCompilationDialogComponent } from 'src/app/dialogs';
import { DialogHelperService } from '~services';

@Component({
selector: 'app-grid-element',
Expand Down Expand Up @@ -52,7 +51,7 @@ export class GridElementComponent {
@Output()
public updateSelectedObject = new EventEmitter<string>();

constructor(private dialog: MatDialog) {}
constructor(private dialogHelper: DialogHelperService) {}

get tooltipContent() {
let description = '';
Expand Down Expand Up @@ -125,23 +124,17 @@ export class GridElementComponent {
public openExploreDialog(element: IEntity | ICompilation) {
if (!element) return;

if (isCompilation(element)) {
// tslint:disable-next-line:no-non-null-assertion
const eId = (Object.values(element.entities)[0] as IEntity)._id;

this.dialog.open(ExploreCompilationDialogComponent, {
data: {
collectionId: element._id,
entityId: eId,
},
id: 'explore-compilation-dialog',
});
} else {
this.dialog.open(ExploreEntityDialogComponent, {
data: element._id,
id: 'explore-entity-dialog',
});
}
console.log(element);
const compilation = isCompilation(element) ? element._id.toString() : undefined;
const entity = compilation
? Object.keys((element as ICompilation).entities)[0].toString()
: element._id.toString();

this.dialogHelper.openViewerDialog({
compilation,
entity,
mode: 'explore',
});
}

public selectObject(id: string | ObjectId) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export { SidenavListComponent } from './navigation/sidenav-list/sidenav-list.com
export { NavbarComponent } from './navigation/navbar/navbar.component';
export { FooterComponent } from './navigation/footer/footer.component';
export { UploadComponent } from './upload/upload.component';
export { GroupElementComponent } from './elements/group-element/group-element.component';
export { GridComponent } from './elements/grid/grid.component';

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions src/app/dialogs/explore-entity/explore-entity-dialog.component.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/app/dialogs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ export { ConfirmationDialogComponent } from './confirmation-dialog/confirmation-
export { EditEntityDialogComponent } from './edit-entity-dialog/edit-entity-dialog.component';
export { EntityRightsDialogComponent } from './entity-rights-dialog/entity-rights-dialog.component';
export { EntitySettingsDialogComponent } from './entity-settings-dialog/entity-settings-dialog.component';
export { ExploreCompilationDialogComponent } from './explore-compilation-dialog/explore-compilation-dialog.component';
export { ExploreEntityDialogComponent } from './explore-entity/explore-entity-dialog.component';
export { GroupMemberDialogComponent } from './group-member-dialog/group-member-dialog.component';
export { PasswordProtectedDialogComponent } from './password-protected-dialog/password-protected-dialog.component';
export { RegisterDialogComponent } from './register-dialog/register-dialog.component';
export { UploadApplicationDialogComponent } from './upload-application-dialog/upload-application-dialog.component';
export { ResetPasswordDialogComponent } from './reset-password-dialog/reset-password-dialog.component';
export { ForgotUsernameDialogComponent } from './forgot-username-dialog/forgot-username-dialog.component';
export { ForgotPasswordDialogComponent } from './forgot-password-dialog/forgot-password-dialog.component';
export { ViewerDialogComponent, ViewerDialogData } from './viewer-dialog/viewer-dialog.component'
4 changes: 4 additions & 0 deletions src/app/dialogs/viewer-dialog/viewer-dialog.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ng-container *ngIf="viewerUrl$ | async as viewerUrl">
<iframe [src]="viewerUrl | safe: 'resourceUrl'" allowfullscreen></iframe>
</ng-container>

Empty file.
31 changes: 31 additions & 0 deletions src/app/dialogs/viewer-dialog/viewer-dialog.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { environment } from '~environments';
import { ReplaySubject } from 'rxjs';

export type ViewerDialogData = {
entity?: string;
compilation?: string;
mode?: 'upload' | 'explore' | 'edit' | 'annotation' | 'open';
};

@Component({
selector: 'app-viewer-dialog',
templateUrl: './viewer-dialog.component.html',
styleUrls: ['./viewer-dialog.component.scss'],
})
export class ViewerDialogComponent {
public viewerUrl$ = new ReplaySubject<string>(0);

constructor(
public dialogRef: MatDialogRef<ViewerDialogComponent>,
@Inject(MAT_DIALOG_DATA) private data: ViewerDialogData,
) {
const url = new URL(environment.viewer_url);
for (const [key, value] of Object.entries(data)) {
if (!value) continue;
url.searchParams.set(key, value);
}
this.viewerUrl$.next(url.toString());
}
}
2 changes: 1 addition & 1 deletion src/app/pages/admin-page/admin-page.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="content">
<div class="content centered-content">
<ng-container *ngIf="!(isAdmin$ | async); else adminBlock">
<h1>User Administration</h1>
<h2>Waiting for admin data</h2>
Expand Down
Loading

0 comments on commit 92b811b

Please sign in to comment.