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
67096fbf
Commit
67096fbf
authored
Sep 30, 2019
by
Ali Arshad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TSLint fixes
parent
6d835fb6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
48 additions
and
106 deletions
+48
-106
form-control.component.html
components/form-control/form-control.component.html
+6
-0
form-control.component.pug
components/form-control/form-control.component.pug
+0
-3
form-control.component.ts
components/form-control/form-control.component.ts
+1
-1
truncate.pipe.ts
pipes/truncate.pipe.ts
+1
-1
http.service.ts
services/http.service.ts
+33
-28
icons.service.ts
services/icons.service.ts
+0
-25
utils.service.ts
services/utils.service.ts
+2
-40
password.validator.ts
validators/password.validator.ts
+2
-2
vqode.module.ts
vqode.module.ts
+3
-6
No files found.
components/form-control/form-control.component.html
0 → 100644
View file @
67096fbf
<div
[
class
]="'
form-control-wrapper
'
+
class
"
*
ngIf=
'fcn'
[
ngClass
]="{
'
has-error
'
:
isHighlighted
}"
>
<ng-content></ng-content>
<span
class=
"error-msg"
*
ngIf=
'isHighlighted'
>
{{ getError() }}
</span>
</div>
components/form-control/form-control.component.pug
deleted
100644 → 0
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 @
67096fbf
...
...
@@ -5,7 +5,7 @@ import { FocusBlurDirective } from '../../directives/focus-blur.directive';
@
Component
({
selector
:
'app-form-control'
,
templateUrl
:
'./form-control.component.
pug
'
templateUrl
:
'./form-control.component.
html
'
})
export
class
FormControlComponent
{
...
...
pipes/truncate.pipe.ts
View file @
67096fbf
...
...
@@ -11,7 +11,7 @@ export class TruncatePipe implements PipeTransform {
}
let
newValue
=
''
;
if
(
value
.
length
>
length
)
{
newValue
=
`
${
value
.
substring
(
0
,
length
-
3
)}
...`
;
newValue
=
`
${
value
.
substring
(
0
,
length
-
3
)}
...`
;
}
return
newValue
;
...
...
services/http.service.ts
View file @
67096fbf
/* tslint:disable */
import
{
HttpClient
,
HttpHeaders
}
from
'@angular/common/http'
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
Router
}
from
'@angular/router'
;
import
{
Subject
}
from
'rxjs'
;
import
{
map
,
share
}
from
'rxjs/operators'
;
import
{
Observable
,
Subject
}
from
'rxjs'
;
import
{
map
}
from
'rxjs/operators'
;
@
Injectable
()
...
...
@@ -13,7 +12,7 @@ export class HttpService {
private
headers
;
private
api
;
private
sendAuthMsg
;
private
logoutNotification
=
new
Subject
();
private
logoutNotification
:
Subject
<
string
>
=
new
Subject
();
constructor
(
private
http
:
HttpClient
,
...
...
@@ -22,40 +21,42 @@ export class HttpService {
this
.
sendAuthMsg
=
true
;
}
setAPIURL
(
url
)
{
setAPIURL
(
url
)
:
void
{
this
.
api
=
url
;
}
setTokken
(
value
)
{
setTokken
(
value
)
:
void
{
this
.
accessTokken
=
value
;
}
getToken
()
{
getToken
()
:
string
{
return
this
.
accessTokken
;
}
getAPIURL
()
{
getAPIURL
()
:
string
{
return
this
.
api
;
}
onLogout
()
{
onLogout
()
:
Observable
<
string
>
{
return
this
.
logoutNotification
.
asObservable
();
}
createHeader
(
extraHeaders
=
{})
{
createHeader
(
extraHeaders
=
{})
:
void
{
const
headers
=
{
'Content-Type'
:
'application/json'
,
...
extraHeaders
};
Authorization
:
''
,
'Content-Type'
:
'application/json'
,
...
extraHeaders
};
if
(
extraHeaders
[
'Content-Type'
]
===
null
)
{
delete
headers
[
'Content-Type'
];
}
if
(
this
.
accessTokken
)
{
headers
[
`Authorization`
]
=
'Bearer '
+
this
.
accessTokken
;
headers
.
Authorization
=
`Bearer
${
this
.
accessTokken
}
`
;
}
this
.
headers
=
new
HttpHeaders
(
headers
);
}
sendUnAuthorizedMessage
(
m
essage
)
{
message
=
message
||
'You need to login first.'
;
sendUnAuthorizedMessage
(
m
sg
):
void
{
const
message
=
msg
||
'You need to login first.'
;
this
.
sendAuthMsg
=
false
;
// this.toastr.error(message, null, {showCloseButton: true});
setTimeout
(()
=>
{
...
...
@@ -64,54 +65,58 @@ export class HttpService {
this
.
logoutNotification
.
next
(
'user_logout'
);
}
mapResponse
(
resp
,
returnHeaders
=
false
)
{
mapResponse
(
resp
,
returnHeaders
=
false
)
:
{}
{
if
(
returnHeaders
===
false
)
{
return
resp
.
body
;
}
else
{
return
{
body
:
resp
.
body
,
headers
:
resp
.
headers
};
}
return
{
body
:
resp
.
body
,
headers
:
resp
.
headers
};
}
get
(
method
,
value
=
''
,
showErrors
=
{},
returnHeaders
=
false
,
absoluteUrl
=
false
,
extraHeaders
=
{})
{
get
(
method
,
value
=
''
,
showErrors
=
{},
returnHeaders
=
false
,
absoluteUrl
=
false
,
extraHeaders
=
{})
:
Observable
<
{}
>
{
this
.
createHeader
(
extraHeaders
);
const
url
=
(
absoluteUrl
?
''
:
this
.
api
)
+
method
+
value
;
return
this
.
http
.
get
(
url
,
{
headers
:
this
.
headers
,
observe
:
'response'
}).
pipe
(
map
(
resp
=>
this
.
mapResponse
(
resp
,
returnHeaders
)));
})
.
pipe
(
map
(
resp
=>
this
.
mapResponse
(
resp
,
returnHeaders
)));
}
post
(
method
,
value
,
showErrors
=
{},
returnHeaders
=
false
,
absoluteUrl
=
false
,
extraHeaders
=
{})
{
post
(
method
,
value
,
showErrors
=
{},
returnHeaders
=
false
,
absoluteUrl
=
false
,
extraHeaders
=
{})
:
Observable
<
{}
>
{
this
.
createHeader
(
extraHeaders
);
const
url
=
(
absoluteUrl
?
''
:
this
.
api
)
+
method
;
return
this
.
http
.
post
(
url
,
value
,
{
headers
:
this
.
headers
,
observe
:
'response'
}).
pipe
(
map
(
resp
=>
this
.
mapResponse
(
resp
,
returnHeaders
)));
})
.
pipe
(
map
(
resp
=>
this
.
mapResponse
(
resp
,
returnHeaders
)));
}
put
(
method
,
value
,
showErrors
=
{},
returnHeaders
=
false
)
{
put
(
method
,
value
,
showErrors
=
{},
returnHeaders
=
false
)
:
Observable
<
{}
>
{
this
.
createHeader
();
const
url
=
this
.
api
+
method
;
return
this
.
http
.
put
(
url
,
value
,
{
headers
:
this
.
headers
,
observe
:
'response'
}).
pipe
(
map
(
resp
=>
this
.
mapResponse
(
resp
,
returnHeaders
)));
})
.
pipe
(
map
(
resp
=>
this
.
mapResponse
(
resp
,
returnHeaders
)));
}
delete
(
method
,
value
=
''
,
showErrors
=
{},
returnHeaders
=
false
)
{
delete
(
method
,
value
=
''
,
showErrors
=
{},
returnHeaders
=
false
)
:
Observable
<
{}
>
{
this
.
createHeader
();
const
url
=
this
.
api
+
method
+
value
;
return
this
.
http
.
delete
(
url
,
{
headers
:
this
.
headers
,
observe
:
'response'
}).
pipe
(
map
(
resp
=>
this
.
mapResponse
(
resp
,
returnHeaders
)));
})
.
pipe
(
map
(
resp
=>
this
.
mapResponse
(
resp
,
returnHeaders
)));
}
}
services/icons.service.ts
deleted
100644 → 0
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 @
67096fbf
import
{
HttpErrorResponse
}
from
'@angular/common/http'
;
import
{
Injectable
}
from
'@angular/core'
;
import
{
FormArray
,
FormControl
,
FormGroup
}
from
'@angular/forms'
;
import
{
SHOW_ERRORS
}
from
'../config'
;
@
Injectable
()
...
...
@@ -13,13 +11,13 @@ export class UtilsService {
.
forEach
(
field
=>
{
const
control
=
formGroup
.
get
(
field
);
if
(
control
instanceof
FormControl
)
{
control
.
markAsDirty
({
onlySelf
:
true
});
control
.
markAsDirty
({
onlySelf
:
true
});
}
else
if
(
control
instanceof
FormGroup
)
{
this
.
validateAllFormFields
(
control
);
}
else
if
(
control
instanceof
FormArray
)
{
control
.
controls
.
forEach
(
ctrl
=>
{
if
(
ctrl
instanceof
FormControl
)
{
ctrl
.
markAsDirty
({
onlySelf
:
true
});
ctrl
.
markAsDirty
({
onlySelf
:
true
});
}
else
if
(
ctrl
instanceof
FormGroup
)
{
this
.
validateAllFormFields
(
ctrl
);
}
...
...
@@ -27,40 +25,4 @@ export class UtilsService {
}
});
}
handleHttpError
(
error
:
HttpErrorResponse
):
any
{
switch
(
error
.
status
)
{
case
401
:
if
(
SHOW_ERRORS
.
e401
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
break
;
case
400
:
if
(
SHOW_ERRORS
.
e400
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
break
;
case
500
:
if
(
SHOW_ERRORS
.
e500
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
break
;
case
404
:
if
(
SHOW_ERRORS
.
e404
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
break
;
case
422
:
if
(
SHOW_ERRORS
.
e422
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
break
;
case
403
:
if
(
SHOW_ERRORS
.
e403
)
{
console
.
log
(
`Error
${
error
.
status
}
`
);
}
break
;
default
:
}
}
}
validators/password.validator.ts
View file @
67096fbf
...
...
@@ -16,9 +16,9 @@ export class ConfirmPasswordValidator {
static
ValidPassword
():
ValidatorFn
{
return
(
c
:
FormControl
):
{
[
key
:
string
]:
boolean
}
|
null
=>
{
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
?
undefined
:
{
invalidPassword
:
true
};
};
}
...
...
vqode.module.ts
View file @
67096fbf
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
{
FocusBlurDirective
}
from
'./directives/focus-blur.directive'
;
import
{
PasswordDirective
}
from
'./directives/password.directive'
;
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
=
[
...
...
@@ -25,12 +23,10 @@ const DIRECTIVES = [
const
PROVIDERS
=
[
HttpService
,
UtilsService
,
IconsService
UtilsService
];
const
MODULES
=
[
AngularSvgIconModule
,
HttpClientModule
];
...
...
@@ -48,4 +44,5 @@ const MODULES = [
...
DIRECTIVES
]
})
export
class
VqodeModule
{
}
export
class
VqodeModule
{
}
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