Skip to content

Commit 0f5fd05

Browse files
Statisctics app + service refactorization (#142)
* Added new application that will be used for statistics from various services. * Serfice refactorization to reduce the dependencies.
1 parent 5933bef commit 0f5fd05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+41687
-248
lines changed

angular.json

Lines changed: 159 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,7 @@
365365
"apps/admin-gui/src/styles.scss",
366366
"./node_modules/bootstrap/dist/css/bootstrap.css"
367367
],
368-
"scripts": [
369-
"./node_modules/tinycolor2/dist/tinycolor-min.js"
370-
]
368+
"scripts": ["./node_modules/tinycolor2/dist/tinycolor-min.js"]
371369
},
372370
"configurations": {
373371
"production": {
@@ -486,6 +484,164 @@
486484
}
487485
},
488486
"schematics": {}
487+
},
488+
"statistics": {
489+
"projectType": "application",
490+
"schematics": {
491+
"@nrwl/angular:component": {
492+
"style": "scss"
493+
}
494+
},
495+
"root": "apps/statistics",
496+
"sourceRoot": "apps/statistics/src",
497+
"prefix": "perun-web-apps",
498+
"architect": {
499+
"build": {
500+
"builder": "@angular-devkit/build-angular:browser",
501+
"options": {
502+
"outputPath": "dist/apps/statistics",
503+
"index": "apps/statistics/src/index.html",
504+
"main": "apps/statistics/src/main.ts",
505+
"polyfills": "apps/statistics/src/polyfills.ts",
506+
"tsConfig": "apps/statistics/tsconfig.app.json",
507+
"aot": false,
508+
"assets": [
509+
"apps/statistics/src/favicon.ico",
510+
"apps/statistics/src/assets"
511+
],
512+
"styles": [
513+
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
514+
"apps/statistics/src/styles.scss",
515+
"./node_modules/bootstrap/dist/css/bootstrap.css"
516+
],
517+
"scripts": []
518+
},
519+
"configurations": {
520+
"production": {
521+
"fileReplacements": [
522+
{
523+
"replace": "apps/statistics/src/environments/environment.ts",
524+
"with": "apps/statistics/src/environments/environment.prod.ts"
525+
}
526+
],
527+
"optimization": true,
528+
"outputHashing": "all",
529+
"sourceMap": false,
530+
"extractCss": true,
531+
"namedChunks": false,
532+
"aot": true,
533+
"extractLicenses": true,
534+
"vendorChunk": false,
535+
"buildOptimizer": true,
536+
"budgets": [
537+
{
538+
"type": "initial",
539+
"maximumWarning": "2mb",
540+
"maximumError": "5mb"
541+
},
542+
{
543+
"type": "anyComponentStyle",
544+
"maximumWarning": "6kb",
545+
"maximumError": "10kb"
546+
}
547+
]
548+
}
549+
}
550+
},
551+
"serve": {
552+
"builder": "@angular-devkit/build-angular:dev-server",
553+
"options": {
554+
"browserTarget": "statistics:build"
555+
},
556+
"configurations": {
557+
"production": {
558+
"browserTarget": "statistics:build:production"
559+
}
560+
}
561+
},
562+
"extract-i18n": {
563+
"builder": "@angular-devkit/build-angular:extract-i18n",
564+
"options": {
565+
"browserTarget": "statistics:build"
566+
}
567+
},
568+
"lint": {
569+
"builder": "@angular-devkit/build-angular:tslint",
570+
"options": {
571+
"tsConfig": [
572+
"apps/statistics/tsconfig.app.json",
573+
"apps/statistics/tsconfig.spec.json"
574+
],
575+
"exclude": ["**/node_modules/**", "!apps/statistics/**"]
576+
}
577+
},
578+
"test": {
579+
"builder": "@nrwl/jest:jest",
580+
"options": {
581+
"jestConfig": "apps/statistics/jest.config.js",
582+
"tsConfig": "apps/statistics/tsconfig.spec.json",
583+
"setupFile": "apps/statistics/src/test-setup.ts"
584+
}
585+
}
586+
}
587+
},
588+
"statistics-e2e": {
589+
"root": "apps/statistics-e2e",
590+
"sourceRoot": "apps/statistics-e2e/src",
591+
"projectType": "application",
592+
"architect": {
593+
"e2e": {
594+
"builder": "@nrwl/cypress:cypress",
595+
"options": {
596+
"cypressConfig": "apps/statistics-e2e/cypress.json",
597+
"tsConfig": "apps/statistics-e2e/tsconfig.e2e.json",
598+
"devServerTarget": "statistics:serve"
599+
},
600+
"configurations": {
601+
"production": {
602+
"devServerTarget": "statistics:serve:production"
603+
}
604+
}
605+
},
606+
"lint": {
607+
"builder": "@angular-devkit/build-angular:tslint",
608+
"options": {
609+
"tsConfig": ["apps/statistics-e2e/tsconfig.e2e.json"],
610+
"exclude": ["**/node_modules/**", "!apps/statistics-e2e/**"]
611+
}
612+
}
613+
}
614+
},
615+
"config": {
616+
"projectType": "library",
617+
"root": "libs/config",
618+
"sourceRoot": "libs/config/src",
619+
"prefix": "perun-web-apps",
620+
"architect": {
621+
"lint": {
622+
"builder": "@angular-devkit/build-angular:tslint",
623+
"options": {
624+
"tsConfig": [
625+
"libs/config/tsconfig.lib.json",
626+
"libs/config/tsconfig.spec.json"
627+
],
628+
"exclude": ["**/node_modules/**", "!libs/config/**"]
629+
}
630+
},
631+
"test": {
632+
"builder": "@nrwl/jest:jest",
633+
"options": {
634+
"jestConfig": "libs/config/jest.config.js",
635+
"tsConfig": "libs/config/tsconfig.spec.json",
636+
"setupFile": "libs/config/src/test-setup.ts"
637+
}
638+
}
639+
},
640+
"schematics": {
641+
"@nrwl/angular:component": {
642+
"styleext": "scss"
643+
}
644+
}
489645
}
490646
},
491647
"cli": {

apps/admin-gui/src/app/core/services/common/admin-gui-config.service.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import { Injectable } from '@angular/core';
22
import {
3-
AppConfigService,
4-
ColorConfig,
5-
EntityColorConfig
3+
InitAuthService,
64
} from '@perun-web-apps/perun/services';
5+
import { AppConfigService, ColorConfig, EntityColorConfig } from '@perun-web-apps/config';
76

87

98
@Injectable({
109
providedIn: 'root'
1110
})
1211
export class AdminGuiConfigService {
1312

14-
constructor(private appConfigService:AppConfigService) {}
13+
constructor(
14+
private initAuthService: InitAuthService,
15+
private appConfigService: AppConfigService
16+
) {}
1517

1618
entityColorConfigs: EntityColorConfig[] = [
1719
{
@@ -74,7 +76,7 @@ export class AdminGuiConfigService {
7476
return this.appConfigService.loadAppDefaultConfig()
7577
.then(() => this.appConfigService.loadAppInstanceConfig())
7678
.then(() => this.appConfigService.initializeColors(this.entityColorConfigs, this.colorConfigs))
77-
.then(() => this.appConfigService.authenticateUser())
78-
.then(() => this.appConfigService.loadPrincipal());
79+
.then(() => this.initAuthService.authenticateUser())
80+
.then(() => this.initAuthService.loadPrincipal());
7981
}
8082
}

apps/statistics-e2e/cypress.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"fileServerFolder": ".",
3+
"fixturesFolder": "./src/fixtures",
4+
"integrationFolder": "./src/integration",
5+
"modifyObstructiveCode": false,
6+
"pluginsFile": "./src/plugins/index",
7+
"supportFile": "./src/support/index.ts",
8+
"video": true,
9+
"videosFolder": "../../dist/cypress/apps/statistics-e2e/videos",
10+
"screenshotsFolder": "../../dist/cypress/apps/statistics-e2e/screenshots",
11+
"chromeWebSecurity": false
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]"
4+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { getGreeting } from '../support/app.po';
2+
3+
describe('statistics', () => {
4+
beforeEach(() => cy.visit('/'));
5+
6+
it('should display welcome message', () => {
7+
// Custom command example, see `../support/commands.ts` file
8+
cy.login('[email protected]', 'myPassword');
9+
10+
// Function helper example, see `../support/app.po.ts` file
11+
getGreeting().contains('Welcome to statistics!');
12+
});
13+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// ***********************************************************
2+
// This example plugins/index.js can be used to load plugins
3+
//
4+
// You can change the location of this file or turn off loading
5+
// the plugins file with the 'pluginsFile' configuration option.
6+
//
7+
// You can read more here:
8+
// https://on.cypress.io/plugins-guide
9+
// ***********************************************************
10+
11+
// This function is called when a project is opened or re-opened (e.g. due to
12+
// the project's config changing)
13+
14+
const { preprocessTypescript } = require('@nrwl/cypress/plugins/preprocessor');
15+
16+
module.exports = (on, config) => {
17+
// `on` is used to hook into various events Cypress emits
18+
// `config` is the resolved Cypress config
19+
20+
// Preprocess Typescript
21+
on('file:preprocessor', preprocessTypescript(config));
22+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const getGreeting = () => cy.get('h1');
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
// eslint-disable-next-line @typescript-eslint/no-namespace
11+
declare namespace Cypress {
12+
interface Chainable<Subject> {
13+
login(email: string, password: string): void;
14+
}
15+
}
16+
//
17+
// -- This is a parent command --
18+
Cypress.Commands.add('login', (email, password) => {
19+
console.log('Custom command example: Login', email, password);
20+
});
21+
//
22+
// -- This is a child command --
23+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
24+
//
25+
//
26+
// -- This is a dual command --
27+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
28+
//
29+
//
30+
// -- This will overwrite an existing command --
31+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands';

apps/statistics-e2e/tsconfig.e2e.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"sourceMap": false,
5+
"outDir": "../../dist/out-tsc"
6+
},
7+
"include": ["src/**/*.ts", "src/**/*.js"]
8+
}

apps/statistics-e2e/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"types": ["cypress", "node"]
5+
},
6+
"include": ["**/*.ts", "**/*.js"]
7+
}

apps/statistics-e2e/tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "extends": "../../tslint.json", "rules": {} }

apps/statistics/browserslist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# You can see what browsers were selected by your queries by running:
6+
# npx browserslist
7+
8+
> 0.5%
9+
last 2 versions
10+
Firefox ESR
11+
not dead
12+
not IE 9-11 # For IE 9-11 support, remove 'not'.

apps/statistics/jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
name: 'statistics',
3+
preset: '../../jest.config.js',
4+
coverageDirectory: '../../coverage/apps/statistics',
5+
snapshotSerializers: [
6+
'jest-preset-angular/AngularSnapshotSerializer.js',
7+
'jest-preset-angular/HTMLCommentSerializer.js'
8+
]
9+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { RouterModule, Routes } from '@angular/router';
4+
import { HomePageComponent } from './pages/home-page/home-page.component';
5+
6+
const routes: Routes = [
7+
{
8+
path: '',
9+
component: HomePageComponent
10+
}
11+
];
12+
13+
@NgModule({
14+
imports: [
15+
RouterModule.forRoot(routes),
16+
CommonModule
17+
],
18+
exports: [RouterModule]
19+
})
20+
export class AppRoutingModule { }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<router-outlet></router-outlet>

apps/statistics/src/app/app.component.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)