- add sitelink-view-component with portal REST requests

This commit is contained in:
Arno Kaimbacher 2021-12-01 15:45:01 +01:00
parent 2c0c67cd64
commit 132edd4214
10 changed files with 216 additions and 15 deletions

View file

@ -209,7 +209,8 @@
<a href="#"><i class="fas fa-stamp"></i> Impressum</a>
</li>
<li class="list-group-item">
<a href="#"><i class="fas fa-link"></i> Sitelinks</a>
<!-- <a href="#"><i class="fas fa-link"></i> Sitelinks</a> -->
<router-link to="/sitelinks"><i class="fas fa-link"></i> Sitelinks</router-link>
</li>
<li class="list-group-item">
<a href="#"><i class="far fa-file-alt"></i> Terms &amp; Conditions</a>

View file

@ -4,7 +4,8 @@ import VsResult from "@/components/vs-result/vs-result.vue";
import FacetCategory from "@/components/face-category/facet-category.vue";
import ActiveFacetCategory from "@/components/active-facet-category/active-facet-category.vue";
import { SolrSettings } from "@/models/solr";
import { DatasetService } from "@/services/dataset.service";
// import { DatasetService } from "@/services/dataset.service";
import DatasetService from "../../services/dataset.service";
import { Suggestion, Dataset } from "@/models/dataset";
import { SolrResponse, FacetFields, FacetItem, FacetResults, FacetInstance } from "@/models/headers";
import { ActiveFilterCategories } from "@/models/solr";
@ -39,11 +40,11 @@ export default class SearchViewComponent extends Vue {
core: "rdr_data", // SOLR.core;
host: "tethys.at",
};
private rdrAPI!: DatasetService;
// private rdrAPI!: DatasetService;
private error = "";
mounted(): void {
this.rdrAPI = new DatasetService();
// this.rdrAPI = new DatasetService();
}
// onSearch(term: string): void {
@ -68,7 +69,7 @@ export default class SearchViewComponent extends Vue {
// this.facets = {};
this.searchTerm = suggestion;
this.rdrAPI.facetedSearch(suggestion, this.activeFilterCategories, this.solr.core, this.solr.host, undefined).subscribe(
DatasetService.facetedSearch(suggestion, this.activeFilterCategories, this.solr.core, this.solr.host, undefined).subscribe(
(res: SolrResponse) => this.dataHandler(res),
(error: any) => this.errorHandler(error),
);
@ -152,7 +153,7 @@ export default class SearchViewComponent extends Vue {
if (!this.activeFilterCategories[facetItem.category].some((e) => e === facetItem.val)) {
this.activeFilterCategories[facetItem.category].push(facetItem.val);
this.rdrAPI.facetedSearch(this.searchTerm, this.activeFilterCategories, this.solr.core, this.solr.host, undefined).subscribe(
DatasetService.facetedSearch(this.searchTerm, this.activeFilterCategories, this.solr.core, this.solr.host, undefined).subscribe(
(res: SolrResponse) => this.dataHandler(res, facetItem),
(error: any) => this.errorHandler(error),
);
@ -198,7 +199,7 @@ export default class SearchViewComponent extends Vue {
// alert(categoryName);
delete this.activeFilterCategories[categoryName];
this.rdrAPI.facetedSearch(this.searchTerm, this.activeFilterCategories, this.solr.core, this.solr.host, undefined).subscribe(
DatasetService.facetedSearch(this.searchTerm, this.activeFilterCategories, this.solr.core, this.solr.host, undefined).subscribe(
(res: SolrResponse) => {
this.results = res.response.docs;
this.numFound = res.response.numFound;

View file

@ -0,0 +1,64 @@
import { Observable, Subscription } from "rxjs";
import { Options, Vue } from "vue-class-component";
import DatasetService from "../../services/dataset.service";
import { DbDataset } from "@/models/dataset";
@Options({
name: "SitelinkViewComponent",
})
export default class SitelinkViewComponent extends Vue {
public years: string[] = [];
public selected = "";
private error = "";
// private subscription!: Subscription;
private subscriptions: Array<Subscription> = [];
public datasets: Array<DbDataset> = [];
// constructor() {
// super();
// // this.rdrAPI = new DatasetService();
// }
beforeMount() {
// this.rdrAPI = new DatasetService();
this.getYears();
}
getYears() {
const newSubs: Subscription = DatasetService.getYears().subscribe(
(res: string[]) => this.dataHandler(res),
(error: any) => this.errorHandler(error),
() => newSubs.unsubscribe(),
);
// this.subscriptions.push(newSubs);
}
beforeUnmount() {
//unsunscribe to ensure no memory leaks
// this.subscription.unsubscribe();
for (const subs of this.subscriptions) {
subs.unsubscribe();
}
}
select(year: string) {
this.selected = year;
const newSubs = DatasetService.getDocuments(year).subscribe(
(res: Array<DbDataset>) => {
this.datasets = res;
},
(error: any) => this.errorHandler(error),
);
this.subscriptions.push(newSubs);
}
private dataHandler(res: string[]): void {
// this.results = datasets;
this.years = res;
}
private errorHandler(err: any): void {
this.error = err;
// this.loading = false;
}
}

View file

@ -0,0 +1,77 @@
<template>
<div class="container">
<section class="section">
<div class="title has-text-centered">
<h1 class="title">Sitelinks for Web Crawlers</h1>
<!-- <p class="lead">Want to keep updated or need further information?</p> -->
<hr class="center-line" />
</div>
<!-- <div class="column">
<span>
<a href="" v-for="(year, index) in years" :key="index">
{{ year }}
</a>
</span>
</div> -->
<div class="columns is-mobile is-centered">
<div class="column is-6">
<div class="list" v-if="years.length > 0">
<ul class="block-list has-radius is-primary">
<li v-for="(year, index) in years" :key="index" :class="{ highlight: year == selected }" @click="select(year)">
{{ year }}
</li>
</ul>
</div>
</div>
</div>
<div class="columns is-mobile is-centered">
<div class="column is-6">
<ol v-if="datasets.length > 0">
<li v-for="(dataset, index) in datasets" :key="index">
<div class="post">
<header class="post-header">
<h2 class="post-title">
<a>{{ dataset.type }}; {{ dataset.publish_id }}</a>
</h2>
</header>
</div>
</li>
</ol>
</div>
</div>
</section>
</div>
</template>
<script lang="ts">
import SitelinkViewComponent from "./sitelink-view-component";
export default SitelinkViewComponent;
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss">
.block-list li.is-primary,
.block-list.is-primary > li {
background: #00d1b2;
color: #fff;
}
.block-list li.has-radius,
.block-list.has-radius > li {
border-radius: 4px;
}
.block-list li {
padding: 16px;
background: #f5f5f5;
margin-bottom: 0.25rem;
}
// .block-list li:hover {
// color: red;
// }
.block-list li.highlight {
background: #6b716f;
}
</style>