1
0

Add Soinumpa Service (tests)

This commit is contained in:
Siroco 2019-05-14 22:21:05 +02:00
parent 9770e1b8f9
commit 57d82596db
7 changed files with 2575 additions and 9 deletions

View File

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { GeojsonService } from './geojson.service';
describe('GeojsonService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: GeojsonService = TestBed.get(GeojsonService);
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,36 @@
import { Injectable } from '@angular/core';
import { HttpClient,HttpResponse } from '@angular/common/http';
import { Observable,of } from 'rxjs';
import soinumapa from "../assets/geojson/soinumapa.json";
@Injectable({
providedIn: 'root'
})
export class GeojsonService {
constructor(private http: HttpClient) {
this.items = soinumapa.features as JSON
this.total_pages
let pages = Object.keys(this.items).length/this.per_page
if (pages%1!=0) pages=Math.floor(pages)+1
this.total_pages = pages
}
items:JSON
per_page:number=10
total_pages:number=0
getTotalPages():number { return this.total_pages }
getItems(feed:any):any {
let page = feed.page
let start = (page-1)*this.per_page
let end = (page-1)*this.per_page+this.per_page
return this.items.slice( start, end)
}
getCount():any {
return Object.keys(this.items).length
}
}

View File

@ -2,6 +2,7 @@
* {font-family:"Nunito",sans-serif;transition: opacity 1s ease-in-out;}
a { text-decoration:none;color:#333;}
ul { display:flex; flex-wrap:wrap; list-style:none;padding:0;margin:0;width:720px;margin:auto;clear:both;min-height:100px;}
ul li {padding:0;margin:0; width:100vw;float:left;margin-bottom:20px;}
@ -9,7 +10,7 @@ ul.feeds li {width:10vw;}
ul li a {text-decoration:none;color:#000;}
ul li a:hover {opacity:0.8;}
ul li a img {max-width:100px;float:left;}
ul li a div.content-right {width:550px;padding:0 20px;float:left;}
ul li a div.content-right {width:500px;padding:0 20px;float:left;}
ul li a div.content-right p {margin-top:0;}
ul li.more {border:2px solid transparent; font-weight:bold;width:100%;text-align:center;background-color:#000;color:#fff;padding:5px 0;cursor:pointer;}
ul li.more:hover { opacity:0.8;}
@ -22,17 +23,18 @@ div.term:hover {font-weight:bold;background-color:#333;cursor:pointer;}
ul.counter {position:fixed;top:0;left:0;background:#ccc;z-index:-100;padding:30px;}
span.big-number {font-size:10vmin;transition:1s;font-weight:bold;color:#fff;}
ul.footer {position:fixed;bottom:0;right:0;background:#ccc;z-index:-100;padding:30px;}
ul.footer {position:fixed;bottom:0;right:0;z-index:-100;padding:30px;}
ul li.item {border:2px solid transparent;background:#fff;padding:10px;transition:1s;}
ul li.item:hover {border:2px solid #000;background:#fefefe;}
ul li.item {border-left:20px solid;background:#fff;padding:10px;transition:1s;}
ul li.item:hover {background:#eee;}
.oralitatgasconha {color:#F29A14 !important;}
.oralitatgasconha:hover {border-color:#F29A14 !important;}
.oralitatgasconha {border-color:#F29A14 !important;}
.bambun {color:#FA2D49 !important;}
.bambun:hover {border-color:#FA2D49 !important;}
.bambun {border-color:#FA2D49 !important;}
.binauralnodar {color:#559D30 !important;}
.binauralnodar:hover {border-color:#559D30 !important;}
.binauralnodar {border-color:#559D30 !important;}
.soinumapa {color:#913BBB !important; border-color:#913BBB !important;}
.blink {
animation: opacityLoading 2s 2s infinite linear;

View File

@ -29,5 +29,5 @@
<ul class="footer">
<ul><li *ngFor="let feed of feeds" style="text-align:right;font-size:2em;" [ngClass]="feed.slug"><span class="feeder blink" [ngClass]="{'active':feed.status}"><span *ngIf="!feed.status">Loading</span> {{feed.name}} <span style="display:none">[{{feed.page}}/{{feed.total_pages}}]</span></span></li></ul>
<p style="text-align:right;width:100%;font-size:0.8em;font-weight:bold;">Tramontana Archive - <a href="https://git.audio-lab.org/">Fork me</a></p>
<p style="text-align:right;width:100%;font-size:0.8em;font-weight:bold;">Tramontana Archive - <a href="https://git.audio-lab.org/lrullo/tau_frontend">Fork me</a></p>
</ul>

View File

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { WordpressService } from '../wordpress.service';
import { OmekaClassicService } from '../omeka-classic.service';
import { GeojsonService } from '../geojson.service';
import { Observable } from 'rxjs';
import { Item } from '../item';
@ -21,7 +22,8 @@ export class GridComponent implements OnInit {
{type:"wordpress", categories:"https://www.gransassolagaich.it/wp-json/wp/v2/categories", url:"https://www.gransassolagaich.it/wp-json/wp/v2/posts?_embed",slug:'bambun',name:"Bambun",status:0,per_page:10,page:1,total_pages:0},
{type:"wordpress", categories:"https://www.archive.binauralmedia.org/wp-json/wp/v2/categories", url:"https://www.archive.binauralmedia.org/wp-json/wp/v2/avada_portfolio?_embed",slug:'binauralnodar',name:"Binaural",status:0,per_page:10,page:1,total_pages:0},
// {type:"wordpress", url:"http://backend.industriapaisaia.eus/wp-json/wp/v2/posts?_embed",name:"Local",status:0},
{type:"omeka", categories:"http://oralitat", url:"https://tramontana.audio-lab.org/oralitatdegasconha/",name:"Oralitat de Gasconha",slug:'oralitatgasconha',status:0,per_page:10,page:1,total_pages:0}
{type:"geojson", categories:"",url:"http://www.soinumapa.net/geojson/",name:"Audiolab",slug:"soinumapa",status:0,per_page:10,page:1,total_pages:0},
{type:"omeka", categories:"http://oralitat", url:"https://tramontana.audio-lab.org/oralitatdegasconha/",name:"Oralitat de Gasconha",slug:'oralitatgasconha',status:0,per_page:10,page:1,total_pages:0},
]
// feedsCategories = [
// {type:"wordpress", url:"https://www.gransassolagaich.it/wp-json/wp/v2/categories",name:"Bambun",status:0},
@ -35,6 +37,7 @@ export class GridComponent implements OnInit {
constructor(
private wService:WordpressService,
private oService:OmekaClassicService,
private gService:GeojsonService,
) { }
ngOnInit() {
@ -132,6 +135,30 @@ export class GridComponent implements OnInit {
}
)
}
else if (feed.type==="geojson") {
let features = this.gService.getItems(feed)
feed.total_pages = this.gService.getTotalPages()
let numItems = this.gService.getCount()
this.countItems+=numItems
feed.status = 1
features.map(
(feature) => {
let i = feature.properties
if (i) {
let item:Item = {
id:feed.slug+"_"+i.id,
repository:feed.name,
repositorySlug:feed.slug,
title:i.title,
description:i.content.replace(/(<([^>]+)>)/ig,""),
link:i.href,
thumbnail:'',
}
this.items.push(item)
}
}
)
}
/** omeka **/
else if (feed.type==="omeka") {
this.oService.getItems(feed)

File diff suppressed because one or more lines are too long

5
src/typings.d.ts vendored
View File

@ -3,3 +3,8 @@ declare var module: NodeModule;
interface NodeModule {
id: string;
}
declare module "*.json" {
const value: any;
export default value;
}