Skip to content

Commit

Permalink
Revert "refactor: refactor think tank"
Browse files Browse the repository at this point in the history
This reverts commit d0fae9f.
  • Loading branch information
phodal committed May 9, 2020
1 parent 3f2a56b commit cb0ffc5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 26 deletions.
10 changes: 3 additions & 7 deletions src/app/presentation/think-tank/think-tank.component.html
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>
48 changes: 32 additions & 16 deletions src/app/presentation/think-tank/think-tank.component.ts
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`;
}
}
12 changes: 9 additions & 3 deletions src/app/presentation/think-tank/thinktanks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// todo: 优先级根据内容的质量重新排序。现在的是后来的在后面 + 内容多的在前面,随机组合
import { DocRoute } from '../../shared/components/ledge-multiple-docs/doc-route.model';
export interface Thinktank {
displayName: string;
source: string;
default?: boolean;
}

export type Thinktanks = Array<Thinktank>;

export const thinktanks: DocRoute[] = [
// todo: 优先级根据内容的质量重新排序。现在的是后来的在后面 + 内容多的在前面,随机组合
export const thinktanks: Thinktanks = [
{ displayName: '需求管理', source: 'ba' },
{ displayName: '质量管理', source: 'qa', default: true },
{ displayName: 'Android', source: 'mobile-android' },
Expand Down

0 comments on commit cb0ffc5

Please sign in to comment.