Skip to content

Commit

Permalink
style(prettier): run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Dec 1, 2023
1 parent d8f98b0 commit bc3e084
Show file tree
Hide file tree
Showing 27 changed files with 132 additions and 163 deletions.
4 changes: 1 addition & 3 deletions projects/ngx-uploader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ For whole template code please check [here](https://github.com/bleenco/ngx-uploa
or choose file(s)
</label>

<button type="button" class="start-upload-btn" (click)="startUpload()">
Start Upload
</button>
<button type="button" class="start-upload-btn" (click)="startUpload()">Start Upload</button>
```

### LICENCE
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-uploader/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"lib": {
"entryFile": "src/public_api.ts"
}
}
}
2 changes: 1 addition & 1 deletion projects/ngx-uploader/ng-package.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"lib": {
"entryFile": "src/public_api.ts"
}
}
}
15 changes: 13 additions & 2 deletions projects/ngx-uploader/src/lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,19 @@ export interface UploadFile {
}

export interface UploadOutput {
type: 'addedToQueue' | 'allAddedToQueue' | 'uploading' | 'done' | 'start' | 'cancelled' | 'dragOver'
| 'dragOut' | 'drop' | 'removed' | 'removedAll' | 'rejected';
type:
| 'addedToQueue'
| 'allAddedToQueue'
| 'uploading'
| 'done'
| 'start'
| 'cancelled'
| 'dragOver'
| 'dragOut'
| 'drop'
| 'removed'
| 'removedAll'
| 'rejected';
file?: UploadFile;
nativeFile?: File;
}
Expand Down
18 changes: 9 additions & 9 deletions projects/ngx-uploader/src/lib/ng-file-drop.directive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Directive, ElementRef, EventEmitter, Input, Output, OnInit, OnDestroy, HostListener } from '@angular/core';
import { UploadOutput, UploadInput, UploaderOptions } from './interfaces';
import { NgUploaderService } from './ngx-uploader.class';
import { Directive, ElementRef, EventEmitter, HostListener, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { Subscription } from 'rxjs';
import { UploadInput, UploadOutput, UploaderOptions } from './interfaces';
import { NgUploaderService } from './ngx-uploader.class';

@Directive({
selector: '[ngFileDrop]'
Expand All @@ -22,10 +22,10 @@ export class NgFileDropDirective implements OnInit, OnDestroy {

ngOnInit() {
this._sub = [];
const concurrency = this.options && this.options.concurrency || Number.POSITIVE_INFINITY;
const allowedContentTypes = this.options && this.options.allowedContentTypes || ['*'];
const maxUploads = this.options && this.options.maxUploads || Number.POSITIVE_INFINITY;
const maxFileSize = this.options && this.options.maxFileSize || Number.POSITIVE_INFINITY;
const concurrency = (this.options && this.options.concurrency) || Number.POSITIVE_INFINITY;
const allowedContentTypes = (this.options && this.options.allowedContentTypes) || ['*'];
const maxUploads = (this.options && this.options.maxUploads) || Number.POSITIVE_INFINITY;
const maxFileSize = (this.options && this.options.maxFileSize) || Number.POSITIVE_INFINITY;
this.upload = new NgUploaderService(concurrency, allowedContentTypes, maxUploads, maxFileSize);

this.el = this.elementRef.nativeElement;
Expand All @@ -47,14 +47,14 @@ export class NgFileDropDirective implements OnInit, OnDestroy {

ngOnDestroy() {
if (this._sub) {
this._sub.forEach(sub => sub.unsubscribe())
this._sub.forEach(sub => sub.unsubscribe());
}
}

stopEvent = (e: Event) => {
e.stopPropagation();
e.preventDefault();
}
};

@HostListener('drop', ['$event'])
public onDrop(e: any) {
Expand Down
14 changes: 7 additions & 7 deletions projects/ngx-uploader/src/lib/ng-file-select.directive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Directive, ElementRef, EventEmitter, Input, Output, OnInit, OnDestroy } from '@angular/core';
import { Directive, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { Subscription } from 'rxjs';
import { UploadOutput, UploaderOptions } from './interfaces';
import { NgUploaderService } from './ngx-uploader.class';
import { Subscription } from 'rxjs';

@Directive({
selector: '[ngFileSelect]'
Expand All @@ -22,10 +22,10 @@ export class NgFileSelectDirective implements OnInit, OnDestroy {

ngOnInit() {
this._sub = [];
const concurrency = this.options && this.options.concurrency || Number.POSITIVE_INFINITY;
const allowedContentTypes = this.options && this.options.allowedContentTypes || ['*'];
const maxUploads = this.options && this.options.maxUploads || Number.POSITIVE_INFINITY;
const maxFileSize = this.options && this.options.maxFileSize || Number.POSITIVE_INFINITY;
const concurrency = (this.options && this.options.concurrency) || Number.POSITIVE_INFINITY;
const allowedContentTypes = (this.options && this.options.allowedContentTypes) || ['*'];
const maxUploads = (this.options && this.options.maxUploads) || Number.POSITIVE_INFINITY;
const maxFileSize = (this.options && this.options.maxFileSize) || Number.POSITIVE_INFINITY;
this.upload = new NgUploaderService(concurrency, allowedContentTypes, maxUploads, maxFileSize);

this.el = this.elementRef.nativeElement;
Expand Down Expand Up @@ -53,5 +53,5 @@ export class NgFileSelectDirective implements OnInit, OnDestroy {
if (this.el.files) {
this.upload.handleFiles(this.el.files);
}
}
};
}
8 changes: 4 additions & 4 deletions projects/ngx-uploader/src/lib/ngx-uploader.class.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { NgUploaderService, humanizeBytes } from './ngx-uploader.class';

describe('NgUploaderService constructor', () => {
it('without parameters should return allowedContentTypes = [\'*\']', () => {
it("without parameters should return allowedContentTypes = ['*']", () => {
const uploader: NgUploaderService = new NgUploaderService();
expect(uploader.contentTypes.length).toEqual(1);
expect(uploader.contentTypes).toEqual(['*']);
});

it('should return [\'image/jpeg\']', () => {
it("should return ['image/jpeg']", () => {
const uploader = new NgUploaderService(1, ['image/jpeg']);
expect(uploader.contentTypes.length).toEqual(1);
expect(uploader.contentTypes).not.toContain('*');
Expand All @@ -19,14 +19,14 @@ describe('NgUploaderService constructor', () => {
describe('setContentTypes function', () => {
const uploader = new NgUploaderService();

it('should return [\'*\']', () => {
it("should return ['*']", () => {
uploader.setContentTypes(['*']);
expect(uploader.contentTypes.length).toEqual(1);
expect(uploader.contentTypes).toContain('*');
expect(uploader.contentTypes).toEqual(['*']);
});

it('should return [\'image/jpeg\']', () => {
it("should return ['image/jpeg']", () => {
uploader.setContentTypes(['image/jpeg']);
expect(uploader.contentTypes.length).toEqual(1);
expect(uploader.contentTypes).toContain('image/jpeg');
Expand Down
12 changes: 6 additions & 6 deletions projects/ngx-uploader/src/lib/ngx-uploader.class.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from '@angular/core';
import { Observable, Subject, Subscription, mergeMap, finalize } from 'rxjs';
import { UploadFile, UploadOutput, UploadInput, UploadStatus, BlobFile } from './interfaces';
import { Observable, Subject, Subscription, finalize, mergeMap } from 'rxjs';
import { BlobFile, UploadFile, UploadInput, UploadOutput, UploadStatus } from './interfaces';

export function humanizeBytes(bytes: number): string {
if (bytes === 0) {
Expand Down Expand Up @@ -59,17 +59,17 @@ export class NgUploaderService {
}

return acc as File[];
}, [] as File[]) as File[];


},
[] as File[]
) as File[];

this.queue.push(
...allowedIncomingFiles.map((file: File, i: number) => {
const uploadFile: UploadFile = this.makeUploadFile(file, i);
this.serviceEvents.emit({ type: 'addedToQueue', file: uploadFile });
return uploadFile;
})
)
);

this.serviceEvents.emit({ type: 'allAddedToQueue' });
}
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-uploader/src/lib/ngx-uploader.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import { NgFileSelectDirective } from './ng-file-select.directive';
declarations: [NgFileDropDirective, NgFileSelectDirective],
exports: [NgFileDropDirective, NgFileSelectDirective]
})
export class NgxUploaderModule { }
export class NgxUploaderModule {}
16 changes: 5 additions & 11 deletions projects/ngx-uploader/src/test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import 'core-js/es7/reflect';
import 'zone.js';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false }
}
);
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false }
});
4 changes: 1 addition & 3 deletions projects/ngx-uploader/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@
"inlineSources": true,
"types": []
},
"exclude": [
"**/*.spec.ts"
]
"exclude": ["**/*.spec.ts"]
}
9 changes: 2 additions & 7 deletions projects/ngx-uploader/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
"jasmine"
]
"types": ["jasmine"]
},
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
8 changes: 4 additions & 4 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as path from 'path';
import * as bodyParser from 'body-parser';
import * as cors from 'cors';
import * as express from 'express';
import { existsSync, mkdirSync } from 'fs';
import * as multer from 'multer';
import * as path from 'path';
import * as rimraf from 'rimraf';
import * as cors from 'cors';
import * as bodyParser from 'body-parser';
import { mkdirSync, existsSync } from 'fs';
const config = {
port: 4900
};
Expand Down
42 changes: 33 additions & 9 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,30 @@ <h2>ngx-uploader</h2>
</div>
</div>
<div class="upload-box-content">
<div class="drop-container" ngFileDrop [options]="options" (uploadOutput)="onUploadOutput($event)" [uploadInput]="uploadInput">
<div
class="drop-container"
ngFileDrop
[options]="options"
(uploadOutput)="onUploadOutput($event)"
[uploadInput]="uploadInput"
>
<p>
Drag files here or
<label class="upload-button">
<input type="file" ngFileSelect [options]="options" (uploadOutput)="onUploadOutput($event)" [uploadInput]="uploadInput" multiple> browse
<input
type="file"
ngFileSelect
[options]="options"
(uploadOutput)="onUploadOutput($event)"
[uploadInput]="uploadInput"
multiple
/>
browse
</label>
to upload.
</p>
</div>
<div class="upload-item" *ngFor="let f of files; let i = index;">
<div class="upload-item" *ngFor="let f of files; let i = index">
<div class="upload-item-content">
<div class="filename">
<div class="filename-left">
Expand All @@ -42,28 +56,38 @@ <h2>ngx-uploader</h2>
</div>
<div class="progress-content">
<div class="progress">
<span class="bar" [style.width]="f?.progress?.data?.percentage + '%'" [class.is-done]="f?.progress?.data?.percentage === 100"></span>
<span
class="bar"
[style.width]="f?.progress?.data?.percentage + '%'"
[class.is-done]="f?.progress?.data?.percentage === 100"
></span>
</div>
</div>
<div class="progress-text-content">
<span class="progress-text" [class.is-done]="f?.progress?.data?.percentage === 100">
<span>{{ f.progress.data?.percentage }}% </span>
<span>{{ f.progress.data?.percentage }}%</span>
<span *ngIf="f.progress?.data?.percentage !== 100">Uploading...</span>
<span *ngIf="f.progress?.data?.percentage === 100">Done</span>
</span>
<span class="speed-and-eta-text" *ngIf="f.progress?.data?.percentage !== 0 && f.progress?.data?.percentage !== 100">
<span>{{ f.progress.data?.speedHuman }} </span>
<span
class="speed-and-eta-text"
*ngIf="f.progress?.data?.percentage !== 0 && f.progress?.data?.percentage !== 100"
>
<span>{{ f.progress.data?.speedHuman }}</span>
<span>ETA {{ f.progress.data?.etaHuman }}</span>
</span>
</div>
</div>
</div>
</div>
<div class="help-text">
<span>Upload concurrency is intentionally set to single file. All files are immediately deleted after uploaded.</span>
<span>
Upload concurrency is intentionally set to single file. All files are immediately deleted after
uploaded.
</span>
<span>
<a href="https://github.com/bleenco">
<img src="/assets/images/bleenco-logo.svg">
<img src="/assets/images/bleenco-logo.svg" />
</a>
</span>
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
declarations: [AppComponent]
}).compileComponents();
}));

Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, EventEmitter } from '@angular/core';
import { UploadOutput, UploadInput, UploadFile, humanizeBytes, UploaderOptions, UploadStatus } from 'ngx-uploader';
import { UploadFile, UploadInput, UploadOutput, UploadStatus, UploaderOptions, humanizeBytes } from 'ngx-uploader';

@Component({
selector: 'app-root',
Expand Down
13 changes: 4 additions & 9 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxUploaderModule } from 'ngx-uploader';

import { AppComponent } from './app.component';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgxUploaderModule
],
declarations: [AppComponent],
imports: [BrowserModule, NgxUploaderModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
export class AppModule {}
20 changes: 10 additions & 10 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ngx-uploader - Angular File Uploader</title>
<base href="/">
<head>
<meta charset="utf-8" />
<title>ngx-uploader - Angular File Uploader</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<app-root></app-root>
</body>
</html>
Loading

0 comments on commit bc3e084

Please sign in to comment.