Skip to content

Commit

Permalink
add browser extension
Browse files Browse the repository at this point in the history
Signed-off-by: Mirko Mollik <[email protected]>
  • Loading branch information
Mirko Mollik committed May 8, 2024
1 parent 8b065c5 commit c11b0d3
Show file tree
Hide file tree
Showing 51 changed files with 1,551 additions and 3 deletions.
22 changes: 22 additions & 0 deletions apps/holder-browser-extension-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": ["plugin:playwright/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["src/**/*.{ts,js,tsx,jsx}"],
"rules": {}
}
]
}
69 changes: 69 additions & 0 deletions apps/holder-browser-extension-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { defineConfig, devices } from '@playwright/test';
import { nxE2EPreset } from '@nx/playwright/preset';

import { workspaceRoot } from '@nx/devkit';

// For CI, you may want to set BASE_URL to the deployed application.
const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
...nxE2EPreset(__filename, { testDir: './src' }),
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Run your local dev server before starting the tests */
webServer: {
command: 'pnpm exec nx serve holder-browser-extension',
url: 'http://localhost:4200',
reuseExistingServer: !process.env.CI,
cwd: workspaceRoot,
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

// Uncomment for mobile browsers support
/* {
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
}, */

// Uncomment for branded browsers
/* {
name: 'Microsoft Edge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
},
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
} */
],
});
9 changes: 9 additions & 0 deletions apps/holder-browser-extension-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "holder-browser-extension-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/holder-browser-extension-e2e/src",
"implicitDependencies": ["holder-browser-extension"],
"// targets": "to see all targets run: nx show project holder-browser-extension-e2e --web",
"targets": {}
}
8 changes: 8 additions & 0 deletions apps/holder-browser-extension-e2e/src/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
await page.goto('/');

// Expect h1 to contain a substring.
expect(await page.locator('h1').innerText()).toContain('Welcome');
});
25 changes: 25 additions & 0 deletions apps/holder-browser-extension-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"sourceMap": false,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"**/*.ts",
"**/*.js",
"playwright.config.ts",
"src/**/*.spec.ts",
"src/**/*.spec.js",
"src/**/*.test.ts",
"src/**/*.test.js",
"src/**/*.d.ts"
]
}
36 changes: 36 additions & 0 deletions apps/holder-browser-extension/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
22 changes: 22 additions & 0 deletions apps/holder-browser-extension/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'holder-browser-extension',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/apps/holder-browser-extension',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
77 changes: 77 additions & 0 deletions apps/holder-browser-extension/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"name": "holder-browser-extension",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"prefix": "app",
"sourceRoot": "apps/holder-browser-extension/src",
"tags": [],
"targets": {
"build": {
"executor": "@nx/angular:webpack-browser",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/holder-browser-extension",
"index": "apps/holder-browser-extension/src/index.html",
"main": "apps/holder-browser-extension/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/holder-browser-extension/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"apps/holder-browser-extension/src/favicon.ico",
"apps/holder-browser-extension/src/assets",
"apps/holder-browser-extension/src/manifest.json"
],
"styles": [
"apps/holder-browser-extension/src/styles.scss",
"apps/holder-browser-extension/src/theme.scss"
],
"scripts": [],
"customWebpackConfig": {
"path": "apps/holder-browser-extension/webpack.config.js"
}
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "none"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "holder-browser-extension:build"
}
},
"lint": {
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/holder-browser-extension/jest.config.ts"
}
}
}
}
33 changes: 33 additions & 0 deletions apps/holder-browser-extension/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="content">
<router-outlet></router-outlet>
</div>
<mat-toolbar
*ngIf="isAuthenticated"
fxLayout="row"
fxLayoutAlign="space-between center"
>
<div fxLayout="column" fxLayoutAlign=" center">
<a mat-icon-button routerLink="/scan" routerLinkActive="active-link"
><mat-icon>qr_code_scanner</mat-icon></a
>
<span class="info">scan</span>
</div>
<div fxLayout="column" fxLayoutAlign=" center">
<a mat-icon-button routerLink="/credentials" routerLinkActive="active-link"
><mat-icon>account_balance_wallet</mat-icon></a
>
<span class="info">credentials</span>
</div>
<div fxLayout="column" fxLayoutAlign=" center">
<a mat-icon-button routerLink="/history" routerLinkActive="active-link"
><mat-icon>history</mat-icon></a
>
<span class="info">History</span>
</div>
<div fxLayout="column" fxLayoutAlign=" center">
<a mat-icon-button routerLink="/settings" routerLinkActive="active-link"
><mat-icon>settings</mat-icon></a
>
<span class="info">settings</span>
</div>
</mat-toolbar>
20 changes: 20 additions & 0 deletions apps/holder-browser-extension/src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.mat-toolbar {
background-color: #D7E3FF;
padding: 10px 40px;
height: 84px;
position: fixed;
bottom: 0px;
}

.content {
height: calc(100vh - 84px);
overflow: auto;
width: 100%;
padding-bottom: 84px;
}


.info {
font-size: 14px;
}

16 changes: 16 additions & 0 deletions apps/holder-browser-extension/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppComponent],
}).compileComponents();
});

it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
});
37 changes: 37 additions & 0 deletions apps/holder-browser-extension/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatButtonModule } from '@angular/material/button';
import { FlexLayoutModule } from 'ng-flex-layout';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { AuthService } from './auth/auth.service';

@Component({
selector: 'app-root',
standalone: true,
imports: [
CommonModule,
RouterOutlet,
RouterLink,
RouterLinkActive,
MatToolbarModule,
MatButtonModule,
MatIconModule,
FlexLayoutModule,
MatMenuModule,
],
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
})
export class AppComponent implements OnInit {
isAuthenticated = false;
constructor(public authService: AuthService) {}

ngOnInit(): void {
this.authService.changed.subscribe((isAuthenticated) => {
this.isAuthenticated = isAuthenticated;
});
}
}
Loading

0 comments on commit c11b0d3

Please sign in to comment.