From 9ed7602e307db403bd32164f8e480bae870a53f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mehmet=20=C3=87etin?=
<92744169+mehmetcetin01140@users.noreply.github.com>
Date: Thu, 9 May 2024 18:14:21 +0300
Subject: [PATCH 11/11] update fileupload templatedoc
---
.../showcase/doc/fileupload/templatedoc.ts | 157 +++++++++++++++---
1 file changed, 134 insertions(+), 23 deletions(-)
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: `
+ html: `
-
- Upload 3 Files
+
+
+
+
100 }">
+ {{ totalSize }}B / 1Mb
+
+
-
- Custom UI to display a file
+
+ 0">
+
Pending
+
+
+
+
+
+
{{ file.name }}
+
{{ formatSize(file.size) }}
+
+
+
+
+ 0">
+
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]}\`;
+ }
+}`
};
}