Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #22 from karenia-works/lyf
Browse files Browse the repository at this point in the history
fix paginator,fix searchpage,edit adminpage
  • Loading branch information
lynzrand authored Dec 20, 2019
2 parents 9c80b0e + 603e1dc commit 484bda6
Show file tree
Hide file tree
Showing 16 changed files with 213 additions and 66 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</div>
<div *ngIf="hasBtn == true">
<div class="rightbtn">
<button class="btn edit-btn">修改</button>
<button class="btn delete-btn">删除</button>
<button (click)="clickEdit()" class="btn edit-btn">修改</button>
<button (click)="clickDelete()" class="btn delete-btn">删除</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class ArticleAbstractComponent implements OnInit {
@Input() hasBtn: boolean = false;

@Input() linked: boolean = true;
deleted: boolean = false;
constructor(private router: Router) {}

ngOnInit() {}
Expand All @@ -39,4 +40,12 @@ export class ArticleAbstractComponent implements OnInit {
this.router.navigateByUrl('/p/' + this.id);
}
}
clickEdit() {
// 接口
}
clickDelete() {
alert('删除');
this.deleted = true;
// 接口
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.paginator {
float : left
display: flex
flex-direction: row
margin: var(--theme-pad-03) calc(-1 * var(--theme-pad-01))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
</div>
<div class="right-panel">
<div class="title">{{name}}</div>
<div class="title" ngClass="{'link': linked}" (click)="jump()">{{name}}</div>
<div class="info">{{ proInfo }}</div>
<div class="tag-container">
<div class="tag" *ngFor="let tag of tags">
Expand All @@ -16,8 +16,8 @@
</div>
<div *ngIf="hasBtn == true">
<div class="rightbtn">
<button class="btn edit-btn">{{btn1Name}}</button>
<button class="btn delete-btn">{{btn2Name}}</button>
<button (click)="clickBtn1()" class="btn edit-btn">{{btn1Name}}</button>
<button (click)="clickBtn2()" class="btn delete-btn">{{btn2Name}}</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Component, OnInit, Input } from '@angular/core';

import { Router } from '@angular/router';
@Component({
selector: 'app-pro-abstract',
templateUrl: './pro-abstract.component.html',
styleUrls: ['./pro-abstract.component.styl']
})
export class ProAbstractComponent implements OnInit {
@Input() id: number;
@Input() name: string;
@Input() photoURL: string;
@Input() unit?: string;
Expand All @@ -19,10 +20,12 @@ export class ProAbstractComponent implements OnInit {
@Input() hasBtn: boolean = false;
@Input() btn1Name: string = '修改';
@Input() btn2Name: string = '删除';
constructor() { }

ngOnInit() {
}
@Input() linked: boolean = true;
deleted: boolean = false;
constructor(private router: Router) { }

ngOnInit() {this.id = 1}
get proInfo(): string {

return [this.unit, '发文:'.concat(this.articleCount.toString()),
Expand All @@ -31,4 +34,16 @@ export class ProAbstractComponent implements OnInit {
.filter(val => val !== undefined)
.join(' | ');
}
jump() {
if (this.linked && this.id) {
this.router.navigateByUrl('/prof/'+ this.id);
}
}
clickBtn1() {
// 1
}
clickBtn2() {
alert(this.btn2Name);
//
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</div>
<div *ngIf="hasBtn == true">
<div class="rightbtn">
<button class="btn edit-btn">修改</button>
<button class="btn delete-btn">删除</button>
<button (click)="clickEdit()" class="btn edit-btn">修改</button>
<button (click)="clickDelete()" class="btn delete-btn">删除</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export class UserAbstractComponent implements OnInit {

ngOnInit() {
}

clickEdit() {
//
}
clickDelete() {
alert('删除');
//
}
}

55 changes: 34 additions & 21 deletions src/pages/admin-page/article-manage/article-manage.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,42 @@
<h5><br/></h5>

<div class="left_part">
<app-searchbar [type]="'论文'"></app-searchbar>
<div *ngFor="let article of returnedArticles">
<app-article-abstract
[title]="article.title"
[articleType]="article.articleType"
[abstract]="article.abstract"
[authors]="article.authors"
[releaseDate]="article.releaseDate"
[tags]="article.tags"
[refCount]="article.refCount"
[downloadCount]="article.downloadCount"
[hasFile]="article.hasFile"
[showFavorite]="article.showFavorite"
[hasBtn]="true">
<app-searchbar [type]="'论文'"
[params]="queryParams"
(startQuery)="startQuery($event)"
[canShowAdvancedSearch]="true"></app-searchbar>
<div [ngClass]="pagerClass" *ngIf="articles.length !== 0">
<div class="article-wrapper">
<div *ngFor="let article of returnArticles">
<app-article-abstract
[title]="article.title"
[articleType]="article.type"
[abstract]="article.summary"
[authors]="article.authors"
[releaseDate]="article.date"
[tags]="article.keywords"
[refCount]="article.quote"
[hasFile]="article.site"
[showFavorite]="false"
[hasBtn]="true"
[id]="article.paperId"
>
</app-article-abstract>
</div>
</div>

</app-article-abstract>
<app-paginator
[totalItems]="totalCount"
[currentItem]="currentCount"
[itemsPerPage]="5"
[showBoundary]="true"
(pageChanged)="pageChanged($event)"
></app-paginator>
</div>
<div class="no-result" *ngIf="articles.length === 0 && searching">
<div class="jumbotron">啥都没搜到</div>
<div class="smaller">换一下关键词试试吧</div>
</div>
<app-paginator
[totalItems]="articles.length"
[itemsPerPage]="5"
[showBoundary]="true"
(pageChanged)="pageChanged($event)">
</app-paginator>
</div>

<div class="func_part">
Expand Down
77 changes: 71 additions & 6 deletions src/pages/admin-page/article-manage/article-manage.component.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,88 @@
import { Component, OnInit } from '@angular/core';
import {articles} from '../../../articleAbstractList';
import { PageChangedEvent } from '../../../components/base-components/paginator/paginator.component';

import { ActivatedRoute, Router } from '@angular/router';
import {
PaperSearchService as PaperQueryService,
PaperQueryParam,
paperQueryParamToWebQuery,
webQueryToPaperQueryParam,
} from 'src/services/data/paper-search.service';
import { Paper } from 'src/models/paper';
@Component({
selector: 'app-article-manage',
templateUrl: './article-manage.component.html',
styleUrls: ['./article-manage.component.styl']
})
export class ArticleManageComponent implements OnInit {
articles = articles;
returnedArticles;
constructor() { }
// articles = articles;
// returnedArticles;
constructor(
private queryService: PaperQueryService,
activeRoute: ActivatedRoute,
private router: Router
) {
activeRoute.queryParams.subscribe({
next: params => {
this.articles = [];
this.queryParams = webQueryToPaperQueryParam(params);
if (
this.queryParams.author ||
this.queryParams.keyword ||
this.queryParams.kw
) {
this.loading = true;
this.searching = true;
queryService
.query(this.queryParams)
.query()
.subscribe({
next: val => {
this.loading = false;
this.articles = val.data;
this.returnArticles = this.articles.slice(0, 5);
this.totalCount = val.totalCount;
this.currentCount = parseInt(params.skip, 10);
},
});
} else {
this.queryParams = { take: 20, skip: 0 };
this.searching = false;
}
},
});
}

queryParams: PaperQueryParam;

searching: boolean = false;
loading: boolean = true;

get pagerClass() {
return { loading: this.loading, pager: true };
}

articles: Paper[] = [];
// 分页组件配置项
private itemsPerpage: number = 20;
// 总条数
totalCount: number;
// 当前页码
currentCount: number = 0;
returnArticles: Paper[];
startQuery(query: PaperQueryParam) {
console.log('Searched', query);
this.router.navigate(['admin/article'], {
queryParams: paperQueryParamToWebQuery(query),
});
}

ngOnInit() {
this.returnedArticles = this.articles.slice(0, 5);

}
pageChanged(event: PageChangedEvent): void {
const startItem = (event.page - 1) * event.itemsPerPage;
const endItem = event.page * event.itemsPerPage;
this.returnedArticles = this.articles.slice(startItem, endItem);
this.returnArticles = this.articles.slice(startItem, endItem);
}
}
24 changes: 12 additions & 12 deletions src/pages/admin-page/pro-manage/pro-manage.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
<h5><br/></h5>

<div class="left_part">
<app-searchbar [type]="'专家'"></app-searchbar>
<div *ngFor="let pro of returnedPros">
<div *ngFor="let pro of professors">
<app-pro-abstract
[name]="pro.name"
[photoURL]="pro.photoURL"
[unit]="pro.unit"
[description]="pro.description"
[tags]="pro.tags"
[articleCount]="pro.articleCount"
[citationsCount]="pro.citationsCount"
[downloadCount]="pro.downloadCount"
[photoURL]="'https://pic3.zhimg.com/a82b51c4284beda5b29d645fa4f91c97_xl.jpg'"
[unit]="pro.institution"
[description]="pro.contract"
[tags]="pro.reachFields"
[articleCount]="30"
[citationsCount]="115"
[downloadCount]="65536"
[showFavorite]="true"
[hasBtn]="true">
[hasBtn]="true"
[id] = "pro.professorId">

</app-pro-abstract>
</div>
Expand All @@ -31,13 +31,13 @@ <h5><br/></h5>
<div class="func_h">
<a routerLink="../">个人中心</a>
</div>
<div class="func_t">
<div class="func_h">
<a routerLink="../user">用户管理</a>
</div>
<div class="func_h">
<a routerLink="../article">论文管理</a>
</div>
<div class="func_h">
<div class="func_t">
<a routerLink="." class="func_t">专家管理</a>
</div>
<div class="func_h">
Expand Down
Loading

0 comments on commit 484bda6

Please sign in to comment.