Skip to content

Commit

Permalink
Add app global setting
Browse files Browse the repository at this point in the history
  • Loading branch information
honza-rychtar committed Mar 9, 2018
1 parent a80aa69 commit 934ab42
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 61 deletions.
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AppSettings } from './services/app-settings';
import { PeriodicalFulltextItemComponent } from './periodical/periodical-content/periodical-fulltext-layout/periodical-fulltext-item/periodical-fulltext-item.component';
import { PeriodicalFulltextLayoutComponent } from './periodical/periodical-content/periodical-fulltext-layout/periodical-fulltext-layout.component';
import { MusicService } from './services/music.service';
Expand Down Expand Up @@ -199,7 +200,8 @@ const ROUTES: Routes = [
CollectionService,
HistoryService,
AltoService,
MusicService
MusicService,
AppSettings
],
bootstrap: [AppComponent]
})
Expand Down
8 changes: 4 additions & 4 deletions src/app/logo/logo.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppSettings } from './../services/app-settings';
import { Component, OnInit } from '@angular/core';
import { environment } from '../../environments/environment';

@Component({
selector: 'app-logo',
Expand All @@ -10,9 +10,9 @@ export class LogoComponent implements OnInit {
logo;
title;

constructor() {
this.title = environment.title;
this.logo = environment.logo;
constructor(private appSettings: AppSettings) {
this.title = appSettings.title;
this.logo = appSettings.logo;
}

ngOnInit() {
Expand Down
12 changes: 6 additions & 6 deletions src/app/search/search_query.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { environment } from '../../environments/environment';
import { Utils } from '../services/utils.service';
import { AppSettings } from '../services/app-settings';

export class SearchQuery {
accessibility: string;
Expand Down Expand Up @@ -206,11 +206,11 @@ export class SearchQuery {
q += '&q1=' + qString
+ '&fl=PID,dostupnost,model_path,dc.creator,root_title,root_pid,datum_str,img_full_mime,score'
+ '&group=true&group.field=root_pid&group.ngroups=true&group.sort=score desc';
if (environment.solr.facetTruncate) {
q += '&group.truncate=true';
} else {
q += '&group.facet=true';
}
// if (environment.solr.facetTruncate) {
q += '&group.truncate=true';
// } else {
// q += '&group.facet=true';
// }
} else {
q += '&fl=PID,dostupnost,fedora.model,dc.creator,dc.title,datum_str,img_full_mime';
}
Expand Down
14 changes: 14 additions & 0 deletions src/app/services/app-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Injectable } from '@angular/core';

declare var APP_GLOBAL: any;

@Injectable()

export class AppSettings {

public title = APP_GLOBAL.title;
public logo = APP_GLOBAL.logo;
public url = APP_GLOBAL.url;
public joinedDoctypes = APP_GLOBAL.joinedDoctypes;
public doctypes = APP_GLOBAL.doctypes;
}
5 changes: 3 additions & 2 deletions src/app/services/kramerius-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import { UnauthorizedError } from '../common/errors/unauthorized-error';
import { Response } from '@angular/http/src/static_response';
import { environment } from '../../environments/environment';
import { AppSettings } from './app-settings';

@Injectable()
export class KrameriusApiService {
Expand All @@ -37,8 +37,9 @@ export class KrameriusApiService {

constructor(private http: Http,
private utils: Utils,
private appSettings: AppSettings,
private solrService: SolrService) {
this.BASE_URL = environment.url;
this.BASE_URL = appSettings.url;
this.API_URL = this.BASE_URL + '/search/api/v5.0';
}

Expand Down
8 changes: 3 additions & 5 deletions src/app/services/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SearchQuery } from './../search/search_query.model';
import { Page } from './../model/page.model';
import { Injectable } from '@angular/core';
import { CollectionService } from './collection.service';
import { environment } from '../../environments/environment';
import { AppSettings } from './app-settings';


@Injectable()
Expand All @@ -32,19 +32,17 @@ export class SearchService {

activeMobilePanel: String;

solrConfig;

constructor(
private router: Router,
private collectionService: CollectionService,
private solrService: SolrService,
private localStorageService: LocalStorageService,
private krameriusApiService: KrameriusApiService,
private appSettings: AppSettings,
private translator: Translator) {
translator.languageChanged.subscribe(() => {
this.translateCollections();
});
this.solrConfig = environment.solr;
}


Expand Down Expand Up @@ -175,7 +173,7 @@ export class SearchService {
break;
}
case 'doctypes': {
this.doctypes = this.solrService.facetDoctypeList(response, this.solrConfig.joinedDoctypes, this.solrConfig.doctypes);
this.doctypes = this.solrService.facetDoctypeList(response, this.appSettings.joinedDoctypes, this.appSettings.doctypes);
break;
}
case 'authors': {
Expand Down
2 changes: 0 additions & 2 deletions src/app/services/solr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ export class SolrService {
} else {
item.doctype = dp;
}
console.log('qqqqqq', query);
if (item.doctype === 'periodical') {
if (query.accessibility !== 'all') {
params['accessibility'] = query.accessibility;
Expand All @@ -195,7 +194,6 @@ export class SolrService {
item.authors = doc['dc.creator'];
item.resolveUrl();
item.params = params;
console.log(item);
items.push(item);
}
return items;
Expand Down
8 changes: 8 additions & 0 deletions src/assets/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var APP_GLOBAL = {
title: 'Moravská zemská knihovna',
logo: 'http://registr.digitalniknihovna.cz/libraries/mzk/logo',
url: 'https://kramerius.mzk.cz',
ga: 'UA-65303593-14',
joinedDoctypes: true,
doctypes: ['monograph', 'periodical', 'map', 'graphic', 'archive', 'manuscript', 'soundrecording', 'sheetmusic']
};
41 changes: 1 addition & 40 deletions src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,3 @@
export const environment = {
production: true,
// MZK
// title: 'Moravská zemská knihovna',
// logo: 'http://registr.digitalniknihovna.cz/libraries/mzk/logo',
// url: 'https://kramerius.mzk.cz',
// solr: {
// joinedDoctypes: true,
// facetTruncate: true,
// doctypes: ['monograph', 'periodical', 'map', 'graphic', 'archive', 'manuscript', 'soundrecording', 'sheetmusic']
// }

// KNAV
// title: 'Knihovna Akademie věd ČR',
// logo: 'http://registr.digitalniknihovna.cz/libraries/knav/logo',
// url: 'https://kramerius.lib.cas.cz',
// solr: {
// joinedDoctypes: false,
// facetTruncate: true,
// doctypes: ['monograph', 'periodical']
// }

// NKP
// title: 'Národní knihovna České republiky',
// logo: 'http://registr.digitalniknihovna.cz/libraries/nkp/logo',
// url: 'http://kramerius4.nkp.cz',
// solr: {
// joinedDoctypes: false,
// facetTruncate: true,
// doctypes: ['monograph', 'periodical', 'map', 'sheetmusic']
// }

// MLP
title: 'Městská knihovna v Praze',
logo: 'http://registr.digitalniknihovna.cz/libraries/mlp/logo',
url: 'http://kramerius4.mlp.cz',
solr: {
joinedDoctypes: true,
facetTruncate: true,
doctypes: ['monograph', 'periodical', 'soundrecording', 'sheetmusic']
}
production: true
};
3 changes: 2 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<script type="text/javascript" src="assets/globals.js"></script>
<app-root>...</app-root>
<script>
(function(i, s, o, g, r, a, m) {
Expand All @@ -22,7 +23,7 @@
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'gaaa');
gaaa('create', 'UA-65303593-14', 'auto');
gaaa('create', APP_GLOBAL.ga, 'auto');
// gaaa('create', 'UA-65303593-16', 'auto');
</script>

Expand Down

0 comments on commit 934ab42

Please sign in to comment.