Skip to content

Commit

Permalink
Merge pull request #9 from ssysm/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
ssysm committed Feb 4, 2018
2 parents 661ef20 + fbeea37 commit 931cfbb
Show file tree
Hide file tree
Showing 35 changed files with 1,021 additions and 60 deletions.
19 changes: 19 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"file-input-accessor": "^1.0.9",
"jquery": "^3.3.1",
"rxjs": "^5.5.2",
"sweetalert": "^2.1.0",
"zone.js": "^0.8.14"
},
"devDependencies": {
Expand Down
15 changes: 12 additions & 3 deletions client/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {ActivityManagementComponent} from "./view/admin/activity-management/acti
import {WorkManagementComponent} from "./view/admin/work-management/work-management.component";
import {AuthComponent} from "./view/admin/auth/auth.component";
import {AdminGuardService} from "./common/admin-guard.service";
import {FundingManagementComponent} from "./view/admin/funding-management/funding-management.component";
import {QaComponent} from "./view/qa/qa.component";

const routes: Routes = [
{
Expand Down Expand Up @@ -48,7 +48,16 @@ const routes: Routes = [
},
{
path:'about',
component:AboutComponent
children:[
{
path:'',
component:AboutComponent
},
{
path:'question',
component:QaComponent
}
]
},
{
path:'admin',
Expand Down Expand Up @@ -87,7 +96,7 @@ const routes: Routes = [
{
path:'**',
redirectTo:'/404'
}
},
];

@NgModule({
Expand Down
15 changes: 11 additions & 4 deletions client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ import {FileInputAccessorModule} from "file-input-accessor";
import { FundingManagementComponent } from './view/admin/funding-management/funding-management.component';
import {VersionService} from "./service/version.service";
import {environment} from "../environments/environment";

import { QaComponent } from './view/qa/qa.component';
import { QaService } from './service/qa.service';
import { QaManagementComponent } from './view/admin/qa-management/qa-management.component';
import { TextSlicePipe } from './common/pipe/text-slice.pipe';


@NgModule({
Expand All @@ -52,7 +55,10 @@ import {environment} from "../environments/environment";
WorkManagementComponent,
FooterComponent,
AuthComponent,
FundingManagementComponent
FundingManagementComponent,
QaComponent,
QaManagementComponent,
TextSlicePipe,
],
imports: [
BrowserModule,
Expand All @@ -72,8 +78,9 @@ import {environment} from "../environments/environment";
VersionService,
{
provide: BrowserXhr,
useClass:cros
}
useClass:cros,
},
QaService
],
bootstrap: [AppComponent]
})
Expand Down
20 changes: 12 additions & 8 deletions client/src/app/common/admin-guard.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import {AuthService} from "../service/auth.service";
import {Router} from "@angular/router";
import {ActivatedRouteSnapshot, Router, RouterStateSnapshot} from "@angular/router";
import {Observable} from "rxjs/Observable";

@Injectable()
export class AdminGuardService {
Expand All @@ -10,13 +11,16 @@ export class AdminGuardService {
private router:Router
) { }

canActivate(){
if(this.authService.isLoggedIn()){
return true;
}else {
this.router.navigate(['/']);
return false;
}
canActivate(route:ActivatedRouteSnapshot, state:RouterStateSnapshot):Observable<boolean>|boolean {
let the_cookie = document.cookie.split(';');
let token = the_cookie[0].split("=")[1];
if(token){
return true
}else{
this.router.navigate(['/']);
return false;
}

}

}
16 changes: 16 additions & 0 deletions client/src/app/common/pipe/text-slice.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'textSlice'
})
export class TextSlicePipe implements PipeTransform {

transform(value: String, args?: number): String {
if(value.length <= args){
return value
}else{
return value.slice(0,args)+"..."
}
}

}
5 changes: 0 additions & 5 deletions client/src/app/service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@ export class AuthService {
.get(environment.apiBase+'/users/status');
}

isLoggedIn(){
return localStorage.getItem('loggedIn') == 'true';
}


}
39 changes: 39 additions & 0 deletions client/src/app/service/qa.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core';
import {Http, RequestOptions} from "@angular/http";
import {environment} from "../../environments/environment";

@Injectable()
export class QaService {

constructor(
private http:Http
) { }

fetchQaList(page:number,limit:number){
return this.http
.get(environment.apiBase+'/qa?page='+page+'&limit='+limit)
}

createQa(data){
return this.http
.post(environment.apiBase+'/qa/ask',data)
}

fetchAllQaList(page:number,limit:number){
return this.http
.get(environment.apiBase+'/qa/all?page='+page+'&limit='+limit)
}

answerQa(data){
return this.http
.patch(environment.apiBase+'/qa/answer',data)
}

deleteQa(uid:String){
return this.http
.delete(environment.apiBase+'/qa/delete',new RequestOptions({
body: {uid:uid}
}))
}

}
11 changes: 10 additions & 1 deletion client/src/app/view/about/about.component.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
.introh1{
color: #23b1f7;
}
.intro{
font-size: large;
font-family: "微软雅黑",-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
.blockquote{
border-left:5px solid #eee
border-left:5px solid #eee;
font-size: large;
}
.qBox{
padding: 25px;
text-align: center;
}
14 changes: 9 additions & 5 deletions client/src/app/view/about/about.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ <h1 class="text-center introh1 h1">关于我们</h1>
<footer class="blockquote-footer">Aqours<cite title="Source Title">夢で夜空を照らしたい</cite></footer>
</blockquote>
<div class="row" id="sysInfo">
<div class="col-sm-12">
<div class="col-md-6 col-sm-12">
<p class="h5">Latest System Releases: <span class="badge badge-success">{{Version}}</span></p>
<div style="display: inline">
<p style="display: inline">Front-End: <span class="badge badge-success">v1.0.3</span></p>
<p style="display: inline">Back-End: <span class="badge badge-success">v1.0.3</span></p>
<p>Latest Commit: <span class="badge badge-info">{{commit}}</span></p>
<div style="display: inline">
<p style="display: inline">Front-End: <span class="badge badge-success">v1.0.4</span></p>
<p style="display: inline">Back-End: <span class="badge badge-success">v1.0.4</span></p>
<p>Latest Commit: <span class="badge badge-info">{{commit}}</span></p>
</div>
</div>
<div class="col-md-6 col-sm-12 qBox">
<p class="h3">Any Questions?</p>
<button class="btn btn-info" routerLink="/about/question">Question Box</button>
</div>
</div>
</div>
1 change: 0 additions & 1 deletion client/src/app/view/admin/auth/auth.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class AuthComponent implements OnInit {
) { }

loginForm: FormGroup;

ngOnInit() {
this.loginForm = new FormGroup({
username: new FormControl('',[
Expand Down
6 changes: 6 additions & 0 deletions client/src/app/view/admin/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<li class="nav-item">
<a href="#funding" data-toggle="tab" class="nav-link">众筹列表</a>
</li>
<li class="nav-item">
<a href="#qa" data-toggle="tab" class="nav-link">问题列表</a>
</li>
</ul>
<div class="tab-content">
<div id="work" class="container tab-pane active"><br>
Expand Down Expand Up @@ -56,6 +59,9 @@
<div class="container tab-pane fade" id="funding">
<app-funding-management></app-funding-management>
</div>
<div class="container tab-pane fade" id="qa">
<app-qa-management></app-qa-management>
</div>
</div>
</div>
<router-outlet></router-outlet>
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
</table>
</div>
</div>
<div class="modal fade" id="addFund" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal fade" id="addFund" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">新众筹人</h5>
<h5 class="modal-title">新众筹人</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a{
margin: 10px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<div class="container" *ngIf="qaList">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">问题</th>
<th scope="col">提问时间</th>
<th scope="col">操作</th>
</tr>
</thead>
<tbody *ngFor="let qa of qaList">
<tr>
<th scope="row">{{qa._id | textSlice:12}}</th>
<td>{{qa.question|textSlice:8}}</td>
<td>{{qa.created | date : 'yyyy/mm/dd HH:ss'}}</td>
<td>
<button class="btn btn-info" (click)="cQaId=qa._id" *ngIf="!qa.answered" data-toggle="modal" data-value="{{qa._id}}" data-target="#qaAnswerBox">回答</button>
<a (click)="deleteQa(qa._id)" style="cursor: pointer;color:red">删除</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="modal fade" id="qaAnswerBox" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">回答问题</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form (ngSubmit)="answerQa(f.value)" #f="ngForm" [formGroup]="qaAnswerForm">
<div class="form-group">
<label for="uid" class="col-form-label">问题ID:</label>
<input type="text" formControlName="uid" [ngModel]="cQaId" class="form-control disabled" name="uid" disabled id="uid">
</div>
<div class="form-group">
<label for="message-text" class="col-form-label">回复:</label>
<textarea class="form-control" name="answer" formControlName="answer" id="message-text" style="resize: none;"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-primary" *ngIf="qaAnswerForm.valid">回复</button>
</div>
</form>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { QaManagementComponent } from './qa-management.component';

describe('QaManagementComponent', () => {
let component: QaManagementComponent;
let fixture: ComponentFixture<QaManagementComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ QaManagementComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(QaManagementComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit 931cfbb

Please sign in to comment.