Ajout d'un titre aux pages

This commit is contained in:
FyloZ 2021-05-20 12:36:46 -04:00
parent f6d4dc5da5
commit d332e8239c
22 changed files with 109 additions and 20 deletions

View File

@ -4,6 +4,7 @@ import {AccountService} from '../../services/account.service'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorService} from '../../../shared/service/error.service'
import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-login',
@ -18,11 +19,13 @@ export class LoginComponent extends ErrorHandlingComponent implements OnInit {
constructor(
private formBuilder: FormBuilder,
private accountService: AccountService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Connexion'
}
ngOnInit(): void {

View File

@ -7,6 +7,7 @@ import {CompanyService} from '../../../company/service/company.service'
import {map} from 'rxjs/operators'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-add',
@ -104,11 +105,13 @@ export class AddComponent extends ErrorHandlingComponent {
constructor(
private recipeService: RecipeService,
private companyService: CompanyService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = "Nouvelle couleur"
}
submit(values) {

View File

@ -130,6 +130,8 @@ export class EditComponent extends ErrorHandlingComponent {
parseInt(this.activatedRoute.snapshot.paramMap.get('id')),
recipe => {
this.recipe = recipe
this.appState.title = `${recipe.name} (Modifications)`
if (recipeMixCount(this.recipe) == 0) {
this.alertService.pushWarning('Il n\'y a aucun mélange dans cette recette')
}

View File

@ -50,7 +50,6 @@ export class ExploreComponent extends ErrorHandlingComponent {
private alertService: AlertService,
private accountService: AccountService,
private appState: AppState,
private titleService: Title,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@ -70,7 +69,7 @@ export class ExploreComponent extends ErrorHandlingComponent {
id,
r => {
this.recipe = r
this.titleService.setTitle(r.name)
this.appState.title = r.name
if (recipeMixCount(this.recipe) <= 0 || recipeStepCount(this.recipe) <= 0) {
this.alertService.pushWarning('Cette recette n\'est pas complète')

View File

@ -6,6 +6,7 @@ import {AccountService} from '../../../accounts/services/account.service'
import {getRecipeLuma, Recipe, recipeApprobationExpired} from '../../../shared/model/recipe.model'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-list',
@ -23,6 +24,7 @@ export class ListComponent extends ErrorHandlingComponent {
private recipeService: RecipeService,
private accountService: AccountService,
private cdRef: ChangeDetectorRef,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@ -32,6 +34,7 @@ export class ListComponent extends ErrorHandlingComponent {
ngOnInit() {
super.ngOnInit()
this.appState.title = "Explorateur"
this.subscribe(
this.recipeService.allSortedByCompany,

View File

@ -4,6 +4,7 @@ import {ErrorHandlingComponent} from '../../../shared/components/subscribing.com
import {FormField} from '../../../shared/components/entity-add/entity-add.component'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-add',
@ -32,11 +33,13 @@ export class AddComponent extends ErrorHandlingComponent {
constructor(
private companyService: CompanyService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Nouvelle bannière'
}
ngOnInit() {

View File

@ -5,6 +5,7 @@ import {FormField} from '../../../shared/components/entity-add/entity-add.compon
import {CompanyService} from '../../service/company.service'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorHandler, ErrorHandlerComponent, ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-edit',
@ -39,6 +40,7 @@ export class EditComponent extends ErrorHandlingComponent {
constructor(
private companyService: CompanyService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@ -53,7 +55,10 @@ export class EditComponent extends ErrorHandlingComponent {
this.subscribeEntityById(
this.companyService,
id,
company => this.company = company
company => {
this.appState.title = `${company.name} (Modifications)`
this.company = company
}
)
}

View File

@ -4,6 +4,7 @@ import {CompanyService} from '../../service/company.service'
import {Permission} from '../../../shared/model/user'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-list',
@ -23,10 +24,12 @@ export class ListComponent extends ErrorHandlingComponent {
constructor(
private companyService: CompanyService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Bannières'
}
}

View File

@ -6,6 +6,7 @@ import {currentPermissionsFieldComponent} from '../../../shared/components/permi
import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {FormField} from '../../../shared/components/entity-add/entity-add.component'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-add',
@ -39,11 +40,13 @@ export class AddComponent extends ErrorHandlingComponent {
constructor(
private groupService: GroupService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Nouveau groupe'
}
ngOnInit() {

View File

@ -8,6 +8,7 @@ import {AccountService} from '../../../accounts/services/account.service'
import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {FormField} from '../../../shared/components/entity-add/entity-add.component'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-edit',
@ -46,6 +47,7 @@ export class EditComponent extends ErrorHandlingComponent {
constructor(
private accountService: AccountService,
private groupService: GroupService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@ -58,7 +60,10 @@ export class EditComponent extends ErrorHandlingComponent {
this.subscribeEntityById(
this.groupService,
id,
group => this.group = group
group => {
this.appState.title = `${group.name} (Modifications)`
this.group = group
}
)
this.formFields[this.formFields.length - 1].template = this.permissionsTemplateRef

View File

@ -6,6 +6,7 @@ import {ErrorHandlingComponent} from '../../../shared/components/subscribing.com
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {AlertService} from '../../../shared/service/alert.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-groups',
@ -38,11 +39,13 @@ export class ListComponent extends ErrorHandlingComponent {
private groupService: GroupService,
private accountService: AccountService,
private alertService: AlertService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Groupes'
}
ngOnInit(): void {

View File

@ -5,6 +5,7 @@ import {MaterialTypeService} from '../../service/material-type.service'
import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-add',
@ -56,11 +57,13 @@ export class AddComponent extends ErrorHandlingComponent {
constructor(
private materialTypeService: MaterialTypeService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Nouveau type de produit'
}
submit(values) {

View File

@ -6,6 +6,7 @@ import {MaterialTypeService} from '../../service/material-type.service'
import {FormField} from '../../../shared/components/entity-add/entity-add.component'
import {Validators} from '@angular/forms'
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-edit',
@ -58,6 +59,7 @@ export class EditComponent extends ErrorHandlingComponent {
constructor(
private materialTypeService: MaterialTypeService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@ -72,7 +74,10 @@ export class EditComponent extends ErrorHandlingComponent {
this.subscribeEntityById(
this.materialTypeService,
id,
materialType => this.materialType = materialType
materialType => {
this.appState.title = `${materialType.name} (Modifications)`
this.materialType = materialType
}
)
}

View File

@ -4,6 +4,7 @@ import {ErrorHandlingComponent} from '../../../shared/components/subscribing.com
import {Permission} from '../../../shared/model/user'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-list',
@ -28,10 +29,12 @@ export class ListComponent extends ErrorHandlingComponent {
constructor(
private materialTypeService: MaterialTypeService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Types de produit'
}
}

View File

@ -6,7 +6,8 @@ import {MaterialTypeService} from '../../../material-type/service/material-type.
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
import {map} from 'rxjs/operators'
import {ErrorHandler, ErrorHandlerComponent, ErrorService} from '../../../shared/service/error.service'
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-add',
@ -68,11 +69,13 @@ export class AddComponent extends ErrorHandlingComponent {
constructor(
private materialService: MaterialService,
private materialTypeService: MaterialTypeService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Nouveau produit'
}
submit(values) {

View File

@ -8,6 +8,7 @@ import {ActivatedRoute, Router} from '@angular/router'
import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
import {Material, openSimdut} from '../../../shared/model/material.model'
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-edit',
@ -80,6 +81,7 @@ export class EditComponent extends ErrorHandlingComponent {
constructor(
private materialService: MaterialService,
private materialTypeService: MaterialTypeService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@ -96,7 +98,10 @@ export class EditComponent extends ErrorHandlingComponent {
this.subscribeEntityById(
this.materialService,
id,
material => this.material = material
material => {
this.appState.title = `${material.name} (Modifications)`
this.material = material
}
)
}

View File

@ -11,6 +11,7 @@ import {MatSort} from '@angular/material/sort'
import {MatTableDataSource} from '@angular/material/table'
import {MaterialTypeService} from '../../../material-type/service/material-type.service'
import {InventoryService} from '../../service/inventory.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-list',
@ -38,11 +39,13 @@ export class InventoryComponent extends ErrorHandlingComponent {
private materialTypeService: MaterialTypeService,
private inventoryService: InventoryService,
private accountService: AccountService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Inventaire'
}
ngOnInit() {

View File

@ -1,32 +1,39 @@
import {Injectable} from "@angular/core";
import {User} from "./model/user";
import {Subject} from "rxjs";
import {Injectable} from '@angular/core'
import {User} from './model/user'
import {Subject} from 'rxjs'
import {Title} from '@angular/platform-browser'
@Injectable({
providedIn: 'root'
})
export class AppState {
private readonly KEY_AUTHENTICATED = "authenticated"
private readonly KEY_AUTHENTICATION_EXPIRATION = "authentication-expiration"
private readonly KEY_LOGGED_IN_USER = "logged-in-user"
private readonly KEY_AUTHENTICATED = 'authenticated'
private readonly KEY_AUTHENTICATION_EXPIRATION = 'authentication-expiration'
private readonly KEY_LOGGED_IN_USER = 'logged-in-user'
authenticatedUser$ = new Subject<{ authenticated: boolean, authenticatedUser: User }>()
serverOnline$ = new Subject<boolean>()
constructor(
private titleService: Title
) {
}
resetAuthenticatedUser() {
this.isAuthenticated = false
this.authenticationExpiration = -1
this.authenticatedUser = null
}
set isServerOnline(isOnline: boolean) {
if (!isOnline) this.authenticatedUser = null
this.serverOnline$.next(isOnline);
if (!isOnline) {
this.authenticatedUser = null
}
this.serverOnline$.next(isOnline)
}
get isAuthenticated(): boolean {
return sessionStorage.getItem(this.KEY_AUTHENTICATED) === "true"
return sessionStorage.getItem(this.KEY_AUTHENTICATED) === 'true'
}
set isAuthenticated(value: boolean) {
@ -61,4 +68,8 @@ export class AppState {
authenticatedUser: value
})
}
set title(value: string) {
this.titleService.setTitle(`CRE: ${value}`)
}
}

View File

@ -8,6 +8,7 @@ import {ErrorService} from '../../shared/service/error.service'
import {ActivatedRoute, Router} from '@angular/router'
import {Permission} from '../../shared/model/user'
import {RecipeService} from '../../colors/services/recipe.service'
import {AppState} from '../../shared/app-state'
@Component({
selector: 'touchupkit-banner',
@ -39,11 +40,13 @@ export class TouchUpKitList extends ErrorHandlingComponent {
constructor(
private touchUpKitService: TouchUpKitService,
private accountService: AccountService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Kits de retouche'
}
openTouchUpKitPdf(touchUpKit: TouchUpKit) {
@ -66,6 +69,7 @@ export class TouchUpKitDetails extends ErrorHandlingComponent {
constructor(
private touchUpKitService: TouchUpKitService,
private recipeService: RecipeService,
private appState: AppState,
errorService: ErrorService,
activatedRoute: ActivatedRoute,
router: Router
@ -79,7 +83,10 @@ export class TouchUpKitDetails extends ErrorHandlingComponent {
this.subscribeEntityById(
this.touchUpKitService,
this.urlUtils.parseIntUrlParam('id'),
t => this.touchUpKit = t
t => {
this.appState.title = `${t.project} - ${t.buggy}`
this.touchUpKit = t
}
)
}
@ -95,11 +102,13 @@ export class TouchUpKitDetails extends ErrorHandlingComponent {
export class TouchUpKitAdd extends ErrorHandlingComponent {
constructor(
private touchUpKitService: TouchUpKitService,
private appState: AppState,
errorService: ErrorService,
activatedRoute: ActivatedRoute,
router: Router,
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Nouveau kit de retouche'
}
submit(touchUpKit) {
@ -119,6 +128,7 @@ export class TouchUpKitEdit extends ErrorHandlingComponent {
constructor(
private touchUpKitService: TouchUpKitService,
private appState: AppState,
errorService: ErrorService,
activatedRoute: ActivatedRoute,
router: Router
@ -132,7 +142,10 @@ export class TouchUpKitEdit extends ErrorHandlingComponent {
this.subscribeEntityById(
this.touchUpKitService,
this.urlUtils.parseIntUrlParam('id'),
touchUpKit => this.touchUpKit = touchUpKit
touchUpKit => {
this.appState.title = `${touchUpKit.project} - ${touchUpKit.buggy} (Modifications)`
this.touchUpKit = touchUpKit
}
)
}

View File

@ -8,6 +8,7 @@ import {ErrorHandlingComponent} from '../../../shared/components/subscribing.com
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {FormField} from '../../../shared/components/entity-add/entity-add.component'
import {map} from 'rxjs/operators'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-add',
@ -83,11 +84,13 @@ export class AddComponent extends ErrorHandlingComponent {
constructor(
private userService: UserService,
private groupService: GroupService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Nouvel utilisateur'
}
ngOnInit() {

View File

@ -9,6 +9,7 @@ import {ErrorHandlingComponent} from '../../../shared/components/subscribing.com
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
import {FormField} from '../../../shared/components/entity-add/entity-add.component'
import {map} from 'rxjs/operators'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-edit',
@ -70,6 +71,7 @@ export class EditComponent extends ErrorHandlingComponent {
private accountService: AccountService,
private userService: UserService,
private groupService: GroupService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@ -82,7 +84,10 @@ export class EditComponent extends ErrorHandlingComponent {
this.subscribeEntityById(
this.userService,
id,
user => this.user = user
user => {
this.appState.title = `${user.firstName} ${user.lastName} (Modifications)`
this.user = user
}
)
this.formFields[this.formFields.length - 1].template = this.permissionsTemplateRef

View File

@ -8,6 +8,7 @@ import {animate, state, style, transition, trigger} from '@angular/animations'
import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@Component({
selector: 'cre-users',
@ -43,11 +44,13 @@ export class ListComponent extends ErrorHandlingComponent {
constructor(
private userService: UserService,
private accountService: AccountService,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
this.appState.title = 'Utilisateurs'
}
ngOnInit(): void {