从"Blog"仓库中分离出来
This commit is contained in:
50
admin/src/app/pages/a-index/a-index.component.css
Normal file
50
admin/src/app/pages/a-index/a-index.component.css
Normal file
@@ -0,0 +1,50 @@
|
||||
.dashboardUl {
|
||||
width: 100%;
|
||||
padding: 1.6em;
|
||||
}
|
||||
|
||||
.dashboardUl i {
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.dashboardUl li {
|
||||
float: left;
|
||||
border-right: 1px solid #ececec;
|
||||
width: 25%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dashboardUl li:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.circle {
|
||||
border-radius: 50%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.log {
|
||||
margin-top: 20px;
|
||||
max-height: 500px;
|
||||
padding: 10px;
|
||||
background: #F8F8F8;
|
||||
}
|
||||
|
||||
.reloadLog {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 10px;
|
||||
z-index: 990;
|
||||
}
|
||||
|
||||
.card {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.card i {
|
||||
font-size: 40px;
|
||||
}
|
||||
71
admin/src/app/pages/a-index/a-index.component.html
Normal file
71
admin/src/app/pages/a-index/a-index.component.html
Normal file
@@ -0,0 +1,71 @@
|
||||
<!-- content start -->
|
||||
<div class="admin-content" id="index">
|
||||
<div class="admin-content-body" *ngIf="userService.userInfo&&userService.userInfo.role=='user'">
|
||||
<div>
|
||||
<div><strong class="part-title">首页</strong></div>
|
||||
</div>
|
||||
<h2 style="text-align: center;">
|
||||
Welcome {{userService.userInfo.displayName}}!
|
||||
</h2>
|
||||
|
||||
<nz-card class="card">
|
||||
<ul class="dashboardUl">
|
||||
<li style="width: 50%">
|
||||
<div><i nz-icon nzType="login" nzTheme="outline"></i></div>
|
||||
<p>上次登录</p>
|
||||
<p>{{userService.userInfo.recentlyLandedDate}}</p>
|
||||
</li>
|
||||
<li style="width: 50%">
|
||||
<div><i nz-icon nzType="environment" nzTheme="outline"></i></div>
|
||||
<p>您的ip和位置</p>
|
||||
<p>
|
||||
ip:{{ip}}
|
||||
<br>
|
||||
位置:{{location}}
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</nz-card>
|
||||
</div>
|
||||
|
||||
<!-- administrator page -->
|
||||
<div *ngIf="userService.userInfo&&userService.userInfo.role=='admin'">
|
||||
<nz-card>
|
||||
<ul class="dashboardUl">
|
||||
<li>
|
||||
<div><i nz-icon nzType="ie" nzTheme="outline"></i></div>
|
||||
<p>总访问量</p>
|
||||
<p>{{visitorService.totalVisitCount}}</p>
|
||||
</li>
|
||||
<li>
|
||||
<div><i nz-icon nzType="chrome" nzTheme="outline"></i></div>
|
||||
<p>今日访问量</p>
|
||||
<p>{{visitorService.dayVisit}}</p>
|
||||
</li>
|
||||
<li>
|
||||
<div><i nz-icon nzType="login" nzTheme="outline"></i></div>
|
||||
<p>上次登录</p>
|
||||
<p>{{userService.userInfo.recentlyLandedDate}}</p>
|
||||
</li>
|
||||
<li>
|
||||
<div><i nz-icon nzType="arrow-up" nzTheme="outline"></i></div>
|
||||
<p>上次更新</p>
|
||||
<p>{{webUpdateService.lastestUpdateTime}}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</nz-card>
|
||||
|
||||
<div style="position: relative">
|
||||
<button nz-button nzType="danger" nzShape="circle" class="reloadLog" (click)="readLog()">
|
||||
<i nz-icon nzType="reload" nzTheme="outline"></i>
|
||||
</button>
|
||||
<nz-spin [nzSpinning]="Loading">
|
||||
<pre class="log">
|
||||
{{this.logService.logText}}
|
||||
</pre>
|
||||
</nz-spin>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- content end -->
|
||||
25
admin/src/app/pages/a-index/a-index.component.spec.ts
Normal file
25
admin/src/app/pages/a-index/a-index.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AIndexComponent } from './a-index.component';
|
||||
|
||||
describe('AIndexComponent', () => {
|
||||
let component: AIndexComponent;
|
||||
let fixture: ComponentFixture<AIndexComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ AIndexComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AIndexComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
80
admin/src/app/pages/a-index/a-index.component.ts
Normal file
80
admin/src/app/pages/a-index/a-index.component.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {UserService} from '../../services/user/user.service';
|
||||
import {VisitorService} from '../../services/visitor/visitor.service';
|
||||
import {WebUpdateService} from '../../services/update/web-update.service';
|
||||
import {LogService} from '../../services/log/log.service';
|
||||
import {Observable} from 'rxjs';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-a-index',
|
||||
templateUrl: './a-index.component.html',
|
||||
styleUrls: ['./a-index.component.css']
|
||||
})
|
||||
export class AIndexComponent implements OnInit {
|
||||
|
||||
constructor(public userService: UserService,
|
||||
public visitorService: VisitorService,
|
||||
public webUpdateService: WebUpdateService,
|
||||
public logService: LogService) {
|
||||
}
|
||||
|
||||
Loading: boolean = false;
|
||||
ip: string;
|
||||
location: string;
|
||||
|
||||
ngOnInit() {
|
||||
if (this.userService.userInfo) {
|
||||
if (this.userService.userInfo.role === 'admin') {
|
||||
this.admin();
|
||||
} else {
|
||||
this.user();
|
||||
}
|
||||
} else {
|
||||
this.userService.getUserInfo().subscribe(data => {
|
||||
if (data.result.role === 'admin') {
|
||||
this.admin();
|
||||
} else {
|
||||
this.user();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
admin() {
|
||||
if (!this.visitorService.dayVisit) {
|
||||
this.visitorService.getDayVisitor();
|
||||
}
|
||||
this.visitorService.getTotalVisitorCount();
|
||||
if (!this.webUpdateService.lastestUpdateTime) {
|
||||
this.webUpdateService.getLastestUpdateTime();
|
||||
}
|
||||
this.readLog();
|
||||
}
|
||||
|
||||
user() {
|
||||
this.visitorService.getLocalIp().subscribe(data => {
|
||||
if (data.code === 0) {
|
||||
this.ip = data.result;
|
||||
const getip = this.visitorService.getIp(this.ip);
|
||||
if (getip instanceof Observable) {
|
||||
getip.subscribe(ipOb => {
|
||||
this.location = ipOb.result;
|
||||
});
|
||||
} else {
|
||||
this.location = getip;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
readLog() {
|
||||
this.Loading = true;
|
||||
this.logService.getLog().subscribe(date => {
|
||||
setTimeout(() => {
|
||||
this.Loading = false;
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user