Compare commits

..

18 Commits

Author SHA1 Message Date
bebdbcaacc update package lock
All checks were successful
continuous-integration/drone/push Build is passing
2025-03-23 15:53:08 +01:00
e124b8b62c Merge remote-tracking branch 'origin/renovate/jasmine-core-5.x'
Some checks failed
continuous-integration/drone/push Build is failing
2025-03-23 15:37:26 +01:00
96c1bc3c46 Merge branch 'renovate/typescript-eslint-parser-7.x'
Some checks failed
continuous-integration/drone/push Build was killed
2025-03-23 15:37:09 +01:00
9cb3467b2a Merge pull request 'Update dependency @typescript-eslint/eslint-plugin to v7.18.0' (!2) from renovate/typescript-eslint-eslint-plugin-7.x into main
Some checks failed
continuous-integration/drone/push Build was killed
Reviewed-on: #2
2025-03-23 15:34:20 +01:00
cd74e79efd Update dependency jasmine-core to ~5.6.0 2025-03-23 13:28:24 +00:00
5663048b79 Update dependency @typescript-eslint/parser to v7.18.0
Some checks failed
continuous-integration/drone/pr Build is failing
2025-03-23 12:27:34 +00:00
f188a34e7d Update dependency @typescript-eslint/eslint-plugin to v7.18.0
Some checks failed
continuous-integration/drone/pr Build is failing
2025-03-23 11:29:59 +00:00
25e998041c Merge pull request 'Configure Renovate' (!1) from renovate/configure into main
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #1
2025-03-23 11:58:38 +01:00
a91b06213c Add renovate.json
Some checks failed
continuous-integration/drone/pr Build is failing
2025-03-22 23:13:13 +00:00
1c82e15d28 use node 20
All checks were successful
continuous-integration/drone/push Build is passing
2025-03-09 01:31:22 +01:00
12a0b2b1a3 fix code scan
All checks were successful
continuous-integration/drone/push Build is passing
2025-03-09 01:29:59 +01:00
86cd25435e workaround for aarch64
Some checks failed
continuous-integration/drone/push Build is failing
2025-03-09 01:25:59 +01:00
64b8d3e32a use official sonar image
Some checks failed
continuous-integration/drone/push Build is failing
2025-03-09 01:21:15 +01:00
b28915a3a6 fix sonar-scanner
Some checks failed
continuous-integration/drone/push Build is failing
2025-03-09 01:18:35 +01:00
0e16025d56 disable tests
Some checks failed
continuous-integration/drone/push Build is failing
2025-03-09 01:16:24 +01:00
7e4fee5a05 implement drone
Some checks failed
continuous-integration/drone/push Build was killed
2025-03-09 01:14:22 +01:00
1bb4d1d134 RLH-12 | Implement username changing 2024-11-04 11:25:19 +01:00
c4e8e7483a RLH-18 | Implement Account rename APIs 2024-11-04 11:24:14 +01:00
24 changed files with 1756 additions and 42 deletions

61
.drone.yml Normal file
View File

@@ -0,0 +1,61 @@
kind: pipeline
type: docker
name: build
platform:
os: linux
arch: arm64
trigger:
branch:
- main
event:
- push
- pull_request
steps:
# Install project dependencies
- name: install
image: node:20-alpine
commands:
- npm ci
# Build the Angular project
- name: build
image: node:20-alpine
commands:
- npm run build --if-present
# Run unit tests (e.g. using Karma, Jest or your configured test runner)
# - name: test
# image: node:20-alpine
# commands:
# - npm test
# Run SonarQube code analysis
- name: code-analysis
image: openjdk:11-jre-slim
commands:
# Update package lists and install dependencies for Node.js
- apt-get update && apt-get install -y curl gnupg wget unzip
# Install Node.js (e.g., version 18) using Nodesource setup script
- curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
- apt-get install -y nodejs
# Verify Node.js is installed
- node -v
- npm -v
# Download the SonarScanner CLI zip (adjust the version as needed)
- wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-7.0.2.4839-linux-aarch64.zip -O sonar-scanner.zip
# Unzip it to /opt
- unzip sonar-scanner.zip -d /opt/
- rm sonar-scanner.zip
# Add sonar-scanner to the PATH (the folder name may vary with version)
- export PATH=/opt/sonar-scanner-7.0.2.4839-linux-aarch64/bin:$PATH
# Run the scanner
- sonar-scanner -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.sources=. -Dsonar.host.url=$SONAR_INSTANCE_URL -Dsonar.token=$SONAR_LOGIN_KEY
environment:
SONAR_PROJECT_KEY:
from_secret: sonar_project_key
SONAR_INSTANCE_URL:
from_secret: sonar_instance_url
SONAR_LOGIN_KEY:
from_secret: sonar_login_key

