diff --git a/README.md b/README.md index 81e49f09..6c30ee03 100644 --- a/README.md +++ b/README.md @@ -79,3 +79,7 @@ Make sure `ng build cps-ui-kit --watch` is running, so the library will be rebui #### Generate API documentation Execute `npm run generate-json-api` to generate documentation for any changes in the components' API. + +#### Run cypress tests + +`npm run test` diff --git a/projects/composition/src/app/api-data/cps-file-upload.json b/projects/composition/src/app/api-data/cps-file-upload.json index 08b804c5..ec612b5a 100644 --- a/projects/composition/src/app/api-data/cps-file-upload.json +++ b/projects/composition/src/app/api-data/cps-file-upload.json @@ -29,6 +29,14 @@ "default": "100%", "description": "Width of the component, a number denoting pixels or a string." }, + { + "name": "fileInfo", + "optional": false, + "readonly": false, + "type": "string", + "default": "", + "description": "Expected file info block, explaining some extra stuff about file." + }, { "name": "fileProcessingCallback", "optional": true, diff --git a/projects/composition/src/app/pages/file-upload-page/file-upload-page.component.html b/projects/composition/src/app/pages/file-upload-page/file-upload-page.component.html index 5ada0e7f..466e8c56 100644 --- a/projects/composition/src/app/pages/file-upload-page/file-upload-page.component.html +++ b/projects/composition/src/app/pages/file-upload-page/file-upload-page.component.html @@ -1,12 +1,44 @@ - - +

File upload component with the dependency on selected file extension

+
+

+ + +
+ + +

+
+ + + +

File upload component with extra info

+
+

+ + +

+
+
diff --git a/projects/composition/src/app/pages/file-upload-page/file-upload-page.component.ts b/projects/composition/src/app/pages/file-upload-page/file-upload-page.component.ts index 78c70c5c..7d028d3c 100644 --- a/projects/composition/src/app/pages/file-upload-page/file-upload-page.component.ts +++ b/projects/composition/src/app/pages/file-upload-page/file-upload-page.component.ts @@ -1,6 +1,12 @@ import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { CpsFileUploadComponent } from 'cps-ui-kit'; +import { + CpsFileUploadComponent, + CpsButtonToggleComponent, + CpsButtonToggleOption, + CpsIconComponent, + CpsDividerComponent +} from 'cps-ui-kit'; import { Observable, catchError, from, map, of } from 'rxjs'; import ComponentData from '../../api-data/cps-file-upload.json'; @@ -9,7 +15,14 @@ import { ComponentDocsViewerComponent } from '../../components/component-docs-vi @Component({ selector: 'app-file-upload-page', standalone: true, - imports: [CommonModule, CpsFileUploadComponent, ComponentDocsViewerComponent], + imports: [ + CommonModule, + CpsIconComponent, + CpsButtonToggleComponent, + CpsFileUploadComponent, + ComponentDocsViewerComponent, + CpsDividerComponent + ], templateUrl: './file-upload-page.component.html', styleUrls: ['./file-upload-page.component.scss'], host: { class: 'composition-page' } @@ -17,6 +30,17 @@ import { ComponentDocsViewerComponent } from '../../components/component-docs-vi export class FileUploadPageComponent { componentData = ComponentData; + fileUploadOptions: CpsButtonToggleOption[] = [ + { label: 'JPG image', value: '.jpg' }, + { label: 'PDF document', value: '.pdf' }, + { label: 'PNG image', value: '.png' } + ]; + + selectedFileUploadType: CpsButtonToggleOption = this.fileUploadOptions[0]; + + fileInfo: string = + 'The file should be a small sample file to infer the schema, which will be shown in the next step'; + processUploadedFile(file: File): Observable { return from(file.text()).pipe( map((fileContentsAsText) => { @@ -41,4 +65,13 @@ export class FileUploadPageComponent { onUploadedFileRemoved(fileName: string) { console.log('File removed: ', fileName); } + + onFileExtensionChanged(event: string) { + const foundSelectedItem = this.fileUploadOptions.find( + (item) => item.value === event + ); + if (foundSelectedItem) { + this.selectedFileUploadType = foundSelectedItem; + } + } } diff --git a/projects/cps-ui-kit/src/lib/components/cps-file-upload/cps-file-upload.component.html b/projects/cps-ui-kit/src/lib/components/cps-file-upload/cps-file-upload.component.html index 0c3e10ff..82345c8e 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-file-upload/cps-file-upload.component.html +++ b/projects/cps-ui-kit/src/lib/components/cps-file-upload/cps-file-upload.component.html @@ -1,4 +1,4 @@ -
+
+ + {{fileInfo}} +
+ } ext.startsWith('.') ? ext : '.' + ext );