From 53a1407ef82a2aa74710c823b4271dbf6af8bc09 Mon Sep 17 00:00:00 2001 From: Roger Far Date: Fri, 21 Mar 2025 15:31:34 -0600 Subject: [PATCH] Angular cleanup. --- client/.ncurc.js | 14 ++++++++++++++ client/angular.json | 4 ++-- client/package-lock.json | 25 +++++-------------------- client/package.json | 2 +- client/src/app/app.module.ts | 9 ++++----- client/src/app/download-status.pipe.ts | 2 +- client/src/app/filesize.pipe.ts | 20 ++++++++++++++++++++ client/src/app/torrent-status.pipe.ts | 2 +- client/src/styles.scss | 2 +- 9 files changed, 49 insertions(+), 31 deletions(-) create mode 100644 client/.ncurc.js create mode 100644 client/src/app/filesize.pipe.ts diff --git a/client/.ncurc.js b/client/.ncurc.js new file mode 100644 index 0000000..a7a5283 --- /dev/null +++ b/client/.ncurc.js @@ -0,0 +1,14 @@ +const minorOnly = []; +const patchOnly = []; + +module.exports = { + target: (name) => { + if (minorOnly.indexOf(name) > -1) { + return 'minor'; + } + if (patchOnly.indexOf(name) > -1) { + return 'patch'; + } + return 'latest'; + } +}; diff --git a/client/angular.json b/client/angular.json index 80e6234..2d23e7d 100644 --- a/client/angular.json +++ b/client/angular.json @@ -57,8 +57,8 @@ "budgets": [ { "type": "initial", - "maximumWarning": "500kb", - "maximumError": "1mb" + "maximumWarning": "2mb", + "maximumError": "2mb" }, { "type": "anyComponentStyle", diff --git a/client/package-lock.json b/client/package-lock.json index 365ff09..488aecb 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -22,7 +22,7 @@ "bulma": "^1.0.3", "curray": "^1.0.12", "file-saver-es": "^2.0.5", - "ngx-filesize": "^3.0.5", + "filesize": "^10.1.6", "rxjs": "^7.8.2", "tslib": "^2.8.1", "zone.js": "^0.15.0" @@ -5284,13 +5284,12 @@ "license": "MIT" }, "node_modules/filesize": { - "version": "9.0.11", - "resolved": "https://registry.npmjs.org/filesize/-/filesize-9.0.11.tgz", - "integrity": "sha512-gTAiTtI0STpKa5xesyTA9hA3LX4ga8sm2nWRcffEa1L/5vQwb4mj2MdzMkoHoGv4QzfDshQZuYscQSf8c4TKOA==", + "version": "10.1.6", + "resolved": "https://registry.npmjs.org/filesize/-/filesize-10.1.6.tgz", + "integrity": "sha512-sJslQKU2uM33qH5nqewAwVB2QgR6w1aMNsYUp3aN5rMRyXEwJGmZvaWzeJFNTOXWlHQyBFCWrdj3fV/fsTOX8w==", "license": "BSD-3-Clause", - "peer": true, "engines": { - "node": ">= 0.4.0" + "node": ">= 10.4.0" } }, "node_modules/fill-range": { @@ -6576,20 +6575,6 @@ "node": ">= 0.6" } }, - "node_modules/ngx-filesize": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/ngx-filesize/-/ngx-filesize-3.0.5.tgz", - "integrity": "sha512-Q9xM7Wp/RkhLWOGRnY3D2hPlpX/6WJpr7m84xSJJKTlqRXfK4FaFL3fbuuLvF09I8s/UL6httGLIrbTB9UDGJA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.3.0" - }, - "peerDependencies": { - "@angular/common": ">= 14.2.0 < 20.0.0", - "@angular/core": ">= 14.2.0 < 20.0.0", - "filesize": ">= 6.0.0 < 10.0.0" - } - }, "node_modules/node-addon-api": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", diff --git a/client/package.json b/client/package.json index b11bb01..3e21da5 100644 --- a/client/package.json +++ b/client/package.json @@ -26,7 +26,7 @@ "bulma": "^1.0.3", "curray": "^1.0.12", "file-saver-es": "^2.0.5", - "ngx-filesize": "^3.0.5", + "filesize": "^10.1.6", "rxjs": "^7.8.2", "tslib": "^2.8.1", "zone.js": "^0.15.0" diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 8ccbf8f..fb07c04 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -1,11 +1,10 @@ +import 'curray'; import { ClipboardModule } from '@angular/cdk/clipboard'; import { APP_BASE_HREF } from '@angular/common'; import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; -import { curray } from 'curray'; -import { FileSizePipe, NgxFilesizeModule } from 'ngx-filesize'; import { AddNewTorrentComponent } from './add-new-torrent/add-new-torrent.component'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; @@ -23,8 +22,7 @@ import { TorrentStatusPipe } from './torrent-status.pipe'; import { TorrentTableComponent } from './torrent-table/torrent-table.component'; import { TorrentComponent } from './torrent/torrent.component'; import { SortPipe } from './sort.pipe'; - -curray(); +import { FileSizePipe } from './filesize.pipe'; @NgModule({ declarations: [ @@ -43,9 +41,10 @@ curray(); ProfileComponent, Nl2BrPipe, SortPipe, + FileSizePipe, ], bootstrap: [AppComponent], - imports: [BrowserModule, AppRoutingModule, FormsModule, NgxFilesizeModule, ClipboardModule], + imports: [BrowserModule, AppRoutingModule, FormsModule, ClipboardModule], providers: [ FileSizePipe, { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }, diff --git a/client/src/app/download-status.pipe.ts b/client/src/app/download-status.pipe.ts index f82fb23..d223a55 100644 --- a/client/src/app/download-status.pipe.ts +++ b/client/src/app/download-status.pipe.ts @@ -1,6 +1,6 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { FileSizePipe } from 'ngx-filesize'; import { Download } from './models/download.model'; +import { FileSizePipe } from './filesize.pipe'; @Pipe({ name: 'downloadStatus', diff --git a/client/src/app/filesize.pipe.ts b/client/src/app/filesize.pipe.ts new file mode 100644 index 0000000..8c540a6 --- /dev/null +++ b/client/src/app/filesize.pipe.ts @@ -0,0 +1,20 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { filesize } from 'filesize'; + +@Pipe({ + name: 'filesize', + standalone: false, +}) +export class FileSizePipe implements PipeTransform { + private static transformOne(value: number, options?: any): string { + return filesize(value, options).toString(); + } + + transform(value: number | number[], options?: any) { + if (Array.isArray(value)) { + return value.map((val) => FileSizePipe.transformOne(val, options)); + } + + return FileSizePipe.transformOne(value, options); + } +} diff --git a/client/src/app/torrent-status.pipe.ts b/client/src/app/torrent-status.pipe.ts index ee93df0..96065a3 100644 --- a/client/src/app/torrent-status.pipe.ts +++ b/client/src/app/torrent-status.pipe.ts @@ -1,6 +1,6 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { FileSizePipe } from 'ngx-filesize'; import { RealDebridStatus, Torrent } from './models/torrent.model'; +import { FileSizePipe } from './filesize.pipe'; @Pipe({ name: 'status', diff --git a/client/src/styles.scss b/client/src/styles.scss index 8d15669..690af48 100644 --- a/client/src/styles.scss +++ b/client/src/styles.scss @@ -1,2 +1,2 @@ -@forward "../node_modules/bulma/bulma.sass"; +@forward "../node_modules/bulma/bulma.scss"; @forward "../node_modules/@fortawesome/fontawesome-free/css/all.css";