-
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.
feat(changelog): UI page to view changelog
- Loading branch information
1 parent
ed1361b
commit ccc5a03
Showing
13 changed files
with
135 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {HttpClientModule} from '@angular/common/http'; | ||
import {NgModule} from '@angular/core'; | ||
|
||
import {MdPreviewModule} from '../../pipes/md-preview/md-preview.module'; | ||
|
||
import {ChangelogPageComponent} from './changelog.page'; | ||
import {ChangelogRouteModule} from './changelog.routing'; | ||
import {ChangelogService} from './changelog.service'; | ||
|
||
@NgModule({ | ||
declarations: [ChangelogPageComponent], | ||
providers: [ChangelogService], | ||
imports: [ChangelogRouteModule, CommonModule, HttpClientModule, MdPreviewModule], | ||
exports: [], | ||
}) | ||
export class ChangelogPageModule {} |
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 {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
|
||
import {Observable} from 'rxjs'; | ||
import {tap} from 'rxjs/operators'; | ||
|
||
import {ChangelogService} from './changelog.service'; | ||
|
||
@Component({ | ||
templateUrl: './changelog.template.html', | ||
styles: [ | ||
` | ||
section { | ||
padding: 16px; | ||
} | ||
`, | ||
], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ChangelogPageComponent { | ||
public changelogContent: Observable<string>; | ||
|
||
constructor(private changelogService: ChangelogService) { | ||
this.changelogContent = this.changelogService | ||
.getChangelogContent() | ||
.pipe(tap((value) => console.log(value))); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
apps/frontend/src/app/pages/changelog/changelog.routing.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,12 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {RouterModule, Routes} from '@angular/router'; | ||
|
||
import {ChangelogPageComponent} from './changelog.page'; | ||
|
||
const routes: Routes = [{path: '', component: ChangelogPageComponent}]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class ChangelogRouteModule {} |
26 changes: 26 additions & 0 deletions
26
apps/frontend/src/app/pages/changelog/changelog.service.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,26 @@ | ||
import {HttpClient, HttpHeaders} from '@angular/common/http'; | ||
import {Injectable} from '@angular/core'; | ||
|
||
import {Observable} from 'rxjs'; | ||
import {map} from 'rxjs/operators'; | ||
|
||
@Injectable() | ||
export class ChangelogService { | ||
constructor(private http: HttpClient) {} | ||
|
||
public getChangelogContent(): Observable<string> { | ||
const headers = new HttpHeaders(); | ||
headers.append('Access', 'text/markdown'); | ||
headers.append('Content-Type', 'text/markdown'); | ||
|
||
const request = this.http.get<ArrayBuffer>('/api/changelog', { | ||
headers, | ||
responseType: 'arraybuffer' as 'json', | ||
}); | ||
|
||
return request.pipe(map(this.getContentFromArrayBuffer)); | ||
} | ||
|
||
private getContentFromArrayBuffer = (arrbuffer: ArrayBuffer): string => | ||
new TextDecoder().decode(arrbuffer); | ||
} |
7 changes: 7 additions & 0 deletions
7
apps/frontend/src/app/pages/changelog/changelog.template.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,7 @@ | ||
<section> | ||
<p [innerHTML]="changelogContent | async | mdPreview"></p> | ||
<a | ||
href="https://github.com/ducktordanny/opres.help/blob/master/apps/backend/src/assets/CHANGELOG.md" | ||
>See on GitHub.</a | ||
> | ||
</section> |
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,9 @@ | ||
import {NgModule} from '@angular/core'; | ||
|
||
import {MdPreviewPipe} from './md-preview.pipe'; | ||
|
||
@NgModule({ | ||
declarations: [MdPreviewPipe], | ||
exports: [MdPreviewPipe], | ||
}) | ||
export class MdPreviewModule {} |
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 {Pipe, SecurityContext} from '@angular/core'; | ||
import {DomSanitizer} from '@angular/platform-browser'; | ||
import {PipeTransform} from '@nestjs/common'; | ||
|
||
import {marked} from 'marked'; | ||
|
||
@Pipe({ | ||
name: 'mdPreview', | ||
}) | ||
export class MdPreviewPipe implements PipeTransform { | ||
constructor(private sanitizer: DomSanitizer) {} | ||
|
||
public transform(value: string | null): string { | ||
if (value === null) { | ||
console.error('mdPreview input value is null'); | ||
return ''; | ||
} | ||
const rawPreview = marked.parse(value); | ||
const preview = this.sanitizer.sanitize(SecurityContext.HTML, rawPreview); | ||
if (preview === null) console.error('Cannot display HTML content because of security reasons.'); | ||
return preview ?? ''; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7768,6 +7768,11 @@ [email protected]: | |
dependencies: | ||
tmpl "1.0.5" | ||
|
||
marked@^11.2.0: | ||
version "11.2.0" | ||
resolved "https://registry.yarnpkg.com/marked/-/marked-11.2.0.tgz#fc908aeca962b721b0392ee4205e6f90ebffb074" | ||
integrity sha512-HR0m3bvu0jAPYiIvLUUQtdg1g6D247//lvcekpHO1WMvbwDlwSkZAX9Lw4F4YHE1T0HaaNve0tuAWuV1UJ6vtw== | ||
|
||
[email protected]: | ||
version "2.3.0" | ||
resolved "https://registry.yarnpkg.com/md5/-/md5-2.3.0.tgz#c3da9a6aae3a30b46b7b0c349b87b110dc3bda4f" | ||
|