Skip to content

Commit

Permalink
Merge pull request #81 from GSI-Xapiens-CSIRO/main
Browse files Browse the repository at this point in the history
Merge Main to Xapiens
  • Loading branch information
titus-zx authored Jan 10, 2025
2 parents abec733 + 6ba252e commit 99601d9
Show file tree
Hide file tree
Showing 54 changed files with 818 additions and 404 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
# BGSI-GeneticAnalysisSupportPlatformIndonesia-GASPI

## AMI Details for AWS based deployment

```
al2023-ami-2023.6.20241212.0-kernel-6.1-x86_64
```

## Setting up environment in EC2 (Amazon Linux 2023)

Install necessary tools

```bash
RUN dnf update -y
RUN dnf install -y git docker
```

Start docker deamon and build the container

```bash
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo docker build --build-arg PLATFORM=linux/amd64 -t gaspi .devcontainer
```

Start the container

```bash
sudo docker run --init --rm --privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:`pwd` \
-w `pwd` \
--platform linux/x86_64 \
-it gaspi:latest \
/bin/bash
```

## Clone Source Code

```bash
git clone https://github.com/GSI-Xapiens-CSIRO/BGSI-GeneticAnalysisSupportPlatformIndonesia-GASPI.git
git submodule init
git submodule update
```

## Initialisation

Please run `init.sh` scripts in `svep` and `sbeacon` directories. Then run `pnpm install` from `webgui/webapp` directory.

## Deployment

```bash
terraform apply
```
10 changes: 10 additions & 0 deletions cognito/cognito.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ resource "aws_cognito_user_pool" "gaspi_user_pool" {
mutable = false
required = false
}

schema {
name = "identity_id"
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
required = false

string_attribute_constraints {}
}
}

