diff --git a/src/app/showcase/doc/fileupload/templatedoc.ts b/src/app/showcase/doc/fileupload/templatedoc.ts index 97e918e1670..b9ee610d24d 100644 --- a/src/app/showcase/doc/fileupload/templatedoc.ts +++ b/src/app/showcase/doc/fileupload/templatedoc.ts @@ -1,4 +1,4 @@ -import { Component, inject } from '@angular/core'; +import { Component } from '@angular/core'; import { Code } from '@domain/code'; import { PrimeNGConfig } from 'primeng/api'; @@ -67,7 +67,7 @@ import { PrimeNGConfig } from 'primeng/api'; ` }) export class TemplateDoc { - config = inject(PrimeNGConfig); + constructor(private config: PrimeNGConfig) {} choose(event, callback) { callback(); @@ -97,38 +97,149 @@ export class TemplateDoc { code: Code = { basic: ` - -
Upload 3 Files
-
- -
Custom UI to display a file
-
- -
Additional content.
-
+ +
+
+ + + +
+ + {{ totalSize }}B / 1Mb + +
+
+ +
+
Pending
+
+
+
+ +
+ {{ file.name }} +
{{ formatSize(file.size) }}
+ +
+
+
+
+
Completed
+
+
+
+ +
+ {{ file.name }} +
{{ formatSize(file.size) }}
+ + +
+
+
+
+ +
+ +

Drag and drop files to here to upload.

+
+
`, - html: ` -
+ html: `
- -
Upload 3 Files
+ +
+
+ + + +
+ + {{ totalSize }}B / 1Mb + +
- -
Custom UI to display a file
+ +
+
Pending
+
+
+
+ +
+ {{ file.name }} +
{{ formatSize(file.size) }}
+ +
+
+
+
+
Completed
+
+
+
+ +
+ {{ file.name }} +
{{ formatSize(file.size) }}
+ + +
+
+
- -
Additional content.
+ +
+ +

Drag and drop files to here to upload.

+
`, - typescript: ` -import { Component, Input } from '@angular/core'; - + typescript: `import { Component } from '@angular/core'; +import { PrimeNGConfig} from 'primeng/api'; +import { FileUploadModule } from 'primeng/fileupload'; +import { ButtonModule } from 'primeng/button'; +import { CommonModule } from '@angular/common'; +import { BadgeModule } from 'primeng/badge'; +import { HttpClientModule } from '@angular/common/http'; +import { ProgressBarModule } from 'primeng/progressbar'; + @Component({ selector: 'file-upload-template-demo', templateUrl: './file-upload-template-demo.html', + standalone: true, + imports: [FileUploadModule, ButtonModule, BadgeModule, ProgressBarModule, HttpClientModule, CommonModule] }) -export class FileUploadTemplateDemo {}` +export class FileUploadTemplateDemo { + constructor(private config: PrimeNGConfig) {} + + choose(event, callback) { + callback(); + } + + onRemoveTemplatingFile(event, file, removeFileCallback, index) { + removeFileCallback(event, index); + } + + uploadEvent(callback) { + callback(); + } + + formatSize(bytes) { + const k = 1024; + const dm = 3; + const sizes = this.config.translation.fileSizeTypes; + if (bytes === 0) { + return \`0 \${sizes[0]}\`; + } + + const i = Math.floor(Math.log(bytes) / Math.log(k)); + const formattedSize = parseFloat((bytes / Math.pow(k, i)).toFixed(dm)); + + return \`\${formattedSize} \${sizes[i]}\`; + } +}` }; }