diff --git a/.drone.yml b/.drone.yml
index 11396c2..323a500 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -1,12 +1,13 @@
---
global-variables:
- release: &release ${DRONE_BRANCH##**/}
+ release: &release ${DRONE_TAG}
environment: &environment
- CRE_REGISTRY_IMAGE: registry.fyloz.dev:5443/colorrecipesexplorer/frontend
+ CRE_REGISTRY_IMAGE: registry.fyloz.dev/colorrecipesexplorer/frontend
CRE_PORT: 9102
CRE_RELEASE: *release
alpine-image: &alpine-image alpine:latest
- docker-registry-repo: &docker-registry-repo registry.fyloz.dev:5443/colorrecipesexplorer/frontend
+ docker-registry: &docker-registry registry.fyloz.dev
+ docker-registry-repo: &docker-registry-repo registry.fyloz.dev/colorrecipesexplorer/frontend
kind: pipeline
name: default
@@ -21,6 +22,9 @@ steps:
- echo -n "latest" > .tags
when:
branch: develop
+ event:
+ exclude:
+ - pull_request
- name: set-docker-tags-release
image: *alpine-image
@@ -29,18 +33,40 @@ steps:
commands:
- echo -n "latest-release,$CRE_RELEASE" > .tags
when:
- branch: release/**
+ event:
+ - tag
- - name: containerize
+ - name: containerize-dev
image: plugins/docker
environment:
<<: *environment
settings:
repo: *docker-registry-repo
+ registry: *docker-registry
+ username:
+ from_secret: docker_username
+ password:
+ from_secret: docker_password
when:
- branch:
- - develop
- - release/**
+ branch: develop
+ event:
+ exclude:
+ - pull_request
+
+ - name: containerize-release
+ image: plugins/docker
+ environment:
+ <<: *environment
+ settings:
+ repo: *docker-registry-repo
+ registry: *docker-registry
+ username:
+ from_secret: docker_username
+ password:
+ from_secret: docker_password
+ when:
+ event:
+ - tag
- name: deploy
image: alpine:latest
@@ -70,10 +96,5 @@ steps:
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker pull $CRE_REGISTRY_IMAGE:$CRE_RELEASE"
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker run -d -p $CRE_PORT:80 --name=$DEPLOY_CONTAINER_NAME $CRE_REGISTRY_IMAGE:$CRE_RELEASE"
when:
- branch: release/**
-
-trigger:
- branch:
- - develop
- - release/**
- - master
+ event:
+ - tag
diff --git a/src/app/modules/accounts/accounts-routing.module.ts b/src/app/modules/accounts/accounts-routing.module.ts
index 006c93f..5615140 100644
--- a/src/app/modules/accounts/accounts-routing.module.ts
+++ b/src/app/modules/accounts/accounts-routing.module.ts
@@ -1,14 +1,13 @@
import {NgModule} from '@angular/core'
import {RouterModule, Routes} from '@angular/router'
-import {LogoutComponent} from './pages/logout/logout.component'
-import {Login} from './accounts'
+import {Login, Logout} from './accounts'
const routes: Routes = [{
path: 'login',
component: Login
}, {
path: 'logout',
- component: LogoutComponent
+ component: Logout
}, {
path: '',
redirectTo: 'login'
diff --git a/src/app/modules/accounts/accounts.module.ts b/src/app/modules/accounts/accounts.module.ts
index c8a05ec..353042f 100644
--- a/src/app/modules/accounts/accounts.module.ts
+++ b/src/app/modules/accounts/accounts.module.ts
@@ -1,19 +1,16 @@
import {NgModule} from '@angular/core'
import {AccountsRoutingModule} from './accounts-routing.module'
-import {LoginComponent} from './pages/login/login.component'
import {SharedModule} from '../shared/shared.module'
-import {LogoutComponent} from './pages/logout/logout.component'
-import {Login} from './accounts'
+import {Login, Logout} from './accounts'
import {CreInputsModule} from '../shared/components/inputs/inputs.module'
import {CreButtonsModule} from '../shared/components/buttons/buttons.module'
@NgModule({
declarations: [
- LoginComponent,
- LogoutComponent,
- Login
+ Login,
+ Logout
],
imports: [
SharedModule,
diff --git a/src/app/modules/accounts/accounts.ts b/src/app/modules/accounts/accounts.ts
index 10f850b..81b477f 100644
--- a/src/app/modules/accounts/accounts.ts
+++ b/src/app/modules/accounts/accounts.ts
@@ -1,12 +1,11 @@
import {Component, HostListener, ViewChild} from '@angular/core'
import {FormControl, Validators} from '@angular/forms'
-import {ErrorHandlingComponent} from '../shared/components/subscribing.component'
+import {ErrorHandlingComponent, SubscribingComponent} from '../shared/components/subscribing.component'
import {AccountService} from './services/account.service'
import {AppState} from '../shared/app-state'
import {ErrorHandler, ErrorService} from '../shared/service/error.service'
import {ActivatedRoute, Router} from '@angular/router'
import {CreForm, ICreForm} from "../shared/components/forms/forms";
-import {take, takeUntil} from "rxjs/operators";
import {AlertService} from "../shared/service/alert.service";
@Component({
@@ -61,3 +60,32 @@ export class Login extends ErrorHandlingComponent {
}
}
}
+
+@Component({
+ selector: 'cre-logout',
+ template: ''
+})
+export class Logout extends SubscribingComponent {
+ constructor(
+ private accountService: AccountService,
+ private alertService: AlertService,
+ private appState: AppState,
+ errorService: ErrorService,
+ router: Router,
+ activatedRoute: ActivatedRoute
+ ) {
+ super(errorService, activatedRoute, router)
+ this.appState.title = 'Connexion'
+ }
+
+ ngOnInit(): void {
+ if (!this.appState.isAuthenticated) {
+ this.urlUtils.navigateTo('/account/login')
+ }
+
+ this.subscribeAndNavigate(
+ this.accountService.logout(),
+ '/account/login'
+ )
+ }
+}
diff --git a/src/app/modules/accounts/pages/login/login.component.html b/src/app/modules/accounts/pages/login/login.component.html
deleted file mode 100644
index 28aa77c..0000000
--- a/src/app/modules/accounts/pages/login/login.component.html
+++ /dev/null
@@ -1,36 +0,0 @@
-
diff --git a/src/app/modules/accounts/pages/login/login.component.sass b/src/app/modules/accounts/pages/login/login.component.sass
deleted file mode 100644
index afd1937..0000000
--- a/src/app/modules/accounts/pages/login/login.component.sass
+++ /dev/null
@@ -1,8 +0,0 @@
-mat-card
- width: 25rem
-
- .alert p
- margin: 0
-
- mat-form-field
- width: 100%
diff --git a/src/app/modules/accounts/pages/login/login.component.ts b/src/app/modules/accounts/pages/login/login.component.ts
deleted file mode 100644
index 919bed0..0000000
--- a/src/app/modules/accounts/pages/login/login.component.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import {Component, OnInit} from '@angular/core'
-import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'
-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',
- templateUrl: './login.component.html',
- styleUrls: ['./login.component.sass']
-})
-export class LoginComponent extends ErrorHandlingComponent implements OnInit {
- form: FormGroup
- idFormControl: FormControl
- passwordFormControl: FormControl
-
- 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 {
- this.errorService.activeErrorHandler = this
-
- if (this.appState.isAuthenticated) {
- this.router.navigate(['/color'])
- }
-
- this.idFormControl = this.formBuilder.control(null, Validators.compose([Validators.required, Validators.pattern(new RegExp('^[0-9]+$'))]))
- this.passwordFormControl = this.formBuilder.control(null, Validators.required)
- this.form = this.formBuilder.group({
- id: this.idFormControl,
- password: this.passwordFormControl
- })
- }
-
- submit() {
- this.subscribe(
- this.accountService.login(
- this.idFormControl.value,
- this.passwordFormControl.value
- ),
- response => console.log(response)
- )
- }
-}
diff --git a/src/app/modules/accounts/pages/logout/logout.component.html b/src/app/modules/accounts/pages/logout/logout.component.html
deleted file mode 100644
index e69de29..0000000
diff --git a/src/app/modules/accounts/pages/logout/logout.component.sass b/src/app/modules/accounts/pages/logout/logout.component.sass
deleted file mode 100644
index e69de29..0000000
diff --git a/src/app/modules/accounts/pages/logout/logout.component.ts b/src/app/modules/accounts/pages/logout/logout.component.ts
deleted file mode 100644
index a1433c1..0000000
--- a/src/app/modules/accounts/pages/logout/logout.component.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import {Component} from '@angular/core';
-import {AccountService} from "../../services/account.service";
-import {ActivatedRoute, Router} from "@angular/router";
-import {AppState} from "../../../shared/app-state";
-import {SubscribingComponent} from "../../../shared/components/subscribing.component";
-import {ErrorService} from "../../../shared/service/error.service";
-
-@Component({
- selector: 'cre-logout',
- templateUrl: './logout.component.html',
- styleUrls: ['./logout.component.sass']
-})
-export class LogoutComponent extends SubscribingComponent {
-
- constructor(
- private accountService: AccountService,
- private appState: AppState,
- errorService: ErrorService,
- router: Router,
- activatedRoute: ActivatedRoute
- ) {
- super(errorService, activatedRoute, router)
- }
-
- ngOnInit(): void {
- if (!this.appState.isAuthenticated) {
- this.urlUtils.navigateTo('/account/login')
- }
-
- this.subscribeAndNavigate(
- this.accountService.logout(),
- '/account/login'
- )
- }
-}
diff --git a/src/app/modules/material/pages/edit/edit.component.html b/src/app/modules/material/pages/edit/edit.component.html
index e7be59e..ac7b196 100644
--- a/src/app/modules/material/pages/edit/edit.component.html
+++ b/src/app/modules/material/pages/edit/edit.component.html
@@ -16,8 +16,8 @@
diff --git a/src/app/modules/material/pages/edit/edit.component.ts b/src/app/modules/material/pages/edit/edit.component.ts
index aadc5d7..fbc2a44 100644
--- a/src/app/modules/material/pages/edit/edit.component.ts
+++ b/src/app/modules/material/pages/edit/edit.component.ts
@@ -119,10 +119,6 @@ export class EditComponent extends ErrorHandlingComponent {
)
}
- get hasSimdut(): boolean {
- return this.material.simdutUrl != null
- }
-
openSimdut() {
openSimdut(this.material)
}
diff --git a/src/app/modules/material/pages/inventory/inventory.component.html b/src/app/modules/material/pages/inventory/inventory.component.html
index 130ff57..05850d0 100644
--- a/src/app/modules/material/pages/inventory/inventory.component.html
+++ b/src/app/modules/material/pages/inventory/inventory.component.html
@@ -98,7 +98,7 @@
|
-
+ |
Fiche signalitique
diff --git a/src/app/modules/material/pages/inventory/inventory.component.ts b/src/app/modules/material/pages/inventory/inventory.component.ts
index 81f914f..1e53d54 100644
--- a/src/app/modules/material/pages/inventory/inventory.component.ts
+++ b/src/app/modules/material/pages/inventory/inventory.component.ts
@@ -64,7 +64,7 @@ export class InventoryComponent extends ErrorHandlingComponent {
super.ngOnInit()
this.subscribe(
- this.materialService.allNotMixType,
+ this.materialService.all,
materials => this.materials = materials,
true,
1
@@ -94,10 +94,6 @@ export class InventoryComponent extends ErrorHandlingComponent {
return round(convertQuantity(material.inventoryQuantity, UNIT_MILLILITER, this.units), 2)
}
- materialHasSimdut(material: Material): boolean {
- return material.simdutUrl != null
- }
-
openSimdut(material: Material) {
openSimdut(material)
}
diff --git a/src/app/modules/material/service/material.service.ts b/src/app/modules/material/service/material.service.ts
index 709f0f1..ecafa45 100644
--- a/src/app/modules/material/service/material.service.ts
+++ b/src/app/modules/material/service/material.service.ts
@@ -17,10 +17,6 @@ export class MaterialService {
return this.api.get('/material')
}
- get allNotMixType(): Observable {
- return this.api.get('/material/notmixtype')
- }
-
getAllForMixCreation(recipeId: number): Observable {
return this.api.get(`/material/mix/create/${recipeId}`)
}
@@ -33,14 +29,6 @@ export class MaterialService {
return this.api.get(`/material/${id}`)
}
- hasSimdut(id: number): Observable {
- return this.api.get(`/material/${id}/simdut/exists`)
- }
-
- getSimduts(): Observable {
- return this.api.get('/material/simdut')
- }
-
save(name: string, inventoryQuantity: number, materialType: number, simdutFile: FileInput): Observable {
const body = new FormData()
body.append('name', name)
diff --git a/src/app/modules/recipes/components/images-editor/images-editor.component.html b/src/app/modules/recipes/components/images-editor/images-editor.component.html
index abd0574..7e32892 100644
--- a/src/app/modules/recipes/components/images-editor/images-editor.component.html
+++ b/src/app/modules/recipes/components/images-editor/images-editor.component.html
@@ -1,17 +1,17 @@
-
+
Images
- Aucune image n'est associée à cette couleur
+ Aucune image n'est associée à cette couleur
-
+
-
+
-
-
+
+
diff --git a/src/app/modules/recipes/components/images-editor/images-editor.component.ts b/src/app/modules/recipes/components/images-editor/images-editor.component.ts
index 4b00c2d..eb56138 100644
--- a/src/app/modules/recipes/components/images-editor/images-editor.component.ts
+++ b/src/app/modules/recipes/components/images-editor/images-editor.component.ts
@@ -4,7 +4,8 @@ import {SubscribingComponent} from '../../../shared/components/subscribing.compo
import {ActivatedRoute, Router} from '@angular/router'
import {RecipeImageService} from '../../services/recipe-image.service'
import {ErrorService} from '../../../shared/service/error.service'
-import {openJpg} from '../../../shared/utils/utils'
+import {getImageUrl, openJpg} from '../../../shared/utils/utils'
+import {RecipeService} from "../../services/recipe.service";
@Component({
selector: 'cre-images-editor',
@@ -15,10 +16,11 @@ export class ImagesEditorComponent extends SubscribingComponent {
@Input() recipe: Recipe
@Input() editionMode = false
- imagesUrls: string[]
+ imagesIds: string[] = []
constructor(
private recipeImageService: RecipeImageService,
+ private recipeService: RecipeService,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@@ -29,19 +31,26 @@ export class ImagesEditorComponent extends SubscribingComponent {
ngOnInit() {
super.ngOnInit()
- this.imagesUrls = this.recipe.imagesUrls
+ this.subscribe(
+ this.recipeService.getImagesIds(this.recipe.id),
+ imagesIds => this.imagesIds = imagesIds ?? []
+ )
}
submit(event) {
const image = event.target.files[0]
this.subscribe(
this.recipeImageService.save(image, this.recipe.id),
- r => this.imagesUrls = r.imagesUrls
+ imageId => this.imagesIds.push(imageId)
)
}
- openImage(url: string) {
- openJpg(url)
+ getImageUrl(id: string): string {
+ return getImageUrl(this.getImagePath(id))
+ }
+
+ openImage(id: string) {
+ openJpg(this.getImagePath(id))
}
delete(url: string) {
@@ -52,6 +61,10 @@ export class ImagesEditorComponent extends SubscribingComponent {
}
private removeUrl(url: string) {
- this.imagesUrls = this.imagesUrls.filter(u => u !== url)
+ this.imagesIds = this.imagesIds.filter(u => u !== url)
+ }
+
+ private getImagePath(id: string): string {
+ return `recipes/${this.recipe.id}/${id}`
}
}
diff --git a/src/app/modules/recipes/components/mix-table/mix-table.component.html b/src/app/modules/recipes/components/mix-table/mix-table.component.html
index 7f8a28a..9a94211 100644
--- a/src/app/modules/recipes/components/mix-table/mix-table.component.html
+++ b/src/app/modules/recipes/components/mix-table/mix-table.component.html
@@ -126,7 +126,7 @@
diff --git a/src/app/modules/recipes/components/mix-table/mix-table.component.ts b/src/app/modules/recipes/components/mix-table/mix-table.component.ts
index bd430a6..e50128f 100644
--- a/src/app/modules/recipes/components/mix-table/mix-table.component.ts
+++ b/src/app/modules/recipes/components/mix-table/mix-table.component.ts
@@ -1,5 +1,11 @@
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'
-import {Mix, MixMaterial, MixMaterialDto, mixMaterialsToMixMaterialsDto, Recipe} from '../../../shared/model/recipe.model'
+import {
+ Mix,
+ MixQuantity,
+ MixMaterialDto,
+ mixMaterialsToMixMaterialsDto,
+ Recipe
+} from '../../../shared/model/recipe.model'
import {Subject} from 'rxjs'
import {SubscribingComponent} from '../../../shared/components/subscribing.component'
import {convertMixMaterialQuantity, UNIT_MILLILITER} from '../../../shared/units'
@@ -37,7 +43,7 @@ export class MixTableComponent extends SubscribingComponent {
mixColumns = this.COLUMNS
units = UNIT_MILLILITER
mixMaterials: MixMaterialDto[] = []
- hoveredMixMaterial: MixMaterial | null
+ hoveredMixMaterial: MixQuantity | null
// BPac printer
printer: PtouchPrinter | null
@@ -68,11 +74,7 @@ export class MixTableComponent extends SubscribingComponent {
)
}
- hasSimdut(material: Material): boolean {
- return material.simdutUrl != null
- }
-
- openSimdut(mixMaterial: MixMaterial) {
+ openSimdut(mixMaterial: MixQuantity) {
openSimdut(mixMaterial.material)
}
@@ -102,8 +104,8 @@ export class MixTableComponent extends SubscribingComponent {
})
}
- getMixMaterialFromDto(mixMaterialDto: MixMaterialDto): MixMaterial {
- return this.mix.mixMaterials.find(m => m.material.id === mixMaterialDto.materialId)
+ getMixMaterialFromDto(mixMaterialDto: MixMaterialDto): MixQuantity {
+ return this.mix.mixQuantities.find(m => m.material.id === mixMaterialDto.materialId)
}
getMixMaterialQuantityRounded(mixMaterial: MixMaterialDto): number {
@@ -121,7 +123,7 @@ export class MixTableComponent extends SubscribingComponent {
return totalQuantity
}
- getCalculatedQuantityHtml(mixMaterial: MixMaterial, index: number): string {
+ getCalculatedQuantityHtml(mixMaterial: MixQuantity, index: number): string {
const totalQuantity = this.round(this.getTotalQuantity(index))
const addedQuantity = this.round(this.calculateQuantity(index))
return ` +${addedQuantity} (${totalQuantity})`
@@ -137,7 +139,7 @@ export class MixTableComponent extends SubscribingComponent {
}
async print() {
- const base = this.mix.mixMaterials
+ const base = this.mix.mixQuantities
.map(ma => ma.material)
.filter(m => m.materialType.name === 'Base')[0]
if (!base) {
@@ -192,7 +194,8 @@ export class MixTableComponent extends SubscribingComponent {
quantity: this.calculateQuantity(index),
isPercents: quantity.isPercents,
position: quantity.position,
- units: UNIT_MILLILITER
+ units: UNIT_MILLILITER,
+ isMixType: false // TODO
})
}
diff --git a/src/app/modules/recipes/explore.html b/src/app/modules/recipes/explore.html
index 8d8f714..623858a 100644
--- a/src/app/modules/recipes/explore.html
+++ b/src/app/modules/recipes/explore.html
@@ -39,7 +39,7 @@
-
diff --git a/src/app/modules/recipes/explore.ts b/src/app/modules/recipes/explore.ts
index 084693e..dd59d1e 100644
--- a/src/app/modules/recipes/explore.ts
+++ b/src/app/modules/recipes/explore.ts
@@ -143,7 +143,7 @@ export class CreRecipeExplore extends ErrorHandlingComponent {
}
deductMix() {
- const firstMixMaterial = this.recipe.mixes.filter(m => m.id === this.deductedMixId)[0].mixMaterials[0]
+ const firstMixMaterial = this.recipe.mixes.filter(m => m.id === this.deductedMixId)[0].mixQuantities[0]
if (this.quantitiesChanges.has(this.deductedMixId) && this.quantitiesChanges.get(this.deductedMixId).has(firstMixMaterial.material.id)) {
const originalQuantity = firstMixMaterial.quantity
const currentQuantity = this.quantitiesChanges.get(this.deductedMixId).get(firstMixMaterial.material.id)
diff --git a/src/app/modules/recipes/mix/edit.html b/src/app/modules/recipes/mix/edit.html
index 14267ca..3888e4c 100644
--- a/src/app/modules/recipes/mix/edit.html
+++ b/src/app/modules/recipes/mix/edit.html
@@ -4,11 +4,8 @@
Retour
-
- Enregistrer
-
+ Supprimer
+ Enregistrer
@@ -22,4 +19,10 @@
Modification du mélange {{mix.mixType.name}} de la recette {{recipe.company.name}} - {{recipe.name}}
+
+
+
diff --git a/src/app/modules/recipes/mix/materials-form.html b/src/app/modules/recipes/mix/materials-form.html
index 5c7742c..56d2dc3 100644
--- a/src/app/modules/recipes/mix/materials-form.html
+++ b/src/app/modules/recipes/mix/materials-form.html
@@ -33,7 +33,7 @@
[mix]="mix"
[mixMaterials]="mixMaterials"
[control]="getControls(mixMaterial.position).materialId"
- [materials]="allMaterials"
+ [materials]="allMaterialsValues"
[position]="mixMaterial.position">
|
diff --git a/src/app/modules/recipes/mix/materials-form.ts b/src/app/modules/recipes/mix/materials-form.ts
index 06b22d7..47861ef 100644
--- a/src/app/modules/recipes/mix/materials-form.ts
+++ b/src/app/modules/recipes/mix/materials-form.ts
@@ -1,4 +1,13 @@
-import {AfterViewInit, ChangeDetectorRef, Component, Input, OnDestroy, OnInit, ViewChild, ViewChildren} from '@angular/core'
+import {
+ AfterViewInit,
+ ChangeDetectorRef,
+ Component,
+ Input,
+ OnDestroy,
+ OnInit,
+ ViewChild,
+ ViewChildren
+} from '@angular/core'
import {CreTable} from '../../shared/components/tables/tables'
import {Mix, MixMaterialDto, mixMaterialsToMixMaterialsDto, sortMixMaterialsDto} from '../../shared/model/recipe.model'
import {Observable, Subject} from 'rxjs'
@@ -38,10 +47,6 @@ export class MixMaterialsFormComboBox implements OnInit {
private filterMaterials(): CreInputEntry[] {
return this.materials
.filter(material => {
- if (this.mix && this.mix.mixType.material.id === material.id) {
- return false
- }
-
// Prevent use of percents in first position
if (material.materialType.usePercentages && this.mixMaterial.position <= 1) {
return false
@@ -54,7 +59,18 @@ export class MixMaterialsFormComboBox implements OnInit {
return this.mixMaterials.filter(x => x.materialId === material.id).length <= 0
})
.sort(materialComparator)
- .map(material => new CreInputEntry(material.id, material.name, material.materialType.prefix ? `[${material.materialType.prefix}] ${material.name}` : material.name))
+ .map(this.materialAsInputEntry)
+ }
+
+ private materialAsInputEntry(material: Material): CreInputEntry {
+ return new CreInputEntry(
+ material.id,
+ material.name,
+ material.materialType.prefix ? `[${material.materialType.prefix}] ${material.name}` : material.name,
+ {
+ bold: material.isMixType
+ }
+ )
}
}
@@ -71,7 +87,8 @@ export class MixMaterialsForm implements AfterViewInit, OnDestroy {
mixMaterials: MixMaterialDto[] = []
columns = ['position', 'positionButtons', 'material', 'quantity', 'units', 'endButton']
- allMaterials: Material[]
+ allMaterials = new Map();
+ allMaterialsValues = [];
private _controls: ControlsByPosition[] = []
private _destroy$ = new Subject()
@@ -85,7 +102,9 @@ export class MixMaterialsForm implements AfterViewInit, OnDestroy {
ngAfterViewInit() {
this.materials.subscribe({
next: materials => {
- this.allMaterials = materials
+ this.allMaterials.clear()
+ this.allMaterialsValues = materials
+ materials.forEach(m => this.allMaterials.set(m.id, m))
if (!this.mix) {
this.addRow()
@@ -105,7 +124,7 @@ export class MixMaterialsForm implements AfterViewInit, OnDestroy {
}
addRow() {
- const mixMaterial = new MixMaterialDto(null, 0, false, this.nextPosition, UNIT_MILLILITER)
+ const mixMaterial = new MixMaterialDto(null, 0, false, this.nextPosition, UNIT_MILLILITER, false)
this.insertRow(mixMaterial)
this.table.renderRows()
}
@@ -170,7 +189,7 @@ export class MixMaterialsForm implements AfterViewInit, OnDestroy {
return false
}
- return mixMaterial.materialId ? this.allMaterials?.filter(x => x.id === mixMaterial.materialId)[0].materialType.usePercentages : false
+ return mixMaterial.materialId ? this.allMaterials.get(mixMaterial.materialId)?.materialType.usePercentages : false
}
isDecreasePositionButtonDisabled(mixMaterial: MixMaterialDto): boolean {
@@ -195,19 +214,23 @@ export class MixMaterialsForm implements AfterViewInit, OnDestroy {
}
get materialCount(): number {
- return this.allMaterials ? this.allMaterials.length : 0
+ return this.allMaterials.size
}
get updatedMixMaterials(): MixMaterialDto[] {
const updatedMixMaterials: MixMaterialDto[] = []
this.mixMaterials.forEach(mixMaterial => {
const controls = this.getControlsByPosition(mixMaterial.position).controls
+ const materialId = controls.materialId.value;
+ const material = this.allMaterials.get(materialId)
+
updatedMixMaterials.push({
- materialId: controls.materialId.value,
+ ...mixMaterial,
+ materialId,
quantity: controls.quantity.value,
- position: mixMaterial.position,
units: controls.units.value,
- isPercents: this.areUnitsPercents(mixMaterial)
+ isPercents: material.materialType.usePercentages,
+ isMixType: material.isMixType
})
})
return updatedMixMaterials
diff --git a/src/app/modules/recipes/mix/mix.ts b/src/app/modules/recipes/mix/mix.ts
index a91833f..9480c20 100644
--- a/src/app/modules/recipes/mix/mix.ts
+++ b/src/app/modules/recipes/mix/mix.ts
@@ -27,7 +27,7 @@ abstract class _BaseMixPage extends SubscribingComponent {
protected mixService: MixService,
private recipeService: RecipeService,
private materialTypeService: MaterialTypeService,
- private materialService: MaterialService,
+ protected materialService: MaterialService,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
@@ -50,13 +50,15 @@ abstract class _BaseMixPage extends SubscribingComponent {
set recipe(recipe: Recipe) {
this._recipe = recipe
- this.materials$ = this.materialService.getAllForMixCreation(recipe.id)
+ this.materials$ = this.fetchMaterials(recipe.id)
}
get recipe(): Recipe {
return this._recipe
}
+ protected abstract fetchMaterials(recipeId: number): Observable
+
abstract submit(dto: MixSaveDto)
}
@@ -65,6 +67,10 @@ abstract class _BaseMixPage extends SubscribingComponent {
templateUrl: 'add.html'
})
export class MixAdd extends _BaseMixPage {
+ protected fetchMaterials(recipeId: number): Observable {
+ return this.materialService.getAllForMixCreation(recipeId)
+ }
+
submit(dto: MixSaveDto) {
this.subscribeAndNavigate(
this.mixService.saveDto(dto),
@@ -80,27 +86,40 @@ export class MixAdd extends _BaseMixPage {
export class MixEdit extends _BaseMixPage {
mix: Mix
+ private mixId: number
+
ngOnInit() {
super.ngOnInit()
+ this.mixId = this.urlUtils.parseIntUrlParam('id')
+
this.fetchMix()
}
private fetchMix() {
- const mixId = this.urlUtils.parseIntUrlParam('id')
-
this.subscribe(
- this.mixService.getById(mixId),
+ this.mixService.getById(this.mixId),
mix => this.mix = mix
)
}
+ protected fetchMaterials(recipeId: number): Observable {
+ return this.materialService.getAllForMixUpdate(this.mixId)
+ }
+
submit(dto: MixSaveDto) {
this.subscribeAndNavigate(
this.mixService.updateDto({...dto, id: this.mix.id}),
`/color/edit/${this.recipe.id}`
)
}
+
+ delete() {
+ this.subscribeAndNavigate(
+ this.mixService.delete(this.mixId),
+ '/color/edit/' + this.recipe.id
+ )
+ }
}
@Component({
@@ -126,7 +145,7 @@ export class MixInfoForm implements OnInit {
this.controls = {
name: new FormControl(this.mix?.mixType.name, Validators.required),
- materialType: new FormControl(this.mix?.mixType.material.materialType.id, Validators.required)
+ materialType: new FormControl(this.mix?.mixType.materialType.id, Validators.required)
}
}
@@ -161,7 +180,7 @@ export class MixForm {
name: this.infoForm.mixName,
recipeId: this.recipe.id,
materialTypeId: this.infoForm.mixMaterialTypeId,
- mixMaterials: this.mixMaterialsForm.updatedMixMaterials
+ mixQuantities: this.mixMaterialsForm.updatedMixMaterials
}
}
diff --git a/src/app/modules/recipes/services/mix.service.ts b/src/app/modules/recipes/services/mix.service.ts
index 6a523e1..4e63441 100644
--- a/src/app/modules/recipes/services/mix.service.ts
+++ b/src/app/modules/recipes/services/mix.service.ts
@@ -26,7 +26,7 @@ export class MixService {
dto.name,
dto.recipeId,
dto.materialTypeId,
- dto.mixMaterials,
+ dto.mixQuantities,
)
}
@@ -39,7 +39,7 @@ export class MixService {
name,
recipeId,
materialTypeId,
- mixMaterials: []
+ mixQuantities: []
}
this.appendMixMaterialsToBody(mixMaterials, body)
return this.api.post('/recipe/mix', body)
@@ -50,7 +50,7 @@ export class MixService {
dto.id,
dto.name,
dto.materialTypeId,
- dto.mixMaterials
+ dto.mixQuantities
)
}
@@ -63,7 +63,7 @@ export class MixService {
id,
name,
materialTypeId,
- mixMaterials: []
+ mixQuantities: []
}
this.appendMixMaterialsToBody(mixMaterials, body)
@@ -84,10 +84,11 @@ export class MixService {
private appendMixMaterialsToBody(mixMaterials: MixMaterialDto[], body: any) {
mixMaterials.filter(m => m.materialId != null && m.quantity != null).forEach(m => {
- body.mixMaterials.push({
+ body.mixQuantities.push({
materialId: m.materialId,
quantity: m.quantity,
- position: m.position
+ position: m.position,
+ isMixType: m.isMixType
})
})
}
@@ -97,13 +98,13 @@ export interface MixSaveDto {
name: string
recipeId: number
materialTypeId: number
- mixMaterials: MixMaterialDto[]
+ mixQuantities: MixMaterialDto[]
}
export interface MixUpdateDto {
id: number
name: string
materialTypeId: number
- mixMaterials: MixMaterialDto[]
+ mixQuantities: MixMaterialDto[]
}
diff --git a/src/app/modules/recipes/services/recipe-image.service.ts b/src/app/modules/recipes/services/recipe-image.service.ts
index 0c5f236..ac3ca5f 100644
--- a/src/app/modules/recipes/services/recipe-image.service.ts
+++ b/src/app/modules/recipes/services/recipe-image.service.ts
@@ -12,10 +12,10 @@ export class RecipeImageService {
) {
}
- save(image: File, recipeId: number): Observable {
+ save(image: File, recipeId: number): Observable {
const body = new FormData()
body.append('image', image)
- return this.api.put(`/recipe/${recipeId}/image`, body)
+ return this.api.put(`/recipe/${recipeId}/image`, body)
}
delete(url: string, recipeId: number): Observable {
diff --git a/src/app/modules/recipes/services/recipe.service.ts b/src/app/modules/recipes/services/recipe.service.ts
index 4554569..a68c4bf 100644
--- a/src/app/modules/recipes/services/recipe.service.ts
+++ b/src/app/modules/recipes/services/recipe.service.ts
@@ -84,4 +84,8 @@ export class RecipeService {
delete(id: number): Observable {
return this.api.delete(`/recipe/${id}`)
}
+
+ getImagesIds(id: number): Observable {
+ return this.api.get(`/recipe/${id}/image`)
+ }
}
diff --git a/src/app/modules/shared/components/inputs/combo-box.html b/src/app/modules/shared/components/inputs/combo-box.html
index 67e0162..3b80f93 100644
--- a/src/app/modules/shared/components/inputs/combo-box.html
+++ b/src/app/modules/shared/components/inputs/combo-box.html
@@ -16,7 +16,11 @@
-
+
{{entry.display ? entry.display : entry.value}}
diff --git a/src/app/modules/shared/components/inputs/inputs.ts b/src/app/modules/shared/components/inputs/inputs.ts
index 7b53fef..6822574 100644
--- a/src/app/modules/shared/components/inputs/inputs.ts
+++ b/src/app/modules/shared/components/inputs/inputs.ts
@@ -167,7 +167,6 @@ export class CreComboBoxComponent {
internalControl: FormControl
filteredEntries: CreInputEntry[]
- validValue = false
private _destroy$ = new Subject()
private _entries: CreInputEntry[]
@@ -466,11 +465,16 @@ export class CreInputEntry {
constructor(
public key: any,
public value: any,
- public display?: any
+ public display?: any,
+ public styleOptions?: CreInputEntryStyleOptions
) {
}
}
+export interface CreInputEntryStyleOptions {
+ bold?: boolean
+}
+
export function chipListRequired(): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
return !control.value || control.value.length <= 0 ? {required: true} : null
diff --git a/src/app/modules/shared/model/material.model.ts b/src/app/modules/shared/model/material.model.ts
index 681e1f6..540bfb6 100644
--- a/src/app/modules/shared/model/material.model.ts
+++ b/src/app/modules/shared/model/material.model.ts
@@ -7,13 +7,14 @@ export class Material {
public name: string,
public inventoryQuantity: number,
public materialType: MaterialType,
- public simdutUrl: string
+ public isMixType: boolean,
+ public hasSimdut: boolean
) {
}
}
export function openSimdut(material: Material) {
- openPdf(material.simdutUrl)
+ openPdf(`simdut/${material.name}`)
}
export const materialComparator = (a: Material, b: Material): number => {
diff --git a/src/app/modules/shared/model/recipe.model.ts b/src/app/modules/shared/model/recipe.model.ts
index 7134171..9f822ed 100644
--- a/src/app/modules/shared/model/recipe.model.ts
+++ b/src/app/modules/shared/model/recipe.model.ts
@@ -2,6 +2,7 @@ import {Material} from './material.model'
import {Company} from './company.model'
import {Group} from './user'
import {UNIT_MILLILITER} from "../units";
+import {MaterialType} from "./materialtype.model";
export class Recipe {
public id: number
@@ -16,7 +17,6 @@ export class Recipe {
public mixes: Mix[]
public approbationExpired: boolean
public groupsInformation: RecipeGroupInformation[]
- public imagesUrls: string[]
}
export class RecipeGroupInformation {
@@ -33,13 +33,13 @@ export class Mix {
constructor(
public id: number,
public mixType: MixType,
- public mixMaterials: MixMaterial[],
+ public mixQuantities: MixQuantity[],
public location: string,
) {
}
}
-export class MixMaterial {
+export class MixQuantity {
constructor(
public id: number,
public material: Material,
@@ -55,7 +55,8 @@ export class MixMaterialDto {
public quantity: number,
public isPercents: boolean,
public position: number,
- public units: string
+ public units: string,
+ public isMixType: boolean
) {
}
}
@@ -64,7 +65,7 @@ class MixType {
constructor(
public id: number,
public name: string,
- public material: Material
+ public materialType: MaterialType
) {
}
}
@@ -101,12 +102,13 @@ export function sortRecipeSteps(steps: RecipeStep[]): RecipeStep[] {
}
export function mixMaterialsToMixMaterialsDto(mix: Mix): MixMaterialDto[] {
- return sortMixMaterialsDto(mix.mixMaterials.map(m => new MixMaterialDto(
+ return sortMixMaterialsDto(mix.mixQuantities.map(m => new MixMaterialDto(
m.material.id,
m.quantity,
m.material.materialType.usePercentages,
m.position,
- UNIT_MILLILITER
+ UNIT_MILLILITER,
+ m.material.isMixType
)))
}
diff --git a/src/app/modules/shared/utils/utils.ts b/src/app/modules/shared/utils/utils.ts
index dfa6bf9..9f7972b 100644
--- a/src/app/modules/shared/utils/utils.ts
+++ b/src/app/modules/shared/utils/utils.ts
@@ -10,20 +10,28 @@ export function valueOr(value: T, or: T): T {
const MEDIA_TYPE_PDF = 'application/pdf'
const MEDIA_TYPE_JPG = 'image/jpeg'
-export function openPdf(url: string) {
- openUrl(url, MEDIA_TYPE_PDF)
+export function getImageUrl(path: string): string {
+ return getFileUri(`images/${path}`, MEDIA_TYPE_JPG)
}
-export function openJpg(url: string) {
- openUrl(url, MEDIA_TYPE_JPG)
+export function getFileUri(path: string, mediaType: string): string {
+ return `${environment.apiUrl}/file?path=${encodeURIComponent(path)}&mediaType=${encodeURIComponent(mediaType)}`
+}
+
+export function openPdf(path: string) {
+ openFileUri(`pdf/${path}.pdf`, MEDIA_TYPE_PDF)
+}
+
+export function openJpg(path: string) {
+ openFileUri(`images/${path}`, MEDIA_TYPE_JPG)
}
export function openTouchUpKit(touchUpKit: TouchUpKit) {
openRawUrl(`${environment.apiUrl}/touchupkit/pdf?project=${touchUpKit.project}`)
}
-export function openUrl(url: string, mediaType: string) {
- openRawUrl(`${url}&mediaType=${encodeURIComponent(mediaType)}`)
+export function openFileUri(path: string, mediaType: string) {
+ openRawUrl(getFileUri(path, mediaType))
}
export function openRawUrl(url: string) {
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index ae45e0b..c62f514 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -1,4 +1,5 @@
export const environment = {
production: true,
+ apiBaseUrl: window.location.origin,
apiUrl: window.location.origin + '/api'
};
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 8a40323..e5b8c49 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -4,6 +4,7 @@
export const environment = {
production: false,
+ apiBaseUrl: 'http://localhost:9090',
apiUrl: 'http://localhost:9090/api'
};