resource "aws_cognito_user_pool_client" "gaspi_user_pool_client" {
Expand Down
6 changes: 0 additions & 6 deletions webgui/webapp/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ export class AppComponent implements OnInit {

ngOnInit(): void {
this.isCollapsed = this.el.nativeElement.offsetWidth < 1200;
// TODO - check if this is really necessary
// this prevents users from reloading and landing on same page even when they are logged in
// route security is enabled by the authguards
(async () => {
await this.auth.refresh();
})();
}

@HostListener('window:resize', ['event'])
Expand Down
4 changes: 3 additions & 1 deletion webgui/webapp/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
DetachedRouteHandle,
RouteReuseStrategy,
provideRouter,
withPreloading,
PreloadAllModules,
} from '@angular/router';

import { routes } from './app.routes';
Expand Down Expand Up @@ -64,7 +66,7 @@ export class CustomReuseStrategy implements RouteReuseStrategy {

export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideRouter(routes, withPreloading(PreloadAllModules)),
provideAnimations(),
{
provide: MAT_FORM_FIELD_DEFAULT_OPTIONS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<div>
<h1 mat-dialog-title>
Select a <em>{{ _.startCase(data.scope) }}</em> entry
</h1>
<!-- prettier-ignore -->
<h1 mat-dialog-title>Select a <em>{{ _.startCase(data.scope) }}</em> entry</h1>
@if (data.projects.length > 0) {
<app-component-spinner [loading]="loading"></app-component-spinner>
<div mat-dialog-content>
<div class="bui-filter-selection-table">
<table mat-table [dataSource]="entries">
<table mat-table [dataSource]="dataSourceEntries">
@for (column of displayedColumnsEntries; track column) {
<ng-container [matColumnDef]="column">
<th
Expand All @@ -24,15 +23,12 @@ <h1 mat-dialog-title>
) {
<pre>{{ element[column] }}</pre>
} @else {
#showJSON;|
}
<ng-template #showJSON>
<ngx-json-viewer
style="text-wrap: nowrap"
[expanded]="false"
[json]="element[column]"
></ngx-json-viewer>
</ng-template>
}
</div>
}
@case ("selected") {
Expand All @@ -55,12 +51,13 @@ <h1 mat-dialog-title>
<br />
</div>
<mat-paginator
[style.display]="dataSourceEntries.data.length ? '' : 'none'"
#paginator
[pageSizeOptions]="[10, 50, 100]"
[length]="total"
page
></mat-paginator>
@if (!entries.length && !loading) {
@if (!dataSourceEntries.data.length && !loading) {
<p>No entries available in the selected scope</p>
}
<div>
Expand All @@ -75,4 +72,16 @@ <h1 mat-dialog-title>
<button mat-raised-button color="primary" (click)="done()">Done</button>
</div>
</div>
</div>
} @else {
<div mat-dialog-content>
<p>Please select some projects.</p>
<button
mat-raised-button
color="primary"
(click)="cancel()"
style="margin-right: 10px"
>
Cancel
</button>
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,21 @@ export class EntryIdSelectionDialogComponent {
protected skip = 0;
protected limit = 0;
protected total = 0;
protected entries: any = [];
protected dataSourceEntries = new MatTableDataSource<any>([]);
protected displayedColumnsEntries: string[] = [];
protected selected: string | null = null;

constructor(
public dialogRef: MatDialogRef<EntryIdSelectionDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: { scope: string; projects: string[] },
private qs: QueryService,
private cd: ChangeDetectorRef,
) {}

ngAfterViewInit(): void {
if (this.data.projects.length === 0) {
return;
}
this.paginator.page
.pipe(
startWith({}),
Expand All @@ -79,6 +81,7 @@ export class EntryIdSelectionDialogComponent {
this.limit = this.paginator.pageSize;
return this.qs
.fetch(this.data.scope, {
projects: this.data.projects,
query: {
filters: [],
requestedGranularity: 'record',
Expand Down Expand Up @@ -109,7 +112,7 @@ export class EntryIdSelectionDialogComponent {
? results.response.collections
: results.response.resultSets[0].results;

if (this.entries.length && _.isEmpty(resultsArray)) {
if (this.dataSourceEntries.data.length && _.isEmpty(resultsArray)) {
this.paginator.pageIndex -= 1;
console.log('page out of bounds');
} else {
Expand All @@ -121,7 +124,7 @@ export class EntryIdSelectionDialogComponent {
idName,
..._.filter(_.keys(resultsArray[0]), (item) => item != idName),
];
this.entries = resultsArray;
this.dataSourceEntries = new MatTableDataSource(resultsArray);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@
<mat-label>Filter Value</mat-label>
<input matInput formControlName="value" required />
</mat-form-field>
<div class="flex md:justify-end">
<div class="flex md:justify-end items-center h-[56px]">
<button
type="button"
(click)="removeFilterClicked.emit()"
mat-fab
color="primary"
mat-mini-fab
color="warn"
>
<mat-icon>delete</mat-icon>
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<div>
<h1 mat-dialog-title>
Select <em>{{ _.startCase(data.type) }}</em> filters for
<em>{{ _.startCase(data.scope) }}</em>
</h1>
<!-- prettier-ignore -->
<h1 mat-dialog-title>Select <em>{{ _.startCase(data.type) }}</em> filters for <em>{{ _.startCase(data.scope) }}</em></h1>
@if (data.projects.length > 0) {
<app-component-spinner [loading]="loading"></app-component-spinner>
<div mat-dialog-content>
<mat-form-field>
Expand Down Expand Up @@ -64,4 +62,16 @@ <h1 mat-dialog-title>
<button mat-raised-button color="primary" (click)="done()">Done</button>
</div>
</div>
</div>
} @else {
<div mat-dialog-content>
<p>Please select some projects.</p>
<button
mat-raised-button
color="primary"
(click)="cancel()"
style="margin-right: 10px"
>
Cancel
</button>
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,21 @@ export class FilterSelectionDialogComponent implements AfterViewInit {
protected dataSourceFilters = new MatTableDataSource<any>([]);
protected displayedColumnsFilters = ['selected', 'id', 'label', 'type'];
protected selected: { [key: string]: any } = {};
protected filter = '';
protected filter: string = '';

constructor(
public dialogRef: MatDialogRef<FilterSelectionDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA)
public data: { scope: string; projects: string[]; type: string },
private fs: FilterService,
private cd: ChangeDetectorRef,
private sb: MatSnackBar,
) {}

ngAfterViewInit(): void {
if (this.data.projects.length === 0) {
return;
}
this.paginatorFilters.page
.pipe(
startWith({}),
Expand All @@ -111,6 +115,7 @@ export class FilterSelectionDialogComponent implements AfterViewInit {
.fetch_by_scope(this.data.scope, {
skip: this.limit * this.paginatorFilters.pageIndex,
limit: this.limit,
projects: this.data.projects.join(','),
})
.pipe(catchError(() => of(null)));
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class AdminUserClickDialogComponent implements OnInit {
) {
this.form = this.fb.group({
administrators: [false],
managers: [false],
quotaSize: ['', [Validators.required, Validators.min(0)]],
quotaQueryCount: ['', [Validators.required, Validators.min(0)]],
});
Expand Down Expand Up @@ -204,7 +205,7 @@ export class AdminUserClickDialogComponent implements OnInit {
}

updateUser() {
const groups = _.pick(this.form.value, ['administrators']);
const groups = _.pick(this.form.value, ['administrators', 'managers']);
return this.as
.updateUsersGroups(this.data.email, groups)
.pipe(catchError(() => of(null)));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<div class="flex flex-row justify-between w-full items-center">
<h2 class="flex">Folders tracked under users</h2>
<button
mat-mini-fab
color="primary"
class="flex items-center"
(click)="list()"
>
<mat-icon>refresh</mat-icon>
</button>
</div>
<p>These folders are held by active users.</p>
<table mat-table [dataSource]="dataSource">
<!-- Given Name Column -->
<ng-container matColumnDef="given_name">
<th mat-header-cell *matHeaderCellDef>Given Name</th>
<td mat-cell *matCellDef="let element">{{ element.given_name }}</td>
</ng-container>

<!-- Family Name Column -->
<ng-container matColumnDef="family_name">
<th mat-header-cell *matHeaderCellDef>Family Name</th>
<td mat-cell *matCellDef="let element">{{ element.family_name }}</td>
</ng-container>

<!-- Email Column -->
<ng-container matColumnDef="email">
<th mat-header-cell *matHeaderCellDef>Email</th>
<td mat-cell *matCellDef="let element">{{ element.email }}</td>
</ng-container>

<!-- Actions Column -->
<ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef>Action</th>
<td mat-cell *matCellDef="let element">
<button
mat-mini-fab
color="warn"
(click)="deleteFolder(element['custom:identity_id'])"
>
<mat-icon>delete</mat-icon>
</button>
</td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
</table>

@if (inactiveIdentities.length) {
<h2>Folders not tracked under users</h2>
<p>
These folders either belong to past users and currently does not belong to
anyone.
</p>

<div class="flex flex-col space-y-1">
@for (identity of inactiveIdentities; track identity) {
<div class="flex flex-row space-x-2 items-center">
<button mat-mini-fab color="warn" (click)="deleteFolder(identity)">
<mat-icon>delete</mat-icon>
</button>
<div class="flex font-semibold">{{ identity }}</div>
</div>
}
</div>
}
Loading

0 comments on commit 99601d9

Please sign in to comment.