合并为一个项目 #14
@@ -3,6 +3,7 @@ import {NzMessageService} from 'ng-zorro-antd';
|
||||
import {ApiService} from '../../../api/api.service';
|
||||
import {PageList} from '../../../class/HttpReqAndResp';
|
||||
import {Comment, CommentReq} from '../../../class/Comment';
|
||||
import {GlobalUserService} from '../../../services/global-user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin-comment',
|
||||
@@ -11,7 +12,23 @@ import {Comment, CommentReq} from '../../../class/Comment';
|
||||
})
|
||||
export class AdminCommentComponent implements OnInit {
|
||||
|
||||
constructor(private apiService: ApiService, private messageService: NzMessageService) {
|
||||
constructor(private apiService: ApiService, private messageService: NzMessageService, private userService: GlobalUserService) {
|
||||
this.userService.watchUserInfo({
|
||||
next: data => {
|
||||
if (data.result) {
|
||||
if (data.result.role === 'admin') {
|
||||
this.getComment = this.getCommentForAdmin;
|
||||
} else {
|
||||
this.getComment = this.getCommentForUser;
|
||||
}
|
||||
} else {
|
||||
this.getComment = this.getCommentForUser;
|
||||
}
|
||||
this.getComment()
|
||||
},
|
||||
error: null,
|
||||
complete: null
|
||||
})
|
||||
}
|
||||
|
||||
loading: boolean = true;
|
||||
@@ -23,12 +40,20 @@ export class AdminCommentComponent implements OnInit {
|
||||
content: new CommentReq(true),
|
||||
editFocus: false,
|
||||
}
|
||||
getComment: any;// 存放获取评论的方法
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getComment();
|
||||
}
|
||||
|
||||
getComment = () => this.apiService.getCommentByTypeForAdmin(true, this.pageIndex, this.pageSize).subscribe({
|
||||
|
||||
getCommentForAdmin = () => this.apiService.getCommentByTypeForAdmin(true, this.pageIndex, this.pageSize).subscribe({
|
||||
next: data => this.pageList = data.result,
|
||||
complete: () => this.loading = false,
|
||||
error: err => this.loading = false
|
||||
})
|
||||
|
||||
getCommentForUser = () => this.apiService.getCommentByTypeForUser(true, this.pageIndex, this.pageSize).subscribe({
|
||||
next: data => this.pageList = data.result,
|
||||
complete: () => this.loading = false,
|
||||
error: err => this.loading = false
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<div *ngIf="userInfo&&userInfo.role==='admin'">
|
||||
<div nz-row>
|
||||
<nz-card nzTitle="统计" nz-col nzSpan="12" nzSize="small">
|
||||
<nz-row [nzGutter]="24">
|
||||
@@ -40,3 +41,27 @@
|
||||
</nz-spin>
|
||||
</nz-card>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="userInfo&&userInfo.role==='user'">
|
||||
<div nz-row>
|
||||
<nz-card nzTitle="信息" nz-col nzSpan="6" nzOffset="1" nzSize="small">
|
||||
<nz-statistic [nzValue]="userInfo.recentlyLandedDate?userInfo.recentlyLandedDate:''"
|
||||
nzTitle="上次登录"></nz-statistic>
|
||||
</nz-card>
|
||||
<nz-card nzTitle="关于此博客" nzSize="small" nz-col nzSpan="6" nzOffset="2">
|
||||
<p>此博客由 <a href="https://github.com/xiaohai2271" target="_blank">禾几海(郑海)</a> 设计并实现的</p>
|
||||
<p>博客自2019年3月开始开发编写 5月开始正式运行至今</p>
|
||||
<p>博客所有代码都是开源的,你可以随意修改,运行和发布</p>
|
||||
<p>
|
||||
<a href="https://github.com/xiaohai2271/blog-backEnd" target="_blank">后端代码可以在此处找到</a>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<a href="https://github.com/xiaohai2271/blog-frontEnd" target="_blank">前端代码可以在此处找到</a>
|
||||
</p>
|
||||
<p>如果觉得博客还不错,请前往Github支持我,给我点一个star吧</p>
|
||||
</nz-card>
|
||||
<nz-card nz-col nzSpan="6" nzOffset="2">
|
||||
<p style="font-style: italic">坚强的信心,能使平凡的人做出惊人的事业。</p>
|
||||
<p style="text-align: right"> ——马尔顿</p>
|
||||
</nz-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,9 +11,6 @@ import {User} from '../../../class/User';
|
||||
})
|
||||
export class AdminDashboardComponent implements OnInit {
|
||||
constructor(private apiService: ApiService, private userService: GlobalUserService, private http: HttpClient) {
|
||||
this.getLog();
|
||||
this.getCounts();
|
||||
this.getDayVisitCount();
|
||||
this.getUserInfo();
|
||||
}
|
||||
|
||||
@@ -50,7 +47,14 @@ export class AdminDashboardComponent implements OnInit {
|
||||
})
|
||||
|
||||
getUserInfo = () => this.userService.watchUserInfo({
|
||||
next: data => this.userInfo = data.result,
|
||||
next: data => {
|
||||
this.userInfo = data.result
|
||||
if (data.result && data.result.role === 'admin') {
|
||||
this.getLog();
|
||||
this.getCounts();
|
||||
this.getDayVisitCount();
|
||||
}
|
||||
},
|
||||
error: null,
|
||||
complete: null
|
||||
})
|
||||
|
||||
@@ -2,7 +2,15 @@ import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {AdminDashboardComponent} from './admin-dashboard.component';
|
||||
import {RouterModule} from '@angular/router';
|
||||
import {NzButtonModule, NzCardModule, NzGridModule, NzIconModule, NzSpinModule, NzStatisticModule} from 'ng-zorro-antd';
|
||||
import {
|
||||
NzButtonModule,
|
||||
NzCardModule,
|
||||
NzDividerModule,
|
||||
NzGridModule,
|
||||
NzIconModule,
|
||||
NzSpinModule,
|
||||
NzStatisticModule
|
||||
} from 'ng-zorro-antd';
|
||||
|
||||
|
||||
@NgModule({
|
||||
@@ -15,7 +23,8 @@ import {NzButtonModule, NzCardModule, NzGridModule, NzIconModule, NzSpinModule,
|
||||
NzButtonModule,
|
||||
NzSpinModule,
|
||||
NzIconModule,
|
||||
NzStatisticModule
|
||||
NzStatisticModule,
|
||||
NzDividerModule
|
||||
]
|
||||
})
|
||||
export class AdminDashboardModule {
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
<!-- <span>分类管理</span>-->
|
||||
<!-- </li>-->
|
||||
|
||||
<!-- <li nz-menu-item routerLink="/admin/userInfo">-->
|
||||
<!-- <i nz-icon nzType="idcard" nzTheme="outline"></i>-->
|
||||
<!-- <span>修改信息</span>-->
|
||||
<!-- </li>-->
|
||||
<li nz-menu-item (click)="infoDrawerVisible = true">
|
||||
<i nz-icon nzType="idcard" nzTheme="outline"></i>
|
||||
<span>查看信息</span>
|
||||
</li>
|
||||
|
||||
<li nz-menu-item routerLink="/admin/user" *ngIf="user.role=='admin'">
|
||||
<i nz-icon nzType="user" nzTheme="outline"></i>
|
||||
@@ -95,19 +95,26 @@
|
||||
<br><br>
|
||||
<nz-descriptions [nzColumn]="1">
|
||||
<nz-descriptions-item nzTitle="邮箱">
|
||||
<!-- 抽屉的宽度是256px -->
|
||||
<div style="width: 256px">
|
||||
<i nz-icon nzType="mail" class="icon" nzTheme="twotone"></i>
|
||||
<span>{{user.email}}</span>
|
||||
<i nz-icon nzType="edit" class="edit-icon" nzTheme="twotone" (click)="showEditInfoModal()"></i>
|
||||
</div>
|
||||
</nz-descriptions-item>
|
||||
<nz-descriptions-item nzTitle="昵称">
|
||||
<div style="width: 256px">
|
||||
<i nz-icon nzType="crown" class="icon" nzTheme="twotone"></i>
|
||||
<span>{{user.displayName}}</span>
|
||||
<i nz-icon nzType="edit" class="edit-icon" nzTheme="twotone" (click)="showEditInfoModal()"></i>
|
||||
</div>
|
||||
</nz-descriptions-item>
|
||||
<nz-descriptions-item nzTitle="描述" *ngIf="user.desc">
|
||||
<div style="width: 256px">
|
||||
<i nz-icon nzType="info-circle" class="icon" nzTheme="twotone"></i>
|
||||
<span>{{user.desc}}</span>
|
||||
<i nz-icon nzType="edit" class="edit-icon" nzTheme="twotone" (click)="showEditInfoModal()"></i>
|
||||
</div>
|
||||
</nz-descriptions-item>
|
||||
</nz-descriptions>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user