#24 ajout du support pour les configurations env.build.time et recipe.approbation.expiration

This commit is contained in:
FyloZ 2021-06-09 21:06:33 -04:00
parent b58c389f16
commit 7fac208428
10 changed files with 51 additions and 33 deletions

View File

@ -11,7 +11,7 @@
<p>Non approuvée</p>
<mat-icon svgIcon="alert" class="color-warning"></mat-icon>
</div>
<div *ngIf="isApprobationExpired" class="recipe-not-approved-wrapper d-flex flex-row" title="Cette recette a été approuvée il y a plus de 4 ans">
<div *ngIf="recipe.approbationExpired" class="recipe-not-approved-wrapper d-flex flex-row" title="Cette recette a été approuvée il y a plus de 4 ans">
<p>Approbation expirée</p>
<mat-icon svgIcon="clock-alert" class="color-warning"></mat-icon>
</div>

View File

@ -1,5 +1,5 @@
import {AfterViewInit, Component, Input} from '@angular/core'
import {getRecipeLuma, recipeApprobationExpired, Recipe} from '../../../shared/model/recipe.model'
import {Recipe} from '../../../shared/model/recipe.model'
import {formatDate} from '../../../shared/utils/utils'
@Component({
@ -20,8 +20,4 @@ export class RecipeInfoComponent implements AfterViewInit {
get approbationDate(): string {
return formatDate(this.recipe.approbationDate)
}
get isApprobationExpired(): boolean {
return recipeApprobationExpired(this.recipe)
}
}

View File

@ -74,10 +74,10 @@
title="Cette recette n'est pas approuvée">
</mat-icon>
<mat-icon
*ngIf="isRecipeApprobationExpired(recipe)"
*ngIf="recipe.approbationExpired"
svgIcon="clock-alert"
class="color-warning"
title="L'approbation de l'échantillon est expirée (il y a plus de 4 ans)">
title="L'approbation de l'échantillon est expirée">
</mat-icon>
</td>
</ng-container>

View File

@ -3,7 +3,7 @@ import {ErrorHandlingComponent} from '../../../shared/components/subscribing.com
import {RecipeService} from '../../services/recipe.service'
import {Permission} from '../../../shared/model/user'
import {AccountService} from '../../../accounts/services/account.service'
import {getRecipeLuma, Recipe, recipeApprobationExpired} from '../../../shared/model/recipe.model'
import {getRecipeLuma, Recipe} from '../../../shared/model/recipe.model'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorService} from '../../../shared/service/error.service'
import {AppState} from '../../../shared/app-state'
@ -65,10 +65,6 @@ export class ListComponent extends ErrorHandlingComponent {
.forEach(r => this.recipeMatchesSearchQuery(r))
}
isRecipeApprobationExpired(recipe: Recipe): boolean {
return recipeApprobationExpired(recipe)
}
isCompanyHidden(companyRecipes: Recipe[]): boolean {
return (this.searchQuery && this.searchQuery.length > 0) && companyRecipes.map(r => this.hiddenRecipes[r.id]).filter(r => !r).length <= 0
}

View File

@ -7,7 +7,7 @@ import {
CreImageConfig,
CreConfigList,
CreConfigActions,
CreConfigTooltip, CrePeriodConfig, CreBoolConfig
CreConfigTooltip, CrePeriodConfig, CreBoolConfig, CreDateConfig
} from './config'
import {SharedModule} from '../shared/shared.module'
import {CreInputsModule} from '../shared/components/inputs/inputs.module'
@ -25,7 +25,8 @@ import {CreButtonsModule} from '../shared/components/buttons/buttons.module'
CreConfigList,
CreConfigActions,
CreBoolConfig,
CrePeriodConfig
CrePeriodConfig,
CreDateConfig
],
imports: [
SharedModule,

View File

@ -15,7 +15,7 @@ import {Config} from '../shared/model/config.model'
import {ErrorHandlingComponent, SubscribingComponent} from '../shared/components/subscribing.component'
import {ErrorService} from '../shared/service/error.service'
import {ActivatedRoute, Router} from '@angular/router'
import {formatDateTime, getFileUrl, readFile} from '../shared/utils/utils'
import {formatDate, formatDateTime, getFileUrl, readFile} from '../shared/utils/utils'
import {FormControl, Validators} from '@angular/forms'
import {ConfirmBoxComponent} from '../shared/components/confirm-box/confirm-box.component'
import {environment} from '../../../environments/environment'
@ -116,10 +116,6 @@ export class CreConfig extends SubscribingComponent {
}
}
get configuredImageUrl(): string {
return getFileUrl(this.configuration.content)
}
get lastUpdated(): string {
return 'Dernière mise à jour: ' + formatDateTime(this.configuration.lastUpdated)
}
@ -151,8 +147,9 @@ export class CreImageConfig extends CreConfig {
readFile(file, (content) => this.updatedImage = content)
}
get imageUrl(): string {
return `${environment.apiUrl}/file?path=${this.configuration.content}`
get configuredImageUrl(): string {
return getFileUrl(this.configuration.content)
}
}
@ -172,7 +169,17 @@ export class CreBoolConfig extends CreConfig {
templateUrl: 'period.html'
})
export class CrePeriodConfig extends CreConfig {
}
@Component({
selector: 'cre-date-config',
templateUrl: 'date.html'
})
export class CreDateConfig extends CreConfig {
setConfig(config: Config) {
super.setConfig(config);
this.config.control.setValue(formatDate(config.content))
}
}
@Component({
@ -191,9 +198,11 @@ export class CreConfigEditor extends ErrorHandlingComponent {
DATABASE_USER: Config.DATABASE_USER,
DATABASE_PASSWORD: Config.DATABASE_PASSWORD,
DATABASE_VERSION: Config.DATABASE_VERSION,
RECIPE_APPROBATION_EXPIRATION: Config.RECIPE_APPROBATION_EXPIRATION,
TOUCH_UP_KIT_CACHE_PDF: Config.TOUCH_UP_KIT_CACHE_PDF,
TOUCH_UP_KIT_EXPIRATION: Config.TOUCH_UP_KIT_EXPIRATION,
APP_VERSION: Config.APP_VERSION,
BACKEND_BUILD_VERSION: Config.BACKEND_BUILD_VERSION,
BACKEND_BUILD_TIME: Config.BACKEND_BUILD_TIME,
JAVA_VERSION: Config.JAVA_VERSION,
OPERATING_SYSTEM: Config.OPERATING_SYSTEM
}

View File

@ -0,0 +1,12 @@
<div *ngIf="configuration" [attr.title]="tooltip?.content">
<cre-input [class.has-hint]="configuration.editable"
class="w-100"
type="text"
[label]="label.content"
[hint]="configuration.editable ? lastUpdated : null"
[control]="config.control"
[icon]="configuration.requireRestart ? 'alert' : null"
[iconTitle]="configuration.requireRestart ? 'Requiert un redémarrage' : null"
iconColor="warning">
</cre-input>
</div>

View File

@ -41,8 +41,12 @@
</cre-config-section>
<cre-config-section>
<cre-config-label>Kits de retouche</cre-config-label>
<cre-config-label>Données</cre-config-label>
<cre-config-list class="pt-2">
<cre-period-config [config]="getConfig(keys.RECIPE_APPROBATION_EXPIRATION)">
<cre-config-label>Période d'expiration de l'approbation de l'échantillon des recettes</cre-config-label>
</cre-period-config>
<cre-period-config [config]="getConfig(keys.TOUCH_UP_KIT_EXPIRATION)">
<cre-config-label>Période d'expiration des kits de retouches complets</cre-config-label>
<cre-config-tooltip>
@ -87,10 +91,14 @@
<cre-config-label>Version de la base de données</cre-config-label>
</cre-config>
<cre-config [config]="getConfig(keys.APP_VERSION)">
<cre-config [config]="getConfig(keys.BACKEND_BUILD_VERSION)">
<cre-config-label>Version de Color Recipes Explorer</cre-config-label>
</cre-config>
<cre-date-config [config]="getConfig(keys.BACKEND_BUILD_TIME)">
<cre-config-label>Date de compilation de Color Recipes Explorer</cre-config-label>
</cre-date-config>
<cre-config [config]="getConfig(keys.JAVA_VERSION)">
<cre-config-label>Version de Java</cre-config-label>
</cre-config>

View File

@ -7,10 +7,12 @@ export class Config {
static readonly DATABASE_USER = 'database.user'
static readonly DATABASE_PASSWORD = 'database.password'
static readonly DATABASE_VERSION = 'database.version.supported'
static readonly RECIPE_APPROBATION_EXPIRATION = 'recipe.approbation.expiration'
static readonly TOUCH_UP_KIT_CACHE_PDF = 'touchupkit.pdf.cache'
static readonly TOUCH_UP_KIT_EXPIRATION = 'touchupkit.expiration'
static readonly EMERGENCY_MODE = 'env.emergency'
static readonly APP_VERSION = 'env.version'
static readonly BACKEND_BUILD_VERSION = 'env.build.version'
static readonly BACKEND_BUILD_TIME = 'env.build.time'
static readonly JAVA_VERSION = 'env.java.version'
static readonly OPERATING_SYSTEM = 'env.os'

View File

@ -12,6 +12,7 @@ export class Recipe {
public gloss: number,
public sample: number,
public approbationDate: string,
public approbationExpired: boolean,
public remark: string,
public company: Company,
public mixes: Mix[],
@ -124,10 +125,3 @@ export function getRecipeLuma(recipe: Recipe): number {
return 0.2126 * r + 0.7152 * g + 0.0722 * b // per ITU-R BT.709
}
// TODO hard-coded for prototype
export function recipeApprobationExpired(recipe: Recipe): boolean {
// @ts-ignore
return recipe.approbationDate && LocalDate.parse(recipe.approbationDate).year() < new Date().getFullYear() - 4
}