c3-components 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +80 -0
- package/_index.scss +3 -0
- package/ng-package.json +19 -0
- package/package.json +11 -23
- package/src/lib/c3-dialog/c3-dialog.module.ts +30 -0
- package/src/lib/c3-dialog/components/c3-dialog-confirm.component.ts +44 -0
- package/src/lib/c3-dialog/components/c3-dialog-embed-child.component.ts +40 -0
- package/src/lib/c3-dialog/components/c3-dialog-prompt.component.ts +81 -0
- package/src/lib/c3-dialog/services/c3-dialog.service.ts +87 -0
- package/src/lib/c3-dropdown/c3-dropdown.module.ts +12 -0
- package/src/lib/c3-dropdown/components/c3-dropdown.component.spec.ts +22 -0
- package/src/lib/c3-dropdown/components/c3-dropdown.component.ts +39 -0
- package/src/lib/c3-dropdown/directives/c3-dropdown.trigger.ts +161 -0
- package/src/lib/c3-file/c3-download/c3-download.module.ts +10 -0
- package/src/lib/c3-file/c3-download/c3-download.service.ts +16 -0
- package/src/lib/c3-file/c3-input-file/c3-input-file.module.ts +30 -0
- package/src/lib/c3-file/c3-input-file/class/c3-input-file.ts +62 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.html +7 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.ts +96 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file-container/c3-input-file-container.component.ts +53 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file-displayer/c3-input-file-displayer.component.ts +107 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file-trigger/c3-input-file-trigger.component.ts +22 -0
- package/src/lib/c3-file/c3-input-file/directives/c3-input-file-trigger.directive.ts +27 -0
- package/src/lib/c3-file-upload/c3-file-upload.module.ts +8 -0
- package/src/lib/c3-file-viewer/c3-file-viewer.module.ts +34 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.html +185 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.ts +15 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.html +7 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.ts +14 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.html +7 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.ts +25 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.css +0 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.html +1 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.ts +35 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.html +32 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.ts +93 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.ts +34 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.spec.ts +22 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.ts +12 -0
- package/src/lib/c3-file-viewer/consts/default.config.ts +41 -0
- package/src/lib/c3-file-viewer/directives/full-screen.directive.spec.ts +11 -0
- package/src/lib/c3-file-viewer/directives/full-screen.directive.ts +68 -0
- package/src/lib/c3-file-viewer/models/custom-file-event.model.ts +9 -0
- package/src/lib/c3-file-viewer/models/file-metadata.ts +13 -0
- package/src/lib/c3-file-viewer/models/file-viewer-config.model.ts +53 -0
- package/src/lib/c3-file-viewer/models/file-viewer.ts +259 -0
- package/src/lib/c3-file-viewer/models/http.client.ts +23 -0
- package/src/lib/c3-highlight-text/c3-highlight-text.module.ts +12 -0
- package/src/lib/c3-menu/c3-menu.module.ts +12 -0
- package/src/lib/c3-modal/c3-modal.module.ts +12 -0
- package/src/lib/c3-navbar/c3-navbar.module.ts +12 -0
- package/src/lib/c3-pdf-dialog/c3-pdf-dialog.module.ts +12 -0
- package/src/lib/c3-rounded-title/c3-rounded-title.module.ts +12 -0
- package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.spec.ts +8 -0
- package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.ts +13 -0
- package/src/lib/c3-tabs/c3-tabs.module.ts +12 -0
- package/{public-api.d.ts → src/public-api.ts} +8 -0
- package/tailwind.config.js +8 -0
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2020/c3-components.mjs +0 -5
- package/esm2020/lib/c3-dialog/c3-dialog.module.mjs +0 -56
- package/esm2020/lib/c3-dialog/components/c3-dialog-confirm.component.mjs +0 -52
- package/esm2020/lib/c3-dialog/components/c3-dialog-embed-child.component.mjs +0 -32
- package/esm2020/lib/c3-dialog/components/c3-dialog-prompt.component.mjs +0 -95
- package/esm2020/lib/c3-dialog/services/c3-dialog.service.mjs +0 -79
- package/esm2020/lib/c3-dropdown/c3-dropdown.module.mjs +0 -20
- package/esm2020/lib/c3-dropdown/components/c3-dropdown.component.mjs +0 -45
- package/esm2020/lib/c3-dropdown/directives/c3-dropdown.trigger.mjs +0 -128
- package/esm2020/lib/c3-file-viewer/c3-file-viewer.module.mjs +0 -51
- package/esm2020/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.mjs +0 -17
- package/esm2020/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.mjs +0 -20
- package/esm2020/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.mjs +0 -23
- package/esm2020/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.mjs +0 -32
- package/esm2020/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.mjs +0 -86
- package/esm2020/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.mjs +0 -37
- package/esm2020/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.mjs +0 -26
- package/esm2020/lib/c3-file-viewer/consts/default.config.mjs +0 -40
- package/esm2020/lib/c3-file-viewer/directives/full-screen.directive.mjs +0 -66
- package/esm2020/lib/c3-file-viewer/models/custom-file-event.model.mjs +0 -7
- package/esm2020/lib/c3-file-viewer/models/file-metadata.mjs +0 -2
- package/esm2020/lib/c3-file-viewer/models/file-viewer-config.model.mjs +0 -2
- package/esm2020/lib/c3-file-viewer/models/file-viewer.mjs +0 -206
- package/esm2020/lib/c3-file-viewer/models/http.client.mjs +0 -2
- package/esm2020/lib/c3-safe-url/pipes/c3-safe-url.pipe.mjs +0 -21
- package/esm2020/public-api.mjs +0 -35
- package/fesm2015/c3-components.mjs +0 -1064
- package/fesm2015/c3-components.mjs.map +0 -1
- package/fesm2020/c3-components.mjs +0 -1062
- package/fesm2020/c3-components.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/c3-dialog/c3-dialog.module.d.ts +0 -16
- package/lib/c3-dialog/components/c3-dialog-confirm.component.d.ts +0 -23
- package/lib/c3-dialog/components/c3-dialog-embed-child.component.d.ts +0 -18
- package/lib/c3-dialog/components/c3-dialog-prompt.component.d.ts +0 -31
- package/lib/c3-dialog/services/c3-dialog.service.d.ts +0 -19
- package/lib/c3-dropdown/c3-dropdown.module.d.ts +0 -10
- package/lib/c3-dropdown/components/c3-dropdown.component.d.ts +0 -15
- package/lib/c3-dropdown/directives/c3-dropdown.trigger.d.ts +0 -45
- package/lib/c3-file-viewer/c3-file-viewer.module.d.ts +0 -18
- package/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.d.ts +0 -8
- package/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.d.ts +0 -9
- package/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.d.ts +0 -9
- package/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.d.ts +0 -12
- package/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.d.ts +0 -25
- package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.d.ts +0 -12
- package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.d.ts +0 -8
- package/lib/c3-file-viewer/consts/default.config.d.ts +0 -2
- package/lib/c3-file-viewer/directives/full-screen.directive.d.ts +0 -12
- package/lib/c3-file-viewer/models/custom-file-event.model.d.ts +0 -5
- package/lib/c3-file-viewer/models/file-metadata.d.ts +0 -12
- package/lib/c3-file-viewer/models/file-viewer-config.model.d.ts +0 -48
- package/lib/c3-file-viewer/models/file-viewer.d.ts +0 -65
- package/lib/c3-file-viewer/models/http.client.d.ts +0 -14
- package/lib/c3-safe-url/pipes/c3-safe-url.pipe.d.ts +0 -10
- /package/{lib → src/lib}/c3-dropdown/styles/_c3-dropdown.sass +0 -0
- /package/{lib → src/lib}/c3-file-viewer/styles/_c3-file-viewer.sass +0 -0
- /package/{lib → src/lib}/c3-styles/_c3-core.sass +0 -0
- /package/{lib → src/lib}/c3-styles/_c3-root-variables.sass +0 -0
- /package/{lib → src/lib}/c3-styles/_utils.sass +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { HttpClient } from '@angular/common/http';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: 'root',
|
|
7
|
+
})
|
|
8
|
+
export class C3DownloadService {
|
|
9
|
+
constructor(private _http: HttpClient) {}
|
|
10
|
+
|
|
11
|
+
download(url: string): Observable<Blob> {
|
|
12
|
+
return this._http.get(url, {
|
|
13
|
+
responseType: 'blob',
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { C3InputFileTriggerComponent } from './components/c3-input-file-trigger/c3-input-file-trigger.component';
|
|
4
|
+
import { C3InputFileContainerComponent } from './components/c3-input-file-container/c3-input-file-container.component';
|
|
5
|
+
import { C3InputFileDisplayerComponent } from './components/c3-input-file-displayer/c3-input-file-displayer.component';
|
|
6
|
+
import { C3InputFileTriggerDirective } from './directives/c3-input-file-trigger.directive';
|
|
7
|
+
|
|
8
|
+
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
9
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
10
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
11
|
+
import { C3InputFileComponent } from './components/c3-input-file/c3-input-file.component';
|
|
12
|
+
|
|
13
|
+
@NgModule({
|
|
14
|
+
declarations: [
|
|
15
|
+
C3InputFileComponent,
|
|
16
|
+
C3InputFileTriggerComponent,
|
|
17
|
+
C3InputFileContainerComponent,
|
|
18
|
+
C3InputFileDisplayerComponent,
|
|
19
|
+
C3InputFileTriggerDirective,
|
|
20
|
+
],
|
|
21
|
+
imports: [CommonModule, MatProgressBarModule, MatButtonModule, MatIconModule],
|
|
22
|
+
exports: [
|
|
23
|
+
C3InputFileComponent,
|
|
24
|
+
C3InputFileTriggerComponent,
|
|
25
|
+
C3InputFileContainerComponent,
|
|
26
|
+
C3InputFileDisplayerComponent,
|
|
27
|
+
C3InputFileTriggerDirective,
|
|
28
|
+
],
|
|
29
|
+
})
|
|
30
|
+
export class C3InputFileModule {}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
|
|
4
|
+
export class C3InputFile<ResponseType = any> extends EventEmitter {
|
|
5
|
+
name?: string;
|
|
6
|
+
id?: number;
|
|
7
|
+
fileName: string;
|
|
8
|
+
mimetype: string;
|
|
9
|
+
progressionChange = new Subject<number>();
|
|
10
|
+
private _progression = 0;
|
|
11
|
+
loaded: boolean = false;
|
|
12
|
+
path?: string;
|
|
13
|
+
size?: number;
|
|
14
|
+
aborded: boolean = false;
|
|
15
|
+
response?: ResponseType;
|
|
16
|
+
|
|
17
|
+
constructor({
|
|
18
|
+
fileName,
|
|
19
|
+
mimetype,
|
|
20
|
+
size,
|
|
21
|
+
}: {
|
|
22
|
+
fileName: string;
|
|
23
|
+
mimetype: string;
|
|
24
|
+
size: number;
|
|
25
|
+
}) {
|
|
26
|
+
super();
|
|
27
|
+
this.fileName = fileName;
|
|
28
|
+
this.mimetype = mimetype;
|
|
29
|
+
this.size = size;
|
|
30
|
+
this.progressionChange.next(this._progression);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
set progression(value: number) {
|
|
34
|
+
this._progression = value;
|
|
35
|
+
if (value === 100) {
|
|
36
|
+
this.loaded = true;
|
|
37
|
+
this.emit('loaded');
|
|
38
|
+
}
|
|
39
|
+
this.progressionChange.next(value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get progression(): number {
|
|
43
|
+
return this._progression;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override on(event: string | symbol, listener: (...args: any[]) => void) {
|
|
47
|
+
return super.on(event, listener);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override emit(event: string | symbol, ...args: any[]): boolean {
|
|
51
|
+
return super.emit(event, args);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override off(event: string | symbol, listener: (...args: any[]) => void) {
|
|
55
|
+
return super.off(event, listener);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
abord() {
|
|
59
|
+
this.aborded = true;
|
|
60
|
+
this.emit('abord');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Input,
|
|
5
|
+
ViewChild,
|
|
6
|
+
ElementRef,
|
|
7
|
+
Output,
|
|
8
|
+
EventEmitter,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { C3InputFile } from '../../class/c3-input-file';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'c3-input-file',
|
|
14
|
+
templateUrl: './c3-input-file.component.html',
|
|
15
|
+
styleUrls: ['./c3-input-file.component.scss'],
|
|
16
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
17
|
+
})
|
|
18
|
+
export class C3InputFileComponent {
|
|
19
|
+
@Input() accept!: string;
|
|
20
|
+
@Input() multiple: Boolean = false;
|
|
21
|
+
@Input() dest: string = 'api/upload';
|
|
22
|
+
@Input() baseUrl: string = 'localhost:3000';
|
|
23
|
+
@Input() method: string = 'POST';
|
|
24
|
+
@Input() headers?: Object;
|
|
25
|
+
|
|
26
|
+
@ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>;
|
|
27
|
+
@Output()
|
|
28
|
+
fileAdded: EventEmitter<C3InputFile> = new EventEmitter<C3InputFile>();
|
|
29
|
+
|
|
30
|
+
click() {
|
|
31
|
+
this.fileInput.nativeElement.click();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
change({ target }: any) {
|
|
35
|
+
const files = Array.from(target.files as FileList);
|
|
36
|
+
|
|
37
|
+
files.forEach((file) => {
|
|
38
|
+
const formData = new FormData();
|
|
39
|
+
const xhr = new XMLHttpRequest();
|
|
40
|
+
|
|
41
|
+
formData.append('upload', file);
|
|
42
|
+
|
|
43
|
+
// ecoute la progression de l'upload
|
|
44
|
+
xhr.upload.addEventListener(
|
|
45
|
+
'progress',
|
|
46
|
+
(progress) => {
|
|
47
|
+
_file.progression = Math.round(
|
|
48
|
+
(progress.loaded / progress.total) * 100
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
false
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// ecoute si une erreur survient lors de l'upload
|
|
55
|
+
xhr.addEventListener('error', (event) => console.log(event), false);
|
|
56
|
+
|
|
57
|
+
// ecoute si l'utilisateur annul l'upload en cours
|
|
58
|
+
xhr.addEventListener('abort', (event) => console.log(event), false);
|
|
59
|
+
|
|
60
|
+
xhr.addEventListener('readystatechange', (ev) => {
|
|
61
|
+
if (xhr.readyState === 4) {
|
|
62
|
+
const data = JSON.parse(xhr.response);
|
|
63
|
+
_file.name = data.name;
|
|
64
|
+
_file.id = data.id;
|
|
65
|
+
_file.path = data.path;
|
|
66
|
+
_file.response = data;
|
|
67
|
+
if (_file.progression !== 100) _file.progression = 100;
|
|
68
|
+
_file.progressionChange.complete();
|
|
69
|
+
_file.emit('completed');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// initialise le type de connection et l'url
|
|
74
|
+
xhr.open(this.method, `${this.baseUrl}/${this.dest}`);
|
|
75
|
+
|
|
76
|
+
// set header if data is transmitted
|
|
77
|
+
if (this.headers)
|
|
78
|
+
for (const [key, value] of Object.entries(this.headers))
|
|
79
|
+
xhr.setRequestHeader(key, value);
|
|
80
|
+
|
|
81
|
+
// start upload
|
|
82
|
+
xhr.send(formData);
|
|
83
|
+
|
|
84
|
+
const _file: C3InputFile = new C3InputFile({
|
|
85
|
+
fileName: file.name,
|
|
86
|
+
mimetype: file.type,
|
|
87
|
+
size: file.size,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
_file.on('abord', () => {
|
|
91
|
+
xhr.abort();
|
|
92
|
+
});
|
|
93
|
+
this.fileAdded.emit(_file);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ViewEncapsulation,
|
|
4
|
+
ContentChild,
|
|
5
|
+
OnDestroy,
|
|
6
|
+
Input,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { C3InputFileTriggerComponent } from '../c3-input-file-trigger/c3-input-file-trigger.component';
|
|
9
|
+
import { C3InputFileTriggerDirective } from '../../directives/c3-input-file-trigger.directive';
|
|
10
|
+
import { C3InputFileComponent } from '../c3-input-file/c3-input-file.component';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector:
|
|
14
|
+
'c3-input-file-container, [c3InputFileContainer], [c3-input-file-container]',
|
|
15
|
+
template: ` <ng-content> </ng-content>
|
|
16
|
+
<c3-input-file-displayer
|
|
17
|
+
*ngIf="c3InputFile"
|
|
18
|
+
[c3InputFile]="c3InputFile"
|
|
19
|
+
[autoclose]="autoclose"
|
|
20
|
+
></c3-input-file-displayer>`,
|
|
21
|
+
styles: [],
|
|
22
|
+
encapsulation: ViewEncapsulation.None,
|
|
23
|
+
host: {
|
|
24
|
+
class: 'c3-input-file-container',
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
export class C3InputFileContainerComponent implements OnDestroy {
|
|
28
|
+
@Input() autoclose?: boolean | number;
|
|
29
|
+
|
|
30
|
+
@ContentChild(C3InputFileComponent) c3InputFile?: C3InputFileComponent;
|
|
31
|
+
|
|
32
|
+
@ContentChild(C3InputFileTriggerComponent)
|
|
33
|
+
c3Trigger?: C3InputFileTriggerComponent;
|
|
34
|
+
|
|
35
|
+
@ContentChild(C3InputFileTriggerDirective)
|
|
36
|
+
c3TriggerDirective?: C3InputFileTriggerDirective;
|
|
37
|
+
|
|
38
|
+
ngAfterViewInit() {
|
|
39
|
+
if (this.c3Trigger)
|
|
40
|
+
this.c3Trigger.clicked.subscribe(($event) => {
|
|
41
|
+
this.c3InputFile?.click();
|
|
42
|
+
});
|
|
43
|
+
else if (this.c3TriggerDirective)
|
|
44
|
+
this.c3TriggerDirective.click.subscribe(($event) => {
|
|
45
|
+
this.c3InputFile?.click();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ngOnDestroy() {
|
|
50
|
+
if (this.c3Trigger) this.c3Trigger.clicked.unsubscribe();
|
|
51
|
+
if (this.c3TriggerDirective) this.c3TriggerDirective.click.unsubscribe();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
OnInit,
|
|
4
|
+
ViewEncapsulation,
|
|
5
|
+
Input,
|
|
6
|
+
AfterContentInit,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { C3InputFile } from '../../class/c3-input-file';
|
|
9
|
+
import { C3InputFileComponent } from '../c3-input-file/c3-input-file.component';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'c3-input-file-displayer',
|
|
13
|
+
template: `
|
|
14
|
+
<ng-container *ngIf="files.length">
|
|
15
|
+
<div class="c3-input-file-displayer mat-card">
|
|
16
|
+
<div
|
|
17
|
+
class="title-bar mat-elevation-z4"
|
|
18
|
+
fxLayout="row"
|
|
19
|
+
fxLayoutAlign="space-between center"
|
|
20
|
+
>
|
|
21
|
+
<span>Liste des téléversement</span>
|
|
22
|
+
<div>
|
|
23
|
+
<button mat-icon-button (click)="toggleMinimize()">
|
|
24
|
+
<mat-icon *ngIf="minimized">open_in_full</mat-icon>
|
|
25
|
+
<mat-icon *ngIf="!minimized">close_fullscreen</mat-icon>
|
|
26
|
+
</button>
|
|
27
|
+
<button mat-icon-button [disabled]="!closable" (click)="close()">
|
|
28
|
+
<mat-icon>close</mat-icon>
|
|
29
|
+
</button>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="container-list" *ngIf="!minimized">
|
|
33
|
+
<div class="item" *ngFor="let item of files">
|
|
34
|
+
<div class="title">{{ item.fileName }}</div>
|
|
35
|
+
<div
|
|
36
|
+
fxLayout="row"
|
|
37
|
+
fxLayoutAlign="space-around center"
|
|
38
|
+
fxLayoutGap="4px"
|
|
39
|
+
>
|
|
40
|
+
<mat-progress-bar
|
|
41
|
+
fxFlex
|
|
42
|
+
[color]="item.aborded ? 'warn' : 'primary'"
|
|
43
|
+
[mode]="item.aborded ? 'determinate' : 'buffer'"
|
|
44
|
+
[value]="item.progression"
|
|
45
|
+
[bufferValue]="0"
|
|
46
|
+
>
|
|
47
|
+
</mat-progress-bar>
|
|
48
|
+
|
|
49
|
+
<button
|
|
50
|
+
mat-icon-button
|
|
51
|
+
[disabled]="item.aborded || item.loaded"
|
|
52
|
+
(click)="item.abord()"
|
|
53
|
+
>
|
|
54
|
+
<mat-icon>cancel</mat-icon>
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</ng-container>
|
|
61
|
+
`,
|
|
62
|
+
styles: [],
|
|
63
|
+
encapsulation: ViewEncapsulation.None,
|
|
64
|
+
})
|
|
65
|
+
export class C3InputFileDisplayerComponent implements AfterContentInit {
|
|
66
|
+
@Input() c3InputFile!: C3InputFileComponent;
|
|
67
|
+
files: Array<C3InputFile> = [];
|
|
68
|
+
@Input() autoclose?: boolean | number;
|
|
69
|
+
|
|
70
|
+
minimized: boolean = false;
|
|
71
|
+
|
|
72
|
+
get closable() {
|
|
73
|
+
return this.files.every(({ loaded, aborded }) => loaded || aborded);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
constructor() {}
|
|
77
|
+
|
|
78
|
+
ngAfterContentInit(): void {
|
|
79
|
+
this.c3InputFile.fileAdded.subscribe(
|
|
80
|
+
(newFile: C3InputFile) => {
|
|
81
|
+
this.files.push(newFile);
|
|
82
|
+
if (this.autoclose)
|
|
83
|
+
if (newFile.loaded) this._autoclose();
|
|
84
|
+
else newFile.on('loaded', () => this._autoclose());
|
|
85
|
+
},
|
|
86
|
+
console.error,
|
|
87
|
+
() => {
|
|
88
|
+
console.log('completed');
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
toggleMinimize() {
|
|
94
|
+
this.minimized = !this.minimized;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
_autoclose() {
|
|
98
|
+
if (this.closable)
|
|
99
|
+
if (typeof this.autoclose === 'number')
|
|
100
|
+
setTimeout(() => this.close(), 1000 * this.autoclose);
|
|
101
|
+
else this.close();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
close() {
|
|
105
|
+
this.files = [];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ViewEncapsulation,
|
|
4
|
+
Output,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'c3-input-file-trigger',
|
|
10
|
+
template: `
|
|
11
|
+
<button (click)="click($event)">Ajouter des fichiers....</button>
|
|
12
|
+
`,
|
|
13
|
+
styles: [],
|
|
14
|
+
encapsulation: ViewEncapsulation.None,
|
|
15
|
+
})
|
|
16
|
+
export class C3InputFileTriggerComponent {
|
|
17
|
+
@Output('click') clicked: EventEmitter<MouseEvent> = new EventEmitter();
|
|
18
|
+
|
|
19
|
+
click($event: MouseEvent) {
|
|
20
|
+
this.clicked.emit($event);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Directive,
|
|
3
|
+
Output,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
ElementRef,
|
|
6
|
+
AfterViewInit,
|
|
7
|
+
OnDestroy,
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
|
|
10
|
+
@Directive({
|
|
11
|
+
selector: '[c3InputFileTrigger], [c3-input-file-trigger]',
|
|
12
|
+
})
|
|
13
|
+
export class C3InputFileTriggerDirective implements AfterViewInit, OnDestroy {
|
|
14
|
+
@Output() click: EventEmitter<MouseEvent> = new EventEmitter();
|
|
15
|
+
constructor(private elementRef: ElementRef) {}
|
|
16
|
+
|
|
17
|
+
ngAfterViewInit() {
|
|
18
|
+
this.elementRef.nativeElement.addEventListener(
|
|
19
|
+
'click',
|
|
20
|
+
($event: MouseEvent) => this.click.emit($event)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ngOnDestroy() {
|
|
25
|
+
this.elementRef.nativeElement.removeEventListener('click', () => {});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { FullScreenDirective } from './directives/full-screen.directive';
|
|
3
|
+
import { C3FileViewerComponent } from './components/public/c3-file-viewer/c3-file-viewer.component';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { C3FileViewerActionsComponent } from './components/c3-file-viewer-actions/c3-file-viewer-actions.component';
|
|
6
|
+
import { C3FileViewerImageComponent } from './components/c3-file-viewer-image/c3-file-viewer-image.component';
|
|
7
|
+
import { C3FileViewerPdfComponent } from './components/c3-file-viewer-pdf/c3-file-viewer-pdf.component';
|
|
8
|
+
import { C3FileViewerVideoComponent } from './components/c3-file-viewer-video/c3-file-viewer-video.component';
|
|
9
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
10
|
+
import { C3SafeUrlPipe } from '../../public-api';
|
|
11
|
+
import { C3FileViewerDialogComponent } from './components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component';
|
|
12
|
+
import { MatDialogModule } from '@angular/material/dialog';
|
|
13
|
+
import { C3FileViewerDialog } from './components/public/c3-file-viewer-dialog/c3-file-viewer-dialog';
|
|
14
|
+
|
|
15
|
+
@NgModule({
|
|
16
|
+
providers: [],
|
|
17
|
+
declarations: [
|
|
18
|
+
FullScreenDirective,
|
|
19
|
+
C3FileViewerComponent,
|
|
20
|
+
C3FileViewerActionsComponent,
|
|
21
|
+
C3FileViewerImageComponent,
|
|
22
|
+
C3FileViewerPdfComponent,
|
|
23
|
+
C3FileViewerVideoComponent,
|
|
24
|
+
C3FileViewerDialogComponent,
|
|
25
|
+
C3FileViewerDialog,
|
|
26
|
+
],
|
|
27
|
+
imports: [CommonModule, HttpClientModule, C3SafeUrlPipe, MatDialogModule],
|
|
28
|
+
exports: [
|
|
29
|
+
FullScreenDirective,
|
|
30
|
+
C3FileViewerComponent,
|
|
31
|
+
C3FileViewerDialogComponent,
|
|
32
|
+
],
|
|
33
|
+
})
|
|
34
|
+
export class C3FileViewerModule {}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<div class="nav-button-container">
|
|
2
|
+
<button
|
|
3
|
+
*ngIf="config.btnShow?.prev"
|
|
4
|
+
type="button"
|
|
5
|
+
[class]="config.btnClass"
|
|
6
|
+
(click)="fileViewer.previousImage($event)"
|
|
7
|
+
[disabled]="fileViewer.currentIndex === 0"
|
|
8
|
+
>
|
|
9
|
+
<span
|
|
10
|
+
*ngIf="config.btnIcons?.prev?.classes"
|
|
11
|
+
[class]="config.btnIcons?.prev?.classes"
|
|
12
|
+
></span>
|
|
13
|
+
</button>
|
|
14
|
+
<a
|
|
15
|
+
[class]="config.btnClass"
|
|
16
|
+
*ngIf="config.btnIcons?.prev?.text"
|
|
17
|
+
(click)="fileViewer.previousImage($event)"
|
|
18
|
+
>
|
|
19
|
+
<span [class]="config.btnSubClass">{{ config.btnIcons?.prev?.text }}</span>
|
|
20
|
+
</a>
|
|
21
|
+
<button
|
|
22
|
+
*ngIf="config.btnShow?.next"
|
|
23
|
+
type="button"
|
|
24
|
+
[class]="config.btnClass"
|
|
25
|
+
(click)="fileViewer.nextImage($event)"
|
|
26
|
+
[disabled]="fileViewer.currentIndex === fileViewer.files.length - 1"
|
|
27
|
+
>
|
|
28
|
+
<span
|
|
29
|
+
*ngIf="config.btnIcons?.next?.classes"
|
|
30
|
+
[class]="config.btnIcons?.next?.classes"
|
|
31
|
+
></span>
|
|
32
|
+
</button>
|
|
33
|
+
<a
|
|
34
|
+
[class]="config.btnClass"
|
|
35
|
+
*ngIf="config.btnIcons?.next?.text"
|
|
36
|
+
(click)="fileViewer.nextImage($event)"
|
|
37
|
+
>
|
|
38
|
+
<span [class]="config.btnSubClass">{{ config.btnIcons?.next?.text }}</span>
|
|
39
|
+
</a>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<!-- Button Container -->
|
|
43
|
+
<div
|
|
44
|
+
class="btn-container"
|
|
45
|
+
[class]="config.btnContainerClass"
|
|
46
|
+
*ngIf="fileViewer.currentFile.type.startsWith('image')"
|
|
47
|
+
>
|
|
48
|
+
<!-- Rotate Counter Clockwise -->
|
|
49
|
+
<ng-container *ngIf="config.btnShow?.rotateCounterClockwise">
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
[class]="config.btnClass"
|
|
53
|
+
(click)="fileViewer.rotateCounterClockwise()"
|
|
54
|
+
*ngIf="config.btnIcons?.rotateCounterClockwise?.classes"
|
|
55
|
+
>
|
|
56
|
+
<span [class]="config.btnIcons?.rotateCounterClockwise?.classes"></span>
|
|
57
|
+
</button>
|
|
58
|
+
<a
|
|
59
|
+
[class]="config.btnClass"
|
|
60
|
+
*ngIf="config.btnIcons?.rotateCounterClockwise?.text"
|
|
61
|
+
(click)="fileViewer.rotateCounterClockwise()"
|
|
62
|
+
>
|
|
63
|
+
<span [class]="config.btnSubClass">{{
|
|
64
|
+
config.btnIcons?.rotateCounterClockwise?.text
|
|
65
|
+
}}</span>
|
|
66
|
+
</a>
|
|
67
|
+
</ng-container>
|
|
68
|
+
|
|
69
|
+
<!-- Rotate Clockwise -->
|
|
70
|
+
<ng-container *ngIf="config.btnShow?.rotateClockwise">
|
|
71
|
+
<button
|
|
72
|
+
type="button"
|
|
73
|
+
[class]="config.btnClass"
|
|
74
|
+
(click)="fileViewer.rotateClockwise()"
|
|
75
|
+
*ngIf="config.btnIcons?.rotateClockwise?.classes"
|
|
76
|
+
>
|
|
77
|
+
<span [class]="config.btnIcons?.rotateClockwise?.classes"></span>
|
|
78
|
+
</button>
|
|
79
|
+
<a
|
|
80
|
+
[class]="config.btnClass"
|
|
81
|
+
*ngIf="config.btnIcons?.rotateClockwise?.text"
|
|
82
|
+
(click)="fileViewer.rotateClockwise()"
|
|
83
|
+
>
|
|
84
|
+
<span [class]="config.btnSubClass">{{
|
|
85
|
+
config.btnIcons?.rotateClockwise?.text
|
|
86
|
+
}}</span>
|
|
87
|
+
</a>
|
|
88
|
+
</ng-container>
|
|
89
|
+
|
|
90
|
+
<!-- Zoom Out -->
|
|
91
|
+
<ng-container *ngIf="config.btnShow?.zoomOut">
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
[class]="config.btnClass"
|
|
95
|
+
(click)="fileViewer.zoomOut()"
|
|
96
|
+
*ngIf="config.btnIcons?.zoomOut?.classes"
|
|
97
|
+
>
|
|
98
|
+
<span [class]="config.btnIcons?.zoomOut?.classes"></span>
|
|
99
|
+
</button>
|
|
100
|
+
<a
|
|
101
|
+
[class]="config.btnClass"
|
|
102
|
+
*ngIf="config.btnIcons?.zoomOut?.text"
|
|
103
|
+
(click)="fileViewer.zoomOut()"
|
|
104
|
+
>
|
|
105
|
+
<span [class]="config.btnSubClass">{{
|
|
106
|
+
config.btnIcons?.zoomOut?.text
|
|
107
|
+
}}</span>
|
|
108
|
+
</a>
|
|
109
|
+
</ng-container>
|
|
110
|
+
|
|
111
|
+
<!-- Zoom In -->
|
|
112
|
+
<ng-container *ngIf="config.btnShow?.zoomIn">
|
|
113
|
+
<button
|
|
114
|
+
type="button"
|
|
115
|
+
[class]="config.btnClass"
|
|
116
|
+
(click)="fileViewer.zoomIn()"
|
|
117
|
+
*ngIf="config.btnIcons?.zoomIn?.classes"
|
|
118
|
+
>
|
|
119
|
+
<span [class]="config.btnIcons?.zoomIn?.classes"></span>
|
|
120
|
+
</button>
|
|
121
|
+
<a
|
|
122
|
+
[class]="config.btnClass"
|
|
123
|
+
*ngIf="config.btnIcons?.zoomIn?.text"
|
|
124
|
+
(click)="fileViewer.zoomIn()"
|
|
125
|
+
>
|
|
126
|
+
<span [class]="config.btnSubClass">{{
|
|
127
|
+
config.btnIcons?.zoomIn?.text
|
|
128
|
+
}}</span>
|
|
129
|
+
</a>
|
|
130
|
+
</ng-container>
|
|
131
|
+
|
|
132
|
+
<!-- Fullscreen -->
|
|
133
|
+
<ng-container *ngIf="config.allowFullscreen">
|
|
134
|
+
<button
|
|
135
|
+
type="button"
|
|
136
|
+
[class]="config.btnClass"
|
|
137
|
+
(click)="fileViewer.toggleFullscreen()"
|
|
138
|
+
*ngIf="config.btnIcons?.fullscreen?.classes"
|
|
139
|
+
>
|
|
140
|
+
<span [class]="config.btnIcons?.fullscreen?.classes"></span>
|
|
141
|
+
</button>
|
|
142
|
+
<a
|
|
143
|
+
[class]="config.btnClass"
|
|
144
|
+
*ngIf="config.btnIcons?.fullscreen?.text"
|
|
145
|
+
(click)="fileViewer.toggleFullscreen()"
|
|
146
|
+
>
|
|
147
|
+
<span [class]="config.btnSubClass">{{
|
|
148
|
+
config.btnIcons?.fullscreen?.text
|
|
149
|
+
}}</span>
|
|
150
|
+
</a>
|
|
151
|
+
</ng-container>
|
|
152
|
+
|
|
153
|
+
<!-- Reset -->
|
|
154
|
+
<ng-container *ngIf="config.btnShow?.reset">
|
|
155
|
+
<button
|
|
156
|
+
type="button"
|
|
157
|
+
[class]="config.btnClass"
|
|
158
|
+
(click)="fileViewer.reset()"
|
|
159
|
+
*ngIf="config.btnIcons?.reset?.classes"
|
|
160
|
+
>
|
|
161
|
+
<span [class]="config.btnIcons?.reset?.classes"></span>
|
|
162
|
+
</button>
|
|
163
|
+
<a
|
|
164
|
+
[class]="config.btnClass"
|
|
165
|
+
*ngIf="config.btnIcons?.reset?.text"
|
|
166
|
+
(click)="fileViewer.reset()"
|
|
167
|
+
>
|
|
168
|
+
<span [class]="config.btnSubClass">{{
|
|
169
|
+
config.btnIcons?.reset?.text
|
|
170
|
+
}}</span>
|
|
171
|
+
</a>
|
|
172
|
+
</ng-container>
|
|
173
|
+
|
|
174
|
+
<!-- Custom Buttons -->
|
|
175
|
+
<ng-container *ngFor="let cBtn of config.customBtns">
|
|
176
|
+
<button *ngIf="cBtn.icon.classes" type="button" [class]="config.btnClass">
|
|
177
|
+
<span *ngIf="cBtn.icon.classes" [class]="cBtn.icon.classes"></span>
|
|
178
|
+
</button>
|
|
179
|
+
<ng-container *ngIf="cBtn.icon.text">
|
|
180
|
+
<a [class]="config.btnClass" *ngIf="cBtn.icon.text">
|
|
181
|
+
<span [class]="config.btnSubClass">{{ cBtn.icon.text }}</span>
|
|
182
|
+
</a>
|
|
183
|
+
</ng-container>
|
|
184
|
+
</ng-container>
|
|
185
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { C3FileViewerActionsComponent } from './c3-file-viewer-actions.component';
|
|
4
|
+
|
|
5
|
+
describe('C3FileViewerActionsComponent', () => {
|
|
6
|
+
let component: C3FileViewerActionsComponent;
|
|
7
|
+
let fixture: ComponentFixture<C3FileViewerActionsComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ C3FileViewerActionsComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(C3FileViewerActionsComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|