From 0e094836682903ca6d548fda1a64b29979a9e34f Mon Sep 17 00:00:00 2001 From: Luka van der Plas Date: Tue, 4 Jun 2024 19:13:50 +0200 Subject: [PATCH 1/2] add page titles --- frontend/src/app/about/about.component.ts | 6 ++++-- .../src/app/corpus-info/corpus-info.component.ts | 11 +++++++++-- .../src/app/document-page/document-page.component.ts | 4 ++++ .../download-history/download-history.component.ts | 6 +++++- .../search-history/search-history.component.ts | 8 ++++++-- frontend/src/app/home/home.component.ts | 5 +++-- frontend/src/app/login/login.component.html | 2 +- frontend/src/app/login/login.component.ts | 3 ++- .../app/login/registration/registration.component.ts | 9 +++++++-- .../login/reset-password/request-reset.component.ts | 12 ++++++++++-- .../reset-password/reset-password.component.html | 2 +- .../login/reset-password/reset-password.component.ts | 11 ++++++----- .../app/login/verify-email/verify-email.component.ts | 6 +++++- frontend/src/app/manual/manual.component.ts | 9 +++++++-- frontend/src/app/menu/menu.component.ts | 6 +----- frontend/src/app/privacy/privacy.component.html | 2 +- frontend/src/app/privacy/privacy.component.ts | 11 +++++++---- frontend/src/app/search/search.component.ts | 4 ++++ frontend/src/app/settings/settings.component.ts | 12 +++++++++--- .../app/tag/tag-overview/tag-overview.component.ts | 6 +++++- frontend/src/app/utils/app.ts | 4 ++++ .../src/app/word-models/word-models.component.ts | 5 ++++- 22 files changed, 105 insertions(+), 39 deletions(-) create mode 100644 frontend/src/app/utils/app.ts diff --git a/frontend/src/app/about/about.component.ts b/frontend/src/app/about/about.component.ts index 5c76d2ca5..3699bfcf5 100644 --- a/frontend/src/app/about/about.component.ts +++ b/frontend/src/app/about/about.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { SafeHtml } from '@angular/platform-browser'; +import { SafeHtml, Title } from '@angular/platform-browser'; import { environment } from '../../environments/environment'; import { DialogService } from '../services'; @@ -13,12 +13,14 @@ export class AboutComponent implements OnInit { public aboutHtml: SafeHtml; public isLoading = false; - constructor(private dialogService: DialogService) { } + constructor(private dialogService: DialogService, private title: Title) { + } ngOnInit() { this.isLoading = true; this.appName = environment.appName; this.fetchData(); + this.title.setTitle(`About - ${this.appName}`); } async fetchData() { diff --git a/frontend/src/app/corpus-info/corpus-info.component.ts b/frontend/src/app/corpus-info/corpus-info.component.ts index 2c89aafb2..dd12cc57b 100644 --- a/frontend/src/app/corpus-info/corpus-info.component.ts +++ b/frontend/src/app/corpus-info/corpus-info.component.ts @@ -1,8 +1,10 @@ import { Component, OnInit } from '@angular/core'; -import { ApiService, CorpusService, WordmodelsService } from '../services'; +import { ApiService, CorpusService } from '../services'; import { Corpus, CorpusDocumentationPage, FieldCoverage } from '../models'; import { marked } from 'marked'; import { Observable } from 'rxjs'; +import { Title } from '@angular/platform-browser'; +import { pageTitle } from '../utils/app'; @Component({ selector: 'ia-corpus-info', @@ -16,7 +18,11 @@ export class CorpusInfoComponent implements OnInit { documentation$: Observable; - constructor(private corpusService: CorpusService, private apiService: ApiService, private wordModelsService: WordmodelsService) { } + constructor( + private corpusService: CorpusService, + private apiService: ApiService, + private title: Title, + ) { } ngOnInit(): void { this.corpusService.currentCorpus.subscribe(this.setCorpus.bind(this)); @@ -28,6 +34,7 @@ export class CorpusInfoComponent implements OnInit { this.apiService.fieldCoverage(corpus.name).then( result => this.fieldCoverage = result ); + this.title.setTitle(pageTitle(`About ${corpus.title}`)); } renderMarkdown(content: string): string { diff --git a/frontend/src/app/document-page/document-page.component.ts b/frontend/src/app/document-page/document-page.component.ts index 74bb001eb..4d44a7d61 100644 --- a/frontend/src/app/document-page/document-page.component.ts +++ b/frontend/src/app/document-page/document-page.component.ts @@ -6,6 +6,8 @@ import { Corpus, FoundDocument } from '../models'; import { CorpusService, ElasticSearchService } from '../services'; import { makeContextParams } from '../utils/document-context'; import { documentIcons } from '../shared/icons'; +import { Title } from '@angular/platform-browser'; +import { pageTitle } from '../utils/app'; @Component({ selector: 'ia-document-page', @@ -25,6 +27,7 @@ export class DocumentPageComponent implements OnInit { private corpusService: CorpusService, private elasticSearchService: ElasticSearchService, private activatedRoute: ActivatedRoute, + private title: Title, ) { } get contextDisplayName(): string { @@ -53,6 +56,7 @@ export class DocumentPageComponent implements OnInit { this.corpus = corpus; this.documentId = params['id']; this.getDocument(this.documentId); + this.title.setTitle(pageTitle(`Document in ${corpus.title}`)); }); } diff --git a/frontend/src/app/history/download-history/download-history.component.ts b/frontend/src/app/history/download-history/download-history.component.ts index 46f996c3e..eadc44b8b 100644 --- a/frontend/src/app/history/download-history/download-history.component.ts +++ b/frontend/src/app/history/download-history/download-history.component.ts @@ -6,6 +6,8 @@ import { HistoryDirective } from '../history.directive'; import { findByName } from '../../utils/utils'; import { actionIcons } from '../../shared/icons'; import { downloadQueryModel, downloadQueryModels } from '../../utils/download-history'; +import { Title } from '@angular/platform-browser'; +import { pageTitle } from '../../utils/app'; @Component({ selector: 'ia-download-history', @@ -23,12 +25,14 @@ export class DownloadHistoryComponent extends HistoryDirective implements OnInit private downloadService: DownloadService, private apiService: ApiService, corpusService: CorpusService, - private notificationService: NotificationService + private notificationService: NotificationService, + private title: Title, ) { super(corpusService); } ngOnInit(): void { + this.title.setTitle(pageTitle('Downloads')); this.retrieveCorpora(); this.apiService.downloads() .then(downloadHistory => this.downloads = this.sortByDate(downloadHistory)) diff --git a/frontend/src/app/history/search-history/search-history.component.ts b/frontend/src/app/history/search-history/search-history.component.ts index 440b9441a..62d1a8817 100644 --- a/frontend/src/app/history/search-history/search-history.component.ts +++ b/frontend/src/app/history/search-history/search-history.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { Params, Router } from '@angular/router'; +import { Params } from '@angular/router'; import * as _ from 'lodash'; import { apiQueryToQueryModel } from '../../utils/es-query'; import { QueryDb } from '../../models/index'; @@ -7,6 +7,8 @@ import { CorpusService, QueryService } from '../../services/index'; import { HistoryDirective } from '../history.directive'; import { findByName } from '../../utils/utils'; import { actionIcons } from '../../shared/icons'; +import { Title } from '@angular/platform-browser'; +import { pageTitle } from '../../utils/app'; @Component({ selector: 'ia-search-history', @@ -22,12 +24,14 @@ export class SearchHistoryComponent extends HistoryDirective implements OnInit { constructor( corpusService: CorpusService, private queryService: QueryService, - private router: Router + private title: Title, + ) { super(corpusService); } async ngOnInit() { + this.title.setTitle(pageTitle('Search history')); this.retrieveCorpora(); this.queryService.retrieveQueries().then((searchHistory) => { const sortedQueries = this.sortByDate(searchHistory); diff --git a/frontend/src/app/home/home.component.ts b/frontend/src/app/home/home.component.ts index 0b02acb85..b52d53e7e 100644 --- a/frontend/src/app/home/home.component.ts +++ b/frontend/src/app/home/home.component.ts @@ -4,6 +4,7 @@ import { BehaviorSubject } from 'rxjs'; import { Corpus } from '../models/corpus'; import { CorpusService } from '../services/index'; import { showLoading } from '../utils/utils'; +import { environment } from '../../environments/environment'; @Component({ selector: 'ia-home', @@ -15,8 +16,8 @@ export class HomeComponent implements OnInit { isLoading = new BehaviorSubject(false); - constructor(private corpusService: CorpusService, private title: Title) { - this.title.setTitle('Home'); + constructor(private corpusService: CorpusService, title: Title) { + title.setTitle(environment.appName); } ngOnInit() { diff --git a/frontend/src/app/login/login.component.html b/frontend/src/app/login/login.component.html index 7dda417c5..7864f4eee 100644 --- a/frontend/src/app/login/login.component.html +++ b/frontend/src/app/login/login.component.html @@ -2,7 +2,7 @@