48
.eslintrc.json Normal file
View File

@@ -0,0 +1,48 @@
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@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:@angular-eslint/template/recommended",
"plugin:@angular-eslint/template/accessibility"
],
"rules": {}
}
]
}

3
.gitignore vendored
View File

@@ -40,3 +40,6 @@ testem.log
# System files
.DS_Store
Thumbs.db
.nx/cache
.nx/workspace-data

View File

@@ -102,8 +102,22 @@
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
]
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
}
}
}
}
},
"cli": {
"schematicCollections": [
"@angular-eslint/schematics"
]
}
}

1490
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,8 @@
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
"test": "ng test",
"lint": "ng lint"
},
"private": true,
"dependencies": {
@@ -31,11 +32,19 @@
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.3.11",
"@angular-eslint/builder": "17.5.3",
"@angular-eslint/eslint-plugin": "17.5.3",
"@angular-eslint/eslint-plugin-template": "17.5.3",
"@angular-eslint/schematics": "17.5.3",
"@angular-eslint/template-parser": "17.5.3",
"@angular/cli": "^17.3.11",
"@angular/compiler-cli": "^17.3.0",
"@angular/localize": "^17.3.0",
"@types/jasmine": "~5.1.0",
"jasmine-core": "~5.1.0",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"eslint": "^8.57.0",
"jasmine-core": "~5.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",

3
renovate.json Normal file
View File

@@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}

View File

@@ -1,6 +1,6 @@
import {HTTP_INTERCEPTORS} from "@angular/common/http";
import {AuthInterceptorService} from "./services/auth-interceptor.service";
import {AfterViewChecked, AfterViewInit, Component, OnInit} from "@angular/core";
import {Component} from "@angular/core";
import {RouterOutlet} from "@angular/router";
import {LoginComponent} from "./views/login/login.component";
import {ApiService} from "./services/api.service";

View File

