Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angular-vqode-module
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Usman
angular-vqode-module
Commits
6d835fb6
Commit
6d835fb6
authored
Jul 05, 2019
by
Muhammad Usman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Icon service added, pug & config file
parent
3fdfbb10
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
107 additions
and
53 deletions
+107
-53
form-control.component.html
components/form-control/form-control.component.html
+0
-16
form-control.component.pug
components/form-control/form-control.component.pug
+3
-0
form-control.component.ts
components/form-control/form-control.component.ts
+2
-10
config.ts
config.ts
+1
-2
focus-blur.directive.ts
directives/focus-blur.directive.ts
+1
-1
password.directive.ts
directives/password.directive.ts
+30
-0
truncate.pipe.ts
pipes/truncate.pipe.ts
+4
-2
http.service.ts
services/http.service.ts
+5
-5
icons.service.ts
services/icons.service.ts
+25
-0
utils.service.ts
services/utils.service.ts
+14
-9
password.validator.ts
validators/password.validator.ts
+2
-1
vqode.module.ts
vqode.module.ts
+20
-7
No files found.
components/form-control/form-control.component.html
deleted
100644 → 0
View file @
3fdfbb10
<div
[
class
]="'
form-control-wrapper
'
+
class
"
*
ngIf=
"fcn"
[
ngClass
]="{
'
-highlighted
'
:
isHighlighted
,
'
-err-tooltip
'
:
isShowErrorTooltip
}"
>
<ng-content></ng-content>
<div
class=
"form-control-wrapper__error"
*
ngIf=
"isShowErrorTooltip"
>
{{ getError() }}
</div>
</div>
components/form-control/form-control.component.pug
0 → 100644
View file @
6d835fb6
div([class]="'form-control-wrapper ' + class", *ngIf='fcn', [ngClass]="{ 'has-error': isHighlighted }")
ng-content
span.error-msg(*ngIf='isHighlighted') {{ getError() }}
components/form-control/form-control.component.ts
View file @
6d835fb6
import
{
Component
,
ContentChild
,
Input
}
from
'@angular/core'
;
import
{
Component
,
ContentChild
,
Input
}
from
'@angular/core'
;
import
{
FocusBlurDirective
}
from
'../../directives/focus-blur.directive'
;
import
{
AbstractControl
,
FormControlName
}
from
'@angular/forms'
;
import
{
AbstractControl
,
FormControlName
}
from
'@angular/forms'
;
import
{
CONFIG
}
from
'../../config'
;
import
{
CONFIG
}
from
'../../config'
;
import
{
FocusBlurDirective
}
from
'../../directives/focus-blur.directive'
;
@
Component
({
@
Component
({
selector
:
'app-form-control'
,
selector
:
'app-form-control'
,
templateUrl
:
'./form-control.component.
html
'
templateUrl
:
'./form-control.component.
pug
'
})
})
export
class
FormControlComponent
{
export
class
FormControlComponent
{
...
@@ -43,12 +43,4 @@ export class FormControlComponent {
...
@@ -43,12 +43,4 @@ export class FormControlComponent {
return
this
.
control
.
invalid
&&
(
this
.
control
.
dirty
||
this
.
control
.
touched
);
return
this
.
control
.
invalid
&&
(
this
.
control
.
dirty
||
this
.
control
.
touched
);
}
}
get
isShowErrorTooltip
():
boolean
{
if
(
!
this
.
focusBlur
)
{
return
;
}
return
this
.
control
.
invalid
&&
this
.
focusBlur
.
isFocused
;
}
}
}
config.ts
View file @
6d835fb6
...
@@ -9,12 +9,11 @@ export const CONFIG = {
...
@@ -9,12 +9,11 @@ export const CONFIG = {
}
}
};
};
export
const
SHOW_ERRORS
=
{
export
const
SHOW_ERRORS
=
{
e400
:
false
,
e400
:
false
,
e401
:
false
,
e401
:
false
,
e500
:
false
,
e500
:
false
,
e404
:
false
,
e404
:
false
,
e422
:
false
,
e422
:
false
,
e403
:
false
,
e403
:
false
};
};
directives/focus-blur.directive.ts
View file @
6d835fb6
import
{
Directive
,
HostListener
}
from
'@angular/core'
;
import
{
Directive
,
HostListener
}
from
'@angular/core'
;
@
Directive
({
@
Directive
({
selector
:
'[appFocusBlur]'
selector
:
'[appFocusBlur]'
...
...
directives/password.directive.ts
0 → 100644
View file @
6d835fb6
import
{
Directive
,
ElementRef
,
OnInit
}
from
'@angular/core'
;
@
Directive
({
selector
:
'[appPassword]'
})
export
class
PasswordDirective
implements
OnInit
{
private
readonly
element
:
HTMLInputElement
;
constructor
(
private
elRef
:
ElementRef
)
{
this
.
element
=
elRef
.
nativeElement
;
}
ngOnInit
():
void
{
const
img
=
document
.
createElement
(
'img'
);
img
.
classList
.
add
(
'password-eye'
);
img
.
src
=
'/assets/svgs/eye.svg'
;
img
.
addEventListener
(
'click'
,
()
=>
{
const
type
=
this
.
element
.
getAttribute
(
'type'
);
type
===
'password'
?
this
.
element
.
setAttribute
(
'type'
,
'text'
)
:
this
.
element
.
setAttribute
(
'type'
,
'password'
);
});
setTimeout
(()
=>
{
this
.
element
.
parentElement
.
appendChild
(
img
);
this
.
element
.
classList
.
add
(
'password-field'
);
},
0
);
}
}
pipes/truncate.pipe.ts
View file @
6d835fb6
...
@@ -9,10 +9,12 @@ export class TruncatePipe implements PipeTransform {
...
@@ -9,10 +9,12 @@ export class TruncatePipe implements PipeTransform {
if
(
!
value
)
{
if
(
!
value
)
{
return
''
;
return
''
;
}
}
let
newValue
=
''
;
if
(
value
.
length
>
length
)
{
if
(
value
.
length
>
length
)
{
value
=
value
.
substring
(
0
,
length
-
3
)
+
' ...'
;
newValue
=
`
${
value
.
substring
(
0
,
length
-
3
)}
...`
;
}
}
return
value
;
return
newValue
;
}
}
}
}
services/http.service.ts
View file @
6d835fb6
import
{
Injectable
}
from
'@angular/core'
;
/* tslint:disable */
import
{
Subject
}
from
'rxjs'
;
import
{
HttpClient
,
HttpHeaders
}
from
'@angular/common/http'
;
import
{
HttpClient
,
HttpHeaders
}
from
'@angular/common/http'
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
Router
}
from
'@angular/router'
;
import
{
Router
}
from
'@angular/router'
;
import
{
Subject
}
from
'rxjs'
;
import
{
map
,
share
}
from
'rxjs/operators'
;
import
{
map
,
share
}
from
'rxjs/operators'
;
@
Injectable
()
@
Injectable
()
...
@@ -42,9 +43,8 @@ export class HttpService {
...
@@ -42,9 +43,8 @@ export class HttpService {
}
}
createHeader
(
extraHeaders
=
{})
{
createHeader
(
extraHeaders
=
{})
{
const
headers
=
Object
.
assign
({
const
headers
=
{
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
...
extraHeaders
};
},
extraHeaders
);
if
(
extraHeaders
[
'Content-Type'
]
===
null
)
{
if
(
extraHeaders
[
'Content-Type'
]
===
null
)
{
delete
headers
[
'Content-Type'
];
delete
headers
[
'Content-Type'
];
}
}
...
...
services/icons.service.ts
0 → 100644
View file @
6d835fb6
import
{
Injectable
}
from
'@angular/core'
;
import
{
SvgIconRegistryService
}
from
'angular-svg-icon'
;
import
{
forkJoin
}
from
'rxjs'
;
import
{
retry
}
from
'rxjs/operators'
;
import
{
ICONS
}
from
'../../config/icon-list'
;
@
Injectable
()
export
class
IconsService
{
icons
=
ICONS
;
constructor
(
private
iconReg
:
SvgIconRegistryService
)
{
}
async
loadSvgIcons
():
Promise
<
any
>
{
return
new
Promise
<
any
>
(
resolve
=>
{
forkJoin
(
this
.
icons
.
map
(
icon
=>
this
.
iconReg
.
loadSvg
(
icon
.
url
,
icon
.
name
).
pipe
(
retry
(
3
))))
.
subscribe
(()
=>
{
resolve
();
});
});
}
}
services/utils.service.ts
View file @
6d835fb6
import
{
HttpErrorResponse
}
from
'@angular/common/http'
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
FormArray
,
FormControl
,
FormGroup
}
from
'@angular/forms'
;
import
{
FormArray
,
FormControl
,
FormGroup
}
from
'@angular/forms'
;
import
{
HttpErrorResponse
}
from
'@angular/common/http'
;
import
{
SHOW_ERRORS
}
from
'../config'
;
import
{
SHOW_ERRORS
}
from
'../config'
;
@
Injectable
()
@
Injectable
()
export
class
UtilsService
{
export
class
UtilsService
{
constructor
()
{
}
validateAllFormFields
(
formGroup
?:
FormGroup
):
void
{
validateAllFormFields
(
formGroup
?:
FormGroup
):
void
{
Object
Object
.
keys
(
formGroup
.
controls
)
.
keys
(
formGroup
.
controls
)
...
@@ -33,29 +31,36 @@ export class UtilsService {
...
@@ -33,29 +31,36 @@ export class UtilsService {
handleHttpError
(
error
:
HttpErrorResponse
):
any
{
handleHttpError
(
error
:
HttpErrorResponse
):
any
{
switch
(
error
.
status
)
{
switch
(
error
.
status
)
{
case
401
:
case
401
:
if
(
SHOW_ERRORS
.
e401
!==
false
)
{
if
(
SHOW_ERRORS
.
e401
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
}
break
;
break
;
case
400
:
case
400
:
if
(
SHOW_ERRORS
.
e400
!==
false
)
{
if
(
SHOW_ERRORS
.
e400
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
}
break
;
break
;
case
500
:
case
500
:
if
(
SHOW_ERRORS
.
e500
!==
false
)
{
if
(
SHOW_ERRORS
.
e500
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
}
break
;
break
;
case
404
:
case
404
:
if
(
SHOW_ERRORS
.
e404
!==
false
)
{
if
(
SHOW_ERRORS
.
e404
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
}
break
;
break
;
case
422
:
case
422
:
if
(
SHOW_ERRORS
.
e422
!==
false
)
{
if
(
SHOW_ERRORS
.
e422
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
}
break
;
break
;
case
403
:
case
403
:
if
(
SHOW_ERRORS
.
e403
!==
false
)
{
if
(
SHOW_ERRORS
.
e403
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
}
break
;
break
;
default
:
}
}
}
}
}
}
validators/password.validator.ts
View file @
6d835fb6
...
@@ -8,15 +8,16 @@ export class ConfirmPasswordValidator {
...
@@ -8,15 +8,16 @@ export class ConfirmPasswordValidator {
if
(
!
fieldValue
||
fieldValue
!==
comparisonValue
)
{
if
(
!
fieldValue
||
fieldValue
!==
comparisonValue
)
{
return
{
notMatch
:
true
};
return
{
notMatch
:
true
};
}
}
return
null
;
return
null
;
};
};
}
}
static
ValidPassword
():
ValidatorFn
{
static
ValidPassword
():
ValidatorFn
{
return
(
c
:
FormControl
):
{
[
key
:
string
]:
boolean
}
|
null
=>
{
return
(
c
:
FormControl
):
{
[
key
:
string
]:
boolean
}
|
null
=>
{
const
fieldValue
=
c
.
value
;
const
fieldValue
=
c
.
value
;
const
isValid
=
(
fieldValue
.
length
>=
8
&&
/
[
A-Z
]
/
.
test
(
fieldValue
)
&&
/
[
a-z
]
/
.
test
(
fieldValue
)
&&
/
[
0-9
]
/
.
test
(
fieldValue
));
const
isValid
=
(
fieldValue
.
length
>=
8
&&
/
[
A-Z
]
/
.
test
(
fieldValue
)
&&
/
[
a-z
]
/
.
test
(
fieldValue
)
&&
/
[
0-9
]
/
.
test
(
fieldValue
));
return
isValid
?
null
:
{
invalidPassword
:
true
};
return
isValid
?
null
:
{
invalidPassword
:
true
};
};
};
}
}
...
...
vqode.module.ts
View file @
6d835fb6
import
{
NgModule
}
from
'@angular/core'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
CommonModule
}
from
'@angular/common'
;
import
{
HttpClientModule
}
from
'@angular/common/http'
;
import
{
NgModule
}
from
'@angular/core'
;
import
{
AngularSvgIconModule
}
from
'angular-svg-icon'
;
import
{
FormControlComponent
}
from
'./components/form-control/form-control.component'
;
import
{
FormControlComponent
}
from
'./components/form-control/form-control.component'
;
import
{
HttpService
}
from
'./services/http.service'
;
import
{
FocusBlurDirective
}
from
'./directives/focus-blur.directive'
;
import
{
UtilsService
}
from
'./services/utils.service'
;
import
{
PasswordDirective
}
from
'./directives/password.directive'
;
import
{
FocusBlurDirective
}
from
'./directives/focus-blur.directive'
;
import
{
TruncatePipe
}
from
'./pipes/truncate.pipe'
;
import
{
TruncatePipe
}
from
'./pipes/truncate.pipe'
;
import
{
HttpService
}
from
'./services/http.service'
;
import
{
IconsService
}
from
'./services/icons.service'
;
import
{
UtilsService
}
from
'./services/utils.service'
;
const
PIPES
=
[
const
PIPES
=
[
TruncatePipe
TruncatePipe
...
@@ -15,21 +19,30 @@ const COMPONENTS = [
...
@@ -15,21 +19,30 @@ const COMPONENTS = [
];
];
const
DIRECTIVES
=
[
const
DIRECTIVES
=
[
FocusBlurDirective
FocusBlurDirective
,
PasswordDirective
];
];
const
PROVIDERS
=
[
const
PROVIDERS
=
[
HttpService
,
HttpService
,
UtilsService
UtilsService
,
IconsService
];
const
MODULES
=
[
AngularSvgIconModule
,
HttpClientModule
];
];
@
NgModule
({
@
NgModule
({
declarations
:
[...
COMPONENTS
,
...
DIRECTIVES
,
...
PIPES
],
declarations
:
[...
COMPONENTS
,
...
DIRECTIVES
,
...
PIPES
],
imports
:
[
imports
:
[
CommonModule
CommonModule
,
...
MODULES
],
],
providers
:
PROVIDERS
,
providers
:
PROVIDERS
,
exports
:
[
exports
:
[
...
MODULES
,
...
COMPONENTS
,
...
COMPONENTS
,
...
PIPES
,
...
PIPES
,
...
DIRECTIVES
...
DIRECTIVES
...
...
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