Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
e7480bee
Commit
e7480bee
authored
5 years ago
by
Alex ORLUC
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #11954 TIME 0:30 add ext + size control upload file
parent
00b77ab8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/frontend/app/viewer/document-viewer.component.scss
+5
-0
5 additions, 0 deletions
src/frontend/app/viewer/document-viewer.component.scss
src/frontend/app/viewer/document-viewer.component.ts
+41
-3
41 additions, 3 deletions
src/frontend/app/viewer/document-viewer.component.ts
with
46 additions
and
3 deletions
src/frontend/app/viewer/document-viewer.component.scss
+
5
−
0
View file @
e7480bee
...
@@ -86,3 +86,8 @@
...
@@ -86,3 +86,8 @@
border-radius
:
10px
;
border-radius
:
10px
;
background
:
#ffffff
47
;
background
:
#ffffff
47
;
}
}
.extensionsList
{
height
:
200px
;
overflow
:
auto
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/frontend/app/viewer/document-viewer.component.ts
+
41
−
3
View file @
e7480bee
...
@@ -8,6 +8,8 @@ import { tap, catchError, finalize, filter } from 'rxjs/operators';
...
@@ -8,6 +8,8 @@ import { tap, catchError, finalize, filter } from 'rxjs/operators';
import
{
of
}
from
'
rxjs
'
;
import
{
of
}
from
'
rxjs
'
;
import
{
ConfirmComponent
}
from
'
../../plugins/modal/confirm.component
'
;
import
{
ConfirmComponent
}
from
'
../../plugins/modal/confirm.component
'
;
import
{
MatDialogRef
,
MatDialog
}
from
'
@angular/material
'
;
import
{
MatDialogRef
,
MatDialog
}
from
'
@angular/material
'
;
import
{
AlertComponent
}
from
'
../../plugins/modal/alert.component
'
;
import
{
SortPipe
}
from
'
../../plugins/sorting.pipe
'
;
@
Component
({
@
Component
({
...
@@ -16,7 +18,7 @@ import { MatDialogRef, MatDialog } from '@angular/material';
...
@@ -16,7 +18,7 @@ import { MatDialogRef, MatDialog } from '@angular/material';
styleUrls
:
[
styleUrls
:
[
'
document-viewer.component.scss
'
,
'
document-viewer.component.scss
'
,
],
],
providers
:
[
NotificationService
,
AppService
]
providers
:
[
NotificationService
,
AppService
,
SortPipe
]
})
})
export
class
DocumentViewerComponent
implements
OnInit
{
export
class
DocumentViewerComponent
implements
OnInit
{
...
@@ -33,6 +35,9 @@ export class DocumentViewerComponent implements OnInit {
...
@@ -33,6 +35,9 @@ export class DocumentViewerComponent implements OnInit {
src
:
null
src
:
null
};
};
allowedExtensions
:
any
[]
=
[];
maxFileSize
:
number
=
0
;
dialogRef
:
MatDialogRef
<
any
>
;
dialogRef
:
MatDialogRef
<
any
>
;
constructor
(
constructor
(
...
@@ -41,12 +46,29 @@ export class DocumentViewerComponent implements OnInit {
...
@@ -41,12 +46,29 @@ export class DocumentViewerComponent implements OnInit {
private
headerService
:
HeaderService
,
private
headerService
:
HeaderService
,
public
appService
:
AppService
,
public
appService
:
AppService
,
private
dialog
:
MatDialog
,
private
dialog
:
MatDialog
,
private
sortPipe
:
SortPipe
)
{
)
{
(
<
any
>
window
).
pdfWorkerSrc
=
'
../../node_modules/pdfjs-dist/build/pdf.worker.min.js
'
;
(
<
any
>
window
).
pdfWorkerSrc
=
'
../../node_modules/pdfjs-dist/build/pdf.worker.min.js
'
;
}
}
ngOnInit
()
{
ngOnInit
()
{
this
.
http
.
get
(
'
../../rest/indexing/fileInformations
'
).
pipe
(
tap
((
data
:
any
)
=>
{
this
.
allowedExtensions
=
data
.
informations
.
allowedFiles
.
map
((
ext
:
any
)
=>
{
return
{
extension
:
'
.
'
+
ext
.
extension
.
toLowerCase
(),
mimeType
:
ext
.
mimeType
,
}
});
this
.
allowedExtensions
=
this
.
sortPipe
.
transform
(
this
.
allowedExtensions
,
'
extension
'
);
this
.
maxFileSize
=
data
.
informations
.
maximumSize
;
}),
catchError
((
err
:
any
)
=>
{
this
.
notify
.
handleErrors
(
err
);
return
of
(
false
);
})
).
subscribe
();
}
}
uploadTrigger
(
fileInput
:
any
)
{
uploadTrigger
(
fileInput
:
any
)
{
...
@@ -58,7 +80,8 @@ export class DocumentViewerComponent implements OnInit {
...
@@ -58,7 +80,8 @@ export class DocumentViewerComponent implements OnInit {
};
};
this
.
noConvertedFound
=
false
;
this
.
noConvertedFound
=
false
;
this
.
loading
=
true
;
this
.
loading
=
true
;
if
(
fileInput
.
target
.
files
&&
fileInput
.
target
.
files
[
0
])
{
if
(
fileInput
.
target
.
files
&&
fileInput
.
target
.
files
[
0
]
&&
this
.
checkFile
(
fileInput
.
target
.
files
[
0
]))
{
var
reader
=
new
FileReader
();
var
reader
=
new
FileReader
();
this
.
file
.
name
=
fileInput
.
target
.
files
[
0
].
name
;
this
.
file
.
name
=
fileInput
.
target
.
files
[
0
].
name
;
...
@@ -76,6 +99,8 @@ export class DocumentViewerComponent implements OnInit {
...
@@ -76,6 +99,8 @@ export class DocumentViewerComponent implements OnInit {
this
.
loading
=
false
;
this
.
loading
=
false
;
}
}
};
};
}
else
{
this
.
loading
=
false
;
}
}
}
}
...
@@ -152,4 +177,17 @@ export class DocumentViewerComponent implements OnInit {
...
@@ -152,4 +177,17 @@ export class DocumentViewerComponent implements OnInit {
this
.
uploadTrigger
(
fileInput
);
this
.
uploadTrigger
(
fileInput
);
}
}
checkFile
(
file
:
any
)
{
if
(
this
.
allowedExtensions
.
map
(
ext
=>
ext
.
mimeType
).
indexOf
(
file
.
type
)
===
-
1
)
{
this
.
dialog
.
open
(
AlertComponent
,
{
autoFocus
:
false
,
disableClose
:
true
,
data
:
{
title
:
'
Extension non autorisé !
'
,
msg
:
'
<u>Extension autorisée</u> : <br/>
'
+
this
.
allowedExtensions
.
map
(
ext
=>
ext
.
extension
).
filter
((
elem
:
any
,
index
:
any
,
self
:
any
)
=>
index
===
self
.
indexOf
(
elem
)).
join
(
'
,
'
)
}
});
return
false
;
}
else
if
(
file
.
size
>
this
.
maxFileSize
)
{
this
.
dialog
.
open
(
AlertComponent
,
{
autoFocus
:
false
,
disableClose
:
true
,
data
:
{
title
:
'
Taille maximale dépassée !
'
,
msg
:
'
Taille maximale :
'
+
this
.
maxFileSize
}
});
return
false
;
}
else
{
return
true
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment