Skip to content

Commit

Permalink
Removing focus test and running prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz committed Jan 31, 2024
1 parent 0a01ea4 commit 50ceecc
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 46 deletions.
126 changes: 84 additions & 42 deletions src/app/components/attachments/attachments.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ <h5>Upload new attachments</h5>
class="custom-file-input"
id="newAttachment"
/>
<label
class="custom-file-label"
for="newAttachment"
<label class="custom-file-label" for="newAttachment"
>Choose files</label
>
</div>
Expand All @@ -75,45 +73,70 @@ <h5>Upload new attachments</h5>
<h5>Upload queue</h5>
<p>Queue length: {{ uploader?.queue?.length }}</p>
<table class="table">
<thead>
<thead>
<tr>
<th width="50%">Name</th>
<th>Size</th>
<th>Progress</th>
<th>Status</th>
<th>Actions</th>
<th width="50%">Name</th>
<th>Size</th>
<th>Progress</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</thead>
<tbody>
<tr *ngFor="let item of uploader.queue">
<td><strong>{{ item?.file?.name }}</strong></td>
<td *ngIf="uploader.options.isHTML5" nowrap>{{ item?.file?.size/1024/1024 | number:'.2' }} MB</td>
<td *ngIf="uploader.options.isHTML5">
<div class="progress" style="margin-bottom: 0;">
<div class="progress-bar" role="progressbar" [ngStyle]="{ 'width': item.progress + '%' }"></div>
</div>
</td>
<td class="text-center">
<span *ngIf="item.isSuccess" class="text-success"><i class="fa fa-check-circle"></i></span>
<span *ngIf="item.isCancel" class="text-warning"><i class="fa fa-ban"></i></span>
<span *ngIf="item.isError" class="text-danger"><i class="fa fa-exclamation-triangle"></i></span>
</td>
<td nowrap>
<button type="button" class="btn btn-success"
(click)="item.upload()" [disabled]="item.isReady || item.isUploading || item.isSuccess">
<span class="glyphicon glyphicon-upload"></span> Upload
</button>
<button type="button" class="btn btn-warning"
(click)="item.cancel()" [disabled]="!item.isUploading">
<span class="glyphicon glyphicon-ban-circle"></span> Cancel
</button>
<button type="button" class="btn btn-danger"
(click)="item.remove()">
<span class="glyphicon glyphicon-trash"></span> Remove
</button>
</td>
<td>
<strong>{{ item?.file?.name }}</strong>
</td>
<td *ngIf="uploader.options.isHTML5" nowrap>
{{ item?.file?.size / 1024 / 1024 | number: '.2' }} MB
</td>
<td *ngIf="uploader.options.isHTML5">
<div class="progress" style="margin-bottom: 0">
<div
class="progress-bar"
role="progressbar"
[ngStyle]="{ width: item.progress + '%' }"
></div>
</div>
</td>
<td class="text-center">
<span *ngIf="item.isSuccess" class="text-success"
><i class="fa fa-check-circle"></i
></span>
<span *ngIf="item.isCancel" class="text-warning"
><i class="fa fa-ban"></i
></span>
<span *ngIf="item.isError" class="text-danger"
><i class="fa fa-exclamation-triangle"></i
></span>
</td>
<td nowrap>
<button
type="button"
class="btn btn-success"
(click)="item.upload()"
[disabled]="item.isReady || item.isUploading || item.isSuccess"
>
<span class="glyphicon glyphicon-upload"></span> Upload
</button>
<button
type="button"
class="btn btn-warning"
(click)="item.cancel()"
[disabled]="!item.isUploading"
>
<span class="glyphicon glyphicon-ban-circle"></span> Cancel
</button>
<button
type="button"
class="btn btn-danger"
(click)="item.remove()"
>
<span class="glyphicon glyphicon-trash"></span> Remove
</button>
</td>
</tr>
</tbody>
</tbody>
</table>
<div>
<ngb-alert type="info" [dismissible]="false" *ngIf="uploader.isUploading">
Expand All @@ -124,21 +147,40 @@ <h5>Upload queue</h5>
</ngb-alert>
</div>
<div class="btn-toolbar justify-content-between">
<button type="button" class="btn btn-danger" (click)="uploader.clearQueue()" [disabled]="!uploader.queue.length">
<button
type="button"
class="btn btn-danger"
(click)="uploader.clearQueue()"
[disabled]="!uploader.queue.length"
>
<i class="fa fa-trash"></i> Remove all
</button>
<div>
<button type="button" class="btn btn-warning" (click)="uploader.cancelAll()" [disabled]="!uploader.isUploading">
<button
type="button"
class="btn btn-warning"
(click)="uploader.cancelAll()"
[disabled]="!uploader.isUploading"
>
<i class="fa fa-ban"></i> Cancel all
</button>
<button type="button" class="btn btn-success ml-2" (click)="uploadNewFile()" [disabled]="!uploader.getNotUploadedItems().length">
<button
type="button"
class="btn btn-success ml-2"
(click)="uploadNewFile()"
[disabled]="!uploader.getNotUploadedItems().length"
>
<i class="fa fa-cloud-upload"></i> Upload all
</button>
</div>
</div>
</div>
</div>
<ngb-alert type="danger" [dismissible]="false" *ngFor="let error of errorMessages">
<ngb-alert
type="danger"
[dismissible]="false"
*ngFor="let error of errorMessages"
>
{{ error }}
</ngb-alert>
<ngb-alert type="warning" [dismissible]="false" *ngIf="loading">
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/attachments/attachments.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FormsModule } from '@angular/forms';
import { FileSelectDirective } from 'ng2-file-upload';
import { NgArrayPipesModule } from 'ngx-pipes';

fdescribe('AttachmentsComponent', () => {
describe('AttachmentsComponent', () => {
let comp: AttachmentsComponent;
let fixture: ComponentFixture<AttachmentsComponent>;

Expand Down Expand Up @@ -73,7 +73,7 @@ fdescribe('AttachmentsComponent', () => {
it('includes auth header with file uploads', () => {
spyOn(comp.uploader, 'uploadAll');

comp.uploadNewFile()
comp.uploadNewFile();

expect(comp.uploader.authToken).toBe(authToken);
});
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/attachments/attachments.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ export class AttachmentsComponent implements OnInit {
};

this.uploader.onErrorItem = (item, response, status, headers) => {
const errorText = JSON.parse(response).errors[0].detail || 'Unknown error occured'
const errorText =
JSON.parse(response).errors[0].detail || 'Unknown error occured';
this.errorMessages = [...this.errorMessages, errorText];

Check warning on line 51 in src/app/components/attachments/attachments.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/components/attachments/attachments.component.ts#L51

Added line #L51 was not covered by tests
return { item, response, status, headers };
};
}


private loadAttachments(): void {
this.loading = true;

Expand Down

0 comments on commit 50ceecc

Please sign in to comment.