Skip to content
Next
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Frontend
Project
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
817
Merge Requests
62
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Compare Revisions
325552f9516eae53c49649895485e7c1a91f1eae...0e584de971abab3e011c9cb1fdf883834d1c6712
Source
0e584de971abab3e011c9cb1fdf883834d1c6712
...
Target
325552f9516eae53c49649895485e7c1a91f1eae
Compare
Commits (2)
(feat): Domain validation
· e552651f
Emiliano Balbuena
authored
2 minutes ago
e552651f
Merge branch 'feat/pro-domain-check-e977' into 'master'
· 0e584de9
Mark Harding
authored
2 minutes ago
(feat): Domain validation See merge request
!624
0e584de9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
1 deletion
+107
-1
src/app/modules/pro/pro.service.ts
View file @
0e584de9
...
...
@@ -68,6 +68,27 @@ export class ProService {
return
true
;
}
async
domainCheck
(
domain
:
string
,
remoteUser
:
string
|
null
=
null
):
Promise
<
{
isValid
:
boolean
}
>
{
const
endpoint
=
[
'
api/v2/pro/settings/domain
'
];
if
(
remoteUser
)
{
endpoint
.
push
(
remoteUser
);
}
const
{
isValid
}
=
(
await
this
.
client
.
get
(
endpoint
.
join
(
'
/
'
),
{
domain
,
},
{
cache
:
false
}
))
as
any
;
return
{
isValid
};
}
async
upload
(
type
:
string
,
file
,
remoteUser
:
string
|
null
=
null
)
{
const
endpoint
=
[
'
api/v2/pro/settings/assets
'
,
type
];
...
...
This diff is collapsed.
src/app/modules/pro/settings/settings.component.html
View file @
0e584de9
...
...
@@ -406,12 +406,32 @@
<div
class=
"m-proSettings__field"
>
<label
for=
"domain"
i18n
>
Domain
</label>
<input
class=
"m-proSettingsField__input--hasIcon"
type=
"text"
id=
"domain"
name=
"domain"
[(ngModel)]=
"settings.domain"
(keydown)=
"domainValidationSubject.next($event)"
/>
<m-tooltip
*ngIf=
"isDomainValid !== null"
[icon]=
"isDomainValid ? 'check' : 'close'"
class=
"m-proSettingsDomain__validIcon"
[class.m-proSettingsDomain__validIcon--true]=
"isDomainValid"
[class.m-proSettingsDomain__validIcon--false]=
"!isDomainValid"
>
<ng-container
*ngIf=
"isDomainValid; else notValidDomain"
i18n
>
This domain is available
</ng-container>
<ng-template
#notValidDomain
>
<ng-container
i18n
>
This domain is taken
</ng-container>
</ng-template>
</m-tooltip>
</div>
<div
class=
"m-proSettings__field"
>
...
...
This diff is collapsed.
src/app/modules/pro/settings/settings.component.scss
View file @
0e584de9
...
...
@@ -61,6 +61,10 @@
@media
screen
and
(
max-width
:
768px
)
{
max-width
:
100%
;
&
.m-proSettingsField__input--hasIcon
{
max-width
:
calc
(
100%
-
24px
);
}
}
@include
m-theme
()
{
...
...
@@ -156,6 +160,36 @@
}
}
.m-proSettingsDomain__validIcon
{
position
:
relative
;
top
:
-1px
;
margin-left
:
4px
;
i
.material-icons
{
font-size
:
18px
;
line-height
:
18px
;
vertical-align
:
middle
;
}
.m-tooltip--bubble
{
width
:
150px
;
left
:
auto
;
right
:
0
;
}
&
.m-proSettingsDomain__validIcon--true
i
.material-icons
{
@include
m-theme
()
{
color
:
themed
(
$m-green
);
}
}
&
.m-proSettingsDomain__validIcon--false
i
.material-icons
{
@include
m-theme
()
{
color
:
themed
(
$m-red
);
}
}
}
.m-proSettings__previewBtn
{
margin-left
:
0
.35em
;
...
...
This diff is collapsed.
src/app/modules/pro/settings/settings.component.ts
View file @
0e584de9
...
...
@@ -7,12 +7,13 @@ import {
OnInit
,
ViewChild
,
}
from
'
@angular/core
'
;
import
{
Subject
,
Subscription
}
from
'
rxjs
'
;
import
{
ProService
}
from
'
../pro.service
'
;
import
{
Session
}
from
'
../../../services/session
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
MindsTitle
}
from
'
../../../services/ux/title
'
;
import
{
Subscription
}
from
'
rxjs
'
;
import
{
SiteService
}
from
'
../../../common/services/site.service
'
;
import
{
debounceTime
}
from
'
rxjs/operators
'
;
import
{
DomSanitizer
,
SafeUrl
}
from
'
@angular/platform-browser
'
;
@
Component
({
...
...
@@ -38,10 +39,16 @@ export class ProSettingsComponent implements OnInit, OnDestroy {
user
:
string
|
null
=
null
;
isDomainValid
:
boolean
|
null
=
null
;
error
:
string
;
domainValidationSubject
:
Subject
<
any
>
=
new
Subject
<
any
>
();
protected
param$
:
Subscription
;
protected
domainValidation$
:
Subscription
;
@
ViewChild
(
'
logoField
'
,
{
static
:
false
})
protected
logoField
:
ElementRef
<
HTMLInputElement
>
;
...
...
@@ -67,10 +74,15 @@ export class ProSettingsComponent implements OnInit, OnDestroy {
this
.
load
();
});
this
.
domainValidation$
=
this
.
domainValidationSubject
.
pipe
(
debounceTime
(
300
))
.
subscribe
(()
=>
this
.
validateDomain
());
}
ngOnDestroy
()
{
this
.
param$
.
unsubscribe
();
this
.
domainValidation$
.
unsubscribe
();
}
async
load
()
{
...
...
@@ -92,6 +104,25 @@ export class ProSettingsComponent implements OnInit, OnDestroy {
this
.
detectChanges
();
}
async
validateDomain
()
{
this
.
isDomainValid
=
null
;
this
.
detectChanges
();
try
{
const
{
isValid
}
=
await
this
.
service
.
domainCheck
(
this
.
settings
.
domain
,
this
.
user
);
this
.
isDomainValid
=
isValid
;
}
catch
(
e
)
{
this
.
isDomainValid
=
null
;
this
.
error
=
(
e
&&
e
.
message
)
||
'
Error checking domain
'
;
}
this
.
detectChanges
();
}
onAssetFileSelect
(
type
:
string
,
files
:
FileList
|
null
)
{
if
(
!
files
||
!
files
.
item
(
0
))
{
this
.
settings
[
type
]
=
null
;
...
...
This diff is collapsed.