Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: admin dashboard #201

Merged
merged 10 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions apps/picsa-apps/dashboard-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": ["plugin:cypress/recommended", "../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {
"@angular-eslint/component-selector": ["off"],
"@angular-eslint/component-class-suffix": ["off"]
}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.cy.{ts,js,tsx,jsx}", "src/**/*.{ts,js,tsx,jsx}"],
"rules": {}
}
]
}
6 changes: 6 additions & 0 deletions apps/picsa-apps/dashboard-e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: nxE2EPreset(__filename, { cypressDir: 'src' }),
});
33 changes: 33 additions & 0 deletions apps/picsa-apps/dashboard-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "picsa-apps-dashboard-e2e",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/picsa-apps/dashboard-e2e/src",
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/picsa-apps/dashboard-e2e/cypress.config.ts",
"testingType": "e2e",
"devServerTarget": "picsa-apps-dashboard:serve:development"
},
"configurations": {
"production": {
"devServerTarget": "picsa-apps-dashboard:serve:production"
},
"ci": {
"devServerTarget": "picsa-apps-dashboard:serve-static"
}
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/picsa-apps/dashboard-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["picsa-apps-dashboard"]
}
13 changes: 13 additions & 0 deletions apps/picsa-apps/dashboard-e2e/src/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getGreeting } from '../support/app.po';

describe('picsa-apps-dashboard-e2e', () => {
beforeEach(() => cy.visit('/'));

it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('[email protected]', 'myPassword');

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains(/Welcome/);
});
});
5 changes: 5 additions & 0 deletions apps/picsa-apps/dashboard-e2e/src/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
1 change: 1 addition & 0 deletions apps/picsa-apps/dashboard-e2e/src/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getGreeting = () => cy.get('h1');
35 changes: 35 additions & 0 deletions apps/picsa-apps/dashboard-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// <reference types="cypress" />

// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}

// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
17 changes: 17 additions & 0 deletions apps/picsa-apps/dashboard-e2e/src/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.ts using ES2015 syntax:
import './commands';
17 changes: 17 additions & 0 deletions apps/picsa-apps/dashboard-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"types": ["cypress", "node"],
"sourceMap": false,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": ["**/*.ts", "**/*.js", "cypress.config.ts", "**/*.cy.ts", "**/*.cy.js", "**/*.d.ts"]
}
35 changes: 35 additions & 0 deletions apps/picsa-apps/dashboard/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"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": "dashboard",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "dashboard",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {
"@angular-eslint/template/prefer-control-flow": ["error"]
}
}
]
}
14 changes: 14 additions & 0 deletions apps/picsa-apps/dashboard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## PICSA Dashboard

## Code Style

The project is built on top of Angular 17. Within this app modern angular practices should be adopted,
this includes use of standalone components, signals and new control flow syntax (e.g. `@if()` instead of `*ngIf`)

https://blog.angular.io/introducing-angular-v17-4d7033312e4b

https://angular.dev/

Some conventions are enforced using lint rules defined in [.eslintrc.json](./.eslintrc.json)

https://github.com/angular-eslint/angular-eslint/tree/main/packages/eslint-plugin-template
22 changes: 22 additions & 0 deletions apps/picsa-apps/dashboard/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'picsa-apps-dashboard',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../../coverage/apps/picsa-apps/dashboard',
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',
],
};
91 changes: 91 additions & 0 deletions apps/picsa-apps/dashboard/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"name": "picsa-apps-dashboard",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"prefix": "app",
"sourceRoot": "apps/picsa-apps/dashboard/src",
"tags": [],
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:application",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/picsa-apps/dashboard",
"index": "apps/picsa-apps/dashboard/src/index.html",
"browser": "apps/picsa-apps/dashboard/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/picsa-apps/dashboard/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": ["apps/picsa-apps/dashboard/src/favicon.ico", "apps/picsa-apps/dashboard/src/assets"],
"styles": ["apps/picsa-apps/dashboard/src/styles.scss"],
"stylePreprocessorOptions": {
"includePaths": ["libs/theme/src"]
},

"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "picsa-apps-dashboard:build:production"
},
"development": {
"buildTarget": "picsa-apps-dashboard:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "picsa-apps-dashboard:build"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/picsa-apps/dashboard/**/*.ts", "apps/picsa-apps/dashboard/**/*.html"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/picsa-apps/dashboard/jest.config.ts"
}
},
"serve-static": {
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "picsa-apps-dashboard:build",
"staticFilePath": "dist/apps/picsa-apps/dashboard/browser"
}
}
}
}
38 changes: 38 additions & 0 deletions apps/picsa-apps/dashboard/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<div class="page">
<mat-toolbar color="primary" class="mat-elevation-z2" style="display: flex; align-items: center">
<button mat-icon-button (click)="sidenav.opened = !sidenav.opened">
<mat-icon>menu</mat-icon>
</button>
<span style="flex: 1">PICSA Dashboard</span>
@if(supabaseService.authUser(); as user){
<div style="position: relative">
<button mat-button (click)="supabaseService.signOut()" style="margin-top: 16px">
<mat-icon>person</mat-icon>
Sign Out
</button>
<div style="position: absolute; top: 4px; right: 0; font-size: 12px">
{{ user.email }}
</div>
</div>

} @else {
<button mat-button (click)="supabaseService.signInPrompt()" style="margin: 8px 0">
<mat-icon>person</mat-icon>
Sign In
</button>
}
</mat-toolbar>

<mat-sidenav-container style="flex: 1">
<mat-sidenav #sidenav mode="side" opened [fixedInViewport]="true" fixedTopGap="48">
<mat-nav-list>
@for (link of navLinks; track link.href) {
<a mat-list-item [routerLink]="link.href" routerLinkActive="mdc-list-item--activated">{{ link.label }}</a>
}
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<router-outlet></router-outlet>
</mat-sidenav-content>
</mat-sidenav-container>
</div>
13 changes: 13 additions & 0 deletions apps/picsa-apps/dashboard/src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mat-sidenav {
width: 256px;
}
mat-nav-list {
--mdc-list-list-item-one-line-container-height: 48px;
}
mat-toolbar {
z-index: 2;
}
mat-sidenav-content {
display: flex;
flex-direction: column;
}
Loading
Loading