Skip to content

Commit

Permalink
feat: Add images endpoint (#71)
Browse files Browse the repository at this point in the history
* feat: connected images service to theme

* feat: add images

* feat: add bff security

* feat: change image upload

* feat: lint update

* feat: constraint fix

* feat: test change

* feat: change img size

* fix: url problems fix

* feat: url reset

* feat: fetchingURLs update

* feat: fetching URL change update

---------

Co-authored-by: Henry Täschner <[email protected]>
  • Loading branch information
jsteenke and HenryT-CG authored Feb 19, 2024
1 parent f8daeb4 commit b38bc9b
Show file tree
Hide file tree
Showing 20 changed files with 773 additions and 96 deletions.
4 changes: 3 additions & 1 deletion src/app/shared/generated/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
README.md
api.module.ts
api/api.ts
api/imagesInternal.service.ts
api/themes.service.ts
configuration.ts
encoder.ts
Expand All @@ -14,21 +15,22 @@ model/eximTheme.ts
model/exportThemeRequest.ts
model/getThemeResponse.ts
model/getThemesResponse.ts
model/imageInfo.ts
model/importThemeResponse.ts
model/importThemeResponseStatus.ts
model/models.ts
model/pagingResponse.ts
model/problemDetailInvalidParam.ts
model/problemDetailParam.ts
model/problemDetailResponse.ts
model/refType.ts
model/searchThemeRequest.ts
model/searchThemeResponse.ts
model/theme.ts
model/themeSnapshot.ts
model/themeUpdateCreate.ts
model/updateThemeRequest.ts
model/updateThemeResponse.ts
model/validationConstraint.ts
model/workspace.ts
param.ts
variables.ts
4 changes: 3 additions & 1 deletion src/app/shared/generated/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './imagesInternal.service';
import { ImagesInternalAPIService } from './imagesInternal.service';
export * from './themes.service';
import { ThemesAPIService } from './themes.service';
export const APIS = [ThemesAPIService];
export const APIS = [ImagesInternalAPIService, ThemesAPIService];
335 changes: 335 additions & 0 deletions src/app/shared/generated/api/imagesInternal.service.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
*/


export interface ValidationConstraint {
name?: string;
message?: string;
export interface ImageInfo {
id?: string;
}

3 changes: 2 additions & 1 deletion src/app/shared/generated/model/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ export * from './eximTheme';
export * from './exportThemeRequest';
export * from './getThemeResponse';
export * from './getThemesResponse';
export * from './imageInfo';
export * from './importThemeResponse';
export * from './importThemeResponseStatus';
export * from './pagingResponse';
export * from './problemDetailInvalidParam';
export * from './problemDetailParam';
export * from './problemDetailResponse';
export * from './refType';
export * from './searchThemeRequest';
export * from './searchThemeResponse';
export * from './theme';
export * from './themeSnapshot';
export * from './themeUpdateCreate';
export * from './updateThemeRequest';
export * from './updateThemeResponse';
export * from './validationConstraint';
export * from './workspace';
18 changes: 18 additions & 0 deletions src/app/shared/generated/model/refType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* onecx-theme-bff
* OneCx theme Bff
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


export enum RefType {
Logo = 'logo',
Favicon = 'favicon'
}

2 changes: 1 addition & 1 deletion src/app/shared/generated/model/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


export interface Theme {
version?: number;
modificationCount?: number;
creationDate?: string;
creationUser?: string;
modificationDate?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/generated/model/themeUpdateCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


export interface ThemeUpdateCreate {
version?: number;
modificationCount?: number;
creationDate?: string;
creationUser?: string;
modificationDate?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/generated/model/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


export interface Workspace {
workspaceName?: string;
name?: string;
description?: string;
}

20 changes: 16 additions & 4 deletions src/app/theme/theme-designer/theme-designer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
accept=".png, .jpg, .jpeg"
/>

<div class="field col-12 mb-3">
<div class="field col-12 mb-3" *ngIf="constraintUpload()">
<div class="flex flex-wrap sm:flex-nowrap align-items-center pb-2 row-gap-2 column-gap-4">
<app-image-container
[imageUrl]="fetchingLogoUrl"
Expand All @@ -98,7 +98,13 @@
<i class="pi pi-upload"></i>
</span>
<span class="p-float-label">
<input pInputText type="text" id="theme_detail_upload_logo" formControlName="logoUrl" />
<input
pInputText
type="text"
id="theme_detail_upload_logo"
formControlName="logoUrl"
(input)="inputChange(theme, 'logo')"
/>
<label for="theme_detail_upload_logo">{{ 'Logo' }}</label>
</span>
<span
Expand All @@ -116,7 +122,7 @@
</div>
</div>
</div>
<div class="field col-12 mb-0">
<div class="field col-12 mb-0" *ngIf="constraintUpload()">
<div class="flex flex-wrap sm:flex-nowrap align-items-center row-gap-2 column-gap-4">
<app-image-container
[imageUrl]="fetchingFaviconUrl"
Expand All @@ -134,7 +140,13 @@
<i class="pi pi-upload"></i>
</span>
<span class="p-float-label">
<input pInputText type="text" id="favicon" formControlName="faviconUrl" />
<input
pInputText
type="text"
id="favicon"
formControlName="faviconUrl"
(input)="inputChange(theme, 'favicon')"
/>
<label for="favicon">Favicon</label>
</span>
<div class="flex flex-column">
Expand Down
23 changes: 2 additions & 21 deletions src/app/theme/theme-designer/theme-designer.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,25 +259,6 @@ describe('ThemeDesignerComponent', () => {
expect(component.themeId).toBe('id')
})

it('should fetch logo and favicon from backend on edit mode when no http[s] present', () => {
const themeData = {
name: 'themeName',
logoUrl: 'logo_url',
faviconUrl: 'fav_url'
}
const themeResponse = {
resource: themeData
}
themeApiSpy.getThemeByName.and.returnValue(of(themeResponse) as any)
component.mode = 'EDIT'
component.themeName = 'themeName'

component.ngOnInit()

expect(component.fetchingLogoUrl).toBe(prepareUrl(themeData.logoUrl))
expect(component.fetchingFaviconUrl).toBe(prepareUrl(themeData.faviconUrl))
})

it('should fetch logo and favicon from external source on edit mode when http[s] present', () => {
const themeData = {
logoUrl: 'http://myWeb.com/logo_url',
Expand Down Expand Up @@ -967,8 +948,8 @@ describe('ThemeDesignerComponent', () => {
general: jasmine.objectContaining({ 'primary-color': 'rgb(255,255,255)' })
})
)
expect(component.fetchingFaviconUrl).toBe(prepareUrl('fetchedFavUrl'))
expect(component.fetchingLogoUrl).toBe(prepareUrl('fetchedLogoUrl'))
expect(component.fetchingFaviconUrl).toBe(undefined)
expect(component.fetchingLogoUrl).toBe(prepareUrl(undefined))
})
})
})
Loading

0 comments on commit b38bc9b

Please sign in to comment.