@@ -1,8 +1,8 @@
import {ApplicationConfig} from '@angular/core';
import {provideRouter, provideRoutes, withComponentInputBinding} from '@angular/router';
import {provideRouter} from '@angular/router';
import {routes} from './app.routes';
import {provideHttpClient, withInterceptors, withInterceptorsFromDi} from "@angular/common/http";
import {provideHttpClient, withInterceptorsFromDi} from "@angular/common/http";
import {httpInterceptorProviders} from "./app.component";
export const appConfig: ApplicationConfig = {

View File

@@ -1,7 +1,10 @@
<button
<ng-container *ngIf="!!button.visible && button.visible()">
<button
type="button"
class="m-1 {{classes}}"
[disabled]="isDisabled()"
(click)="button.click()">
{{ button.text }}
</button>
</button>
</ng-container>

View File

@@ -1,10 +1,13 @@
import {Component, Input, OnInit} from '@angular/core';
import {ButtonModel, ButtonType} from "./models/button.model";
import {NgIf} from "@angular/common";
@Component({
selector: 'rlh-button',
standalone: true,
imports: [],
imports: [
NgIf
],
templateUrl: './button.component.html',
styleUrl: './button.component.scss'
})
@@ -14,6 +17,7 @@ export class ButtonComponent implements OnInit
@Input() button: ButtonModel = {
text: 'text',
disabled: () => false,
visible: () => true,
click: () => {},
type: ButtonType.PRIMARY
};
@@ -26,12 +30,16 @@ export class ButtonComponent implements OnInit
this.button.disabled = this.button.disabled
? this.button.disabled
: () => false;
//
setTimeout(() => {
this.isDisabled = () => {
return this.button.disabled();
};
});
this.button.visible =
this.button.visible ?
this.button.visible : () => true;
}
get classes(): string {

View File

@@ -3,9 +3,17 @@ export class ButtonModel {
type: ButtonType;
disabled: () => boolean;
click: () => void;
visible?: () => boolean;
}
export enum ButtonType {
LINK = "btn-link",
PRIMARY = "btn-primary",
SECONDARY = "btn-secondary",
SUCCESS = "btn-success",
DANGER = "btn-danger",
WARNING = "btn-warning",
INFO = "btn-info",
LIGHT = "btn-light",
DARK = "btn-dark"
}

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { AccountService } from './account.service';
describe('AccountService', () => {
let service: AccountService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AccountService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {UserData} from "../interface/user";
import {Observable} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class AccountService {
private apiUrl = 'http://localhost:8080/api/';
constructor(
private http: HttpClient
) {}
// v1 ACCOUNT
changeUsername(uuid: string, username: string): Observable<string> {
const body = {
uuid: uuid,
username: username
}
return this.http.post<string>(this.apiUrl + 'v1/account/edit', body);
}
}

View File

@@ -11,9 +11,7 @@ export class ApiService {
constructor(
private http: HttpClient
) {
}
) {}
// v1 USERS

View File

@@ -11,7 +11,7 @@ export class AuthInterceptorService implements HttpInterceptor {
const tokenId = localStorage.getItem('tokenId');
if (!!tokenId) {
if (tokenId) {
const cloned = req.clone({
headers: req.headers.set("Authorization",
"Bearer " + tokenId)

View File

@@ -13,7 +13,7 @@ import {ButtonModel, ButtonType} from "../../../libraries/components/button/mode
})
export class AccountNavigationComponent {
@Output() onNavChange = new EventEmitter<string>();
@Output() navChange = new EventEmitter<string>();
selectedMenu = "ACC";
@@ -22,7 +22,7 @@ export class AccountNavigationComponent {
click: () =>
{
this.selectedMenu = 'ACC';
this.onNavChange.emit(this.selectedMenu);
this.navChange.emit(this.selectedMenu);
},
text: 'Account Management',
type: ButtonType.LINK
@@ -32,7 +32,7 @@ export class AccountNavigationComponent {
disabled: () => this.selectedMenu === 'PPF',
click: () => {
this.selectedMenu = 'PPF';
this.onNavChange.emit(this.selectedMenu);
this.navChange.emit(this.selectedMenu);
},
text: 'Public Profile',
type: ButtonType.LINK

View File

@@ -2,7 +2,7 @@
<div class="row">
<div class="col-3">
<app-account-navigation
(onNavChange)="navChanged($event)"
(navChange)="navChanged($event)"
>
</app-account-navigation>
</div>

View File

@@ -1,6 +1,5 @@
import { Component } from '@angular/core';
import {ButtonComponent} from "../../libraries/components/button/button.component";
import {ButtonModel} from "../../libraries/components/button/models/button.model";
import {DashboardComponent} from "../dashboard/dashboard.component";
import {NgIf} from "@angular/common";
import {LoginComponent} from "../login/login.component";

View File

@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import {LoginComponent} from "../../login/login.component";
import {NgIf} from "@angular/common";
import {RegisterComponent} from "../../register/register.component";
@@ -15,7 +15,7 @@ import {AuthService} from "../../../services/auth.service";
templateUrl: './auth-form.component.html',
styleUrl: './auth-form.component.scss'
})
export class AuthFormComponent {
export class AuthFormComponent implements OnInit {
constructor(private authService: AuthService) {
}

View File

@@ -12,10 +12,13 @@
</div>
</div>
<div class="col-2">
<i>Modify</i>
Actions
<div>
<rlh-button
[button]="editUserNameButton">
<rlh-button *ngIf="!isEditingUsername"
[button]="editUsernameButton">
</rlh-button>
<rlh-button *ngIf="isEditingUsername"
[button]="saveUsernameButton">
</rlh-button>
</div>
</div>

View File

@@ -10,6 +10,7 @@ import {InputComponent} from "../../libraries/components/input/input.component";
import {InputModel, InputType} from "../../libraries/components/input/input.model";
import {ButtonComponent} from "../../libraries/components/button/button.component";
import {ButtonModel, ButtonType} from "../../libraries/components/button/models/button.model";
import {AccountService} from "../../services/account.service";
@Component({
selector: 'app-dashboard',
@@ -30,7 +31,7 @@ export class DashboardComponent implements OnInit {
usernameInput: InputModel = {
type: InputType.TEXT,
disabled: () => true,
disabled: () => !this.isEditingUsername,
modelChange: () => {}
}
@@ -52,12 +53,23 @@ export class DashboardComponent implements OnInit {
modelChange: () => {}
}
editUserNameButton: ButtonModel = {
disabled: () => false,
editUsernameButton: ButtonModel = {
disabled: () => this.isEditingUsername,
visible: () => !this.isEditingUsername,
click: () => {
console.log(this.userData.username);
this.isEditingUsername = true;
},
text: 'Edit',
type: ButtonType.SECONDARY
}
saveUsernameButton: ButtonModel = {
disabled: () => !this.isEditingUsername,
visible: () => this.isEditingUsername,
click: () => {
this.saveUsername();
},
text: 'Save',
type: ButtonType.PRIMARY
}
@@ -68,7 +80,12 @@ export class DashboardComponent implements OnInit {
createdAt: null
}
constructor(private authService: AuthService, private apiService: ApiService, private router: Router) {
isEditingUsername = false;
constructor(private authService: AuthService,
private apiService: ApiService,
private accountService: AccountService,
private router: Router) {
}
ngOnInit(): void {
@@ -82,4 +99,19 @@ export class DashboardComponent implements OnInit {
}
}
saveUsername(): void {
this.isEditingUsername = false;
this.apiService.getCurrentUser().subscribe(res => {
if(!res) return;
let uuid = res.uuid;
if(!!uuid) {
this.accountService.changeUsername(uuid, this.userData.username)
.subscribe(res => {
this.userData.username = res;
});
}
});
}
}

View File

@@ -10,7 +10,7 @@
*ngIf="!!loggedUser && !!loggedUser.username">
<div class="col-4">
<div class="form-group" data-mdb-input-init>
<label class="form-label">Username</label>
<p class="form-label">Username</p>
<input type="text"
class="form-control"
name="loggedUser.username"
@@ -22,7 +22,7 @@
<div class="row justify-content-center mb-2">
<div class="col-4">
<div class="form-group" data-mdb-input-init>
<label class="form-label">Email address</label>
<p class="form-label">Email address</p>
<input type="text"
name="email"
[disabled]="isLoggedIn"
@@ -34,7 +34,7 @@
<div class="row justify-content-center mb-4">
<div class="col-4">
<div class="form-group" data-mdb-input-init>
<label class="form-label">Password</label>
<p class="form-label">Password</p>
<input type="password"
name="password"
[disabled]="isLoggedIn"

View File

@@ -36,7 +36,7 @@ export class LoginComponent implements OnInit {
public attemptLogin() {
this.authService.authenticate(this.email, this.password)
.subscribe(token => {
.subscribe(() => {
this.router.navigate(['/']).then();
});
}