forked from teocomi/BCFier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
276f4f0
commit 34a6d73
Showing
9 changed files
with
226 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/ipa-bcfier-ui/src/app/components/bcf-file/bcf-file.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<div class="issue-list"> | ||
<div class="issue-list-buttons"> | ||
<button mat-raised-button color="primary">Add Issue</button> | ||
<button mat-raised-button color="warn">Delete Issue</button> | ||
</div> | ||
<div> | ||
<mat-form-field> | ||
<mat-label>Search</mat-label> | ||
<input matInput placeholder="Title or description" [(ngModel)]="search" /> | ||
@if (search) { | ||
<button matSuffix mat-icon-button (click)="search = ''"> | ||
<mat-icon>close</mat-icon> | ||
</button> | ||
} | ||
</mat-form-field> | ||
</div> | ||
<div class="topic-list"> | ||
<mat-card *ngFor="let topic of bcfFile.topics | topicFilter : search"> | ||
<mat-card-header> | ||
<mat-card-title-group> | ||
<mat-card-title>{{ topic.title }}</mat-card-title> | ||
<mat-card-subtitle>{{ | ||
topic.creationDate | date : "dd.MM.yyyy" | ||
}}</mat-card-subtitle> | ||
|
||
<img | ||
mat-card-md-image | ||
[bcfierTopicPreviewImage]="topic" | ||
src="https://material.angular.io/assets/img/examples/shiba2.jpg" | ||
/> | ||
</mat-card-title-group> | ||
</mat-card-header> | ||
<mat-card-content> | ||
<div class="topic-info"> | ||
<mat-icon color="primary">chat</mat-icon> | ||
{{ topic.comments.length }} | ||
</div> | ||
<div class="topic-info"> | ||
<mat-icon color="primary">visibility</mat-icon> | ||
{{ topic.viewpoints.length }} | ||
</div> | ||
</mat-card-content> | ||
</mat-card> | ||
</div> | ||
</div> | ||
<div class="issue-details"></div> |
41 changes: 41 additions & 0 deletions
41
src/ipa-bcfier-ui/src/app/components/bcf-file/bcf-file.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.issue-list { | ||
margin-top: 4px; | ||
margin-left: 4px; | ||
display: flex; | ||
flex-direction: column; | ||
width: 30%; | ||
height: 100%; | ||
} | ||
|
||
.issue-list-buttons { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-evenly; | ||
margin-bottom: 4px; | ||
|
||
button { | ||
width: 45%; | ||
} | ||
} | ||
|
||
.topic-list { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 12px; | ||
} | ||
|
||
mat-form-field { | ||
width: 100%; | ||
} | ||
|
||
mat-card-content { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 12px; | ||
} | ||
|
||
.topic-info { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 6px; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/ipa-bcfier-ui/src/app/components/bcf-file/bcf-file.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { BcfFileComponent } from './bcf-file.component'; | ||
|
||
describe('BcfFileComponent', () => { | ||
let component: BcfFileComponent; | ||
let fixture: ComponentFixture<BcfFileComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [BcfFileComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(BcfFileComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/ipa-bcfier-ui/src/app/components/bcf-file/bcf-file.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Component, Input } from '@angular/core'; | ||
|
||
import { BcfFile } from '../../../generated/models'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatCardModule } from '@angular/material/card'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
import { TopicFilterPipe } from '../../pipes/topic-filter.pipe'; | ||
import { TopicPreviewImageDirective } from '../../directives/topic-preview-image.directive'; | ||
|
||
@Component({ | ||
selector: 'bcfier-bcf-file', | ||
standalone: true, | ||
imports: [ | ||
MatButtonModule, | ||
MatInputModule, | ||
CommonModule, | ||
MatCardModule, | ||
MatIconModule, | ||
TopicPreviewImageDirective, | ||
FormsModule, | ||
TopicFilterPipe, | ||
], | ||
templateUrl: './bcf-file.component.html', | ||
styleUrl: './bcf-file.component.scss', | ||
}) | ||
export class BcfFileComponent { | ||
@Input() bcfFile!: BcfFile; | ||
|
||
private _search = ''; | ||
public set search(value: string) { | ||
this._search = value; | ||
} | ||
public get search(): string { | ||
return this._search; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/ipa-bcfier-ui/src/app/directives/topic-preview-image.directive.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { TopicPreviewImageDirective } from './topic-preview-image.directive'; | ||
|
||
describe('TopicPreviewImageDirective', () => { | ||
it('should create an instance', () => { | ||
const directive = new TopicPreviewImageDirective(); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
src/ipa-bcfier-ui/src/app/directives/topic-preview-image.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { BcfFile, BcfTopic } from '../../generated/models'; | ||
import { Directive, ElementRef, Input, OnInit } from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[bcfierTopicPreviewImage]', | ||
standalone: true, | ||
}) | ||
export class TopicPreviewImageDirective implements OnInit { | ||
@Input() bcfierTopicPreviewImage!: BcfTopic; | ||
|
||
constructor(private elementRef: ElementRef) {} | ||
|
||
ngOnInit(): void { | ||
const viewpoints = this.bcfierTopicPreviewImage.viewpoints.filter( | ||
(vp) => vp.snapshotBase64 | ||
); | ||
if (viewpoints.length === 0) { | ||
return; | ||
} | ||
|
||
// We're using the base64 data from the snapshot to | ||
// generate a base64 data url with png type | ||
const imageUrl = `data:image/png;base64,${viewpoints[0].snapshotBase64}`; | ||
// Then we're appending it to the host element as src attribute | ||
this.elementRef.nativeElement.src = imageUrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { TopicFilterPipe } from './topic-filter.pipe'; | ||
|
||
describe('TopicFilterPipe', () => { | ||
it('create an instance', () => { | ||
const pipe = new TopicFilterPipe(); | ||
expect(pipe).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
|
||
import { BcfTopic } from '../../generated/models'; | ||
|
||
@Pipe({ | ||
name: 'topicFilter', | ||
standalone: true, | ||
}) | ||
export class TopicFilterPipe implements PipeTransform { | ||
transform(value: BcfTopic[], filter: string): BcfTopic[] { | ||
if (!filter) { | ||
return value; | ||
} | ||
|
||
return value.filter((topic) => { | ||
if ( | ||
topic.title != null && | ||
topic.title.toUpperCase().indexOf(filter.toUpperCase()) !== -1 | ||
) { | ||
return true; | ||
} | ||
|
||
if ( | ||
topic.description != null && | ||
topic.description.toUpperCase().indexOf(filter.toUpperCase()) !== -1 | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}); | ||
} | ||
} |