Skip to content

Commit 332d348

Browse files
committed
fix: add file uploads progress indicator
1 parent fc9aa1f commit 332d348

File tree

8 files changed

+3069
-11658
lines changed

8 files changed

+3069
-11658
lines changed

package-lock.json

Lines changed: 2987 additions & 11656 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"@angular/common": "^20.3.0",
3838
"@angular/compiler": "^20.3.0",
3939
"@angular/core": "^20.3.0",
40+
"@angular/cdk": "^20.2.3",
41+
"@angular/forms": "^20.3.0",
42+
"@angular/material": "^20.2.3",
4043
"@angular/platform-browser": "^20.3.0",
4144
"@angular/platform-browser-dynamic": "^20.3.0",
4245
"@angular/router": "^20.3.0",
@@ -63,4 +66,4 @@
6366
"ng-packagr": "^20.3.0",
6467
"typescript": "~5.9.2"
6568
}
66-
}
69+
}

projects/ngx-file-upload/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"@angular/common": "^20.3.0",
1111
"@angular/compiler": "^20.3.0",
1212
"@angular/core": "^20.3.0",
13+
"@angular/cdk": "^20.2.3",
14+
"@angular/forms": "^20.3.0",
15+
"@angular/material": "^20.2.3",
1316
"@angular/platform-browser": "^20.3.0",
1417
"@angular/platform-browser-dynamic": "^20.3.0",
1518
"@angular/router": "^20.3.0"
@@ -18,4 +21,4 @@
1821
"tslib": "^2.3.0"
1922
},
2023
"sideEffects": false
21-
}
24+
}

projects/ngx-file-upload/src/lib/file-uploads-progress/file-uploads-progress.component.css

Whitespace-only changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div [hidden]="!totalUploads()"
2+
class="fixed bottom-0 right-0 z-10 rounded-tl-lg rounded-tr-lg md:rounded-tr-none w-full md:max-w-sm p-6 bg-blue-700 text-white">
3+
<div class="flex justify-between gap-x-6">
4+
<h4 class="font-medium">Uploading Files</h4>
5+
<h6 class="text-sm">{{currentUploadIndex()}} of {{totalUploads()}}</h6>
6+
</div>
7+
<div class="flex">
8+
<div class="h-4 bg-gray-200 overflow-hidden mt-2 flex-grow">
9+
<div class="bg-gradient-to-r from-purple-500 to-pink-500 h-4 relative" [style]="'width:'+(uploadProgress()??0)+'%'">
10+
<p class="absolute top-0 left-0 w-full text-center text-xs text-white">{{uploadProgress()}}%</p>
11+
</div>
12+
</div>
13+
@if (isUploadsResumeData()) {
14+
<button (click)="resumeUploadFilesEvent.emit()" matRipple class="p-1 !overflow-visible">
15+
<mat-icon class="align-middle !h-[20px] !w-[20px] text-[20px]">play_circle_outline</mat-icon>
16+
</button>
17+
}
18+
</div>
19+
@for (fileUploadProgress of filesUploadProgress(); track fileUploadProgress.name) {
20+
<div class="mt-2">
21+
<p class="text-xs text-right text-ellipsis whitespace-nowrap overflow-hidden">{{fileUploadProgress.name}}</p>
22+
<div class="h-4 bg-gray-200 overflow-hidden flex-grow">
23+
<div class="bg-gradient-to-r from-purple-500 to-pink-500 h-4 relative"
24+
[style]="'width:'+(fileUploadProgress.progress)+'%'">
25+
<p class="absolute top-0 left-0 w-full text-center text-xs text-white">{{fileUploadProgress.progress}}%
26+
</p>
27+
</div>
28+
</div>
29+
</div>
30+
}
31+
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { FileUploadsProgressComponent } from './file-uploads-progress.component';
4+
5+
describe('FileUploadsProgressComponent', () => {
6+
let component: FileUploadsProgressComponent;
7+
let fixture: ComponentFixture<FileUploadsProgressComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [FileUploadsProgressComponent]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(FileUploadsProgressComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, input, output } from '@angular/core';
2+
import { MatIcon } from '@angular/material/icon';
3+
4+
@Component({
5+
selector: 'ngx-file-uploads-progress',
6+
imports: [MatIcon],
7+
templateUrl: './file-uploads-progress.component.html',
8+
styleUrl: './file-uploads-progress.component.css'
9+
})
10+
export class FileUploadsProgressComponent {
11+
readonly resumeUploadFilesEvent = output<void>();
12+
readonly isPhotoUploadsBusy = input<boolean>(false);
13+
14+
public totalUploads = input<number | undefined>();
15+
public uploadProgress = input<number | undefined>();
16+
public currentUploadIndex = input<number | undefined>();
17+
public filesUploadProgress = input<{ name: string, progress: number }[] | undefined>();
18+
public isUploadsResumeData = input<boolean>();
19+
}

projects/ngx-file-upload/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Public API Surface of ngx-file-upload
33
*/
44

5+
export * from './lib/file-uploads-progress/file-uploads-progress.component';
56
export * from './lib/file-upload/file-upload-response.interface';
67
export * from './lib/file-upload/file-upload-timeout.error';
78
export * from './lib/file-upload/file-upload.service';

0 commit comments

Comments
 (0)