从"Blog"仓库中分离出来

This commit is contained in:
小海
2019-11-28 19:26:45 +08:00
commit c2aaf280db
616 changed files with 104128 additions and 0 deletions

View 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;
}

View 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 -->

View 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();
});
});

View 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);
});
}
}