-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implenenting groupped markdowns #711
- Loading branch information
Showing
24 changed files
with
492 additions
and
310 deletions.
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
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
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
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
17 changes: 17 additions & 0 deletions
17
src/frontend/app/ui/gallery/blog/blog.gallery.component.css
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
37 changes: 23 additions & 14 deletions
37
src/frontend/app/ui/gallery/blog/blog.gallery.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 |
---|---|---|
@@ -1,16 +1,25 @@ | ||
<div class="blog"> | ||
<div class="card"> | ||
<div class="card-body" style="min-height: 77px" [style.height]="collapsed ? '77px':''"> | ||
<ng-container *ngFor="let md of markdowns; let i = index"> | ||
<markdown | ||
*ngIf="!collapsed" | ||
[data]="md"> | ||
</markdown> | ||
<span *ngIf="collapsed" class="text-preview"> | ||
{{md}} | ||
</span> | ||
<hr *ngIf="i != markdowns.length-1"> | ||
</ng-container> | ||
<ng-container *ngIf="mkObservable | async as markdowns"> | ||
<div class="blog" *ngIf="markdowns.length > 0"> | ||
<div class="card"> | ||
<div class="card-body" style="min-height: 77px" [style.height]="!open ? '77px':''"> | ||
<ng-container *ngFor="let md of markdowns; let last = last"> | ||
<markdown | ||
*ngIf="open" | ||
[data]="md.text"> | ||
</markdown> | ||
<span *ngIf="!open" class="text-preview"> | ||
<markdown | ||
[inline]="true" | ||
[data]="md.text"> | ||
</markdown> | ||
</span> | ||
<hr *ngIf="!last"> | ||
</ng-container> | ||
</div> | ||
</div> | ||
|
||
<button class="btn btn-blog-details text-body" (click)="toggleCollapsed()"> | ||
<ng-icon [name]="open ? 'ionChevronUpOutline' : 'ionChevronDownOutline'"></ng-icon> | ||
</button> | ||
</div> | ||
</div> | ||
</ng-container> |
37 changes: 23 additions & 14 deletions
37
src/frontend/app/ui/gallery/blog/blog.gallery.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 |
---|---|---|
@@ -1,30 +1,39 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { FileDTO } from '../../../../../common/entities/FileDTO'; | ||
import { BlogService } from './blog.service'; | ||
import { OnChanges } from '../../../../../../node_modules/@angular/core'; | ||
import {Component, EventEmitter, Input, Output} from '@angular/core'; | ||
import {BlogService, GroupedMarkdown} from './blog.service'; | ||
import {OnChanges} from '../../../../../../node_modules/@angular/core'; | ||
import {Utils} from '../../../../../common/Utils'; | ||
import {map, Observable} from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-gallery-blog', | ||
templateUrl: './blog.gallery.component.html', | ||
styleUrls: ['./blog.gallery.component.css'], | ||
}) | ||
export class GalleryBlogComponent implements OnChanges { | ||
@Input() mdFiles: FileDTO[]; | ||
@Input() collapsed: boolean; | ||
markdowns: string[] = []; | ||
@Input() open: boolean; | ||
@Input() date: Date; | ||
@Output() openChange = new EventEmitter<boolean>(); | ||
public markdowns: string[] = []; | ||
mkObservable: Observable<GroupedMarkdown[]>; | ||
|
||
constructor(public blogService: BlogService) {} | ||
constructor(public blogService: BlogService) { | ||
} | ||
|
||
|
||
ngOnChanges(): void { | ||
this.loadMarkdown().catch(console.error); | ||
const utcDate = this.date ? this.date.getTime() : undefined; | ||
this.mkObservable = this.blogService.groupedMarkdowns.pipe(map(gm => { | ||
if (!this.date) { | ||
return gm.filter(g => !g.date); | ||
} | ||
return gm.filter(g => g.date == utcDate); | ||
})); | ||
} | ||
|
||
async loadMarkdown(): Promise<void> { | ||
this.markdowns = []; | ||
for (const f of this.mdFiles) { | ||
this.markdowns.push(await this.blogService.getMarkDown(f)); | ||
} | ||
|
||
toggleCollapsed(): void { | ||
this.open = !this.open; | ||
this.openChange.emit(this.open); | ||
} | ||
} | ||
|
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
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
Oops, something went wrong.