This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from karenia-works/lyf
fix paginator,fix searchpage,edit adminpage
- Loading branch information
Showing
16 changed files
with
213 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/components/base-components/paginator/paginator.component.styl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 71 additions & 6 deletions
77
src/pages/admin-page/article-manage/article-manage.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.