Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
826
Issues
826
List
Boards
Labels
Service Desk
Milestones
Merge Requests
44
Merge Requests
44
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Commits
fc7e7bcf
Commit
fc7e7bcf
authored
22 minutes ago
by
Emiliano Balbuena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(refactor): Parallel uploads and better error display
parent
9590b251
goal/pro-logo-upload
1 merge request
!596
WIP: Pro logo and background upload
Pipeline
#89521096
running with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
39 deletions
+66
-39
src/app/modules/pro/pro.service.ts
src/app/modules/pro/pro.service.ts
+8
-1
src/app/modules/pro/settings/settings.component.html
src/app/modules/pro/settings/settings.component.html
+25
-4
src/app/modules/pro/settings/settings.component.scss
src/app/modules/pro/settings/settings.component.scss
+8
-2
src/app/modules/pro/settings/settings.component.ts
src/app/modules/pro/settings/settings.component.ts
+25
-32
No files found.
src/app/modules/pro/pro.service.ts
View file @
fc7e7bcf
...
...
@@ -75,7 +75,14 @@ export class ProService {
endpoint
.
push
(
remoteUser
);
}
await
this
.
uploadClient
.
post
(
endpoint
.
join
(
'
/
'
),
[
file
]);
const
response
=
(
await
this
.
uploadClient
.
post
(
endpoint
.
join
(
'
/
'
),
[
file
,
]))
as
any
;
if
(
!
response
||
response
.
status
!==
'
success
'
)
{
throw
new
Error
(
response
.
message
||
'
Invalid server response
'
);
}
return
true
;
}
}
This diff is collapsed.
Click to expand it.
src/app/modules/pro/settings/settings.component.html
View file @
fc7e7bcf
...
...
@@ -24,6 +24,17 @@
</m-tooltip>
</a>
<a
class=
"m-topbar--navigation--item"
[class.m-topbar--navigation--item-active]=
"currentTab === 'assets'"
(click)=
"currentTab = 'assets'"
>
<span
i18n
>
Assets
</span>
<m-tooltip
icon=
"help"
i18n
>
Upload a custom logo and background.
</m-tooltip>
</a>
<a
class=
"m-topbar--navigation--item"
[class.m-topbar--navigation--item-active]=
"currentTab === 'hashtags'"
...
...
@@ -207,6 +218,14 @@
</label>
</ng-container>
</div>
</ng-template>
<!-- Assets -->
<ng-template
ngSwitchCase=
"assets"
>
<p
class=
"m-proSettings__note"
i18n
>
Upload a custom logo and background.
</p>
<div
class=
"m-proSettings__field"
>
<label
for=
"logo"
i18n
>
Logo Image
</label>
...
...
@@ -215,7 +234,7 @@
id=
"logo"
name=
"logo"
accept=
"image/*"
(change)=
"on
LogoFileSelect(
logoField.files)"
(change)=
"on
AssetFileSelect('logo',
logoField.files)"
#logoField
/>
</div>
...
...
@@ -227,7 +246,9 @@
id=
"background"
name=
"background"
accept=
"image/*"
(change)=
"onBackgroundFileSelect(backgroundField.files)"
(change)=
"
onAssetFileSelect('background', backgroundField.files)
"
#backgroundField
/>
</div>
...
...
@@ -395,8 +416,8 @@
</ng-template>
</ng-container>
<div
class=
"m-proSettings__error"
*ngIf=
"
!!
error"
>
{{ error }}
<div
class=
"m-proSettings__error"
*ngIf=
"error"
>
Error:
{{ error }}
</div>
<div
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/pro/settings/settings.component.scss
View file @
fc7e7bcf
...
...
@@ -134,10 +134,16 @@
}
.m-proSettings__error
{
margin
:
16px
0
;
font-size
:
20px
;
margin
:
0
0
16px
0
;
padding
:
8px
;
border-radius
:
8px
;
border
:
1px
solid
;
font-size
:
14px
;
line-height
:
1
;
@include
m-theme
()
{
color
:
themed
(
$m-red
);
border-color
:
themed
(
$m-red
);
}
}
}
This diff is collapsed.
Click to expand it.
src/app/modules/pro/settings/settings.component.ts
View file @
fc7e7bcf
...
...
@@ -29,6 +29,7 @@ export class ProSettingsComponent implements OnInit, OnDestroy {
currentTab
:
|
'
general
'
|
'
theme
'
|
'
assets
'
|
'
hashtags
'
|
'
footer
'
|
'
domain
'
...
...
@@ -89,26 +90,31 @@ export class ProSettingsComponent implements OnInit, OnDestroy {
this
.
detectChanges
();
}
on
LogoFileSelect
(
files
:
FileList
|
null
)
{
on
AssetFileSelect
(
type
:
string
,
files
:
FileList
|
null
)
{
if
(
!
files
||
!
files
.
item
(
0
))
{
this
.
settings
.
logo
=
null
;
this
.
settings
[
type
]
=
null
;
this
.
detectChanges
();
return
;
}
this
.
settings
.
logo
=
files
.
item
(
0
);
this
.
settings
[
type
]
=
files
.
item
(
0
);
this
.
detectChanges
();
}
onBackgroundFileSelect
(
files
:
FileList
|
null
)
{
if
(
!
files
||
!
files
.
item
(
0
))
{
this
.
settings
.
background
=
null
;
this
.
detectChanges
();
return
;
protected
async
uploadAsset
(
type
:
string
,
file
:
File
,
htmlInputFileElementRef
:
ElementRef
<
HTMLInputElement
>
|
null
=
null
):
Promise
<
void
>
{
await
this
.
service
.
upload
(
type
,
file
,
this
.
user
);
if
(
htmlInputFileElementRef
&&
htmlInputFileElementRef
.
nativeElement
)
{
try
{
htmlInputFileElementRef
.
nativeElement
.
value
=
''
;
}
catch
(
e
)
{
console
.
warn
(
`Browser prevented
${
type
}
field resetting`
);
}
}
this
.
settings
.
background
=
files
.
item
(
0
);
this
.
detectChanges
();
}
async
save
()
{
...
...
@@ -119,36 +125,23 @@ export class ProSettingsComponent implements OnInit, OnDestroy {
try
{
const
{
logo
,
background
,
...
settings
}
=
this
.
settings
;
if
(
logo
)
{
await
this
.
service
.
upload
(
'
logo
'
,
logo
,
this
.
user
);
if
(
this
.
logoField
.
nativeElement
)
{
try
{
this
.
logoField
.
nativeElement
.
value
=
''
;
}
catch
(
e
)
{
console
.
warn
(
'
Browser prevented logoField resetting
'
);
}
}
const
uploads
:
Promise
<
any
>
[]
=
[];
if
(
logo
)
{
uploads
.
push
(
this
.
uploadAsset
(
'
logo
'
,
logo
,
this
.
logoField
));
settings
.
has_custom_logo
=
true
;
}
if
(
background
)
{
await
this
.
service
.
upload
(
'
background
'
,
background
,
this
.
user
);
if
(
this
.
backgroundField
.
nativeElement
)
{
try
{
this
.
backgroundField
.
nativeElement
.
value
=
''
;
}
catch
(
e
)
{
console
.
warn
(
'
Browser prevented backgroundField resetting
'
);
}
}
uploads
.
push
(
this
.
uploadAsset
(
'
background
'
,
background
,
this
.
backgroundField
)
);
settings
.
has_custom_background
=
true
;
}
this
.
settings
=
settings
;
await
Promise
.
all
(
uploads
)
;
this
.
settings
=
settings
;
await
this
.
service
.
set
(
this
.
settings
,
this
.
user
);
}
catch
(
e
)
{
this
.
error
=
e
.
message
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment