-
-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "refactor: refactor think tank"
This reverts commit d0fae9f.
- Loading branch information
Showing
3 changed files
with
44 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
<ledge-multiple-docs | ||
[items]="items" | ||
[currentUrl]="currentUrl" | ||
[urlPrefix]="urlPrefix" | ||
[source]="currentSource" | ||
> | ||
</ledge-multiple-docs> | ||
<div *ngIf="content"> | ||
<ledge-markdown-render [data]="content" showToc="true"></ledge-markdown-render> | ||
</div> |
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,41 +1,57 @@ | ||
import { Component, OnInit, ViewChild } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Title } from '@angular/platform-browser'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { MatDrawerContent } from '@angular/material/sidenav'; | ||
import { DocRoute } from '../../shared/components/ledge-multiple-docs/doc-route.model'; | ||
import { TranslateService } from '@ngx-translate/core'; | ||
import { thinktanks } from './thinktanks'; | ||
import { HttpClient, HttpHeaders } from '@angular/common/http'; | ||
import { Thinktanks, thinktanks } from './thinktanks'; | ||
|
||
@Component({ | ||
selector: 'app-think-tank', | ||
templateUrl: './think-tank.component.html', | ||
styleUrls: ['./think-tank.component.scss'], | ||
}) | ||
export class ThinkTankComponent implements OnInit { | ||
@ViewChild('drawerContent', { static: false }) | ||
drawerContent: MatDrawerContent; | ||
content: string; | ||
|
||
currentSource: string; | ||
src: string; | ||
currentUrl = '/think-tank'; | ||
urlPrefix = `think-tank`; | ||
items: DocRoute[] = thinktanks; | ||
content: string; | ||
tanks: Thinktanks = thinktanks; | ||
|
||
constructor( | ||
private title: Title, | ||
private activatedRoute: ActivatedRoute, | ||
translate: TranslateService | ||
private http: HttpClient | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.activatedRoute.paramMap.subscribe((p) => { | ||
const param = p.get('tank'); | ||
const currentCase = this.items.find((ca) => ca.source === param); | ||
const currentCase = this.tanks.find((ca) => ca.source === param); | ||
this.title.setTitle( | ||
`${currentCase.displayName}智库 - Ledge DevOps 知识平台` | ||
`DevOps ${currentCase.displayName} 智库 - Ledge DevOps 知识平台` | ||
); | ||
this.currentSource = param; | ||
this.configSource(param); | ||
}); | ||
} | ||
|
||
private configSource(value: string) { | ||
this.getCase(value); | ||
} | ||
|
||
async getCase(source: string) { | ||
this.src = this.buildSrc(source); | ||
this.currentSource = source; | ||
|
||
const headers = new HttpHeaders().set( | ||
'Content-Type', | ||
'text/plain; charset=utf-8' | ||
); | ||
this.http | ||
.get(this.src, { headers, responseType: 'text' }) | ||
.subscribe((response) => { | ||
this.content = response; | ||
}); | ||
} | ||
|
||
private buildSrc(source: string) { | ||
return `assets/docs/think-tank/${source}.md`; | ||
} | ||
} |
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