Browse Source

small fixes and optimization

master
Christian Ziermann 4 years ago
parent
commit
9bb89f6fda
8 changed files with 4 additions and 85 deletions
  1. +0
    -4
      angular.json
  2. +1
    -1
      ngsw-config.json
  3. +1
    -2
      src/app/app-routing.module.ts
  4. +1
    -2
      src/app/app.module.ts
  5. +0
    -61
      src/app/helper/service-helper.ts
  6. +0
    -3
      src/environments/environment.prod.ts
  7. +0
    -8
      src/environments/environment.ts
  8. +1
    -4
      src/main.ts

+ 0
- 4
angular.json View File

"extractLicenses": false, "extractLicenses": false,
"vendorChunk": false, "vendorChunk": false,
"buildOptimizer": true, "buildOptimizer": true,
"fileReplacements": [{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}],
"serviceWorker": true, "serviceWorker": true,
"ngswConfigPath": "ngsw-config.json" "ngswConfigPath": "ngsw-config.json"
} }

+ 1
- 1
ngsw-config.json View File

"resources": { "resources": {
"files": [ "files": [
"/assets/**", "/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
] ]
} }
} }

+ 1
- 2
src/app/app-routing.module.ts View File

import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { environment } from 'environments/environment';
import { NotFoundComponent } from 'app/pages/not-found/not-found.component'; import { NotFoundComponent } from 'app/pages/not-found/not-found.component';
import { ResumeComponent } from './pages/resume/resume.component'; import { ResumeComponent } from './pages/resume/resume.component';
import { GamesDashboardComponent } from './pages/games-dashboard/games-dashboard.component'; import { GamesDashboardComponent } from './pages/games-dashboard/games-dashboard.component';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forRoot(routes, { RouterModule.forRoot(routes, {
enableTracing: !environment.production
enableTracing: false
}), }),
], ],
exports: [RouterModule] exports: [RouterModule]

+ 1
- 2
src/app/app.module.ts View File

import { PdfHeaderComponent } from './page-header/pdf-header/pdf-header.component'; import { PdfHeaderComponent } from './page-header/pdf-header/pdf-header.component';
import { MusicHeaderComponent } from './page-header/music-header/music-header.component'; import { MusicHeaderComponent } from './page-header/music-header/music-header.component';
import { ServiceWorkerModule } from '@angular/service-worker'; import { ServiceWorkerModule } from '@angular/service-worker';
import { environment } from '../environments/environment';




@NgModule({ @NgModule({
AppRoutingModule, AppRoutingModule,
ComponentsModule, ComponentsModule,
PageHeaderModule, PageHeaderModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
ServiceWorkerModule.register('ngsw-worker.js', { enabled: true }),
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]

+ 0
- 61
src/app/helper/service-helper.ts View File


export namespace ServiceHelper {
export class GenericHelper {
public static deepClone(obj: Object) {
return JSON.parse(JSON.stringify(obj));
}
}
export const SPOTIFY_STAUS_CODES = {
OK: 200,
CREATED: 201,
ACCEPTED: 202,
NO_CONTENT: 204,
NOT_MODIFIED: 304,
BAD_REQUEST: 400,
UNAUTHORIZED: 401,
FORBIDDEN: 403,
NOT_FOUND: 404,
TOO_MANY: 429,
INTERNAL: 500,
BAD_GATEWAY: 502,
SERVICE_UNAVAILABLE: 503,
}
export class PaginationOptions { limit: number; offset: number; total: number; current: number; };
export class OfssetHelper {
/**
* Exptract Offset from URL.
*
* @param url url with offset GET Param
* @returns offset if found if not -1
*/
public getNextOffsetFromUrl(url: string): number {
const extractOffsetRegex = /(?:offset=)(\d+)/;
const offset = extractOffsetRegex.exec(url);
if (offset[1]) {
return parseInt(offset[1]);
}
return -1

}
public getNextOffset(responseBody: PaginationOptions) {
const maxOffset = responseBody.total - responseBody.limit;
if (
responseBody.total <= responseBody.limit ||
responseBody.offset >= responseBody.limit ||
responseBody.offset >= maxOffset
) {
return -1;
}
if (responseBody.offset < 0) {
throw new Error("offset can't be smaller than 0!");
}
// if limit + current offset not overflows maxOffset return
if ((responseBody.limit + responseBody.offset) <= maxOffset) {
return responseBody.limit + responseBody.offset;
}
// return the rest
return responseBody.limit % responseBody.total;
}
}
}


+ 0
- 3
src/environments/environment.prod.ts View File

export const environment = {
production: true
};

+ 0
- 8
src/environments/environment.ts View File

// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.

export const environment = {
production: false
};

+ 1
- 4
src/main.ts View File

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';


import { AppModule } from './app/app.module'; import { AppModule } from './app/app.module';
import { environment } from './environments/environment';


if (environment.production) {
enableProdMode();
}
enableProdMode();


platformBrowserDynamic().bootstrapModule(AppModule); platformBrowserDynamic().bootstrapModule(AppModule);

Loading…
Cancel
Save