Merge pull request #1 from Marcel-Haag/mhg_c4po_1
Added SessionStore, Login, Internationalization, Guards and LazyLoading
This commit is contained in:
commit
6c71282798
|
@ -7,3 +7,7 @@
|
|||
## Development server
|
||||
|
||||
Execute 'c4po.sh' and all services will run on a dev server.
|
||||
|
||||
## Credentials:
|
||||
* Username: ttt
|
||||
* Password: Test1234!
|
||||
|
|
4
c4po.sh
4
c4po.sh
|
@ -9,5 +9,5 @@ ______| |______ |_____ |_____| | \_ __|__ | | _/_/_/ _/
|
|||
_/ _/ _/ _/ _/
|
||||
_/_/_/ _/ _/ _/_/
|
||||
"
|
||||
docker-compose up --build
|
||||
#docker-compose up
|
||||
#docker-compose up --build
|
||||
docker-compose up
|
||||
|
|
|
@ -28,9 +28,18 @@
|
|||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.scss"
|
||||
"src/assets/@theme/styles/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
"scripts": [],
|
||||
"allowedCommonJsDependencies": [
|
||||
"buffer",
|
||||
"crypto-js/hmac-sha256",
|
||||
"crypto-js/lib-typedarrays",
|
||||
"js-cookie",
|
||||
"deep-equal",
|
||||
"moment-timezone",
|
||||
"uuid"
|
||||
]
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
|
@ -45,19 +54,19 @@
|
|||
"sourceMap": false,
|
||||
"extractCss": true,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true,
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "2mb",
|
||||
"maximumWarning": "3mb",
|
||||
"maximumError": "5mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "6kb",
|
||||
"maximumError": "10kb"
|
||||
"maximumWarning": "6kb"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -90,8 +99,7 @@
|
|||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"node_modules/@nebular/theme/styles/prebuilt/corporate.css",
|
||||
"src/styles.scss"
|
||||
"src/assets/@theme/styles/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
}
|
||||
|
@ -124,5 +132,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "security-c4po-angular"
|
||||
}
|
||||
"defaultProject": "security-c4po-angular",
|
||||
"cli": {
|
||||
"analytics": false
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,21 +11,39 @@
|
|||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^10.2.0",
|
||||
"@angular/cdk": "^10.2.5",
|
||||
"@angular/common": "~10.2.0",
|
||||
"@angular/animations": "^11.0.3",
|
||||
"@angular/cdk": "^10.2.7",
|
||||
"@angular/common": "^10.2.3",
|
||||
"@angular/compiler": "~10.2.0",
|
||||
"@angular/core": "~10.2.0",
|
||||
"@angular/flex-layout": "^11.0.0-beta.33",
|
||||
"@angular/forms": "~10.2.0",
|
||||
"@angular/localize": "^11.0.2",
|
||||
"@angular/platform-browser": "~10.2.0",
|
||||
"@angular/platform-browser-dynamic": "~10.2.0",
|
||||
"@angular/router": "~10.2.0",
|
||||
"@briebug/jest-schematic": "^3.0.0",
|
||||
"@fortawesome/angular-fontawesome": "^0.8.0",
|
||||
"@fortawesome/fontawesome-common-types": "^0.2.32",
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
||||
"@fortawesome/free-regular-svg-icons": "^5.15.1",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.15.1",
|
||||
"@nebular/eva-icons": "^6.2.1",
|
||||
"@nebular/theme": "^6.2.1",
|
||||
"@ngx-translate/core": "^13.0.0",
|
||||
"@ngx-translate/http-loader": "^6.0.0",
|
||||
"@ngxs/store": "^3.7.0",
|
||||
"eva-icons": "^1.1.3",
|
||||
"i18n-iso-countries": "^6.2.2",
|
||||
"moment": "^2.29.1",
|
||||
"moment-timezone": "latest",
|
||||
"ngx-moment": "^5.0.0",
|
||||
"ngx-take-until-destroy": "^5.4.0",
|
||||
"ngx-translate-testing": "^5.0.0",
|
||||
"roboto-fontface": "^0.10.0",
|
||||
"rxjs": "~6.6.0",
|
||||
"tslib": "^2.0.0",
|
||||
"uuid": "^8.3.1",
|
||||
"zone.js": "~0.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -37,8 +55,9 @@
|
|||
"@types/jasmine": "~3.5.0",
|
||||
"@types/jasminewd2": "~2.0.3",
|
||||
"@types/jest": "26.0.15",
|
||||
"@types/node": "^12.11.1",
|
||||
"@types/node": "^12.19.8",
|
||||
"codelyzer": "^6.0.0",
|
||||
"font-awesome": "^4.7.0",
|
||||
"jasmine-core": "~3.6.0",
|
||||
"jasmine-spec-reporter": "~5.0.0",
|
||||
"jest": "26.6.1",
|
||||
|
|
|
@ -14,7 +14,11 @@ const mock = () => {
|
|||
Object.defineProperty(window, 'localStorage', { value: mock() });
|
||||
Object.defineProperty(window, 'sessionStorage', { value: mock() });
|
||||
Object.defineProperty(window, 'getComputedStyle', {
|
||||
value: () => ['-webkit-appearance'],
|
||||
value: () => ({
|
||||
getPropertyValue: (prop) => {
|
||||
return '';
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Object.defineProperty(document.body.style, 'transform', {
|
||||
|
|
|
@ -1,7 +1,24 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import {HomeComponent} from './home/home.component';
|
||||
import {AuthGuardService} from '../shared/guards/auth-guard.service';
|
||||
import {LoginGuardService} from '../shared/guards/login-guard.service';
|
||||
|
||||
const routes: Routes = [];
|
||||
export const START_PAGE = 'home';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'home', component: HomeComponent,
|
||||
canActivate: [AuthGuardService]
|
||||
},
|
||||
{
|
||||
path: 'login',
|
||||
loadChildren: () => import('./login').then(mod => mod.LoginModule),
|
||||
canActivate: [LoginGuardService]
|
||||
},
|
||||
{path: '**', redirectTo: START_PAGE},
|
||||
{path: '', redirectTo: START_PAGE, pathMatch: 'full'},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
|
|
|
@ -1,549 +1,9 @@
|
|||
<nb-layout>
|
||||
|
||||
<nb-layout-header fixed>
|
||||
<!-- Insert header here -->
|
||||
</nb-layout-header>
|
||||
|
||||
<nb-layout-column>
|
||||
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * The content below * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * Delete the template below * * * * * * * * * * -->
|
||||
<!-- * * * * * * * to get started with your project! * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
|
||||
<style>
|
||||
:host {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
box-sizing: border-box;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #1976d2;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.toolbar img {
|
||||
margin: 0 16px;
|
||||
}
|
||||
|
||||
.toolbar #twitter-logo {
|
||||
height: 40px;
|
||||
margin: 0 16px;
|
||||
}
|
||||
|
||||
.toolbar #twitter-logo:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
margin: 82px auto 32px;
|
||||
padding: 0 16px;
|
||||
max-width: 960px;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
svg.material-icons {
|
||||
height: 24px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
svg.material-icons:not(:last-child) {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.card svg.material-icons path {
|
||||
fill: #888;
|
||||
}
|
||||
|
||||
.card-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.card {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #eee;
|
||||
background-color: #fafafa;
|
||||
height: 40px;
|
||||
width: 200px;
|
||||
margin: 0 8px 16px;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
transition: all 0.2s ease-in-out;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.card-container .card:not(:last-child) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.card.card-small {
|
||||
height: 16px;
|
||||
width: 168px;
|
||||
}
|
||||
|
||||
.card-container .card:not(.highlight-card) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.card-container .card:not(.highlight-card):hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 4px 17px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
.card-container .card:not(.highlight-card):hover .material-icons path {
|
||||
fill: rgb(105, 103, 103);
|
||||
}
|
||||
|
||||
.card.highlight-card {
|
||||
background-color: #1976d2;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
width: auto;
|
||||
min-width: 30%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.card.card.highlight-card span {
|
||||
margin-left: 60px;
|
||||
}
|
||||
|
||||
svg#rocket {
|
||||
width: 80px;
|
||||
position: absolute;
|
||||
left: -10px;
|
||||
top: -24px;
|
||||
}
|
||||
|
||||
svg#rocket-smoke {
|
||||
height: calc(100vh - 95px);
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 180px;
|
||||
z-index: -10;
|
||||
}
|
||||
|
||||
a,
|
||||
a:visited,
|
||||
a:hover {
|
||||
color: #1976d2;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #125699;
|
||||
}
|
||||
|
||||
.terminal {
|
||||
position: relative;
|
||||
width: 80%;
|
||||
max-width: 600px;
|
||||
border-radius: 6px;
|
||||
padding-top: 45px;
|
||||
margin-top: 8px;
|
||||
overflow: hidden;
|
||||
background-color: rgb(15, 15, 16);
|
||||
}
|
||||
|
||||
.terminal::before {
|
||||
content: "\2022 \2022 \2022";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 4px;
|
||||
background: rgb(58, 58, 58);
|
||||
color: #c2c3c4;
|
||||
width: 100%;
|
||||
font-size: 2rem;
|
||||
line-height: 0;
|
||||
padding: 14px 0;
|
||||
text-indent: 4px;
|
||||
}
|
||||
|
||||
.terminal pre {
|
||||
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
|
||||
color: white;
|
||||
padding: 0 1rem 1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.circle-link {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
border-radius: 40px;
|
||||
margin: 8px;
|
||||
background-color: white;
|
||||
border: 1px solid #eeeeee;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
||||
transition: 1s ease-out;
|
||||
}
|
||||
|
||||
.circle-link:hover {
|
||||
transform: translateY(-0.25rem);
|
||||
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
footer {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
footer a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.github-star-badge {
|
||||
color: #24292e;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
padding: 3px 10px;
|
||||
border: 1px solid rgba(27,31,35,.2);
|
||||
border-radius: 3px;
|
||||
background-image: linear-gradient(-180deg,#fafbfc,#eff3f6 90%);
|
||||
margin-left: 4px;
|
||||
font-weight: 600;
|
||||
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
|
||||
}
|
||||
|
||||
.github-star-badge:hover {
|
||||
background-image: linear-gradient(-180deg,#f0f3f6,#e6ebf1 90%);
|
||||
border-color: rgba(27,31,35,.35);
|
||||
background-position: -.5em;
|
||||
}
|
||||
|
||||
.github-star-badge .material-icons {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
svg#clouds {
|
||||
position: fixed;
|
||||
bottom: -160px;
|
||||
left: -230px;
|
||||
z-index: -10;
|
||||
width: 1920px;
|
||||
}
|
||||
|
||||
|
||||
/* Responsive Styles */
|
||||
@media screen and (max-width: 767px) {
|
||||
|
||||
.card-container > *:not(.circle-link) ,
|
||||
.terminal {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.card:not(.highlight-card) {
|
||||
height: 16px;
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
.card.highlight-card span {
|
||||
margin-left: 72px;
|
||||
}
|
||||
|
||||
svg#rocket-smoke {
|
||||
right: 120px;
|
||||
transform: rotate(-5deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 575px) {
|
||||
svg#rocket-smoke {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Toolbar -->
|
||||
<div class="toolbar" role="banner">
|
||||
<img
|
||||
width="40"
|
||||
alt="Angular Logo"
|
||||
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="
|
||||
/>
|
||||
<span>Welcome</span>
|
||||
<div class="spacer"></div>
|
||||
<a aria-label="Angular on twitter" target="_blank" rel="noopener" href="https://twitter.com/angular" title="Twitter">
|
||||
<svg id="twitter-logo" height="24" data-name="Logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400">
|
||||
<rect width="400" height="400" fill="none"/>
|
||||
<path d="M153.62,301.59c94.34,0,145.94-78.16,145.94-145.94,0-2.22,0-4.43-.15-6.63A104.36,104.36,0,0,0,325,122.47a102.38,102.38,0,0,1-29.46,8.07,51.47,51.47,0,0,0,22.55-28.37,102.79,102.79,0,0,1-32.57,12.45,51.34,51.34,0,0,0-87.41,46.78A145.62,145.62,0,0,1,92.4,107.81a51.33,51.33,0,0,0,15.88,68.47A50.91,50.91,0,0,1,85,169.86c0,.21,0,.43,0,.65a51.31,51.31,0,0,0,41.15,50.28,51.21,51.21,0,0,1-23.16.88,51.35,51.35,0,0,0,47.92,35.62,102.92,102.92,0,0,1-63.7,22A104.41,104.41,0,0,1,75,278.55a145.21,145.21,0,0,0,78.62,23" fill="#fff"/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="content" role="main">
|
||||
|
||||
<!-- Highlight Card -->
|
||||
<div class="card highlight-card card-small">
|
||||
|
||||
<svg id="rocket" alt="Rocket Ship" xmlns="http://www.w3.org/2000/svg" width="101.678" height="101.678" viewBox="0 0 101.678 101.678">
|
||||
<g id="Group_83" data-name="Group 83" transform="translate(-141 -696)">
|
||||
<circle id="Ellipse_8" data-name="Ellipse 8" cx="50.839" cy="50.839" r="50.839" transform="translate(141 696)" fill="#dd0031"/>
|
||||
<g id="Group_47" data-name="Group 47" transform="translate(165.185 720.185)">
|
||||
<path id="Path_33" data-name="Path 33" d="M3.4,42.615a3.084,3.084,0,0,0,3.553,3.553,21.419,21.419,0,0,0,12.215-6.107L9.511,30.4A21.419,21.419,0,0,0,3.4,42.615Z" transform="translate(0.371 3.363)" fill="#fff"/>
|
||||
<path id="Path_34" data-name="Path 34" d="M53.3,3.221A3.09,3.09,0,0,0,50.081,0,48.227,48.227,0,0,0,18.322,13.437c-6-1.666-14.991-1.221-18.322,7.218A33.892,33.892,0,0,1,9.439,25.1l-.333.666a3.013,3.013,0,0,0,.555,3.553L23.985,43.641a2.9,2.9,0,0,0,3.553.555l.666-.333A33.892,33.892,0,0,1,32.647,53.3c8.55-3.664,8.884-12.326,7.218-18.322A48.227,48.227,0,0,0,53.3,3.221ZM34.424,9.772a6.439,6.439,0,1,1,9.106,9.106,6.368,6.368,0,0,1-9.106,0A6.467,6.467,0,0,1,34.424,9.772Z" transform="translate(0 0.005)" fill="#fff"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
<span>{{ title }} app is running!</span>
|
||||
|
||||
<svg id="rocket-smoke" alt="Rocket Ship Smoke" xmlns="http://www.w3.org/2000/svg" width="516.119" height="1083.632" viewBox="0 0 516.119 1083.632">
|
||||
<path id="Path_40" data-name="Path 40" d="M644.6,141S143.02,215.537,147.049,870.207s342.774,201.755,342.774,201.755S404.659,847.213,388.815,762.2c-27.116-145.51-11.551-384.124,271.9-609.1C671.15,139.365,644.6,141,644.6,141Z" transform="translate(-147.025 -140.939)" fill="#f5f5f5"/>
|
||||
</svg>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Resources -->
|
||||
<h2>Resources</h2>
|
||||
<p>Here are some links to help you get started:</p>
|
||||
|
||||
<div class="card-container">
|
||||
<a class="card" target="_blank" rel="noopener" href="https://angular.io/tutorial">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82zM12 3L1 9l11 6 9-4.91V17h2V9L12 3z"/></svg>
|
||||
|
||||
<span>Learn Angular</span>
|
||||
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg> </a>
|
||||
|
||||
<a class="card" target="_blank" rel="noopener" href="https://angular.io/cli">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>
|
||||
|
||||
<span>CLI Documentation</span>
|
||||
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>
|
||||
</a>
|
||||
|
||||
<a class="card" target="_blank" rel="noopener" href="https://blog.angular.io/">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M13.5.67s.74 2.65.74 4.8c0 2.06-1.35 3.73-3.41 3.73-2.07 0-3.63-1.67-3.63-3.73l.03-.36C5.21 7.51 4 10.62 4 14c0 4.42 3.58 8 8 8s8-3.58 8-8C20 8.61 17.41 3.8 13.5.67zM11.71 19c-1.78 0-3.22-1.4-3.22-3.14 0-1.62 1.05-2.76 2.81-3.12 1.77-.36 3.6-1.21 4.62-2.58.39 1.29.59 2.65.59 4.04 0 2.65-2.15 4.8-4.8 4.8z"/></svg>
|
||||
|
||||
<span>Angular Blog</span>
|
||||
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Next Steps -->
|
||||
<h2>Next Steps</h2>
|
||||
<p>What do you want to do next with your app?</p>
|
||||
|
||||
<input type="hidden" #selection>
|
||||
|
||||
<div class="card-container">
|
||||
<div class="card card-small" (click)="selection.value = 'component'" tabindex="0">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
||||
|
||||
<span>New Component</span>
|
||||
</div>
|
||||
|
||||
<div class="card card-small" (click)="selection.value = 'material'" tabindex="0">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
||||
|
||||
<span>Angular Material</span>
|
||||
</div>
|
||||
|
||||
<div class="card card-small" (click)="selection.value = 'pwa'" tabindex="0">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
||||
|
||||
<span>Add PWA Support</span>
|
||||
</div>
|
||||
|
||||
<div class="card card-small" (click)="selection.value = 'dependency'" tabindex="0">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
||||
|
||||
<span>Add Dependency</span>
|
||||
</div>
|
||||
|
||||
<div class="card card-small" (click)="selection.value = 'test'" tabindex="0">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
||||
|
||||
<span>Run and Watch Tests</span>
|
||||
</div>
|
||||
|
||||
<div class="card card-small" (click)="selection.value = 'build'" tabindex="0">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
||||
|
||||
<span>Build for Production</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Terminal -->
|
||||
<div class="terminal" [ngSwitch]="selection.value">
|
||||
<pre *ngSwitchDefault>ng generate component xyz</pre>
|
||||
<pre *ngSwitchCase="'material'">ng add @angular/material</pre>
|
||||
<pre *ngSwitchCase="'pwa'">ng add @angular/pwa</pre>
|
||||
<pre *ngSwitchCase="'dependency'">ng add _____</pre>
|
||||
<pre *ngSwitchCase="'test'">ng test</pre>
|
||||
<pre *ngSwitchCase="'build'">ng build --prod</pre>
|
||||
</div>
|
||||
|
||||
<!-- Links -->
|
||||
<div class="card-container">
|
||||
<a class="circle-link" title="Animations" href="https://angular.io/guide/animations" target="_blank" rel="noopener">
|
||||
<svg id="Group_20" data-name="Group 20" xmlns="http://www.w3.org/2000/svg" width="21.813" height="23.453" viewBox="0 0 21.813 23.453">
|
||||
<path id="Path_15" data-name="Path 15" d="M4099.584,972.736h0l-10.882,3.9,1.637,14.4,9.245,5.153,9.245-5.153,1.686-14.4Z" transform="translate(-4088.702 -972.736)" fill="#ffa726"/>
|
||||
<path id="Path_16" data-name="Path 16" d="M4181.516,972.736v23.453l9.245-5.153,1.686-14.4Z" transform="translate(-4170.633 -972.736)" fill="#fb8c00"/>
|
||||
<path id="Path_17" data-name="Path 17" d="M4137.529,1076.127l-7.7-3.723,4.417-2.721,7.753,3.723Z" transform="translate(-4125.003 -1058.315)" fill="#ffe0b2"/>
|
||||
<path id="Path_18" data-name="Path 18" d="M4137.529,1051.705l-7.7-3.723,4.417-2.721,7.753,3.723Z" transform="translate(-4125.003 -1036.757)" fill="#fff3e0"/>
|
||||
<path id="Path_19" data-name="Path 19" d="M4137.529,1027.283l-7.7-3.723,4.417-2.721,7.753,3.723Z" transform="translate(-4125.003 -1015.199)" fill="#fff"/>
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a class="circle-link" title="CLI" href="https://cli.angular.io/" target="_blank" rel="noopener">
|
||||
<svg alt="Angular CLI Logo" xmlns="http://www.w3.org/2000/svg" width="21.762" height="23.447" viewBox="0 0 21.762 23.447">
|
||||
<g id="Group_21" data-name="Group 21" transform="translate(0)">
|
||||
<path id="Path_20" data-name="Path 20" d="M2660.313,313.618h0l-10.833,3.9,1.637,14.4,9.2,5.152,9.244-5.152,1.685-14.4Z" transform="translate(-2649.48 -313.618)" fill="#37474f"/>
|
||||
<path id="Path_21" data-name="Path 21" d="M2741.883,313.618v23.447l9.244-5.152,1.685-14.4Z" transform="translate(-2731.05 -313.618)" fill="#263238"/>
|
||||
<path id="Path_22" data-name="Path 22" d="M2692.293,379.169h11.724V368.618h-11.724Zm11.159-.6h-10.608v-9.345h10.621v9.345Z" transform="translate(-2687.274 -362.17)" fill="#fff"/>
|
||||
<path id="Path_23" data-name="Path 23" d="M2709.331,393.688l.4.416,2.265-2.28-2.294-2.294-.4.4,1.893,1.893Z" transform="translate(-2702.289 -380.631)" fill="#fff"/>
|
||||
<rect id="Rectangle_12" data-name="Rectangle 12" width="3.517" height="0.469" transform="translate(9.709 13.744)" fill="#fff"/>
|
||||
</g>
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a class="circle-link" title="Augury" href="https://augury.rangle.io/" target="_blank" rel="noopener">
|
||||
<svg alt="Angular Augury Logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="21.81" height="23.447" viewBox="0 0 21.81 23.447">
|
||||
<defs>
|
||||
<clipPath id="clip-path">
|
||||
<rect id="Rectangle_13" data-name="Rectangle 13" width="10.338" height="10.27" fill="none"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g id="Group_25" data-name="Group 25" transform="translate(0)">
|
||||
<path id="Path_24" data-name="Path 24" d="M3780.155,311.417h0l-10.881,3.9,1.637,14.4,9.244,5.152,9.244-5.152,1.685-14.4Z" transform="translate(-3769.274 -311.417)" fill="#4a3493"/>
|
||||
<path id="Path_25" data-name="Path 25" d="M3862.088,311.417v23.447l9.244-5.152,1.685-14.4Z" transform="translate(-3851.207 -311.417)" fill="#311b92"/>
|
||||
<g id="Group_24" data-name="Group 24" transform="translate(6.194 6.73)" opacity="0.5">
|
||||
<g id="Group_23" data-name="Group 23" transform="translate(0 0)">
|
||||
<g id="Group_22" data-name="Group 22" clip-path="url(#clip-path)">
|
||||
<path id="Path_26" data-name="Path 26" d="M3832.4,373.252a5.168,5.168,0,1,1-5.828-4.383,5.216,5.216,0,0,1,2.574.3,3.017,3.017,0,1,0,3.252,4.086Z" transform="translate(-3822.107 -368.821)" fill="#fff"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<path id="Path_27" data-name="Path 27" d="M3830.582,370.848a5.162,5.162,0,1,1-3.254-4.086,3.017,3.017,0,1,0,3.252,4.086Z" transform="translate(-3814.311 -359.969)" fill="#fff"/>
|
||||
</g>
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a class="circle-link" title="Protractor" href="https://www.protractortest.org/" target="_blank" rel="noopener">
|
||||
<svg alt="Angular Protractor Logo" xmlns="http://www.w3.org/2000/svg" width="21.81" height="23.447" viewBox="0 0 21.81 23.447">
|
||||
<g id="Group_26" data-name="Group 26" transform="translate(0)">
|
||||
<path id="Path_28" data-name="Path 28" d="M4620.155,311.417h0l-10.881,3.9,1.637,14.4,9.244,5.152,9.244-5.152,1.685-14.4Z" transform="translate(-4609.274 -311.417)" fill="#e13439"/>
|
||||
<path id="Path_29" data-name="Path 29" d="M4702.088,311.417v23.447l9.244-5.152,1.685-14.4Z" transform="translate(-4691.207 -311.417)" fill="#b52f32"/>
|
||||
<path id="Path_30" data-name="Path 30" d="M4651.044,369.58v-.421h1.483a7.6,7.6,0,0,0-2.106-5.052l-1.123,1.123-.3-.3,1.122-1.121a7.588,7.588,0,0,0-4.946-2.055v1.482h-.421v-1.485a7.589,7.589,0,0,0-5.051,2.058l1.122,1.121-.3.3-1.123-1.123a7.591,7.591,0,0,0-2.106,5.052h1.482v.421h-1.489v1.734h15.241V369.58Zm-10.966-.263a4.835,4.835,0,0,1,9.67,0Z" transform="translate(-4634.008 -355.852)" fill="#fff"/>
|
||||
</g>
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a class="circle-link" title="Find a Local Meetup" href="https://www.meetup.com/find/?keywords=angular" target="_blank" rel="noopener">
|
||||
<svg alt="Meetup Logo" xmlns="http://www.w3.org/2000/svg" width="24.607" height="23.447" viewBox="0 0 24.607 23.447">
|
||||
<path id="logo--mSwarm" d="M21.221,14.95A4.393,4.393,0,0,1,17.6,19.281a4.452,4.452,0,0,1-.8.069c-.09,0-.125.035-.154.117a2.939,2.939,0,0,1-2.506,2.091,2.868,2.868,0,0,1-2.248-.624.168.168,0,0,0-.245-.005,3.926,3.926,0,0,1-2.589.741,4.015,4.015,0,0,1-3.7-3.347,2.7,2.7,0,0,1-.043-.38c0-.106-.042-.146-.143-.166a3.524,3.524,0,0,1-1.516-.69A3.623,3.623,0,0,1,2.23,14.557a3.66,3.66,0,0,1,1.077-3.085.138.138,0,0,0,.026-.2,3.348,3.348,0,0,1-.451-1.821,3.46,3.46,0,0,1,2.749-3.28.44.44,0,0,0,.355-.281,5.072,5.072,0,0,1,3.863-3,5.028,5.028,0,0,1,3.555.666.31.31,0,0,0,.271.03A4.5,4.5,0,0,1,18.3,4.7a4.4,4.4,0,0,1,1.334,2.751,3.658,3.658,0,0,1,.022.706.131.131,0,0,0,.1.157,2.432,2.432,0,0,1,1.574,1.645,2.464,2.464,0,0,1-.7,2.616c-.065.064-.051.1-.014.166A4.321,4.321,0,0,1,21.221,14.95ZM13.4,14.607a2.09,2.09,0,0,0,1.409,1.982,4.7,4.7,0,0,0,1.275.221,1.807,1.807,0,0,0,.9-.151.542.542,0,0,0,.321-.545.558.558,0,0,0-.359-.534,1.2,1.2,0,0,0-.254-.078c-.262-.047-.526-.086-.787-.138a.674.674,0,0,1-.617-.75,3.394,3.394,0,0,1,.218-1.109c.217-.658.509-1.286.79-1.918a15.609,15.609,0,0,0,.745-1.86,1.95,1.95,0,0,0,.06-1.073,1.286,1.286,0,0,0-1.051-1.033,1.977,1.977,0,0,0-1.521.2.339.339,0,0,1-.446-.042c-.1-.092-.2-.189-.307-.284a1.214,1.214,0,0,0-1.643-.061,7.563,7.563,0,0,1-.614.512A.588.588,0,0,1,10.883,8c-.215-.115-.437-.215-.659-.316a2.153,2.153,0,0,0-.695-.248A2.091,2.091,0,0,0,7.541,8.562a9.915,9.915,0,0,0-.405.986c-.559,1.545-1.015,3.123-1.487,4.7a1.528,1.528,0,0,0,.634,1.777,1.755,1.755,0,0,0,1.5.211,1.35,1.35,0,0,0,.824-.858c.543-1.281,1.032-2.584,1.55-3.875.142-.355.28-.712.432-1.064a.548.548,0,0,1,.851-.24.622.622,0,0,1,.185.539,2.161,2.161,0,0,1-.181.621c-.337.852-.68,1.7-1.018,2.552a2.564,2.564,0,0,0-.173.528.624.624,0,0,0,.333.71,1.073,1.073,0,0,0,.814.034,1.22,1.22,0,0,0,.657-.655q.758-1.488,1.511-2.978.35-.687.709-1.37a1.073,1.073,0,0,1,.357-.434.43.43,0,0,1,.463-.016.373.373,0,0,1,.153.387.7.7,0,0,1-.057.236c-.065.157-.127.316-.2.469-.42.883-.846,1.763-1.262,2.648A2.463,2.463,0,0,0,13.4,14.607Zm5.888,6.508a1.09,1.09,0,0,0-2.179.006,1.09,1.09,0,0,0,2.179-.006ZM1.028,12.139a1.038,1.038,0,1,0,.01-2.075,1.038,1.038,0,0,0-.01,2.075ZM13.782.528a1.027,1.027,0,1,0-.011,2.055A1.027,1.027,0,0,0,13.782.528ZM22.21,6.95a.882.882,0,0,0-1.763.011A.882.882,0,0,0,22.21,6.95ZM4.153,4.439a.785.785,0,1,0,.787-.78A.766.766,0,0,0,4.153,4.439Zm8.221,18.22a.676.676,0,1,0-.677.666A.671.671,0,0,0,12.374,22.658ZM22.872,12.2a.674.674,0,0,0-.665.665.656.656,0,0,0,.655.643.634.634,0,0,0,.655-.644A.654.654,0,0,0,22.872,12.2ZM7.171-.123A.546.546,0,0,0,6.613.43a.553.553,0,1,0,1.106,0A.539.539,0,0,0,7.171-.123ZM24.119,9.234a.507.507,0,0,0-.493.488.494.494,0,0,0,.494.494.48.48,0,0,0,.487-.483A.491.491,0,0,0,24.119,9.234Zm-19.454,9.7a.5.5,0,0,0-.488-.488.491.491,0,0,0-.487.5.483.483,0,0,0,.491.479A.49.49,0,0,0,4.665,18.936Z" transform="translate(0 0.123)" fill="#f64060"/>
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a class="circle-link" title="Join the Conversation on Gitter" href="https://gitter.im/angular/angular" target="_blank" rel="noopener">
|
||||
<svg alt="Gitter Logo" xmlns="http://www.w3.org/2000/svg" width="19.447" height="19.447" viewBox="0 0 19.447 19.447">
|
||||
<g id="Group_40" data-name="Group 40" transform="translate(-1612 -405)">
|
||||
<rect id="Rectangle_19" data-name="Rectangle 19" width="19.447" height="19.447" transform="translate(1612 405)" fill="#e60257"/>
|
||||
<g id="gitter" transform="translate(1617.795 408.636)">
|
||||
<g id="Group_33" data-name="Group 33" transform="translate(0 0)">
|
||||
<rect id="Rectangle_15" data-name="Rectangle 15" width="1.04" height="9.601" transform="translate(2.304 2.324)" fill="#fff"/>
|
||||
<rect id="Rectangle_16" data-name="Rectangle 16" width="1.04" height="9.601" transform="translate(4.607 2.324)" fill="#fff"/>
|
||||
<rect id="Rectangle_17" data-name="Rectangle 17" width="1.04" height="4.648" transform="translate(6.91 2.324)" fill="#fff"/>
|
||||
<rect id="Rectangle_18" data-name="Rectangle 18" width="1.04" height="6.971" transform="translate(0 0)" fill="#fff"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer>
|
||||
Love Angular?
|
||||
<a href="https://github.com/angular/angular" target="_blank" rel="noopener"> Give our repo a star.
|
||||
<div class="github-star-badge">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>
|
||||
Star
|
||||
</div>
|
||||
</a>
|
||||
<a href="https://github.com/angular/angular" target="_blank" rel="noopener">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" fill="#1976d2"/><path d="M0 0h24v24H0z" fill="none"/></svg>
|
||||
</a>
|
||||
</footer>
|
||||
|
||||
<svg id="clouds" alt="Gray Clouds Background" xmlns="http://www.w3.org/2000/svg" width="2611.084" height="485.677" viewBox="0 0 2611.084 485.677">
|
||||
<path id="Path_39" data-name="Path 39" d="M2379.709,863.793c10-93-77-171-168-149-52-114-225-105-264,15-75,3-140,59-152,133-30,2.83-66.725,9.829-93.5,26.25-26.771-16.421-63.5-23.42-93.5-26.25-12-74-77-130-152-133-39-120-212-129-264-15-54.084-13.075-106.753,9.173-138.488,48.9-31.734-39.726-84.4-61.974-138.487-48.9-52-114-225-105-264,15a162.027,162.027,0,0,0-103.147,43.044c-30.633-45.365-87.1-72.091-145.206-58.044-52-114-225-105-264,15-75,3-140,59-152,133-53,5-127,23-130,83-2,42,35,72,70,86,49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33,61.112,8.015,113.854-5.72,150.492-29.764a165.62,165.62,0,0,0,110.861-3.236c47,94,178,113,251,33,31.385,4.116,60.563,2.495,86.487-3.311,25.924,5.806,55.1,7.427,86.488,3.311,73,80,204,61,251-33a165.625,165.625,0,0,0,120,0c51,13,108,15,157-5a147.188,147.188,0,0,0,33.5-18.694,147.217,147.217,0,0,0,33.5,18.694c49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33C2446.709,1093.793,2554.709,922.793,2379.709,863.793Z" transform="translate(142.69 -634.312)" fill="#eee"/>
|
||||
</svg>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * The content above * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * End of Placeholder * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
|
||||
|
||||
|
||||
<router-outlet></router-outlet>
|
||||
</nb-layout-column>
|
||||
|
||||
<nb-layout-footer fixed>
|
||||
<!-- Insert footer here -->
|
||||
</nb-layout-footer>
|
||||
|
||||
</nb-layout>
|
||||
<div class="content-container">
|
||||
<div class="scrollable-content">
|
||||
<nb-layout>
|
||||
<nb-layout-column>
|
||||
<router-outlet></router-outlet>
|
||||
</nb-layout-column>
|
||||
</nb-layout>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,17 +1,34 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
import {AppComponent} from './app.component';
|
||||
import {NbLayoutModule, NbThemeModule} from '@nebular/theme';
|
||||
import {NbEvaIconsModule} from '@nebular/eva-icons';
|
||||
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||
import {HttpLoaderFactory} from './common-app.module';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {ThemeModule} from '../assets/@theme/theme.module';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
import {SessionState} from '../shared/stores/session-state/session-state';
|
||||
import {NgxsModule} from '@ngxs/store';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterTestingModule,
|
||||
NbThemeModule.forRoot({ name: 'corporate' }),
|
||||
NbThemeModule.forRoot(),
|
||||
NbLayoutModule,
|
||||
NbEvaIconsModule
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
NbEvaIconsModule,
|
||||
ThemeModule,
|
||||
NgxsModule.forRoot([SessionState]),
|
||||
HttpClientTestingModule
|
||||
],
|
||||
declarations: [
|
||||
AppComponent
|
||||
|
|
|
@ -1,10 +1,70 @@
|
|||
import { Component } from '@angular/core';
|
||||
import {Component, Inject, LOCALE_ID, OnDestroy, OnInit} from '@angular/core';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import localeDe from '@angular/common/locales/de';
|
||||
import {registerLocale} from 'i18n-iso-countries';
|
||||
import {registerLocaleData} from '@angular/common';
|
||||
import {Store} from '@ngxs/store';
|
||||
import {BehaviorSubject, of, Subscription} from 'rxjs';
|
||||
import {SessionState} from '../shared/stores/session-state/session-state';
|
||||
import { untilDestroyed } from 'ngx-take-until-destroy';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.scss']
|
||||
})
|
||||
export class AppComponent {
|
||||
export class AppComponent implements OnInit, OnDestroy{
|
||||
title = 'security-c4po-angular';
|
||||
|
||||
$authState: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
private authStateSubscription: Subscription;
|
||||
|
||||
constructor(private translateService: TranslateService,
|
||||
private store: Store,
|
||||
@Inject(LOCALE_ID) private localeId: string) {
|
||||
this.initApp();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
// authState change handling
|
||||
of(this.store.selectSnapshot(SessionState.isAuthenticated)).pipe(
|
||||
untilDestroyed(this)
|
||||
).subscribe({
|
||||
next: (authState: boolean) => {
|
||||
this.$authState.next(authState);
|
||||
},
|
||||
error: (err) => console.error('auth error:', err)
|
||||
});
|
||||
}
|
||||
|
||||
initApp(): void {
|
||||
// for global language
|
||||
this.translateService.use(this.localeId);
|
||||
|
||||
// for number, date and time
|
||||
registerLocaleData(localeDe, 'de-DE');
|
||||
|
||||
this.setupCountryCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* i18n-iso-countries
|
||||
* TODO: can be also lazy loaded if selected language exist
|
||||
*/
|
||||
setupCountryCode(): void {
|
||||
// Support german languages.
|
||||
// @ts-ignore
|
||||
registerLocale(require('i18n-iso-countries/langs/en.json'));
|
||||
// @ts-ignore
|
||||
registerLocale(require('i18n-iso-countries/langs/de.json'));
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
// This method must be present when using ngx-take-until-destroy
|
||||
// even when empty
|
||||
if (this.authStateSubscription) {
|
||||
this.authStateSubscription.unsubscribe();
|
||||
this.authStateSubscription = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,26 @@
|
|||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { AppComponent } from './app.component';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NbThemeModule, NbLayoutModule } from '@nebular/theme';
|
||||
import { NbEvaIconsModule } from '@nebular/eva-icons';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {AppRoutingModule} from './app-routing.module';
|
||||
import {AppComponent} from './app.component';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {
|
||||
NbLayoutModule,
|
||||
NbToastrModule,
|
||||
NbIconModule,
|
||||
} from '@nebular/theme';
|
||||
import {NbEvaIconsModule} from '@nebular/eva-icons';
|
||||
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||
import {HttpClient, HttpClientModule} from '@angular/common/http';
|
||||
import {HttpLoaderFactory} from './common-app.module';
|
||||
import {RouterModule} from '@angular/router';
|
||||
import {FaConfig, FaIconLibrary, FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
||||
import {fas} from '@fortawesome/free-solid-svg-icons';
|
||||
import {far} from '@fortawesome/free-regular-svg-icons';
|
||||
import {NgxsModule} from '@ngxs/store';
|
||||
import {SessionState} from '../shared/stores/session-state/session-state';
|
||||
import {environment} from '../environments/environment';
|
||||
import {NotificationService} from '../shared/services/notification.service';
|
||||
import {ThemeModule} from '@assets/@theme/theme.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -14,12 +29,33 @@ import { NbEvaIconsModule } from '@nebular/eva-icons';
|
|||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
RouterModule,
|
||||
FontAwesomeModule,
|
||||
NbToastrModule.forRoot(), // used for notification service
|
||||
BrowserAnimationsModule,
|
||||
NbThemeModule.forRoot({ name: 'corporate' }),
|
||||
ThemeModule.forRoot(),
|
||||
NbLayoutModule,
|
||||
NbEvaIconsModule
|
||||
NbIconModule,
|
||||
NbEvaIconsModule,
|
||||
NgxsModule.forRoot([SessionState], {developmentMode: !environment.production}),
|
||||
HttpClientModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
HttpClient,
|
||||
NotificationService
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule { }
|
||||
export class AppModule {
|
||||
constructor(library: FaIconLibrary, faConfig: FaConfig) {
|
||||
library.addIconPacks(fas, far);
|
||||
faConfig.defaultPrefix = 'fas';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
|
||||
import {HttpClient, HttpClientModule} from '@angular/common/http';
|
||||
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
||||
import {FlexLayoutModule, FlexModule} from '@angular/flex-layout';
|
||||
import {MomentModule} from 'ngx-moment';
|
||||
import {NotificationService} from '../shared/services/notification.service';
|
||||
import {NbToastrModule} from '@nebular/theme';
|
||||
import {ThemeModule} from '../assets/@theme/theme.module';
|
||||
|
||||
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
|
||||
return new TranslateHttpLoader(http);
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [
|
||||
CommonModule,
|
||||
NbToastrModule, // used for notification service
|
||||
FontAwesomeModule,
|
||||
FlexLayoutModule,
|
||||
ThemeModule.forRoot(),
|
||||
FlexModule,
|
||||
HttpClientModule,
|
||||
TranslateModule.forChild({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
})
|
||||
],
|
||||
providers: [
|
||||
HttpClient,
|
||||
NotificationService
|
||||
],
|
||||
exports: [
|
||||
// modules
|
||||
MomentModule
|
||||
]
|
||||
})
|
||||
export class CommonAppModule {
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<p>home works!</p>
|
|
@ -0,0 +1,25 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ HomeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
templateUrl: './home.component.html',
|
||||
styleUrls: ['./home.component.scss']
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import {HomeComponent} from './home.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
HomeComponent
|
||||
]
|
||||
})
|
||||
export class HomeModule { }
|
|
@ -0,0 +1,2 @@
|
|||
export {LoginModule} from './login.module';
|
||||
export {LoginRoutingModule} from './login-routing.module';
|
|
@ -0,0 +1,16 @@
|
|||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {LoginComponent} from './login.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: LoginComponent
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class LoginRoutingModule {}
|
|
@ -0,0 +1,59 @@
|
|||
<div class="login-background"></div>
|
||||
<div class="login-container">
|
||||
<nb-card class="login-card">
|
||||
<nb-card-body fxLayout="column"
|
||||
fxLayoutGap="0.5rem">
|
||||
<form [formGroup]="loginFormGroup">
|
||||
<div fxLayout="column"
|
||||
fxLayoutGap="0.5rem">
|
||||
<h2 class="login-label">
|
||||
{{SECURITYC4PO_TITLE}}
|
||||
</h2>
|
||||
|
||||
<nb-form-field class="username">
|
||||
<input formControlName="username" required
|
||||
type="text" nbInput
|
||||
status="{{formCtrlStatus}}"
|
||||
placeholder="{{'global.username' | translate}}"
|
||||
[min]="MIN_LENGTH"
|
||||
(keydown.enter)="onEnterPressed()">
|
||||
</nb-form-field>
|
||||
|
||||
<nb-form-field class="password">
|
||||
<input formControlName="password" required
|
||||
type="password" nbInput
|
||||
status="{{formCtrlStatus}}"
|
||||
placeholder="{{'global.password' | translate}}"
|
||||
(keydown.enter)="onEnterPressed()">
|
||||
</nb-form-field>
|
||||
|
||||
<div id="login-failed-error"
|
||||
class="alert"
|
||||
*ngIf="loginFailedWithCurrentCredentials">
|
||||
{{'login.failed' | translate}}
|
||||
</div>
|
||||
|
||||
<button nbButton class="login-button" status="primary"
|
||||
[disabled]="formIsEmptyOrInvalid()"
|
||||
(click)="login()">
|
||||
{{'global.action.login' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="bottom-text" fxLayout="row" fxLayoutAlign="space-around center">
|
||||
<div class="version-text">
|
||||
{{version}}
|
||||
</div>
|
||||
<div>
|
||||
© {{NOVATEC_NAME}}
|
||||
</div>
|
||||
</div>
|
||||
</nb-card-body>
|
||||
</nb-card>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
@import '~@nebular/theme/styles/theming';
|
||||
|
||||
$login-width: 24em;
|
||||
$input-width: 16rem;
|
||||
|
||||
.login-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
|
||||
.login-card {
|
||||
z-index: 10;
|
||||
align-self: center;
|
||||
text-align: center;
|
||||
border-radius: 0.5rem;
|
||||
|
||||
max-width: $login-width;
|
||||
max-height: $login-width;
|
||||
|
||||
.login-label {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 2rem !important;
|
||||
color: #8f9bb3;
|
||||
}
|
||||
|
||||
.username {
|
||||
width: $input-width;
|
||||
margin-bottom: 1.5rem !important;
|
||||
}
|
||||
|
||||
.password {
|
||||
width: $input-width;
|
||||
margin-bottom: 1.25rem !important;
|
||||
}
|
||||
|
||||
.login-button {
|
||||
max-width: $input-width;
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding-bottom: 0.5rem;
|
||||
color: #e74c3c;
|
||||
}
|
||||
}
|
||||
|
||||
.bottom-text {
|
||||
display: flex;
|
||||
text-align: center;
|
||||
margin-top: auto;
|
||||
margin-bottom: 1rem;
|
||||
justify-content: space-around;
|
||||
padding: 0.625rem;
|
||||
.version-text{
|
||||
max-width: 50%;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.login-background {
|
||||
background-image: url("../../assets/images/login/login.jpg");
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
|
||||
min-width: 100vw;
|
||||
min-height: 100vh;
|
||||
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
|
||||
filter: grayscale(100%) blur(2.5px) brightness(1);
|
||||
z-index: 1;
|
||||
margin: -2%
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
import {ComponentFixture, fakeAsync, inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {LoginComponent} from './login.component';
|
||||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
import {
|
||||
NbButtonModule,
|
||||
NbCardModule,
|
||||
NbFormFieldModule,
|
||||
NbInputModule,
|
||||
NbLayoutModule,
|
||||
} from '@nebular/theme';
|
||||
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||
import {HttpLoaderFactory} from '../common-app.module';
|
||||
import {HttpClient, HttpClientModule} from '@angular/common/http';
|
||||
import {ThemeModule} from '../../assets/@theme/theme.module';
|
||||
import {NgxsModule, Store} from '@ngxs/store';
|
||||
import {SESSION_STATE_NAME, SessionState, SessionStateModel} from '../../shared/stores/session-state/session-state';
|
||||
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
|
||||
import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
import {User} from '../../shared/models/user.model';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {NotificationService} from '../../shared/services/notification.service';
|
||||
import {NotificationServiceMock} from '../../shared/services/notification.service.mock';
|
||||
|
||||
const DESIRED_STORE_STATE_SESSION: SessionStateModel = {
|
||||
userAccount: {
|
||||
...new User('ttt', 'test', 'user', 'default.user@test.de', 'en-US'),
|
||||
id: '11c47c56-3bcd-45f1-a05b-c197dbd33110'
|
||||
},
|
||||
isAuthenticated: true
|
||||
};
|
||||
|
||||
describe('LoginComponent', () => {
|
||||
let component: LoginComponent;
|
||||
let fixture: ComponentFixture<LoginComponent>;
|
||||
let httpMock: HttpTestingController;
|
||||
let store: Store;
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
NbCardModule,
|
||||
FlexLayoutModule,
|
||||
BrowserAnimationsModule,
|
||||
ReactiveFormsModule,
|
||||
NbInputModule,
|
||||
NbCardModule,
|
||||
NbButtonModule,
|
||||
NbLayoutModule,
|
||||
ThemeModule.forRoot(),
|
||||
NbFormFieldModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
RouterTestingModule.withRoutes([]),
|
||||
NgxsModule.forRoot([SessionState]),
|
||||
HttpClientModule,
|
||||
HttpClientTestingModule
|
||||
],
|
||||
declarations: [
|
||||
LoginComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: NotificationService, useValue: new NotificationServiceMock()}
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(inject([Store], (inStore: Store) => {
|
||||
store = inStore;
|
||||
store.reset({
|
||||
...store.snapshot(),
|
||||
[SESSION_STATE_NAME]: DESIRED_STORE_STATE_SESSION
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(LoginComponent);
|
||||
component = fixture.componentInstance;
|
||||
httpMock = TestBed.inject(HttpTestingController);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,129 @@
|
|||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {AbstractControl, FormBuilder, FormGroup, Validators} from '@angular/forms';
|
||||
import {Router} from '@angular/router';
|
||||
import {Store} from '@ngxs/store';
|
||||
import {NotificationService, PopupType} from '../../shared/services/notification.service';
|
||||
import {untilDestroyed} from 'ngx-take-until-destroy';
|
||||
import {User} from '../../shared/models/user.model';
|
||||
import {throwError} from 'rxjs';
|
||||
import {UpdateIsAuthenticated, UpdateUser} from '../../shared/stores/session-state/session-state.actions';
|
||||
import {GlobalTitlesVariables} from '../../shared/config/global-variables';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {FieldStatus} from '../../shared/models/form-field-status.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
templateUrl: './login.component.html',
|
||||
styleUrls: ['./login.component.scss']
|
||||
})
|
||||
export class LoginComponent implements OnInit, OnDestroy {
|
||||
readonly MIN_LENGTH: number = 2;
|
||||
readonly SECURITYC4PO_TITLE = GlobalTitlesVariables.SECURITYC4PO_TITLE;
|
||||
readonly NOVATEC_NAME = GlobalTitlesVariables.NOVATEC_NAME;
|
||||
|
||||
// ToDo: Remove after adding real authentication
|
||||
private readonly user = new User('ttt', 'test', 'user', 'default.user@test.de', 'en-US');
|
||||
|
||||
version: string;
|
||||
|
||||
// form control elements
|
||||
loginFormGroup: FormGroup;
|
||||
loginUsernameCtrl: AbstractControl;
|
||||
loginPasswordCtrl: AbstractControl;
|
||||
|
||||
loginFailedWithCurrentCredentials = false;
|
||||
invalidUsername: string;
|
||||
invalidPassword: string;
|
||||
|
||||
formCtrlStatus = FieldStatus.BASIC;
|
||||
|
||||
constructor(private fb: FormBuilder,
|
||||
private router: Router,
|
||||
private store: Store,
|
||||
private readonly httpClient: HttpClient,
|
||||
private notificationService: NotificationService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loginFormGroup = this.fb.group({
|
||||
username: ['', [Validators.required, Validators.minLength(this.MIN_LENGTH)]],
|
||||
password: ['', Validators.required]
|
||||
});
|
||||
|
||||
this.loginUsernameCtrl = this.loginFormGroup.get('username');
|
||||
this.loginPasswordCtrl = this.loginFormGroup.get('password');
|
||||
|
||||
this.loginFormGroup.valueChanges
|
||||
.pipe(untilDestroyed(this))
|
||||
.subscribe(() => {
|
||||
this.formCtrlStatus = FieldStatus.BASIC;
|
||||
this.loginFailedWithCurrentCredentials = false;
|
||||
});
|
||||
this.readAppVersion();
|
||||
}
|
||||
|
||||
login(): void {
|
||||
const username = this.loginUsernameCtrl.value;
|
||||
const password = this.loginPasswordCtrl.value;
|
||||
if (username === DefaultUser.username
|
||||
&& password === DefaultUser.password) {
|
||||
// ToDo: Should be handled in Guards
|
||||
this.store.dispatch(new UpdateIsAuthenticated(true));
|
||||
this.store.dispatch(new UpdateUser(this.user, true));
|
||||
this.router.navigate(['/home']).then(() => {
|
||||
this.notificationService.showPopup('popup.login.successful', PopupType.SUCCESS);
|
||||
}, err => {
|
||||
console.error(err);
|
||||
});
|
||||
} else {
|
||||
this.invalidUsername = username;
|
||||
this.invalidPassword = password;
|
||||
this.loginFailedWithCurrentCredentials = true;
|
||||
this.formCtrlStatus = FieldStatus.DANGER;
|
||||
throwError('Invalid Credentials');
|
||||
console.error('Invalid Credentials');
|
||||
}
|
||||
}
|
||||
|
||||
onEnterPressed(): void {
|
||||
this.login();
|
||||
}
|
||||
|
||||
formIsEmptyOrInvalid(): boolean {
|
||||
return this.isEmpty(this.loginUsernameCtrl.value)
|
||||
|| this.isEmpty(this.loginPasswordCtrl.value)
|
||||
|| this.loginPasswordCtrl.invalid
|
||||
|| this.loginFailedWithCurrentCredentials === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ctrlValue of type string
|
||||
* @return if ctrlValue is empty or not
|
||||
*/
|
||||
isEmpty(ctrlValue: string): boolean {
|
||||
return ctrlValue === '';
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
// This method must be present when using ngx-take-until-destroy
|
||||
// even when empty
|
||||
}
|
||||
|
||||
readAppVersion(): void {
|
||||
this.httpClient.get<Version>('assets/version.json', {responseType: 'json'})
|
||||
.subscribe((data: Version) => {
|
||||
this.version = data.version;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface Version {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export enum DefaultUser {
|
||||
username = 'ttt',
|
||||
password = 'Test1234!'
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {LoginComponent} from './login.component';
|
||||
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||
import {HttpLoaderFactory} from '../common-app.module';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {NotificationService} from '../../shared/services/notification.service';
|
||||
import {LoginRoutingModule} from './login-routing.module';
|
||||
import {NbButtonModule, NbCardModule, NbFormFieldModule, NbInputModule, NbLayoutModule} from '@nebular/theme';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
import {ThemeModule} from '@assets/@theme/theme.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
LoginComponent
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
LoginRoutingModule,
|
||||
TranslateModule.forChild({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
NbCardModule,
|
||||
FlexLayoutModule,
|
||||
ReactiveFormsModule,
|
||||
NbInputModule,
|
||||
ThemeModule,
|
||||
NbCardModule,
|
||||
NbButtonModule,
|
||||
NbLayoutModule,
|
||||
NbFormFieldModule
|
||||
], providers: [
|
||||
NotificationService
|
||||
]
|
||||
})
|
||||
export class LoginModule {
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
@mixin ngx-layout() {
|
||||
@include media-breakpoint-down(is) {
|
||||
.row {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
@import './themes';
|
||||
|
||||
@mixin nb-overrides() {
|
||||
nb-select.size-medium button {
|
||||
padding: 0.4375rem 2.2rem 0.4375rem 1.125rem !important;
|
||||
|
||||
nb-icon {
|
||||
right: 0.41rem !important;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
.chromeframe {
|
||||
margin: 0.2em 0;
|
||||
background: #ccc;
|
||||
color: #000;
|
||||
padding: 0.2em 0;
|
||||
}
|
||||
|
||||
#loader-wrapper {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#loader {
|
||||
display: block;
|
||||
position: relative;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
margin: -75px 0 0 -75px;
|
||||
border-radius: 50%;
|
||||
border: 3px solid transparent;
|
||||
border-top-color: #3498db;
|
||||
|
||||
-webkit-animation: spin 2s linear infinite; /* Chrome, Opera 15+, Safari 5+ */
|
||||
animation: spin 2s linear infinite; /* Chrome, Firefox 16+, IE 10+, Opera */
|
||||
}
|
||||
|
||||
#loader:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
left: 5px;
|
||||
right: 5px;
|
||||
bottom: 5px;
|
||||
border-radius: 50%;
|
||||
border: 3px solid transparent;
|
||||
border-top-color: #e74c3c;
|
||||
|
||||
-webkit-animation: spin 3s linear infinite; /* Chrome, Opera 15+, Safari 5+ */
|
||||
animation: spin 3s linear infinite; /* Chrome, Firefox 16+, IE 10+, Opera */
|
||||
}
|
||||
|
||||
#loader:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
left: 15px;
|
||||
right: 15px;
|
||||
bottom: 15px;
|
||||
border-radius: 50%;
|
||||
border: 3px solid transparent;
|
||||
border-top-color: #f9c922;
|
||||
|
||||
-webkit-animation: spin 1.5s linear infinite; /* Chrome, Opera 15+, Safari 5+ */
|
||||
animation: spin 1.5s linear infinite; /* Chrome, Firefox 16+, IE 10+, Opera */
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Akveo. All Rights Reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*/
|
||||
|
||||
@mixin ngx-pace-theme() {
|
||||
|
||||
.pace .pace-progress {
|
||||
background: nb-theme(color-primary-default);
|
||||
}
|
||||
|
||||
.pace .pace-progress-inner {
|
||||
box-shadow: 0 0 10px nb-theme(color-primary-default), 0 0 5px nb-theme(color-primary-default);
|
||||
}
|
||||
|
||||
.pace .pace-activity {
|
||||
display: none;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// themes - our custom or/and out of the box themes
|
||||
@import 'themes';
|
||||
|
||||
// framework component themes (styles tied to theme variables)
|
||||
@import '~@nebular/theme/styles/globals';
|
||||
|
||||
// loading progress bar theme
|
||||
@import './pace.theme';
|
||||
|
||||
@import './layout';
|
||||
@import './overrides';
|
||||
|
||||
* {
|
||||
font-family: Roboto, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@include nb-install() {
|
||||
// framework global styles
|
||||
@include nb-theme-global();
|
||||
|
||||
@include ngx-layout();
|
||||
|
||||
@include nb-overrides();
|
||||
};
|
||||
/* You can add global styles to this file, and also import other style files */
|
|
@ -0,0 +1,308 @@
|
|||
import { NbJSThemeOptions, CORPORATE_THEME as baseTheme } from '@nebular/theme';
|
||||
|
||||
const baseThemeVariables = baseTheme.variables;
|
||||
|
||||
export const CORPORATE_THEME = {
|
||||
name: 'corporate',
|
||||
base: 'corporate',
|
||||
variables: {
|
||||
temperature: {
|
||||
arcFill: [ '#ffa36b', '#ffa36b', '#ff9e7a', '#ff9888', '#ff8ea0' ],
|
||||
arcEmpty: baseThemeVariables.bg2,
|
||||
thumbBg: baseThemeVariables.bg2,
|
||||
thumbBorder: '#ffa36b',
|
||||
},
|
||||
|
||||
solar: {
|
||||
gradientLeft: baseThemeVariables.primary,
|
||||
gradientRight: baseThemeVariables.primary,
|
||||
shadowColor: 'rgba(0, 0, 0, 0)',
|
||||
secondSeriesFill: baseThemeVariables.bg2,
|
||||
radius: ['80%', '90%'],
|
||||
},
|
||||
|
||||
traffic: {
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 4px 16px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
|
||||
yAxisSplitLine: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
lineBg: baseThemeVariables.primary,
|
||||
lineShadowBlur: '0',
|
||||
itemColor: baseThemeVariables.border4,
|
||||
itemBorderColor: baseThemeVariables.border4,
|
||||
itemEmphasisBorderColor: baseThemeVariables.primaryLight,
|
||||
shadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
shadowLineShadow: 'rgba(0, 0, 0, 0)',
|
||||
gradFrom: baseThemeVariables.bg,
|
||||
gradTo: baseThemeVariables.bg,
|
||||
},
|
||||
|
||||
electricity: {
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipLineColor: baseThemeVariables.fgText,
|
||||
tooltipLineWidth: '0',
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 8px 24px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
|
||||
axisLineColor: baseThemeVariables.border3,
|
||||
xAxisTextColor: baseThemeVariables.fg,
|
||||
yAxisSplitLine: baseThemeVariables.separator,
|
||||
|
||||
itemBorderColor: baseThemeVariables.primary,
|
||||
lineStyle: 'solid',
|
||||
lineWidth: '4',
|
||||
lineGradFrom: baseThemeVariables.primary,
|
||||
lineGradTo: baseThemeVariables.primary,
|
||||
lineShadow: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
areaGradFrom: 'rgba(0, 0, 0, 0)',
|
||||
areaGradTo: 'rgba(0, 0, 0, 0)',
|
||||
shadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
},
|
||||
|
||||
bubbleMap: {
|
||||
titleColor: baseThemeVariables.fgText,
|
||||
areaColor: baseThemeVariables.bg4,
|
||||
areaHoverColor: baseThemeVariables.fgHighlight,
|
||||
areaBorderColor: baseThemeVariables.border5,
|
||||
},
|
||||
|
||||
profitBarAnimationEchart: {
|
||||
textColor: baseThemeVariables.fgText,
|
||||
|
||||
firstAnimationBarColor: baseThemeVariables.primary,
|
||||
secondAnimationBarColor: baseThemeVariables.success,
|
||||
|
||||
splitLineStyleOpacity: '1',
|
||||
splitLineStyleWidth: '1',
|
||||
splitLineStyleColor: baseThemeVariables.separator,
|
||||
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
tooltipFontSize: '16',
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipBorderWidth: '1',
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 4px 16px;',
|
||||
},
|
||||
|
||||
trafficBarEchart: {
|
||||
gradientFrom: baseThemeVariables.warningLight,
|
||||
gradientTo: baseThemeVariables.warning,
|
||||
shadow: baseThemeVariables.warningLight,
|
||||
shadowBlur: '0',
|
||||
|
||||
axisTextColor: baseThemeVariables.fgText,
|
||||
axisFontSize: '12',
|
||||
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 8px 24px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
},
|
||||
|
||||
countryOrders: {
|
||||
countryBorderColor: baseThemeVariables.border4,
|
||||
countryFillColor: baseThemeVariables.bg4,
|
||||
countryBorderWidth: '1',
|
||||
hoveredCountryBorderColor: baseThemeVariables.primary,
|
||||
hoveredCountryFillColor: baseThemeVariables.primaryLight,
|
||||
hoveredCountryBorderWidth: '1',
|
||||
|
||||
chartAxisLineColor: baseThemeVariables.border4,
|
||||
chartAxisTextColor: baseThemeVariables.fg,
|
||||
chartAxisFontSize: '16',
|
||||
chartGradientTo: baseThemeVariables.primary,
|
||||
chartGradientFrom: baseThemeVariables.primaryLight,
|
||||
chartAxisSplitLine: baseThemeVariables.separator,
|
||||
chartShadowLineColor: baseThemeVariables.primaryLight,
|
||||
|
||||
chartLineBottomShadowColor: baseThemeVariables.primary,
|
||||
|
||||
chartInnerLineColor: baseThemeVariables.bg2,
|
||||
},
|
||||
|
||||
echarts: {
|
||||
bg: baseThemeVariables.bg,
|
||||
textColor: baseThemeVariables.fgText,
|
||||
axisLineColor: baseThemeVariables.fgText,
|
||||
splitLineColor: baseThemeVariables.separator,
|
||||
itemHoverShadowColor: 'rgba(0, 0, 0, 0.5)',
|
||||
tooltipBackgroundColor: baseThemeVariables.primary,
|
||||
areaOpacity: '0.7',
|
||||
},
|
||||
|
||||
chartjs: {
|
||||
axisLineColor: baseThemeVariables.separator,
|
||||
textColor: baseThemeVariables.fgText,
|
||||
},
|
||||
|
||||
orders: {
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipLineColor: 'rgba(0, 0, 0, 0)',
|
||||
tooltipLineWidth: '0',
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 8px 24px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
tooltipFontSize: '20',
|
||||
|
||||
axisLineColor: baseThemeVariables.border4,
|
||||
axisFontSize: '16',
|
||||
axisTextColor: baseThemeVariables.fg,
|
||||
yAxisSplitLine: baseThemeVariables.separator,
|
||||
|
||||
itemBorderColor: baseThemeVariables.primary,
|
||||
lineStyle: 'solid',
|
||||
lineWidth: '4',
|
||||
|
||||
// first line
|
||||
firstAreaGradFrom: baseThemeVariables.bg3,
|
||||
firstAreaGradTo: baseThemeVariables.bg3,
|
||||
firstShadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
// second line
|
||||
secondLineGradFrom: baseThemeVariables.primary,
|
||||
secondLineGradTo: baseThemeVariables.primary,
|
||||
|
||||
secondAreaGradFrom: 'rgba(0, 0, 0, 0)',
|
||||
secondAreaGradTo: 'rgba(0, 0, 0, 0)',
|
||||
secondShadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
// third line
|
||||
thirdLineGradFrom: baseThemeVariables.success,
|
||||
thirdLineGradTo: baseThemeVariables.successLight,
|
||||
|
||||
thirdAreaGradFrom: 'rgba(0, 0, 0, 0)',
|
||||
thirdAreaGradTo: 'rgba(0, 0, 0, 0)',
|
||||
thirdShadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
},
|
||||
|
||||
profit: {
|
||||
bg: baseThemeVariables.bg,
|
||||
textColor: baseThemeVariables.fgText,
|
||||
axisLineColor: baseThemeVariables.border4,
|
||||
splitLineColor: baseThemeVariables.separator,
|
||||
areaOpacity: '1',
|
||||
|
||||
axisFontSize: '16',
|
||||
axisTextColor: baseThemeVariables.fg,
|
||||
|
||||
// first bar
|
||||
firstLineGradFrom: baseThemeVariables.bg3,
|
||||
firstLineGradTo: baseThemeVariables.bg3,
|
||||
firstLineShadow: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
// second bar
|
||||
secondLineGradFrom: baseThemeVariables.primary,
|
||||
secondLineGradTo: baseThemeVariables.primary,
|
||||
secondLineShadow: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
// third bar
|
||||
thirdLineGradFrom: baseThemeVariables.success,
|
||||
thirdLineGradTo: baseThemeVariables.success,
|
||||
thirdLineShadow: 'rgba(0, 0, 0, 0)',
|
||||
},
|
||||
|
||||
orderProfitLegend: {
|
||||
firstItem: baseThemeVariables.success,
|
||||
secondItem: baseThemeVariables.primary,
|
||||
thirdItem: baseThemeVariables.bg3,
|
||||
},
|
||||
|
||||
visitors: {
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipLineColor: 'rgba(0, 0, 0, 0)',
|
||||
tooltipLineWidth: '1',
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 8px 24px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
tooltipFontSize: '20',
|
||||
|
||||
axisLineColor: baseThemeVariables.border4,
|
||||
axisFontSize: '16',
|
||||
axisTextColor: baseThemeVariables.fg,
|
||||
yAxisSplitLine: baseThemeVariables.separator,
|
||||
|
||||
itemBorderColor: baseThemeVariables.primary,
|
||||
lineStyle: 'dotted',
|
||||
lineWidth: '6',
|
||||
lineGradFrom: '#ffffff',
|
||||
lineGradTo: '#ffffff',
|
||||
lineShadow: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
areaGradFrom: baseThemeVariables.primary,
|
||||
areaGradTo: baseThemeVariables.primaryLight,
|
||||
|
||||
innerLineStyle: 'solid',
|
||||
innerLineWidth: '1',
|
||||
|
||||
innerAreaGradFrom: baseThemeVariables.success,
|
||||
innerAreaGradTo: baseThemeVariables.success,
|
||||
},
|
||||
|
||||
visitorsLegend: {
|
||||
firstIcon: baseThemeVariables.success,
|
||||
secondIcon: baseThemeVariables.primary,
|
||||
},
|
||||
|
||||
visitorsPie: {
|
||||
firstPieGradientLeft: baseThemeVariables.success,
|
||||
firstPieGradientRight: baseThemeVariables.success,
|
||||
firstPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
firstPieRadius: ['65%', '90%'],
|
||||
|
||||
secondPieGradientLeft: baseThemeVariables.warning,
|
||||
secondPieGradientRight: baseThemeVariables.warningLight,
|
||||
secondPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
secondPieRadius: ['63%', '92%'],
|
||||
shadowOffsetX: '-4',
|
||||
shadowOffsetY: '-4',
|
||||
},
|
||||
|
||||
visitorsPieLegend: {
|
||||
firstSection: baseThemeVariables.warning,
|
||||
secondSection: baseThemeVariables.success,
|
||||
},
|
||||
|
||||
earningPie: {
|
||||
radius: ['65%', '100%'],
|
||||
center: ['50%', '50%'],
|
||||
|
||||
fontSize: '22',
|
||||
|
||||
firstPieGradientLeft: baseThemeVariables.success,
|
||||
firstPieGradientRight: baseThemeVariables.success,
|
||||
firstPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
secondPieGradientLeft: baseThemeVariables.primary,
|
||||
secondPieGradientRight: baseThemeVariables.primary,
|
||||
secondPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
thirdPieGradientLeft: baseThemeVariables.warning,
|
||||
thirdPieGradientRight: baseThemeVariables.warning,
|
||||
thirdPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
},
|
||||
|
||||
earningLine: {
|
||||
gradFrom: baseThemeVariables.primary,
|
||||
gradTo: baseThemeVariables.primary,
|
||||
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
tooltipFontSize: '16',
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipBorderWidth: '1',
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 4px 16px;',
|
||||
},
|
||||
},
|
||||
} as NbJSThemeOptions;
|
|
@ -0,0 +1,314 @@
|
|||
import { NbJSThemeOptions, DARK_THEME as baseTheme } from '@nebular/theme';
|
||||
|
||||
const baseThemeVariables = baseTheme.variables;
|
||||
|
||||
export const DARK_THEME = {
|
||||
name: 'dark',
|
||||
base: 'dark',
|
||||
variables: {
|
||||
temperature: {
|
||||
arcFill: [
|
||||
baseThemeVariables.primary,
|
||||
baseThemeVariables.primary,
|
||||
baseThemeVariables.primary,
|
||||
baseThemeVariables.primary,
|
||||
baseThemeVariables.primary,
|
||||
],
|
||||
arcEmpty: baseThemeVariables.bg2,
|
||||
thumbBg: baseThemeVariables.bg2,
|
||||
thumbBorder: baseThemeVariables.primary,
|
||||
},
|
||||
|
||||
solar: {
|
||||
gradientLeft: baseThemeVariables.primary,
|
||||
gradientRight: baseThemeVariables.primary,
|
||||
shadowColor: 'rgba(0, 0, 0, 0)',
|
||||
secondSeriesFill: baseThemeVariables.bg2,
|
||||
radius: ['80%', '90%'],
|
||||
},
|
||||
|
||||
traffic: {
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 4px 16px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
|
||||
yAxisSplitLine: baseThemeVariables.separator,
|
||||
|
||||
lineBg: baseThemeVariables.border4,
|
||||
lineShadowBlur: '1',
|
||||
itemColor: baseThemeVariables.border4,
|
||||
itemBorderColor: baseThemeVariables.border4,
|
||||
itemEmphasisBorderColor: baseThemeVariables.primary,
|
||||
shadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
shadowLineShadow: 'rgba(0, 0, 0, 0)',
|
||||
gradFrom: baseThemeVariables.bg2,
|
||||
gradTo: baseThemeVariables.bg2,
|
||||
},
|
||||
|
||||
electricity: {
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipLineColor: baseThemeVariables.fgText,
|
||||
tooltipLineWidth: '0',
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 8px 24px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
|
||||
axisLineColor: baseThemeVariables.border3,
|
||||
xAxisTextColor: baseThemeVariables.fg,
|
||||
yAxisSplitLine: baseThemeVariables.separator,
|
||||
|
||||
itemBorderColor: baseThemeVariables.primary,
|
||||
lineStyle: 'solid',
|
||||
lineWidth: '4',
|
||||
lineGradFrom: baseThemeVariables.primary,
|
||||
lineGradTo: baseThemeVariables.primary,
|
||||
lineShadow: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
areaGradFrom: baseThemeVariables.bg2,
|
||||
areaGradTo: baseThemeVariables.bg2,
|
||||
shadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
},
|
||||
|
||||
bubbleMap: {
|
||||
titleColor: baseThemeVariables.fgText,
|
||||
areaColor: baseThemeVariables.bg4,
|
||||
areaHoverColor: baseThemeVariables.fgHighlight,
|
||||
areaBorderColor: baseThemeVariables.border5,
|
||||
},
|
||||
|
||||
profitBarAnimationEchart: {
|
||||
textColor: baseThemeVariables.fgText,
|
||||
|
||||
firstAnimationBarColor: baseThemeVariables.primary,
|
||||
secondAnimationBarColor: baseThemeVariables.success,
|
||||
|
||||
splitLineStyleOpacity: '1',
|
||||
splitLineStyleWidth: '1',
|
||||
splitLineStyleColor: baseThemeVariables.separator,
|
||||
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
tooltipFontSize: '16',
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipBorderWidth: '1',
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 4px 16px;',
|
||||
},
|
||||
|
||||
trafficBarEchart: {
|
||||
gradientFrom: baseThemeVariables.warningLight,
|
||||
gradientTo: baseThemeVariables.warning,
|
||||
shadow: baseThemeVariables.warningLight,
|
||||
shadowBlur: '0',
|
||||
|
||||
axisTextColor: baseThemeVariables.fgText,
|
||||
axisFontSize: '12',
|
||||
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 4px 16px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
},
|
||||
|
||||
countryOrders: {
|
||||
countryBorderColor: baseThemeVariables.border4,
|
||||
countryFillColor: baseThemeVariables.bg3,
|
||||
countryBorderWidth: '1',
|
||||
hoveredCountryBorderColor: baseThemeVariables.primary,
|
||||
hoveredCountryFillColor: baseThemeVariables.primaryLight,
|
||||
hoveredCountryBorderWidth: '1',
|
||||
|
||||
chartAxisLineColor: baseThemeVariables.border4,
|
||||
chartAxisTextColor: baseThemeVariables.fg,
|
||||
chartAxisFontSize: '16',
|
||||
chartGradientTo: baseThemeVariables.primary,
|
||||
chartGradientFrom: baseThemeVariables.primaryLight,
|
||||
chartAxisSplitLine: baseThemeVariables.separator,
|
||||
chartShadowLineColor: baseThemeVariables.primaryLight,
|
||||
|
||||
chartLineBottomShadowColor: baseThemeVariables.primary,
|
||||
|
||||
chartInnerLineColor: baseThemeVariables.bg2,
|
||||
},
|
||||
|
||||
echarts: {
|
||||
bg: baseThemeVariables.bg,
|
||||
textColor: baseThemeVariables.fgText,
|
||||
axisLineColor: baseThemeVariables.fgText,
|
||||
splitLineColor: baseThemeVariables.separator,
|
||||
itemHoverShadowColor: 'rgba(0, 0, 0, 0.5)',
|
||||
tooltipBackgroundColor: baseThemeVariables.primary,
|
||||
areaOpacity: '0.7',
|
||||
},
|
||||
|
||||
chartjs: {
|
||||
axisLineColor: baseThemeVariables.separator,
|
||||
textColor: baseThemeVariables.fgText,
|
||||
},
|
||||
|
||||
orders: {
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipLineColor: 'rgba(0, 0, 0, 0)',
|
||||
tooltipLineWidth: '0',
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 8px 24px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
tooltipFontSize: '20',
|
||||
|
||||
axisLineColor: baseThemeVariables.border4,
|
||||
axisFontSize: '16',
|
||||
axisTextColor: baseThemeVariables.fg,
|
||||
yAxisSplitLine: baseThemeVariables.separator,
|
||||
|
||||
itemBorderColor: baseThemeVariables.primary,
|
||||
lineStyle: 'solid',
|
||||
lineWidth: '4',
|
||||
|
||||
// first line
|
||||
firstAreaGradFrom: baseThemeVariables.bg3,
|
||||
firstAreaGradTo: baseThemeVariables.bg3,
|
||||
firstShadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
// second line
|
||||
secondLineGradFrom: baseThemeVariables.primary,
|
||||
secondLineGradTo: baseThemeVariables.primary,
|
||||
|
||||
secondAreaGradFrom: 'rgba(51, 102, 255, 0.2)',
|
||||
secondAreaGradTo: 'rgba(51, 102, 255, 0)',
|
||||
secondShadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
// third line
|
||||
thirdLineGradFrom: baseThemeVariables.success,
|
||||
thirdLineGradTo: baseThemeVariables.successLight,
|
||||
|
||||
thirdAreaGradFrom: 'rgba(0, 214, 143, 0.2)',
|
||||
thirdAreaGradTo: 'rgba(0, 214, 143, 0)',
|
||||
thirdShadowLineDarkBg: 'rgba(0, 0, 0, 0)',
|
||||
},
|
||||
|
||||
profit: {
|
||||
bg: baseThemeVariables.bg,
|
||||
textColor: baseThemeVariables.fgText,
|
||||
axisLineColor: baseThemeVariables.border4,
|
||||
splitLineColor: baseThemeVariables.separator,
|
||||
areaOpacity: '1',
|
||||
|
||||
axisFontSize: '16',
|
||||
axisTextColor: baseThemeVariables.fg,
|
||||
|
||||
// first bar
|
||||
firstLineGradFrom: baseThemeVariables.bg3,
|
||||
firstLineGradTo: baseThemeVariables.bg3,
|
||||
firstLineShadow: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
// second bar
|
||||
secondLineGradFrom: baseThemeVariables.primary,
|
||||
secondLineGradTo: baseThemeVariables.primary,
|
||||
secondLineShadow: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
// third bar
|
||||
thirdLineGradFrom: baseThemeVariables.success,
|
||||
thirdLineGradTo: baseThemeVariables.successLight,
|
||||
thirdLineShadow: 'rgba(0, 0, 0, 0)',
|
||||
},
|
||||
|
||||
orderProfitLegend: {
|
||||
firstItem: baseThemeVariables.success,
|
||||
secondItem: baseThemeVariables.primary,
|
||||
thirdItem: baseThemeVariables.bg3,
|
||||
},
|
||||
|
||||
visitors: {
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipLineColor: 'rgba(0, 0, 0, 0)',
|
||||
tooltipLineWidth: '0',
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 8px 24px;',
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
tooltipFontSize: '20',
|
||||
|
||||
axisLineColor: baseThemeVariables.border4,
|
||||
axisFontSize: '16',
|
||||
axisTextColor: baseThemeVariables.fg,
|
||||
yAxisSplitLine: baseThemeVariables.separator,
|
||||
|
||||
itemBorderColor: baseThemeVariables.primary,
|
||||
lineStyle: 'dotted',
|
||||
lineWidth: '6',
|
||||
lineGradFrom: '#ffffff',
|
||||
lineGradTo: '#ffffff',
|
||||
lineShadow: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
areaGradFrom: baseThemeVariables.primary,
|
||||
areaGradTo: baseThemeVariables.primaryLight,
|
||||
|
||||
innerLineStyle: 'solid',
|
||||
innerLineWidth: '1',
|
||||
|
||||
innerAreaGradFrom: baseThemeVariables.success,
|
||||
innerAreaGradTo: baseThemeVariables.success,
|
||||
},
|
||||
|
||||
visitorsLegend: {
|
||||
firstIcon: baseThemeVariables.success,
|
||||
secondIcon: baseThemeVariables.primary,
|
||||
},
|
||||
|
||||
visitorsPie: {
|
||||
firstPieGradientLeft: baseThemeVariables.success,
|
||||
firstPieGradientRight: baseThemeVariables.success,
|
||||
firstPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
firstPieRadius: ['70%', '90%'],
|
||||
|
||||
secondPieGradientLeft: baseThemeVariables.warning,
|
||||
secondPieGradientRight: baseThemeVariables.warningLight,
|
||||
secondPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
secondPieRadius: ['60%', '97%'],
|
||||
shadowOffsetX: '0',
|
||||
shadowOffsetY: '0',
|
||||
},
|
||||
|
||||
visitorsPieLegend: {
|
||||
firstSection: baseThemeVariables.warning,
|
||||
secondSection: baseThemeVariables.success,
|
||||
},
|
||||
|
||||
earningPie: {
|
||||
radius: ['65%', '100%'],
|
||||
center: ['50%', '50%'],
|
||||
|
||||
fontSize: '22',
|
||||
|
||||
firstPieGradientLeft: baseThemeVariables.success,
|
||||
firstPieGradientRight: baseThemeVariables.success,
|
||||
firstPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
secondPieGradientLeft: baseThemeVariables.primary,
|
||||
secondPieGradientRight: baseThemeVariables.primary,
|
||||
secondPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
|
||||
thirdPieGradientLeft: baseThemeVariables.warning,
|
||||
thirdPieGradientRight: baseThemeVariables.warning,
|
||||
thirdPieShadowColor: 'rgba(0, 0, 0, 0)',
|
||||
},
|
||||
|
||||
earningLine: {
|
||||
gradFrom: baseThemeVariables.primary,
|
||||
gradTo: baseThemeVariables.primary,
|
||||
|
||||
tooltipTextColor: baseThemeVariables.fgText,
|
||||
tooltipFontWeight: 'normal',
|
||||
tooltipFontSize: '16',
|
||||
tooltipBg: baseThemeVariables.bg,
|
||||
tooltipBorderColor: baseThemeVariables.border2,
|
||||
tooltipBorderWidth: '1',
|
||||
tooltipExtraCss: 'border-radius: 10px; padding: 4px 16px;',
|
||||
},
|
||||
},
|
||||
} as NbJSThemeOptions;
|
|
@ -0,0 +1,46 @@
|
|||
// @nebular theming framework
|
||||
@import '~@nebular/theme/styles/theming';
|
||||
// @nebular out of the box themes
|
||||
@import '~@nebular/theme/styles/themes';
|
||||
|
||||
$nb-themes: nb-register-theme((
|
||||
layout-padding-top: 2.25rem,
|
||||
|
||||
menu-item-icon-margin: 0 0.5rem 0 0,
|
||||
|
||||
card-height-tiny: 13.5rem,
|
||||
card-height-small: 21.1875rem,
|
||||
card-height-medium: 28.875rem,
|
||||
card-height-large: 36.5625rem,
|
||||
card-height-giant: 44.25rem,
|
||||
card-margin-bottom: 1.875rem,
|
||||
card-header-with-select-padding-top: 0.5rem,
|
||||
card-header-with-select-padding-bottom: 0.5rem,
|
||||
|
||||
select-min-width: 6rem,
|
||||
|
||||
slide-out-background: linear-gradient(270deg, #edf1f7 0%, #e4e9f2 100%),
|
||||
slide-out-shadow-color: 0 4px 14px 0 #8f9bb3,
|
||||
slide-out-shadow-color-rtl: 0 4px 14px 0 #8f9bb3,
|
||||
), corporate, corporate);
|
||||
|
||||
$nb-themes: nb-register-theme((
|
||||
layout-padding-top: 2.25rem,
|
||||
|
||||
menu-item-icon-margin: 0 0.5rem 0 0,
|
||||
|
||||
card-height-tiny: 13.5rem,
|
||||
card-height-small: 21.1875rem,
|
||||
card-height-medium: 28.875rem,
|
||||
card-height-large: 36.5625rem,
|
||||
card-height-giant: 44.25rem,
|
||||
card-margin-bottom: 1.875rem,
|
||||
card-header-with-select-padding-top: 0.5rem,
|
||||
card-header-with-select-padding-bottom: 0.5rem,
|
||||
|
||||
select-min-width: 6rem,
|
||||
|
||||
slide-out-background: linear-gradient(270deg, #222b45 0%, #151a30 100%),
|
||||
slide-out-shadow-color: 0 4px 14px 0 #8f9bb3,
|
||||
slide-out-shadow-color-rtl: 0 4px 14px 0 #8f9bb3,
|
||||
), dark, dark);
|
|
@ -0,0 +1,57 @@
|
|||
import { ModuleWithProviders, NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
NbActionsModule,
|
||||
NbLayoutModule,
|
||||
NbMenuModule,
|
||||
NbSearchModule,
|
||||
NbSidebarModule,
|
||||
NbUserModule,
|
||||
NbContextMenuModule,
|
||||
NbButtonModule,
|
||||
NbSelectModule,
|
||||
NbIconModule,
|
||||
NbThemeModule,
|
||||
} from '@nebular/theme';
|
||||
import { NbEvaIconsModule } from '@nebular/eva-icons';
|
||||
import { CORPORATE_THEME } from './styles/theme.corporate';
|
||||
import { DARK_THEME } from './styles/theme.dark';
|
||||
|
||||
const NB_MODULES = [
|
||||
NbLayoutModule,
|
||||
NbMenuModule,
|
||||
NbUserModule,
|
||||
NbActionsModule,
|
||||
NbSearchModule,
|
||||
NbSidebarModule,
|
||||
NbContextMenuModule,
|
||||
NbButtonModule,
|
||||
NbSelectModule,
|
||||
NbIconModule,
|
||||
NbEvaIconsModule,
|
||||
];
|
||||
const COMPONENTS = [
|
||||
];
|
||||
const PIPES = [
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, ...NB_MODULES],
|
||||
exports: [CommonModule, ...PIPES, ...COMPONENTS],
|
||||
declarations: [...COMPONENTS, ...PIPES],
|
||||
})
|
||||
export class ThemeModule {
|
||||
static forRoot(): ModuleWithProviders<ThemeModule> {
|
||||
return {
|
||||
ngModule: ThemeModule,
|
||||
providers: [
|
||||
...NbThemeModule.forRoot(
|
||||
{
|
||||
name: 'corporate',
|
||||
},
|
||||
[CORPORATE_THEME, DARK_THEME],
|
||||
).providers,
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"global": {
|
||||
"action.login": "Einloggen",
|
||||
"action.retry": "Erneut Versuchen",
|
||||
"username": "Nutzername",
|
||||
"password": "Passwort"
|
||||
},
|
||||
"popup": {
|
||||
"success": "✔",
|
||||
"failure": "✘",
|
||||
"warning": "!",
|
||||
"info": "",
|
||||
"error.position": {
|
||||
"permissionDenied": "Berechtigung verweigert",
|
||||
"timeout": "Zeitüberschreitung"
|
||||
},
|
||||
"login": {
|
||||
"successful": "Einloggen erfolgreich"
|
||||
}
|
||||
},
|
||||
"login": {
|
||||
"title": "Einloggen",
|
||||
"failed": "Benutzername oder Passwort falsch",
|
||||
"unauthorized": "Benutzer nicht gefunden. Bitte registrieren und erneut versuchen"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"global": {
|
||||
"action.login": "Login",
|
||||
"action.retry": "Try again",
|
||||
"username": "Username",
|
||||
"password": "Password"
|
||||
},
|
||||
"popup": {
|
||||
"success": "✔",
|
||||
"failure": "✘",
|
||||
"warning": "!",
|
||||
"info": "",
|
||||
"error.position": {
|
||||
"permissionDenied": "Permission Denied",
|
||||
"timeout": "Timeout"
|
||||
},
|
||||
"login": {
|
||||
"successful": "Login successful"
|
||||
}
|
||||
},
|
||||
"login": {
|
||||
"title": "Login",
|
||||
"failed": "Wrong username or password",
|
||||
"unauthorized": "User not found. Please register and try again"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
|
@ -0,0 +1 @@
|
|||
{"version": "local"}
|
|
@ -7,7 +7,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
<body id="loader-wrapper">
|
||||
<app-root id="loader"></app-root>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
export * from './main';
|
||||
export * from './polyfills';
|
|
@ -1,3 +1,7 @@
|
|||
/***************************************************************************************************
|
||||
* Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.
|
||||
*/
|
||||
import '@angular/localize/init';
|
||||
/**
|
||||
* This file includes polyfills needed by Angular and is loaded before the app.
|
||||
* You can add your own extra polyfills to this file.
|
||||
|
@ -56,8 +60,10 @@
|
|||
* Zone JS is required by default for Angular itself.
|
||||
*/
|
||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
|
||||
|
||||
(window as any).global = window;
|
||||
(window as any).process = {
|
||||
env: {DEBUG: undefined},
|
||||
};
|
||||
/***************************************************************************************************
|
||||
* APPLICATION IMPORTS
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export const GlobalTitlesVariables = {
|
||||
SECURITYC4PO_TITLE: 'SecurityC4PO',
|
||||
NOVATEC_NAME: 'Novatec'
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
import moment from 'moment-timezone';
|
||||
|
||||
export function getUtcMomentFromDate(date: Date): moment.Moment {
|
||||
return moment(date).tz('Etc/UTC');
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AuthGuardService } from './auth-guard.service';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||
import {HttpLoaderFactory} from '../../app/common-app.module';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {NgxsModule} from '@ngxs/store';
|
||||
import {SessionState} from '../stores/session-state/session-state';
|
||||
|
||||
describe('AuthGuardService', () => {
|
||||
let service: AuthGuardService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
HttpClientTestingModule,
|
||||
RouterTestingModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
NgxsModule.forRoot([SessionState])
|
||||
],
|
||||
providers: [
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(AuthGuardService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,47 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {Store} from '@ngxs/store';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {SessionState} from '../stores/session-state/session-state';
|
||||
import {catchError, map} from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthGuardService implements CanActivate {
|
||||
constructor(
|
||||
private readonly router: Router,
|
||||
private readonly store: Store) {
|
||||
}
|
||||
|
||||
canActivate(
|
||||
next: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot): Observable<boolean> {
|
||||
return this.isAuthenticated()
|
||||
.pipe(
|
||||
map((canAccess: boolean) => {
|
||||
if (canAccess) {
|
||||
return canAccess;
|
||||
} else {
|
||||
this.router.navigate(['/login']);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
private isAuthenticated(): Observable<boolean> {
|
||||
// ToDo: Should check from Authentication Provider
|
||||
return of(this.store.selectSnapshot(SessionState.isAuthenticated))
|
||||
.pipe(
|
||||
map((isLoggedIn: boolean) => {
|
||||
return isLoggedIn;
|
||||
}),
|
||||
catchError(() => {
|
||||
return of(false);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LoginGuardService } from './login-guard.service';
|
||||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
import {NgxsModule} from '@ngxs/store';
|
||||
import {SessionState} from '../stores/session-state/session-state';
|
||||
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||
import {HttpLoaderFactory} from '../../app/common-app.module';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
|
||||
describe('LoginGuardService', () => {
|
||||
let service: LoginGuardService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
HttpClientTestingModule,
|
||||
RouterTestingModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
NgxsModule.forRoot([SessionState])
|
||||
],
|
||||
providers: [
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(LoginGuardService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,46 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {Store} from '@ngxs/store';
|
||||
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {catchError, map, tap} from 'rxjs/operators';
|
||||
import {SessionState} from '../stores/session-state/session-state';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LoginGuardService implements CanActivate {
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private store: Store) {
|
||||
}
|
||||
|
||||
canActivate(routeSnapshot: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
||||
return this.isAuthenticated().pipe(
|
||||
tap((canAccess: boolean) => {
|
||||
if (canAccess) {
|
||||
this.router.navigate(['']).then();
|
||||
}
|
||||
}),
|
||||
// return true if login should be loaded (=> invert)
|
||||
map((canAccess: boolean) => !canAccess)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return state of authentication
|
||||
*/
|
||||
private isAuthenticated(): Observable<boolean> {
|
||||
// ToDo: Should check from Authentication Provider
|
||||
return of(this.store.selectSnapshot(SessionState.isAuthenticated))
|
||||
.pipe(
|
||||
map((isLoggedIn: boolean) => {
|
||||
return isLoggedIn;
|
||||
}),
|
||||
catchError(() => {
|
||||
return of(false);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
export enum FieldStatus {
|
||||
BASIC = 'basic',
|
||||
PRIMARY = 'primary',
|
||||
INFO = 'info',
|
||||
SUCCESS = 'success',
|
||||
WARNING = 'warning',
|
||||
DANGER = 'danger'
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
import { v4 as UUID } from 'uuid';
|
||||
|
||||
export class User {
|
||||
id: string;
|
||||
username: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
mailAddress: string;
|
||||
interfaceLang: string;
|
||||
|
||||
constructor(username?: string,
|
||||
firstName?: string,
|
||||
lastName?: string,
|
||||
email?: string,
|
||||
interfaceLang?: string) {
|
||||
this.id = UUID();
|
||||
this.username = username;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.mailAddress = email;
|
||||
this.interfaceLang = interfaceLang;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import {NotificationService, PopupType} from './notification.service';
|
||||
|
||||
export class NotificationServiceMock implements Required<NotificationService> {
|
||||
public showPopup(translationKey: string, popupType?: PopupType): void {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotificationService } from './notification.service';
|
||||
import {NbToastrModule, NbToastrService} from '@nebular/theme';
|
||||
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {HttpLoaderFactory} from '../../app/common-app.module';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {NgxsModule} from '@ngxs/store';
|
||||
import {SessionState} from '../stores/session-state/session-state';
|
||||
|
||||
describe('NotificationService', () => {
|
||||
let toastrServiceStub: Partial<NbToastrService>;
|
||||
let translateServiceStub: Partial<TranslateService>;
|
||||
let service: NotificationService;
|
||||
|
||||
toastrServiceStub = {
|
||||
show(): any {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
translateServiceStub = {
|
||||
get(): Observable<string | any> {
|
||||
return of(new Observable<string>());
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
HttpClientTestingModule,
|
||||
BrowserAnimationsModule,
|
||||
NbToastrModule,
|
||||
NgxsModule.forRoot([SessionState]),
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
NotificationService,
|
||||
{provide: NbToastrService, useValue: toastrServiceStub},
|
||||
{provide: TranslateService, useValue: translateServiceStub}]
|
||||
});
|
||||
service = TestBed.inject(NotificationService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,39 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {NbGlobalPhysicalPosition, NbToastrService} from '@nebular/theme';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NotificationService {
|
||||
|
||||
constructor(private toastrService: NbToastrService,
|
||||
private translateService: TranslateService) {
|
||||
}
|
||||
|
||||
public showPopup(translationKey: string, popupType: PopupType): void {
|
||||
// TODO: Eliminate subscriptions by using flattening operators
|
||||
this.translateService.get([popupType, translationKey])
|
||||
.subscribe((translationContainer) => {
|
||||
this.toastrService.show(
|
||||
'',
|
||||
translationContainer[popupType] + ' ' + translationContainer[translationKey], {
|
||||
position: NbGlobalPhysicalPosition.BOTTOM_RIGHT,
|
||||
duration: 5000,
|
||||
toastClass: createCssClassName(popupType)
|
||||
});
|
||||
});
|
||||
|
||||
function createCssClassName(type: PopupType): string {
|
||||
const currentType = type ? type : PopupType.INFO;
|
||||
return currentType.toString().replace('.', '-');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export enum PopupType {
|
||||
SUCCESS = 'popup.success',
|
||||
FAILURE = 'popup.failure',
|
||||
WARNING = 'popup.warning',
|
||||
INFO = 'popup.info'
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserService } from './user.service';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||
import {HttpLoaderFactory} from '../../app/common-app.module';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {NgxsModule} from '@ngxs/store';
|
||||
import {SessionState} from '../stores/session-state/session-state';
|
||||
|
||||
describe('UserService', () => {
|
||||
let service: UserService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
HttpClientTestingModule,
|
||||
BrowserAnimationsModule,
|
||||
NgxsModule.forRoot([SessionState]),
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
],
|
||||
providers: []
|
||||
});
|
||||
service = TestBed.inject(UserService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,26 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||
import {User} from '../models/user.model';
|
||||
import {Observable} from 'rxjs';
|
||||
import {Store} from '@ngxs/store';
|
||||
import {SessionState} from '../stores/session-state/session-state';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserService {
|
||||
|
||||
constructor(private http: HttpClient,
|
||||
private store: Store) {
|
||||
}
|
||||
|
||||
private static createHttpHeadersWithContentType(token: string): HttpHeaders {
|
||||
return new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
});
|
||||
}
|
||||
|
||||
getCurrentAuthenticatedUser(): Observable<User> {
|
||||
return this.store.select(SessionState.userAccount);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
import {User} from '../../models/user.model';
|
||||
|
||||
export class InitSession {
|
||||
static readonly type = '[Session] InitSession';
|
||||
}
|
||||
|
||||
// resetLocalUser
|
||||
export class ResetSession {
|
||||
static readonly type = '[Session] ResetSession';
|
||||
}
|
||||
|
||||
export class UpdateUser {
|
||||
static readonly type = '[Session] UpdateUser';
|
||||
|
||||
/**
|
||||
* Updates the current user-account, if user isn't equal!
|
||||
* @param user of type User (user can be null if no user is logged in)
|
||||
* @param force if update should be forced!
|
||||
*/
|
||||
constructor(public user: User, public force = false) {
|
||||
}
|
||||
}
|
||||
|
||||
// updateUserSpecificSettings
|
||||
export class UpdateUserSettings {
|
||||
static readonly type = '[Session] UpdateUserSettings';
|
||||
|
||||
constructor(public user: User) {
|
||||
}
|
||||
}
|
||||
|
||||
export class UpdateIsAuthenticated {
|
||||
static readonly type = '[Session] UpdateIsAuthenticated';
|
||||
|
||||
constructor(public authenticated: boolean) {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
import {NgxsModule, Store} from '@ngxs/store';
|
||||
import {fakeAsync, TestBed, tick} from '@angular/core/testing';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
|
||||
import {HttpLoaderFactory} from '../../../app/common-app.module';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {SESSION_STATE_NAME, SessionState, SessionStateModel} from './session-state';
|
||||
import {User} from '../../models/user.model';
|
||||
import {InitSession, UpdateUser} from './session-state.actions';
|
||||
|
||||
const INITIAL_STORE_STATE_SESSION: SessionStateModel = {
|
||||
userAccount: {
|
||||
...new User(),
|
||||
id: ''
|
||||
},
|
||||
isAuthenticated: false
|
||||
};
|
||||
|
||||
const DESIRED_STORE_STATE_SESSION: SessionStateModel = {
|
||||
userAccount: {
|
||||
...new User('ttt', 'test', 'user', 'default.user@test.de', 'en-US'),
|
||||
id: '11c47c56-3bcd-45f1-a05b-c197dbd33110'
|
||||
},
|
||||
isAuthenticated: true
|
||||
};
|
||||
|
||||
describe('SessionState', () => {
|
||||
let store: Store;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
HttpClientTestingModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useFactory: HttpLoaderFactory,
|
||||
deps: [HttpClient]
|
||||
}
|
||||
}),
|
||||
NgxsModule.forRoot([SessionState]),
|
||||
],
|
||||
providers: []
|
||||
});
|
||||
store = TestBed.inject(Store);
|
||||
store.reset({
|
||||
...store.snapshot(),
|
||||
[SESSION_STATE_NAME]: DESIRED_STORE_STATE_SESSION
|
||||
});
|
||||
});
|
||||
|
||||
it('should contain store for SESSION_STATE_NAME', (done) => {
|
||||
store.selectSnapshot(state => {
|
||||
expect(state[SESSION_STATE_NAME]).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('SelectorTests', () => {
|
||||
describe('userAccount', () => {
|
||||
it('should return userAccount', () => {
|
||||
const user = store.selectSnapshot(SessionState.userAccount);
|
||||
expect(user).toBeTruthy();
|
||||
});
|
||||
});
|
||||
describe('isAuthenticated', () => {
|
||||
it('should return isAuthenticated', () => {
|
||||
const isAuthenticated = store.selectSnapshot(SessionState.isAuthenticated);
|
||||
expect(isAuthenticated).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ActionTests', () => {
|
||||
describe('InitSessionState', () => {
|
||||
it('should initialize default state', () => {
|
||||
store.dispatch(new InitSession());
|
||||
const currentState = store.selectSnapshot(SessionState);
|
||||
expect(currentState).toBeTruthy();
|
||||
});
|
||||
});
|
||||
describe('UpdateUser', () => {
|
||||
it('should update user', fakeAsync(() => {
|
||||
const newUser = {
|
||||
...new User('ttt', 'test', 'user', 'default.user@test.de', 'en-US'),
|
||||
id: '11c47c56-3bcd-45f1-a05b-c197dbd33110'
|
||||
};
|
||||
store.dispatch(new UpdateUser(newUser));
|
||||
tick();
|
||||
const currentUser = store.selectSnapshot(SessionState.userAccount);
|
||||
expect(currentUser).toEqual(newUser);
|
||||
}));
|
||||
it('should force update user', fakeAsync(() => {
|
||||
const newUser = {
|
||||
...new User('ttt', 'test', 'user', 'default.user@test.de', 'en-US'),
|
||||
id: '11c47c56-3bcd-45f1-a05b-c197dbd33110'
|
||||
};
|
||||
store.dispatch(new UpdateUser(newUser, true));
|
||||
tick();
|
||||
const currentUser = store.selectSnapshot(SessionState.userAccount);
|
||||
expect(currentUser).toEqual(newUser);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,95 @@
|
|||
import {User} from '../../models/user.model';
|
||||
import {Inject, Injectable, LOCALE_ID} from '@angular/core';
|
||||
import {Action, Selector, State, StateContext} from '@ngxs/store';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {InitSession, ResetSession, UpdateIsAuthenticated, UpdateUser, UpdateUserSettings} from './session-state.actions';
|
||||
import deepEqual from 'deep-equal';
|
||||
import moment from 'moment';
|
||||
|
||||
export interface SessionStateModel {
|
||||
userAccount: User;
|
||||
isAuthenticated: boolean;
|
||||
}
|
||||
|
||||
export const SESSION_STATE_NAME = 'session';
|
||||
export const SESSION_STORAGE_KEY_USER = 'user';
|
||||
|
||||
@State<SessionStateModel>({
|
||||
name: SESSION_STATE_NAME,
|
||||
defaults: {
|
||||
userAccount: null,
|
||||
isAuthenticated: false
|
||||
}
|
||||
})
|
||||
@Injectable()
|
||||
export class SessionState {
|
||||
constructor(@Inject(LOCALE_ID) private readonly localeId: string,
|
||||
private readonly translateService: TranslateService) {
|
||||
}
|
||||
|
||||
@Selector()
|
||||
static userAccount(state: SessionStateModel): User {
|
||||
return state.userAccount;
|
||||
}
|
||||
|
||||
@Selector()
|
||||
static isAuthenticated(state: SessionStateModel): boolean {
|
||||
return state.isAuthenticated;
|
||||
}
|
||||
|
||||
@Action(InitSession)
|
||||
initSessionState(ctx: StateContext<SessionStateModel>): void {
|
||||
ctx.setState({
|
||||
userAccount: null,
|
||||
isAuthenticated: false
|
||||
});
|
||||
}
|
||||
|
||||
@Action(ResetSession)
|
||||
resetSession(ctx: StateContext<SessionStateModel>): void {
|
||||
this.deleteSessionStorage();
|
||||
ctx.dispatch(new InitSession());
|
||||
}
|
||||
|
||||
@Action(UpdateUser)
|
||||
updateUser(ctx: StateContext<SessionStateModel>, {user, force}: UpdateUser): void {
|
||||
const state = ctx.getState();
|
||||
if (force || !deepEqual(user, state.userAccount)) {
|
||||
ctx.patchState({
|
||||
userAccount: user
|
||||
});
|
||||
// write to sessionStorage
|
||||
this.setSessionStorage(user);
|
||||
ctx.dispatch(new UpdateUserSettings(user));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Should be connected KeyCloak
|
||||
@Action(UpdateIsAuthenticated)
|
||||
updateIsAuthenticated(ctx: StateContext<SessionStateModel>, {authenticated}: UpdateIsAuthenticated): void {
|
||||
ctx.patchState({isAuthenticated: authenticated});
|
||||
}
|
||||
|
||||
@Action(UpdateUserSettings)
|
||||
updateUserSettings(ctx: StateContext<SessionStateModel>, {user}: UpdateUserSettings): void {
|
||||
if (user) {
|
||||
if (user.interfaceLang) {
|
||||
const newLanguage = user.interfaceLang;
|
||||
this.translateService.use(newLanguage);
|
||||
moment.locale(newLanguage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private setSessionStorage(user: User): void {
|
||||
// TODO: https://www.ngxs.io/plugins/storage
|
||||
if (user) {
|
||||
sessionStorage.setItem(SESSION_STORAGE_KEY_USER, JSON.stringify(user));
|
||||
}
|
||||
}
|
||||
|
||||
private deleteSessionStorage(): void {
|
||||
// TODO: https://www.ngxs.io/plugins/storage
|
||||
sessionStorage.removeItem(SESSION_STORAGE_KEY_USER);
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
@import 'themes';
|
||||
|
||||
@import '~@nebular/theme/styles/globals';
|
||||
|
||||
@include nb-install() {
|
||||
@include nb-theme-global();
|
||||
};
|
||||
/* You can add global styles to this file, and also import other style files */
|
|
@ -1,18 +0,0 @@
|
|||
@import '~@nebular/theme/styles/theming';
|
||||
@import '~@nebular/theme/styles/themes/corporate';
|
||||
|
||||
$nb-themes: nb-register-theme((
|
||||
|
||||
// add your variables here like:
|
||||
|
||||
// color-primary-100: #f2f6ff,
|
||||
// color-primary-200: #d9e4ff,
|
||||
// color-primary-300: #a6c1ff,
|
||||
// color-primary-400: #598bff,
|
||||
// color-primary-500: #3366ff,
|
||||
// color-primary-600: #274bdb,
|
||||
// color-primary-700: #1a34b8,
|
||||
// color-primary-800: #102694,
|
||||
// color-primary-900: #091c7a,
|
||||
|
||||
), corporate, corporate);
|
|
@ -8,6 +8,7 @@
|
|||
"declaration": false,
|
||||
"downlevelIteration": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"moduleResolution": "node",
|
||||
"importHelpers": true,
|
||||
"target": "es2015",
|
||||
|
@ -15,6 +16,10 @@
|
|||
"lib": [
|
||||
"es2018",
|
||||
"dom"
|
||||
]
|
||||
],
|
||||
"paths": {
|
||||
"@shared/*": ["./src/app/shared/*"],
|
||||
"@assets/*": ["./src/assets/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue