-
-
Notifications
You must be signed in to change notification settings - Fork 356
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
Showing
8 changed files
with
161 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
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,15 @@ | ||
<mat-drawer-container class="solution"> | ||
<mat-drawer mode="side" opened class="left-drawer"> | ||
<h2>解决方案</h2> | ||
<ul> | ||
<li *ngFor="let casestudy of solutions" | ||
(click)="clickCase(casestudy.source)" | ||
[ngClass]="casestudy.source === currentSource ? 'active' : '' "> | ||
<span>{{casestudy.displayName}}</span> | ||
</li> | ||
</ul> | ||
</mat-drawer> | ||
<mat-drawer-content> | ||
<component-markdown-render [src]="src"></component-markdown-render> | ||
</mat-drawer-content> | ||
</mat-drawer-container> |
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,44 @@ | ||
@import '~@angular/material/theming'; | ||
@import '../../../styles/behavior'; | ||
|
||
.solution { | ||
min-height: 600px; | ||
height: calc(100% - 64px); | ||
|
||
.active { | ||
background-color: #ff4081; | ||
color: #fff; | ||
} | ||
} | ||
|
||
.left-drawer { | ||
width: 15%; | ||
min-width: 200px; | ||
min-height: 100vh; | ||
|
||
h2 { | ||
padding: 20px 0; | ||
text-align: center; | ||
font-weight: bold; | ||
border-bottom: 1px solid rgba(0,0,0,.12); | ||
|
||
margin-bottom: 0; | ||
} | ||
|
||
ul { | ||
margin: 0; | ||
padding: 0; | ||
|
||
li { | ||
font-size: 1.2rem; | ||
padding: 1rem; | ||
display: block; | ||
|
||
@extend .noselect; | ||
|
||
&:hover { | ||
cursor: pointer; | ||
} | ||
} | ||
} | ||
} |
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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SolutionComponent } from './solution.component'; | ||
|
||
describe('SolutionComponent', () => { | ||
let component: SolutionComponent; | ||
let fixture: ComponentFixture<SolutionComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ SolutionComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SolutionComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).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,67 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Title } from '@angular/platform-browser'; | ||
import { StorageMap } from '@ngx-pwa/local-storage'; | ||
import { ActivatedRoute, Params, Router } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'app-solution', | ||
templateUrl: './solution.component.html', | ||
styleUrls: ['./solution.component.scss'] | ||
}) | ||
export class SolutionComponent implements OnInit { | ||
solutions = [ | ||
{displayName: 'Coding', source: 'coding'}, | ||
]; | ||
currentSource: string; | ||
src: string; | ||
|
||
constructor(title: Title, private storage: StorageMap, private activatedRoute: ActivatedRoute, private router: Router) { | ||
title.setTitle('DevOps 知识平台 Ledge - 解决方案'); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.activatedRoute.queryParams.subscribe(params => { | ||
const source = params.source; | ||
if (source) { | ||
this.configSource(source); | ||
} else { | ||
this.getSourceFromLocalStorage(); | ||
} | ||
}); | ||
} | ||
|
||
private getSourceFromLocalStorage() { | ||
this.storage.get('solution.last').subscribe((value: string) => { | ||
if (!!value) { | ||
this.configSource(value); | ||
} else { | ||
this.configSource('coding'); | ||
} | ||
}); | ||
} | ||
|
||
private configSource(value: string) { | ||
this.currentSource = value; | ||
this.src = this.buildSrc(this.currentSource); | ||
} | ||
|
||
clickCase(source: string) { | ||
this.src = this.buildSrc(source); | ||
this.currentSource = source; | ||
|
||
this.storage.set('solution.last', source).subscribe(); | ||
|
||
const queryParams: Params = { source }; | ||
this.router.navigate( | ||
[], | ||
{ | ||
relativeTo: this.activatedRoute, | ||
queryParams, | ||
queryParamsHandling: 'merge', // remove to replace all query params by provided | ||
}); | ||
} | ||
|
||
private buildSrc(source: string) { | ||
return `assets/docs/solutions/${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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Coding DevOps 平台 |