Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
utils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
EIT-SWE
ux
utils
Commits
cadfd664
Commit
cadfd664
authored
Mar 27, 2020
by
Ryan Diehl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code review feedback
parent
d05f9165
Pipeline
#90419
passed with stages
in 4 minutes and 20 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
101 additions
and
18 deletions
+101
-18
libs/utils/loading-events/src/index.ts
libs/utils/loading-events/src/index.ts
+2
-2
libs/utils/loading-events/src/lib/loading-events.ts
libs/utils/loading-events/src/lib/loading-events.ts
+1
-3
libs/utils/logger/README.md
libs/utils/logger/README.md
+27
-2
libs/utils/logger/src/index.ts
libs/utils/logger/src/index.ts
+3
-3
libs/utils/logger/src/lib/logger.service.ts
libs/utils/logger/src/lib/logger.service.ts
+1
-1
libs/utils/package.json
libs/utils/package.json
+2
-2
libs/utils/properties/README.md
libs/utils/properties/README.md
+62
-2
libs/utils/properties/src/index.ts
libs/utils/properties/src/index.ts
+3
-3
No files found.
libs/utils/loading-events/src/index.ts
View file @
cadfd664
export
*
from
'
./lib/loading-events
'
;
export
*
from
'
./lib/loading-events.module
'
;
export
{
LoadingEvents
}
from
'
./lib/loading-events
'
;
export
{
LoadingEventsModule
}
from
'
./lib/loading-events.module
'
;
libs/utils/loading-events/src/lib/loading-events.ts
View file @
cadfd664
...
...
@@ -16,10 +16,8 @@ export class LoadingEvents {
if
(
this
.
isAppReady
)
{
return
;
}
const
bubbles
=
true
;
const
cancelable
=
false
;
this
.
log
.
debug
(
'
appready event triggered
'
);
this
.
doc
.
dispatchEvent
(
this
.
createEvent
(
'
appready
'
,
bubbles
,
cancelabl
e
));
this
.
doc
.
dispatchEvent
(
this
.
createEvent
(
'
appready
'
,
true
,
fals
e
));
this
.
isAppReady
=
true
;
}
...
...
libs/utils/logger/README.md
View file @
cadfd664
#
utils-
logger
#
@psu/utils/
logger
This library was generated with
[
Nx
](
https://nx.dev
)
.
`Logger`
is a simple facade around console logging. In the future, if we are
able to add some type of RESTful logging (Splunk for example), it would go here.
## Usage
1.
Define logger options in your environment files
```
typescript
// environment.ts
export
function
loggerOptions
():
Options
{
return
{
level
:
Level
.
LOG
};
}
export
const
environment
=
{
production
:
false
,
loggerOptions
};
```
2.
Import LoggerModule into your AppModule
```
typescript
imports
:
[
LoggerModule
.
forRoot
(
environment
.
loggerOptions
)];
```
3.
Inject
`Logger`
and log stuff
## Running unit tests
...
...
libs/utils/logger/src/index.ts
View file @
cadfd664
export
*
from
'
./lib/log-level.model
'
;
export
*
from
'
./lib/logger.module
'
;
export
*
from
'
./lib/logger.service
'
;
export
{
Level
}
from
'
./lib/log-level.model
'
;
export
{
LoggerModule
}
from
'
./lib/logger.module
'
;
export
{
Logger
}
from
'
./lib/logger.service
'
;
libs/utils/logger/src/lib/logger.service.ts
View file @
cadfd664
...
...
@@ -11,7 +11,7 @@ export class Options {
level
:
Level
;
}
// For browsers that don't implement the debug method, log will be used instead.
Fixes #62.
// For browsers that don't implement the debug method, log will be used instead.
const
CONSOLE_DEBUG_METHOD
=
console
[
'
debug
'
]
?
'
debug
'
:
'
log
'
;
const
DEFAULT_OPTIONS
:
Options
=
{
...
...
libs/utils/package.json
View file @
cadfd664
...
...
@@ -5,9 +5,9 @@
"@angular/common"
:
"^8.0.0"
,
"@angular/core"
:
"^8.0.0"
,
"@angular/cdk"
:
"^8.2.3"
,
"ngx-cookie"
:
"
>=
4.1.2"
,
"ngx-cookie"
:
"
^
4.1.2"
,
"ramda"
:
"^0.27.0"
,
"short-uuid"
:
"
>=
3.1.1"
"short-uuid"
:
"
^
3.1.1"
},
"private"
:
false
,
"repository"
:
{
...
...
libs/utils/properties/README.md
View file @
cadfd664
#
utils-
properties
#
@psu/utils/
properties
This library was generated with
[
Nx
](
https://nx.dev
)
.
This library handles loading application properties asyncronously.
Typical Angular documentation shows the use of
`environment.ts`
and
`environment.prod.ts`
to
store application properties. However, that strategy means that the properties are compile-time
dependencies - so in order to change a property at runtime, you need to re-compile the whole app.
This library is the first piece of supporting property changes at runtime.
`PropetiesService`
will
load the property file via HTTP, and exposes a
`Promise<T>`
to work with Angular's
`APP_INITIALIZER`
.
## Usage
1.
Import PropertiesModule into your AppModule
2.
Define an interface(s) that describes the shape of your application properties.
```
typescript
import
{
SecurityConfig
}
from
'
@psu/security
'
;
export
interface
MyAppProperties
{
myAppConfig
:
MyAppConfig
;
security
:
SecurityConfig
;
}
export
interface
MyAppConfig
{
someUrl
:
string
;
doStuff
:
boolean
;
}
```
3.
Setup an
[
APP_INITIALIZER
](
https://angular.io/api/core/APP_INITIALIZER
)
to load properties and delay loading of the application by returning a Promise
```
typescript
// inside AppMdoule's providers array:
{
provide
:
MY_APP_CONFIG
,
// provide your app's token
useValue
:
{}
// provide default values for the token
},
{
provide
:
SECURITY_CONFIG
,
useValue
:
{}
},
{
provide
:
APP_INITIALIZER
,
useFactory
:
initProperties
,
multi
:
true
,
deps
:
[
PropertiesService
,
MY_APP_CONFIG
,
// your app config injection token
SECURITY_CONFIG
]
}
// Define the initProperties function
export
function
initProperties
(
propertiesService
:
PropertiesService
<
MyAppProperties
>
,
myAppConfig
:
MyAppConfig
,
securityConfig
:
SecurityConfig
):
()
=>
Promise
<
MyAppProperties
>
{
return
()
=>
propertiesService
.
load
(
'
my-app
'
).
then
(
props
=>
{
// populate injection tokens with values from property file
// "props" is of type MyAppProperties
Object
.
assign
(
myAppConfig
,
p
.
myAppConfig
);
Object
.
assign
(
securityConfig
,
p
.
security
);
});
}
```
## Running unit tests
...
...
libs/utils/properties/src/index.ts
View file @
cadfd664
export
*
from
'
./lib/properties.config
'
;
export
*
from
'
./lib/properties.module
'
;
export
*
from
'
./lib/properties.service
'
;
export
{
PropertiesConfig
,
PROPERTIES_CONFIG
}
from
'
./lib/properties.config
'
;
export
{
PropertiesModule
}
from
'
./lib/properties.module
'
;
export
{
PropertiesService
}
from
'
./lib/properties.service
'
;
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