From 63b943336d49be36f38a87fc52f80977f1ec9d6f Mon Sep 17 00:00:00 2001 From: Hans-Peter Herzog Date: Wed, 4 Jul 2018 17:49:34 +0200 Subject: [PATCH] TT#39754 Global: Implement dynamic page title Change-Id: Ice88aaffb810daf422294601c0d66ff87c003fdd --- src/index.html | 2 +- src/locales/en.json | 4 ++-- src/router.js | 16 ++++++++++++++++ src/routes.js | 5 ++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/index.html b/src/index.html index 8aa90e20..56d97b3b 100644 --- a/src/index.html +++ b/src/index.html @@ -5,7 +5,7 @@ - Sipwise Customer Self Care + diff --git a/src/locales/en.json b/src/locales/en.json index 3ab98a3d..57f250f4 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1,5 +1,5 @@ { - "title": "Customer Self-Care Portal", + "title": "CSC", "rtcEngineDisconnected": "You can not start a call. Service ist currently unavailable.", "startCall": "Call", "startAudioCall": "Audio Only", @@ -58,7 +58,7 @@ }, "pages": { "login": { - "title": "Customer Self-Care Portal", + "title": "Subscriber Sign In", "button": "Sign In", "error": "Wrong username or password", "username": "Username", diff --git a/src/router.js b/src/router.js index 458f3aba..16e75ba7 100644 --- a/src/router.js +++ b/src/router.js @@ -1,8 +1,10 @@ +import _ from 'lodash' import Vue from 'vue' import VueRouter from 'vue-router' import { store } from './store' import routes from './routes' +import { i18n } from './i18n' Vue.use(VueRouter); @@ -10,6 +12,20 @@ var router = new VueRouter({ routes: routes }); +router.beforeEach((to, from, next) => { + let mainTitle = i18n.t('title'); + let title = _.get(to, 'meta.title', ''); + let subTitle = _.get(to, 'meta.subtitle', ''); + if(mainTitle !== '') { + title = mainTitle + ' - ' + title; + } + if(subTitle !== '') { + title = title + " - " + subTitle; + } + document.title = title; + next(); +}); + router.beforeEach((to, from, next) => { if (!store.getters['user/isLogged'] && to.path !== '/login') { next({ diff --git a/src/routes.js b/src/routes.js index 1281a562..368d7025 100644 --- a/src/routes.js +++ b/src/routes.js @@ -120,7 +120,10 @@ export default [ }, { path: '/login', - component: Login + component: Login, + meta: { + title: i18n.t('pages.login.title') + } }, { path: '/',