in app/src/app/pages/explore/explore.component.ts [80:127]
update(upd: boolean = true) {
if (!this.params || !this.params.query) { return; }
const query = JSON.stringify(this.jsonParser.parse(this.params.query));
const sort = (this.params.sort !== '')
? JSON.stringify(this.jsonParser.parse(this.params.sort))
: '{}';
const project = (this.params.project !== '')
? JSON.stringify(this.jsonParser.parse(this.params.project))
: '{}';
if (!query || !sort) { return ; }
if (upd) {
this.router.navigate([], {
relativeTo: this.activatedRoute,
queryParams: this.params
});
}
// Set loading status
this.loading.content = true;
this.loading.count = true;
// Reset status
this.items = [];
this.count.total = 0;
// Load Content
this.mongoDb.query(this.server, this.database, this.collection, query, project, sort, this.params.skip, this.params.limit)
.subscribe((res: any) => {
this.loading.content = false;
if (res.ok) {
this.items = res.results;
}
});
// Count documents
this.mongoDb.count(this.server, this.database, this.collection, query)
.subscribe((res: any) => {
this.loading.count = false;
if (res.ok) {
this.count.total = res.count;
this.count.start = this.params.skip;
}
});
}