Refactoring
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Application-wide constants
|
||||
*/
|
||||
|
||||
// Guild/Clan constants
|
||||
export const MAX_CLAN_MEMBERS = 30;
|
||||
|
||||
// Default values
|
||||
export const DEFAULT_PAGE_SIZE = 10;
|
||||
export const DEFAULT_TIMEOUT = 30000; // ms
|
||||
@@ -0,0 +1 @@
|
||||
export * from './app.constants';
|
||||
@@ -2,7 +2,7 @@ import { inject } from '@angular/core';
|
||||
import { CanActivateFn, Router } from '@angular/router';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
|
||||
import { UserService } from 'src/app/core/services';
|
||||
import { UserService } from '@services';
|
||||
|
||||
export const adminGuard: CanActivateFn = () => {
|
||||
const router = inject(Router);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { inject } from '@angular/core';
|
||||
import { CanActivateFn, Router } from '@angular/router';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
|
||||
import { UserService } from 'src/app/core/services';
|
||||
import { UserService } from '@services';
|
||||
|
||||
export const authGuard: CanActivateFn = () => {
|
||||
const router = inject(Router);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CanActivateFn } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
|
||||
import { UserService } from 'src/app/core/services';
|
||||
import { UserService } from '@services';
|
||||
|
||||
export const noauthGuard: CanActivateFn = (): Observable<boolean> => {
|
||||
/*
|
||||
|
||||
@@ -4,3 +4,4 @@ export * from './interceptors';
|
||||
export * from './models';
|
||||
export * from './resolvers';
|
||||
export * from './services';
|
||||
export * from './viewmodels';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HttpInterceptorFn } from "@angular/common/http";
|
||||
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { environment } from '@environments/environment';
|
||||
|
||||
export const apiInterceptor: HttpInterceptorFn = (req, next) => {
|
||||
const apiReq = req.clone({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { inject } from "@angular/core";
|
||||
import { HttpInterceptorFn } from "@angular/common/http";
|
||||
import { JwtService } from "src/app/core/services/jwt.service";
|
||||
import { JwtService } from "@services/jwt.service";
|
||||
|
||||
export const tokenInterceptor: HttpInterceptorFn = (req, next) => {
|
||||
const token = inject(JwtService).getToken();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface CardColors {
|
||||
background: string;
|
||||
text: string;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { HWClan } from './clan.model';
|
||||
import { PageLinks, PageMeta } from '../shared.model';
|
||||
|
||||
export interface HWClanPageData {
|
||||
clan: HWClan;
|
||||
_links: PageLinks;
|
||||
_meta: PageMeta;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { HWMember } from './member.model';
|
||||
import { HWActivityStat, HWGuildStat, HWMemberStat } from './stat.model';
|
||||
import { PageLinks, PageMeta } from '../shared.model';
|
||||
import { HWActivityStat, HWClanIcon, HWGuildStat, HWMemberStat } from './stat.model';
|
||||
|
||||
export interface HWGuildClan {
|
||||
id: string;
|
||||
@@ -8,13 +7,7 @@ export interface HWGuildClan {
|
||||
level: string;
|
||||
title: string;
|
||||
description: string;
|
||||
icon: {
|
||||
flagColor1: number;
|
||||
flagColor2: number;
|
||||
flagShape: number;
|
||||
iconColor: number;
|
||||
iconShape: number;
|
||||
};
|
||||
icon: HWClanIcon;
|
||||
country: string;
|
||||
minLevel: string;
|
||||
serverId: string;
|
||||
@@ -58,13 +51,7 @@ export interface HWClan {
|
||||
description: string;
|
||||
disbanding: boolean;
|
||||
frameId: number;
|
||||
icon: {
|
||||
flagColor1: number;
|
||||
flagColor2: number;
|
||||
flagShape: number;
|
||||
iconColor: number;
|
||||
iconShape: number;
|
||||
};
|
||||
icon: HWClanIcon;
|
||||
level: string;
|
||||
members: {[key: string]: HWMember};
|
||||
membersCount: string;
|
||||
@@ -76,9 +63,3 @@ export interface HWClan {
|
||||
topActivity: string;
|
||||
topDungeon: string;
|
||||
}
|
||||
|
||||
export interface HWClanPageData {
|
||||
clan: HWClan;
|
||||
_links: PageLinks;
|
||||
_meta: PageMeta;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
export * from './clan.model';
|
||||
export * from './clan-list-config.model';
|
||||
export * from './clan-list.model';
|
||||
export * from './clan.model';
|
||||
export * from './clan-page-data.model';
|
||||
export * from './fortification.model';
|
||||
export * from './guildwar.model';
|
||||
//export * from './hw.model';
|
||||
export * from './member.model';
|
||||
export * from './member-list-config.model';
|
||||
export * from './member-list.model';
|
||||
export * from './member-page-data.model';
|
||||
export * from './raid.model';
|
||||
export * from './stat.model';
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
export interface HWMemberListConfig {
|
||||
type: string;
|
||||
filters: HWMemberListFilters;
|
||||
}
|
||||
|
||||
export interface HWMemberListFilters {
|
||||
id?: string;
|
||||
name?: string;
|
||||
clanId?: string;
|
||||
clanTitle?: string;
|
||||
serverId?: string;
|
||||
level?: string;
|
||||
commander?: boolean;
|
||||
champion?: boolean;
|
||||
leagueId?: number;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { HWMember } from './member.model';
|
||||
|
||||
export interface HWMemberList {
|
||||
members: Array<HWMember>;
|
||||
membersCount: number;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { HWMember } from './member.model';
|
||||
import { PageLinks, PageMeta } from '../shared.model';
|
||||
|
||||
export interface HWMemberPageData {
|
||||
member: HWMember;
|
||||
_links: PageLinks;
|
||||
_meta: PageMeta;
|
||||
}
|
||||
@@ -1,18 +1,14 @@
|
||||
import { HWGuildRaid } from './raid.model';
|
||||
import { HWMemberStat, HWWeekStat } from './stat.model';
|
||||
import { HWGuildWarHeroTeam, HWGuildWarTitanTeam } from './guildwar.model';
|
||||
import {
|
||||
HWMemberStat, HWWeekStat, HWClanIcon, HWInactivity,
|
||||
HWRaidsInfo, HWMemberHeroes, HWMemberTitans
|
||||
} from './stat.model';
|
||||
|
||||
export interface HWMember {
|
||||
id: string;
|
||||
allowPm: string;
|
||||
avatarId: string;
|
||||
clanIcon: {
|
||||
flagColor1: number;
|
||||
flagColor2: number;
|
||||
flagShape: number;
|
||||
iconColor: number;
|
||||
iconShape: number;
|
||||
};
|
||||
clanIcon: HWClanIcon;
|
||||
clanId: string;
|
||||
clanRole: string;
|
||||
clanTitle: string;
|
||||
@@ -26,21 +22,10 @@ export interface HWMember {
|
||||
serverId: string;
|
||||
showProfile: boolean;
|
||||
champion: boolean;
|
||||
heroes: {
|
||||
power: number;
|
||||
teams: HWGuildWarHeroTeam[];
|
||||
};
|
||||
titans: {
|
||||
power: number;
|
||||
teams: HWGuildWarTitanTeam[];
|
||||
};
|
||||
heroes: HWMemberHeroes;
|
||||
titans: HWMemberTitans;
|
||||
stat: HWMemberStat;
|
||||
inactivity: {
|
||||
daysLeft: number,
|
||||
timeLeft: number,
|
||||
dropDate: number;
|
||||
dropDelay: string;
|
||||
}
|
||||
inactivity: HWInactivity;
|
||||
adventureSum: number;
|
||||
clanGiftsSum: number;
|
||||
clanWarSum: number;
|
||||
@@ -50,8 +35,5 @@ export interface HWMember {
|
||||
warGifts: number;
|
||||
rewards: number;
|
||||
raids: HWGuildRaid[];
|
||||
raidsInfo: {
|
||||
variationAvg: number;
|
||||
variationSum: number;
|
||||
}
|
||||
raidsInfo: HWRaidsInfo;
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
import { HWGuildWarHeroTeam, HWGuildWarTitanTeam } from './guildwar.model';
|
||||
|
||||
export interface HWGuildStat {
|
||||
todayActivity: number;
|
||||
activitySum: number;
|
||||
@@ -39,4 +41,34 @@ export interface HWMemberStat {
|
||||
wasChampion: boolean;
|
||||
todayPrestige: number;
|
||||
prestigeSum: number;
|
||||
}
|
||||
|
||||
export interface HWClanIcon {
|
||||
flagColor1: number;
|
||||
flagColor2: number;
|
||||
flagShape: number;
|
||||
iconColor: number;
|
||||
iconShape: number;
|
||||
}
|
||||
|
||||
export interface HWInactivity {
|
||||
daysLeft: number;
|
||||
timeLeft: number;
|
||||
dropDate: number;
|
||||
dropDelay: string;
|
||||
}
|
||||
|
||||
export interface HWRaidsInfo {
|
||||
variationAvg: number;
|
||||
variationSum: number;
|
||||
}
|
||||
|
||||
export interface HWMemberHeroes {
|
||||
power: number;
|
||||
teams: HWGuildWarHeroTeam[];
|
||||
}
|
||||
|
||||
export interface HWMemberTitans {
|
||||
power: number;
|
||||
teams: HWGuildWarTitanTeam[];
|
||||
}
|
||||
@@ -9,6 +9,7 @@ export * from './application-list-config.model';
|
||||
export * from './brand.model';
|
||||
export * from './calculator.model';
|
||||
export * from './canopy.model';
|
||||
export * from './card-colors.model';
|
||||
export * from './category.model';
|
||||
export * from './chart.model';
|
||||
export * from './dropzone.model';
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { AeronefsPageData } from 'src/app/core/models';
|
||||
import { PagesService } from 'src/app/core/services';
|
||||
import { AeronefsPageData } from '@models';
|
||||
import { PagesService } from '@services';
|
||||
|
||||
export const aeronefsPageResolver: ResolveFn<AeronefsPageData> = () => {
|
||||
return inject(PagesService).getAeronefsPage().pipe(take(1));
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { ArticlePageData } from 'src/app/core/models';
|
||||
import { ArticlesService } from 'src/app/core/services';
|
||||
import { ArticlePageData } from '@models';
|
||||
import { ArticlesService } from '@services';
|
||||
|
||||
export const articleResolver: ResolveFn<ArticlePageData> = (
|
||||
route: ActivatedRouteSnapshot
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { Article } from 'src/app/core/models';
|
||||
import { ArticlesService } from 'src/app/core/services';
|
||||
import { Article } from '@models';
|
||||
import { ArticlesService } from '@services';
|
||||
|
||||
export const articlesResolver: ResolveFn<Array<Article>> = () => {
|
||||
return inject(ArticlesService).getAll().pipe(take(1));
|
||||
|
||||
@@ -2,7 +2,7 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { UserService } from 'src/app/core/services';
|
||||
import { UserService } from '@services';
|
||||
|
||||
export const authResolver: ResolveFn<boolean> = () => {
|
||||
return inject(UserService).isAuthenticated.pipe(take(1));
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { CanopiesPageData } from 'src/app/core/models';
|
||||
import { PagesService } from 'src/app/core/services';
|
||||
import { CanopiesPageData } from '@models';
|
||||
import { PagesService } from '@services';
|
||||
|
||||
export const canopiesPageResolver: ResolveFn<CanopiesPageData> = () => {
|
||||
return inject(PagesService).getCanopiesPage().pipe(take(1));
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { DropZonesPageData } from 'src/app/core/models';
|
||||
import { PagesService } from 'src/app/core/services';
|
||||
import { DropZonesPageData } from '@models';
|
||||
import { PagesService } from '@services';
|
||||
|
||||
export const dropZonesPageResolver: ResolveFn<DropZonesPageData> = () => {
|
||||
return inject(PagesService).getDropZonesPage().pipe(take(1));
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { JumpPageData } from 'src/app/core/models';
|
||||
import { JumpsService } from 'src/app/core/services';
|
||||
import { JumpPageData } from '@models';
|
||||
import { JumpsService } from '@services';
|
||||
|
||||
export const jumpResolver: ResolveFn<JumpPageData> = (
|
||||
route: ActivatedRouteSnapshot
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { JumpsPageData } from 'src/app/core/models';
|
||||
import { PagesService } from 'src/app/core/services';
|
||||
import { JumpsPageData } from '@models';
|
||||
import { PagesService } from '@services';
|
||||
|
||||
export const jumpsPageResolver: ResolveFn<JumpsPageData> = () => {
|
||||
return inject(PagesService).getJumpsPage().pipe(take(1));
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { Jump } from 'src/app/core/models';
|
||||
import { JumpsService } from 'src/app/core/services';
|
||||
import { Jump } from '@models';
|
||||
import { JumpsService } from '@services';
|
||||
|
||||
export const jumpsResolver: ResolveFn<Array<Jump>> = () => {
|
||||
return inject(JumpsService).getAll().pipe(take(1));
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { Jump } from 'src/app/core/models';
|
||||
import { JumpsService } from 'src/app/core/services';
|
||||
import { Jump } from '@models';
|
||||
import { JumpsService } from '@services';
|
||||
|
||||
export const lastjumpResolver: ResolveFn<Jump> = () => {
|
||||
return inject(JumpsService).getLastJump().pipe(take(1));
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { ProductPageData } from 'src/app/core/models';
|
||||
import { ProductsService } from 'src/app/core/services';
|
||||
import { ProductPageData } from '@models';
|
||||
import { ProductsService } from '@services';
|
||||
|
||||
export const productResolver: ResolveFn<ProductPageData> = (
|
||||
route: ActivatedRouteSnapshot
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { ProductsPageData } from 'src/app/core/models';
|
||||
import { ProductsService } from 'src/app/core/services';
|
||||
import { ProductsPageData } from '@models';
|
||||
import { ProductsService } from '@services';
|
||||
|
||||
export const productsResolver: ResolveFn<ProductsPageData> = (
|
||||
route: ActivatedRouteSnapshot
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { Profile } from 'src/app/core/models';
|
||||
import { ProfilesService } from 'src/app/core/services';
|
||||
import { Profile } from '@models';
|
||||
import { ProfilesService } from '@services';
|
||||
|
||||
export const profileResolver: ResolveFn<Profile> = (
|
||||
route: ActivatedRouteSnapshot
|
||||
|
||||
@@ -2,8 +2,8 @@ import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { Qcm } from 'src/app/core/models';
|
||||
import { QcmService } from 'src/app/core/services';
|
||||
import { Qcm } from '@models';
|
||||
import { QcmService } from '@services';
|
||||
|
||||
export const qcmResolver: ResolveFn<Qcm> = (
|
||||
route: ActivatedRouteSnapshot
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
//import { environment } from 'src/environments/environment';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ApiService {
|
||||
constructor(
|
||||
|
||||
@@ -3,11 +3,12 @@ import { HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { Application, ApplicationList, ApplicationListConfig, ApplicationListFilters } from 'src/app/core/models';
|
||||
import { Application, ApplicationList, ApplicationListConfig, ApplicationListFilters } from '@models';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ApplicationsService {
|
||||
private _apiVersion = '/v1';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
@@ -22,7 +23,7 @@ export class ApplicationsService {
|
||||
};
|
||||
return this.apiService
|
||||
.get(
|
||||
'/applications' + ((config.type === 'feed') ? '/feed' : ''),
|
||||
`${this._apiVersion}/applications` + ((config.type === 'feed') ? '/feed' : ''),
|
||||
new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params })
|
||||
@@ -30,22 +31,22 @@ export class ApplicationsService {
|
||||
}
|
||||
|
||||
get(slug: string): Observable<Application> {
|
||||
return this.apiService.get(`/applications/${slug}`)
|
||||
return this.apiService.get(`${this._apiVersion}/applications/${slug}`)
|
||||
.pipe(map(data => data.application));
|
||||
}
|
||||
|
||||
destroy(slug: string): Observable<boolean> {
|
||||
return this.apiService.delete(`/applications/${slug}`).pipe(map(data => data.deleted));
|
||||
return this.apiService.delete(`${this._apiVersion}/applications/${slug}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(application: Application): Observable<Application> {
|
||||
if (application.slug) {
|
||||
// If we're updating an existing application
|
||||
return this.apiService.put(`/applications/${application.slug}`, { application: application })
|
||||
return this.apiService.put(`${this._apiVersion}/applications/${application.slug}`, { application: application })
|
||||
.pipe(map(data => data.application));
|
||||
} else {
|
||||
// Otherwise, create a new application
|
||||
return this.apiService.post('/applications/', { application: application })
|
||||
return this.apiService.post(`${this._apiVersion}/applications/`, { application: application })
|
||||
.pipe(map(data => data.application));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { Article, ArticleList, ArticleListConfig, ArticleListFilters, ArticlePageData } from 'src/app/core/models';
|
||||
import { Article, ArticleList, ArticleListConfig, ArticleListFilters, ArticlePageData } from '@models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ArticlesService {
|
||||
private _apiVersion = '/v2';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
@@ -18,7 +19,7 @@ export class ArticlesService {
|
||||
Object.assign(params, config.filters);
|
||||
return this.apiService
|
||||
.get(
|
||||
'/articles' + ((config.type === 'feed') ? '/feed' : ''),
|
||||
`${this._apiVersion}/articles` + ((config.type === 'feed') ? '/feed' : ''),
|
||||
new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params })
|
||||
@@ -26,49 +27,49 @@ export class ArticlesService {
|
||||
}
|
||||
|
||||
get(slug: string): Observable<ArticlePageData> {
|
||||
/*return this.apiService.get('/articles/' + slug).pipe(map(data => {
|
||||
/*return this.apiService.get(`${this._apiVersion}/articles/${slug}`).pipe(map(data => {
|
||||
data.article.tagList = data.article.tagNameTagTagLists;
|
||||
delete data.article.tagNameTagTagLists;
|
||||
return data;
|
||||
}));*/
|
||||
return this.apiService.get(`/articles/${slug}`);
|
||||
return this.apiService.get(`${this._apiVersion}/articles/${slug}`);
|
||||
}
|
||||
|
||||
getAll(): Observable<Array<Article>> {
|
||||
return this.apiService.get('/articles').pipe(map(data => data.articles));
|
||||
return this.apiService.get(`${this._apiVersion}/articles`).pipe(map(data => data.articles));
|
||||
}
|
||||
|
||||
create(article: Article): Observable<Article> {
|
||||
return this.apiService.post('/articles/', { article: article }).pipe(map(data => data.article));
|
||||
return this.apiService.post(`${this._apiVersion}/articles/`, { article: article }).pipe(map(data => data.article));
|
||||
}
|
||||
|
||||
update(article: Article): Observable<Article> {
|
||||
return this.apiService.put(`/articles/${article.slug}`, { article: article }).pipe(map(data => data.article));
|
||||
return this.apiService.put(`${this._apiVersion}/articles/${article.slug}`, { article: article }).pipe(map(data => data.article));
|
||||
}
|
||||
|
||||
destroy(slug: string): Observable<boolean> {
|
||||
return this.apiService.delete(`/products/${slug}`).pipe(map(data => data.deleted));
|
||||
return this.apiService.delete(`${this._apiVersion}/articles/${slug}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(article: Article): Observable<Article> {
|
||||
// If we're updating an existing article
|
||||
if (article.slug) {
|
||||
return this.apiService.put('/articles/' + article.slug, { article: article })
|
||||
return this.apiService.put(`${this._apiVersion}/articles/${article.slug}`, { article: article })
|
||||
.pipe(map(data => data.article));
|
||||
|
||||
// Otherwise, create a new article
|
||||
} else {
|
||||
return this.apiService.post('/articles/', { article: article })
|
||||
return this.apiService.post(`${this._apiVersion}/articles/`, { article: article })
|
||||
.pipe(map(data => data.article));
|
||||
}
|
||||
}
|
||||
|
||||
favorite(slug: string): Observable<Article> {
|
||||
return this.apiService.post('/articles/' + slug + '/favorite');
|
||||
return this.apiService.post(`${this._apiVersion}/articles/${slug}/favorite`);
|
||||
}
|
||||
|
||||
unfavorite(slug: string): Observable<Article> {
|
||||
return this.apiService.delete('/articles/' + slug + '/favorite');
|
||||
return this.apiService.delete(`${this._apiVersion}/articles/${slug}/favorite`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from '../api.service';
|
||||
import {
|
||||
HWActivityStat, HWClan, HWClanList, HWClanListConfig,
|
||||
HWClanListFilters, HWClanPageData, HWGuildClan,
|
||||
HWMember
|
||||
} from '@models';
|
||||
|
||||
import guildData from 'src/files-data/hw-guild-data.json'; // page Membres
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class HWClanService {
|
||||
private apiVersion = '/v3';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
private _resetActivity(): HWActivityStat {
|
||||
const activity: HWActivityStat = { activity: 0, prestige: 0, titanite: 0, war: 0, adventure: 0, gifts: 0, score: 0, scoreGifts: 0, warGifts: 0, rewards: 0 };
|
||||
return activity;
|
||||
}
|
||||
|
||||
query(config: HWClanListConfig): Observable<HWClanList> {
|
||||
// Convert any filters over to Angular's URLSearchParams
|
||||
const params: HWClanListFilters = {} as HWClanListFilters;
|
||||
Object.assign(params, config.filters);
|
||||
return this.apiService
|
||||
.get(
|
||||
`${this.apiVersion}/clans`,
|
||||
new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params })
|
||||
);
|
||||
}
|
||||
|
||||
get(id: string): Observable<HWClanPageData> {
|
||||
return this.apiService.get(`${this.apiVersion}/clans/${id}`);
|
||||
}
|
||||
|
||||
getAll(): Observable<Array<HWClan>> {
|
||||
return this.apiService.get(`${this.apiVersion}/clans`).pipe(map(data => data.clans));
|
||||
}
|
||||
|
||||
create(clan: HWClan): Observable<HWClan> {
|
||||
return this.apiService.post(`${this.apiVersion}/clans/`, { clan: clan }).pipe(map(data => data.clan));
|
||||
}
|
||||
|
||||
update(clan: HWClan): Observable<HWClan> {
|
||||
return this.apiService.put(`${this.apiVersion}/clans/${clan.id}`, { clan: clan }).pipe(map(data => data.clan));
|
||||
}
|
||||
|
||||
destroy(id: string): Observable<boolean> {
|
||||
return this.apiService.delete(`${this.apiVersion}/clans/${id}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(clan: HWClan): Observable<HWClan> {
|
||||
// If we're updating an existing clan
|
||||
if (clan.id) {
|
||||
return this.apiService.put(`${this.apiVersion}/clans/${clan.id}`, { clan: clan }).pipe(map(data => data.clan));
|
||||
// Otherwise, create a new clan
|
||||
} else {
|
||||
return this.apiService.post(`${this.apiVersion}/clans/`, { clan: clan }).pipe(map(data => data.clan));
|
||||
}
|
||||
}
|
||||
|
||||
loadClan(): HWGuildClan {
|
||||
const guildClan: HWGuildClan = {} as HWGuildClan;
|
||||
Object.assign(guildClan, guildData.clan);
|
||||
guildClan.sumAverages = this._resetActivity();
|
||||
guildClan.sumTotal = this._resetActivity();
|
||||
guildClan.todayAverages = this._resetActivity();
|
||||
guildClan.todayTotal = this._resetActivity();
|
||||
|
||||
return guildClan;
|
||||
}
|
||||
|
||||
loadClanStats(clan: HWGuildClan, members: HWMember[]): HWGuildClan {
|
||||
members.map((member: HWMember) => {
|
||||
clan.sumTotal.adventure += member.adventureSum;
|
||||
clan.sumTotal.gifts += member.clanGiftsSum;
|
||||
clan.sumTotal.war += member.clanWarSum;
|
||||
clan.todayTotal.activity += member.stat.todayActivity;
|
||||
clan.todayTotal.prestige += member.stat.todayPrestige;
|
||||
clan.todayTotal.titanite += member.stat.todayDungeonActivity;
|
||||
clan.todayTotal.score += (member.stat.todayDungeonActivity + member.stat.todayActivity + member.stat.todayPrestige);
|
||||
clan.sumTotal.activity += member.stat.activitySum;
|
||||
clan.sumTotal.prestige += member.stat.prestigeSum;
|
||||
clan.sumTotal.titanite += member.stat.dungeonActivitySum;
|
||||
clan.sumTotal.score += member.score;
|
||||
clan.sumTotal.warGifts += member.warGifts;
|
||||
});
|
||||
clan.sumTotal.scoreGifts = (clan.giftsCount - Math.floor(clan.sumTotal.warGifts));
|
||||
clan.todayAverages.activity = (clan.todayTotal.activity / members.length);
|
||||
clan.todayAverages.prestige = (clan.todayTotal.prestige / members.length);
|
||||
clan.todayAverages.titanite = (clan.todayTotal.titanite / members.length);
|
||||
clan.todayAverages.score = (clan.todayTotal.score / members.length);
|
||||
clan.sumAverages.activity = (clan.sumTotal.activity / members.length);
|
||||
clan.sumAverages.prestige = (clan.sumTotal.prestige / members.length);
|
||||
clan.sumAverages.titanite = (clan.sumTotal.titanite / members.length);
|
||||
if (clan.league === '3') {
|
||||
clan.sumAverages.war = (clan.sumTotal.war / 10);
|
||||
} else if (clan.league === '2') {
|
||||
clan.sumAverages.war = (clan.sumTotal.war / 15);
|
||||
} else if (clan.league === '1') {
|
||||
clan.sumAverages.war = (clan.sumTotal.war / 20);
|
||||
}
|
||||
clan.sumAverages.adventure = (clan.sumTotal.adventure / members.length);
|
||||
clan.sumAverages.gifts = (clan.sumTotal.gifts / members.length);
|
||||
clan.sumAverages.score = (clan.sumTotal.score / members.length);
|
||||
clan.sumAverages.scoreGifts = (clan.sumTotal.scoreGifts / members.length);
|
||||
clan.sumAverages.warGifts = (clan.sumTotal.warGifts / members.length);
|
||||
members.map((data) => {
|
||||
data.scoreGifts = ((data.score / clan.sumTotal.score) * clan.sumTotal.scoreGifts);
|
||||
data.rewards = Math.floor((data.scoreGifts + data.warGifts));
|
||||
clan.sumTotal.rewards += data.rewards;
|
||||
return data;
|
||||
});
|
||||
clan.sumAverages.rewards = (clan.sumTotal.rewards / members.length);
|
||||
|
||||
return clan;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService, UtilitiesService } from '@services';
|
||||
import {
|
||||
HWGuildClan, HWWeekStat,
|
||||
HWMember, HWMemberList, HWMemberListConfig,
|
||||
HWMemberListFilters, HWMemberPageData, HWMemberStat
|
||||
} from '@models';
|
||||
|
||||
import guildData from 'src/files-data/hw-guild-data.json'; // page Membres
|
||||
import guildStatistics from 'src/files-data/hw-guild-statistics.json'; // page Overview -> Statistics
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class HWMemberService {
|
||||
private apiVersion = '/v3';
|
||||
constructor(
|
||||
private _apiService: ApiService,
|
||||
private _utilitiesService: UtilitiesService
|
||||
) { }
|
||||
|
||||
query(config: HWMemberListConfig): Observable<HWMemberList> {
|
||||
// Convert any filters over to Angular's URLSearchParams
|
||||
const params: HWMemberListFilters = {} as HWMemberListFilters;
|
||||
Object.assign(params, config.filters);
|
||||
return this._apiService
|
||||
.get(
|
||||
`${this.apiVersion}/members`,
|
||||
new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params })
|
||||
);
|
||||
}
|
||||
|
||||
get(id: string): Observable<HWMemberPageData> {
|
||||
return this._apiService.get(`${this.apiVersion}/members/${id}`);
|
||||
}
|
||||
|
||||
getAll(): Observable<Array<HWMember>> {
|
||||
return this._apiService.get(`${this.apiVersion}/members`).pipe(map(data => data.members));
|
||||
}
|
||||
|
||||
create(member: HWMember): Observable<HWMember> {
|
||||
return this._apiService.post(`${this.apiVersion}/members/`, { member: member }).pipe(map(data => data.member));
|
||||
}
|
||||
|
||||
update(member: HWMember): Observable<HWMember> {
|
||||
return this._apiService.put(`${this.apiVersion}/members/${member.id}`, { member: member }).pipe(map(data => data.member));
|
||||
}
|
||||
|
||||
destroy(id: string): Observable<boolean> {
|
||||
return this._apiService.delete(`${this.apiVersion}/members/${id}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(member: HWMember): Observable<HWMember> {
|
||||
// If we're updating an existing member
|
||||
if (member.id) {
|
||||
return this._apiService.put(`${this.apiVersion}/members/${member.id}`, { member: member }).pipe(map(data => data.member));
|
||||
// Otherwise, create a new member
|
||||
} else {
|
||||
return this._apiService.post(`${this.apiVersion}/members/`, { member: member }).pipe(map(data => data.member));
|
||||
}
|
||||
}
|
||||
|
||||
loadMembers(clan: HWGuildClan): HWMember[] {
|
||||
const guildMembers: HWMember[] = [];
|
||||
const now = new Date();
|
||||
const oneDayInSec = (24 * 60 * 60);
|
||||
const daysToKick = parseInt(guildData.clan.daysToKick);
|
||||
for (const data of Object.entries(guildData.clan.members)) {
|
||||
const member: HWMember = {} as HWMember;
|
||||
Object.assign(member, data[1]);
|
||||
if (guildData.clan.warriors.indexOf(parseInt(member.id)) !== -1) {
|
||||
member.champion = true;
|
||||
} else {
|
||||
member.champion = false;
|
||||
}
|
||||
member.heroes = { power: 0, teams: []};
|
||||
member.titans = { power: 0, teams: []};
|
||||
guildMembers.push(member);
|
||||
}
|
||||
guildMembers.map((data: HWMember) => {
|
||||
const last = new Date((parseInt(data.lastLoginTime) * 1000));
|
||||
const exp = new Date(last.getTime() + ((daysToKick * oneDayInSec) * 1000));
|
||||
const diff = Math.floor(((exp.getTime() - now.getTime()) / 1000));
|
||||
const daysLeft = Math.floor((diff / oneDayInSec));
|
||||
let timeLeft = diff;
|
||||
if (daysLeft >= 1) {
|
||||
timeLeft = (diff - (daysLeft * oneDayInSec));
|
||||
}
|
||||
data.inactivity = {
|
||||
daysLeft: daysLeft,
|
||||
timeLeft: timeLeft,
|
||||
dropDelay: `${daysLeft}d, ${this._utilitiesService.secondsToDuration(timeLeft)}`,
|
||||
dropDate: Math.floor((exp.getTime() / 1000))
|
||||
};
|
||||
data.raids = [];
|
||||
data.raidsInfo = {
|
||||
variationAvg: 0,
|
||||
variationSum: 0
|
||||
};
|
||||
data.stat = {} as HWMemberStat;
|
||||
let index = guildData.membersStat.findIndex(stat => stat.userId === data.id);
|
||||
if (index !== -1) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
||||
const { userId, ...memberStatWithoutUserId } = guildData.membersStat[index] as any;
|
||||
Object.assign(data.stat, memberStatWithoutUserId);
|
||||
}
|
||||
index = guildStatistics.stat.findIndex(stat => stat.id === data.id);
|
||||
if (index !== -1) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
||||
const { id, ...weekStatSource } = guildStatistics.stat[index] as any;
|
||||
const stat: HWWeekStat = {} as HWWeekStat;
|
||||
Object.assign(stat, weekStatSource);
|
||||
data.weekStat = stat;
|
||||
data.adventureSum = guildStatistics.stat[index].adventureStat.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
||||
data.clanGiftsSum = guildStatistics.stat[index].clanGifts.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
||||
data.clanWarSum = guildStatistics.stat[index].clanWarStat.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
||||
} else {
|
||||
data.weekStat = {} as HWWeekStat;
|
||||
data.adventureSum = 0;
|
||||
data.clanGiftsSum = 0;
|
||||
data.clanWarSum = 0;
|
||||
}
|
||||
|
||||
data.score = (data.stat.dungeonActivitySum + data.stat.activitySum + data.stat.prestigeSum);
|
||||
data.warGifts = (((clan.giftsCount / 2) * ((data.clanWarSum * 10) / 100)) / 20);
|
||||
data.scoreGifts = 0;
|
||||
data.rewards = 0;
|
||||
return data;
|
||||
});
|
||||
|
||||
return guildMembers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
export * from './hwclan.service';
|
||||
export * from './hwmember.service';
|
||||
@@ -1,60 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import {
|
||||
HWClan, HWClanList, HWClanListConfig, HWClanListFilters, HWClanPageData
|
||||
} from 'src/app/core/models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class HWClanService {
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
query(config: HWClanListConfig): Observable<HWClanList> {
|
||||
// Convert any filters over to Angular's URLSearchParams
|
||||
const params: HWClanListFilters = {} as HWClanListFilters;
|
||||
Object.assign(params, config.filters);
|
||||
return this.apiService
|
||||
.get(
|
||||
'/clans',
|
||||
new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params })
|
||||
);
|
||||
}
|
||||
|
||||
get(id: string): Observable<HWClanPageData> {
|
||||
return this.apiService.get(`/clans/${id}`);
|
||||
}
|
||||
|
||||
getAll(): Observable<Array<HWClan>> {
|
||||
return this.apiService.get('/clans').pipe(map(data => data.clans));
|
||||
}
|
||||
|
||||
create(clan: HWClan): Observable<HWClan> {
|
||||
return this.apiService.post('/clans/', { clan: clan }).pipe(map(data => data.clan));
|
||||
}
|
||||
|
||||
update(clan: HWClan): Observable<HWClan> {
|
||||
return this.apiService.put(`/clans/${clan.id}`, { clan: clan }).pipe(map(data => data.clan));
|
||||
}
|
||||
|
||||
destroy(id: string): Observable<boolean> {
|
||||
return this.apiService.delete(`/clans/${id}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(clan: HWClan): Observable<HWClan> {
|
||||
// If we're updating an existing clan
|
||||
if (clan.id) {
|
||||
return this.apiService.put(`/clans/${clan.id}`, { clan: clan }).pipe(map(data => data.clan));
|
||||
// Otherwise, create a new clan
|
||||
} else {
|
||||
return this.apiService.post('/clans/', { clan: clan }).pipe(map(data => data.clan));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import {
|
||||
HWClan, HWClanList, HWClanListConfig, HWClanListFilters, HWClanPageData
|
||||
} from 'src/app/core/models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class HWClanService {
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
query(config: HWClanListConfig): Observable<HWClanList> {
|
||||
// Convert any filters over to Angular's URLSearchParams
|
||||
const params: HWClanListFilters = {} as HWClanListFilters;
|
||||
Object.assign(params, config.filters);
|
||||
return this.apiService
|
||||
.get(
|
||||
'/clans',
|
||||
new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params })
|
||||
);
|
||||
}
|
||||
|
||||
get(id: string): Observable<HWClanPageData> {
|
||||
return this.apiService.get(`/clans/${id}`);
|
||||
}
|
||||
|
||||
getAll(): Observable<Array<HWClan>> {
|
||||
return this.apiService.get('/clans').pipe(map(data => data.clans));
|
||||
}
|
||||
|
||||
create(clan: HWClan): Observable<HWClan> {
|
||||
return this.apiService.post('/clans/', { clan: clan }).pipe(map(data => data.clan));
|
||||
}
|
||||
|
||||
update(clan: HWClan): Observable<HWClan> {
|
||||
return this.apiService.put(`/clans/${clan.id}`, { clan: clan }).pipe(map(data => data.clan));
|
||||
}
|
||||
|
||||
destroy(id: string): Observable<boolean> {
|
||||
return this.apiService.delete(`/clans/${id}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(clan: HWClan): Observable<HWClan> {
|
||||
// If we're updating an existing clan
|
||||
if (clan.id) {
|
||||
return this.apiService.put(`/clans/${clan.id}`, { clan: clan }).pipe(map(data => data.clan));
|
||||
// Otherwise, create a new clan
|
||||
} else {
|
||||
return this.apiService.post('/clans/', { clan: clan }).pipe(map(data => data.clan));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
export * from './aeronefs.service';
|
||||
export * from './api.service';
|
||||
export * from './applications.service';
|
||||
export * from './articles.service';
|
||||
export * from './calculator.service';
|
||||
export * from './canopies.service';
|
||||
export * from './dropzones.service';
|
||||
export * from './jumps.service';
|
||||
export * from './jump-table.service';
|
||||
export * from './jwt.service';
|
||||
export * from './pages.service';
|
||||
export * from './products.service';
|
||||
export * from './profiles.service';
|
||||
export * from './qcm.service';
|
||||
export * from './user.service';
|
||||
export * from './utilities.service';
|
||||
|
||||
export * from './skydive/';
|
||||
export * from './herowars/';
|
||||
@@ -3,28 +3,29 @@ import { Observable } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { AeronefsPageData, CanopiesPageData, DropZonesPageData, JumpsPageData } from 'src/app/core/models';
|
||||
import { AeronefsPageData, CanopiesPageData, DropZonesPageData, JumpsPageData } from '@models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PagesService {
|
||||
private apiVersion = '/v1';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
getAeronefsPage(): Observable<AeronefsPageData> {
|
||||
return this.apiService.get(`/pages/aeronefs`).pipe(take(1));
|
||||
return this.apiService.get(`${this.apiVersion}/pages/aeronefs`).pipe(take(1));
|
||||
}
|
||||
|
||||
getCanopiesPage(): Observable<CanopiesPageData> {
|
||||
return this.apiService.get(`/pages/canopies`).pipe(take(1));
|
||||
return this.apiService.get(`${this.apiVersion}/pages/canopies`).pipe(take(1));
|
||||
}
|
||||
|
||||
getDropZonesPage(): Observable<DropZonesPageData> {
|
||||
return this.apiService.get(`/pages/dropzones`).pipe(take(1));
|
||||
return this.apiService.get(`${this.apiVersion}/pages/dropzones`).pipe(take(1));
|
||||
}
|
||||
|
||||
getJumpsPage(): Observable<JumpsPageData> {
|
||||
return this.apiService.get(`/pages/jumps`).pipe(take(1));
|
||||
return this.apiService.get(`${this.apiVersion}/pages/jumps`).pipe(take(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { Product, ProductList, ProductListConfig, ProductListFilters, ProductPageData, ProductsPageData } from 'src/app/core/models';
|
||||
import { Product, ProductList, ProductListConfig, ProductListFilters, ProductPageData, ProductsPageData } from '@models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ProductsService {
|
||||
private apiVersion = '/v2';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
@@ -18,7 +19,7 @@ export class ProductsService {
|
||||
Object.assign(params, config.filters);
|
||||
return this.apiService
|
||||
.get(
|
||||
'/products' + ((config.type === 'feed') ? '/feed' : ''),
|
||||
`${this.apiVersion}/products` + ((config.type === 'feed') ? '/feed' : ''),
|
||||
new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params })
|
||||
@@ -26,41 +27,41 @@ export class ProductsService {
|
||||
}
|
||||
|
||||
get(slug: string): Observable<ProductsPageData> {
|
||||
return this.apiService.get(`/product/${slug}`);
|
||||
return this.apiService.get(`${this.apiVersion}/product/${slug}`);
|
||||
}
|
||||
|
||||
getProductBySlug(slug: string): Observable<ProductPageData> {
|
||||
return this.apiService.get(`/product/${slug}`);
|
||||
return this.apiService.get(`${this.apiVersion}/product/${slug}`);
|
||||
}
|
||||
|
||||
getAll(): Observable<Array<Product>> {
|
||||
return this.apiService.get('/products').pipe(map(data => data.products));
|
||||
return this.apiService.get(`${this.apiVersion}/products`).pipe(map(data => data.products));
|
||||
}
|
||||
|
||||
getAllByCategory(category: string): Observable<ProductsPageData> {
|
||||
return this.apiService.get(`/products/${category}`); //.pipe(map(data => data.products));
|
||||
return this.apiService.get(`${this.apiVersion}/products/${category}`); //.pipe(map(data => data.products));
|
||||
}
|
||||
|
||||
create(product: Product): Observable<Product> {
|
||||
return this.apiService.post('/products/', { product: product }).pipe(map(data => data.product));
|
||||
return this.apiService.post(`${this.apiVersion}/products/`, { product: product }).pipe(map(data => data.product));
|
||||
}
|
||||
|
||||
update(product: Product): Observable<Product> {
|
||||
return this.apiService.put(`/products/${product.slug}`, { product: product }).pipe(map(data => data.product));
|
||||
return this.apiService.put(`${this.apiVersion}/products/${product.slug}`, { product: product }).pipe(map(data => data.product));
|
||||
}
|
||||
|
||||
destroy(slug: string): Observable<boolean> {
|
||||
return this.apiService.delete(`/products/${slug}`).pipe(map(data => data.deleted));
|
||||
return this.apiService.delete(`${this.apiVersion}/products/${slug}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(product: Product): Observable<Product> {
|
||||
// If we're updating an existing product
|
||||
if (product.slug) {
|
||||
return this.apiService.put(`/products/${product.slug}`, { product: product }).pipe(map(data => data.product));
|
||||
return this.apiService.put(`${this.apiVersion}/products/${product.slug}`, { product: product }).pipe(map(data => data.product));
|
||||
|
||||
// Otherwise, create a new product
|
||||
} else {
|
||||
return this.apiService.post('/products/', { product: product }).pipe(map(data => data.product));
|
||||
return this.apiService.post(`${this.apiVersion}/products/`, { product: product }).pipe(map(data => data.product));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { ApiService } from 'src/app/core/services';
|
||||
import { Profile } from 'src/app/core/models';
|
||||
import { ApiService } from '@services';
|
||||
import { Profile } from '@models';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ProfilesService {
|
||||
private _apiVersion = '/v2';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
get(username: string): Observable<Profile> {
|
||||
return this.apiService.get('/profiles/' + username)
|
||||
return this.apiService.get(`${this._apiVersion}/profiles/${username}`)
|
||||
.pipe(map((data: { profile: Profile }) => data.profile));
|
||||
}
|
||||
|
||||
follow(username: string): Observable<Profile> {
|
||||
return this.apiService.post('/profiles/' + username + '/follow');
|
||||
return this.apiService.post(`${this._apiVersion}/profiles/${username}/follow`);
|
||||
}
|
||||
|
||||
unfollow(username: string): Observable<Profile> {
|
||||
return this.apiService.delete('/profiles/' + username + '/follow');
|
||||
return this.apiService.delete(`${this._apiVersion}/profiles/${username}/follow`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-4
@@ -2,22 +2,23 @@ import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { AeronefByImat, AeronefByYear } from 'src/app/core/models';
|
||||
import { ApiService } from '../api.service';
|
||||
import { AeronefByImat, AeronefByYear } from '@models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AeronefsService {
|
||||
private _apiVersion = '/v1';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
getAllByImat(): Observable<Array<AeronefByImat>> {
|
||||
return this.apiService.get('/aeronefs/allByImat')
|
||||
return this.apiService.get(`${this._apiVersion}/aeronefs/allByImat`)
|
||||
.pipe(map(data => data.aeronefs));
|
||||
}
|
||||
|
||||
getAllByImatByYear(): Observable<Array<AeronefByYear>> {
|
||||
return this.apiService.get('/aeronefs/allByImatByYear')
|
||||
return this.apiService.get(`${this._apiVersion}/aeronefs/allByImatByYear`)
|
||||
.pipe(map(data => data.aeronefs));
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CalculatorResult, WeightSizeRange, weightSizes } from 'src/app/core/models';
|
||||
import { UtilitiesService } from 'src/app/core/services';
|
||||
import { CalculatorResult, WeightSizeRange, weightSizes } from '@models';
|
||||
import { UtilitiesService } from '@services';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CalculatorService {
|
||||
+7
-6
@@ -2,32 +2,33 @@ import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { CanopyBySize, CanopyByYear, CanopyModelBySize, CanopyModelByYear } from 'src/app/core/models';
|
||||
import { ApiService } from '../api.service';
|
||||
import { CanopyBySize, CanopyByYear, CanopyModelBySize, CanopyModelByYear } from '@models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CanopiesService {
|
||||
private _apiVersion = '/v1';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
getAllBySize(): Observable<Array<CanopyBySize>> {
|
||||
return this.apiService.get('/canopies/allBySize')
|
||||
return this.apiService.get(`${this._apiVersion}/canopies/allBySize`)
|
||||
.pipe(map(data => data.canopies));
|
||||
}
|
||||
|
||||
getAllBySizeByYear(): Observable<Array<CanopyByYear>> {
|
||||
return this.apiService.get('/canopies/allBySizeByYear')
|
||||
return this.apiService.get(`${this._apiVersion}/canopies/allBySizeByYear`)
|
||||
.pipe(map(data => data.canopies));
|
||||
}
|
||||
|
||||
getAllBySizeByModel(): Observable<Array<CanopyModelBySize>> {
|
||||
return this.apiService.get('/canopies/allBySizeByModel')
|
||||
return this.apiService.get(`${this._apiVersion}/canopies/allBySizeByModel`)
|
||||
.pipe(map(data => data.canopies));
|
||||
}
|
||||
|
||||
getAllBySizeByModelByYear(): Observable<Array<CanopyModelByYear>> {
|
||||
return this.apiService.get('/canopies/allBySizeByModelByYear')
|
||||
return this.apiService.get(`${this._apiVersion}/canopies/allBySizeByModelByYear`)
|
||||
.pipe(map(data => data.canopies));
|
||||
}
|
||||
|
||||
+5
-4
@@ -2,22 +2,23 @@ import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { DropZoneByOaci, DropZoneByYear } from 'src/app/core/models';
|
||||
import { ApiService } from '../api.service';
|
||||
import { DropZoneByOaci, DropZoneByYear } from '@models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class DropZonesService {
|
||||
private _apiVersion = '/v1';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
getAllByOaci(): Observable<Array<DropZoneByOaci>> {
|
||||
return this.apiService.get('/dropzones/allByOaci')
|
||||
return this.apiService.get(`${this._apiVersion}/dropzones/allByOaci`)
|
||||
.pipe(map(data => data.dropzones));
|
||||
}
|
||||
|
||||
getAllByOaciByYear(): Observable<Array<DropZoneByYear>> {
|
||||
return this.apiService.get('/dropzones/allByOaciByYear')
|
||||
return this.apiService.get(`${this._apiVersion}/dropzones/allByOaciByYear`)
|
||||
.pipe(map(data => data.dropzones));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from './aeronefs.service';
|
||||
export * from './calculator.service';
|
||||
export * from './canopies.service';
|
||||
export * from './dropzones.service';
|
||||
export * from './jumps.service';
|
||||
export * from './jump-table.service';
|
||||
export * from './qcm.service';
|
||||
+20
-19
@@ -3,15 +3,16 @@ import { HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { ApiService } from '../api.service';
|
||||
import {
|
||||
Jump, JumpByCategorie, JumpByDate, JumpByDay, JumpByModule, JumpFile,
|
||||
JumpList, JumpListConfig, JumpListFilters, JumpPageData,
|
||||
X2Data, SkydiverIdJumps
|
||||
} from 'src/app/core/models';
|
||||
} from '@models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class JumpsService {
|
||||
private _apiVersion = '/v1';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
@@ -50,7 +51,7 @@ export class JumpsService {
|
||||
Object.assign(params, config.filters);
|
||||
return this.apiService
|
||||
.get(
|
||||
'/jumps' + ((config.type === 'feed') ? '/feed' : ''),
|
||||
`${this._apiVersion}/jumps` + ((config.type === 'feed') ? '/feed' : ''),
|
||||
new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params })
|
||||
@@ -62,82 +63,82 @@ export class JumpsService {
|
||||
.pipe(map(data => {
|
||||
return { jump: data.jump, prevJump: data.prevJump, nextJump: data.nextJump };
|
||||
})); */
|
||||
return this.apiService.get(`/jumps/${slug}`);
|
||||
return this.apiService.get(`${this._apiVersion}/jumps/${slug}`);
|
||||
}
|
||||
|
||||
getAll(): Observable<Array<Jump>> {
|
||||
return this.apiService.get('/jumps').pipe(map(data => data.jumps));
|
||||
return this.apiService.get(`${this._apiVersion}/jumps`).pipe(map(data => data.jumps));
|
||||
}
|
||||
|
||||
getAllByDate(): Observable<Array<JumpByDate>> {
|
||||
return this.apiService.get('/jumps/allByDate').pipe(map(data => data.jumps));
|
||||
return this.apiService.get(`${this._apiVersion}/jumps/allByDate`).pipe(map(data => data.jumps));
|
||||
}
|
||||
|
||||
getAllByCategorie(): Observable<Array<JumpByCategorie>> {
|
||||
return this.apiService.get('/jumps/allByCategorie').pipe(map(data => data.jumps));
|
||||
return this.apiService.get(`${this._apiVersion}/jumps/allByCategorie`).pipe(map(data => data.jumps));
|
||||
}
|
||||
|
||||
getAllByDay(config: JumpListConfig): Observable<Array<JumpByDay>> {
|
||||
const params: JumpListFilters = {} as JumpListFilters;
|
||||
Object.assign(params, config.filters);
|
||||
return this.apiService.get('/jumps/allByDay', new HttpParams({ fromObject: <{
|
||||
return this.apiService.get(`${this._apiVersion}/jumps/allByDay`, new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params }))
|
||||
.pipe(map(data => data.days));
|
||||
}
|
||||
|
||||
getAllByModule(): Observable<Array<JumpByModule>> {
|
||||
return this.apiService.get('/jumps/allByModule').pipe(map(data => data.jumps));
|
||||
return this.apiService.get(`${this._apiVersion}/jumps/allByModule`).pipe(map(data => data.jumps));
|
||||
}
|
||||
|
||||
getAllFromSkydiverIdApi(config: JumpListConfig): Observable<SkydiverIdJumps> {
|
||||
const params: JumpListFilters = {} as JumpListFilters;
|
||||
Object.assign(params, config.filters);
|
||||
return this.apiService.get('/jumps/allFromSkydiverIdApi', new HttpParams({ fromObject: <{
|
||||
return this.apiService.get(`${this._apiVersion}/jumps/allFromSkydiverIdApi`, new HttpParams({ fromObject: <{
|
||||
[param: string]: string | number | boolean | readonly (string | number | boolean)[];
|
||||
}>params }))
|
||||
.pipe(map(data => data.jumps));
|
||||
}
|
||||
|
||||
getLastJump(): Observable<Jump> {
|
||||
return this.apiService.get('/jumps/last').pipe(map(data => data.jump));
|
||||
return this.apiService.get(`${this._apiVersion}/jumps/last`).pipe(map(data => data.jump));
|
||||
}
|
||||
|
||||
create(jump: Jump): Observable<Jump> {
|
||||
return this.apiService.post('/jumps/', { jump: jump }).pipe(map(data => data.jump));
|
||||
return this.apiService.post(`${this._apiVersion}/jumps/`, { jump: jump }).pipe(map(data => data.jump));
|
||||
}
|
||||
|
||||
update(jump: Jump): Observable<Jump> {
|
||||
return this.apiService.put(`/jumps/${jump.slug}`, { jump: jump }).pipe(map(data => data.jump));
|
||||
return this.apiService.put(`${this._apiVersion}/jumps/${jump.slug}`, { jump: jump }).pipe(map(data => data.jump));
|
||||
}
|
||||
|
||||
destroy(slug: string): Observable<boolean> {
|
||||
return this.apiService.delete(`/jumps/${slug}`).pipe(map(data => data.deleted));
|
||||
return this.apiService.delete(`${this._apiVersion}/jumps/${slug}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(jump: Jump): Observable<Jump> {
|
||||
// If we're updating an existing jump
|
||||
if (jump.slug) {
|
||||
return this.apiService.put(`/jumps/${jump.slug}`, { jump: jump }).pipe(map(data => data.jump));
|
||||
return this.apiService.put(`${this._apiVersion}/jumps/${jump.slug}`, { jump: jump }).pipe(map(data => data.jump));
|
||||
|
||||
// Otherwise, create a new jump
|
||||
} else {
|
||||
return this.apiService.post('/jumps/', { jump: jump }).pipe(map(data => data.jump));
|
||||
return this.apiService.post(`${this._apiVersion}/jumps/`, { jump: jump }).pipe(map(data => data.jump));
|
||||
}
|
||||
}
|
||||
|
||||
saveX2Data(slug: string, file: JumpFile, data: X2Data): Observable<Jump> {
|
||||
return this.apiService.post(`/jumps/data/${slug}`, { file: file, data: data })
|
||||
return this.apiService.post(`${this._apiVersion}/jumps/data/${slug}`, { file: file, data: data })
|
||||
.pipe(map(data => data.jump));
|
||||
}
|
||||
|
||||
saveFile(slug: string, file: JumpFile): Observable<JumpFile> {
|
||||
return this.apiService.post(`/jumps/file/${slug}`, { file: file })
|
||||
return this.apiService.post(`${this._apiVersion}/jumps/file/${slug}`, { file: file })
|
||||
.pipe(map(data => data.file));
|
||||
}
|
||||
|
||||
saveKml(slug: string, file: JumpFile): Observable<JumpFile> {
|
||||
return this.apiService.post(`/jumps/kml/${slug}`, { file: file })
|
||||
return this.apiService.post(`${this._apiVersion}/jumps/kml/${slug}`, { file: file })
|
||||
.pipe(map(data => data.file));
|
||||
}
|
||||
|
||||
@@ -2,27 +2,27 @@ import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { Qcm, QcmCategory, QcmQuestion } from 'src/app/core/models';
|
||||
import { ApiService } from '../api.service';
|
||||
import { Qcm, QcmCategory, QcmQuestion } from '@models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class QcmService {
|
||||
|
||||
private _apiVersion = '/v1';
|
||||
constructor(
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
get(type: string): Observable<Qcm> {
|
||||
return this.apiService.get(`/qcm/type/${type}`).pipe(map(data => data.qcm));
|
||||
return this.apiService.get(`${this._apiVersion}/qcm/type/${type}`).pipe(map(data => data.qcm));
|
||||
}
|
||||
|
||||
saveChoices(question: object): Observable<QcmQuestion> {
|
||||
return this.apiService.post('/qcm/choices', { question: question })
|
||||
return this.apiService.post(`${this._apiVersion}/qcm/choices`, { question: question })
|
||||
.pipe(map(data => data.question));
|
||||
}
|
||||
|
||||
saveQuestions(category: object): Observable<QcmCategory> {
|
||||
return this.apiService.post('/qcm/questions', { category: category })
|
||||
return this.apiService.post(`${this._apiVersion}/qcm/questions`, { category: category })
|
||||
.pipe(map(data => data.category));
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import { HttpClient } from "@angular/common/http";
|
||||
import { Observable, BehaviorSubject, ReplaySubject, Subscription } from 'rxjs';
|
||||
import { distinctUntilChanged, take, tap } from 'rxjs/operators';
|
||||
|
||||
import { User } from 'src/app/core/models';
|
||||
import { JwtService } from 'src/app/core/services';
|
||||
import { User } from '@models';
|
||||
import { JwtService } from '@services';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class UserService implements OnDestroy {
|
||||
@@ -17,6 +17,7 @@ export class UserService implements OnDestroy {
|
||||
public isAuthenticated = this.isAuthenticatedSubject.asObservable();
|
||||
|
||||
|
||||
private apiVersion = '/v2';
|
||||
constructor(
|
||||
private readonly http: HttpClient,
|
||||
private readonly jwtService: JwtService
|
||||
@@ -31,7 +32,7 @@ export class UserService implements OnDestroy {
|
||||
populate() {
|
||||
// If JWT detected, attempt to get & store user's info
|
||||
if (this.jwtService.getToken()) {
|
||||
const user$: Observable<{ user: User }> = this.http.get<{ user: User }>('/user').pipe(take(1));
|
||||
const user$: Observable<{ user: User }> = this.http.get<{ user: User }>(`${this.apiVersion}/user`).pipe(take(1));
|
||||
this._user = user$.subscribe({
|
||||
next: (data) => this.setAuth(data.user),
|
||||
error: () => this.purgeAuth()
|
||||
@@ -63,7 +64,7 @@ export class UserService implements OnDestroy {
|
||||
|
||||
attemptAuth(type: string, credentials?: { email: string; password: string; }): Observable<{ user: User }> {
|
||||
const route = (type === 'login') ? '/login' : '';
|
||||
const user$: Observable<{ user: User }> = this.http.post<{ user: User }>(`/user${route}`, { user: credentials });
|
||||
const user$: Observable<{ user: User }> = this.http.post<{ user: User }>(`${this.apiVersion}/user${route}`, { user: credentials });
|
||||
/*return user$.pipe(map(
|
||||
(data: any) => {
|
||||
this.setAuth(data.user);
|
||||
@@ -83,7 +84,7 @@ export class UserService implements OnDestroy {
|
||||
|
||||
// Update the user on the server (email, pass, etc)
|
||||
update(user: Partial<User>): Observable<{ user: User }> {
|
||||
return this.http.put<{ user: User }>("/user", { user }).pipe(
|
||||
return this.http.put<{ user: User }>(`${this.apiVersion}/user`, { user }).pipe(
|
||||
tap(({ user }) => {
|
||||
this.currentUserSubject.next(user);
|
||||
}),
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { Chart } from 'chart.js';
|
||||
import { Configuration } from 'ng-chartist';
|
||||
|
||||
import { BarConfig, CircleConfig, DoughnutConfig, LineConfig } from 'src/app/core/models';
|
||||
import { BarConfig, CircleConfig, DoughnutConfig, LineConfig } from '@models';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class UtilitiesService {
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
import { HWGuildClan } from '@models';
|
||||
|
||||
export class ClanViewModel {
|
||||
clan: HWGuildClan;
|
||||
|
||||
constructor(clan: HWGuildClan) {
|
||||
this.clan = clan;
|
||||
}
|
||||
|
||||
getTitle(): string {
|
||||
return this.clan.title;
|
||||
}
|
||||
|
||||
getServer(): string {
|
||||
return this.clan.serverId;
|
||||
}
|
||||
|
||||
getMembersCount(): string {
|
||||
return this.clan.membersCount;
|
||||
}
|
||||
|
||||
getCountry(): string {
|
||||
return this.clan.country;
|
||||
}
|
||||
|
||||
getDescription(): string {
|
||||
return this.clan.description;
|
||||
}
|
||||
|
||||
getLevel(): string {
|
||||
return this.clan.level;
|
||||
}
|
||||
|
||||
getMinLevel(): string {
|
||||
return this.clan.minLevel;
|
||||
}
|
||||
|
||||
getTopActivity(): number {
|
||||
return +this.clan.topActivity;
|
||||
}
|
||||
|
||||
getTopDungeon(): number {
|
||||
return +this.clan.topDungeon;
|
||||
}
|
||||
|
||||
getDisbanding(): boolean {
|
||||
return this.clan.disbanding;
|
||||
}
|
||||
|
||||
getFrameId(): number {
|
||||
return this.clan.frameId;
|
||||
}
|
||||
|
||||
getOwnerId(): string {
|
||||
return this.clan.ownerId;
|
||||
}
|
||||
}
|
||||
|
||||
export class ClansViewModel {
|
||||
clans: ClanViewModel[];
|
||||
|
||||
constructor(clans: HWGuildClan[]) {
|
||||
this.clans = clans.map(clan => new ClanViewModel(clan));
|
||||
}
|
||||
|
||||
getClans(): ClanViewModel[] {
|
||||
return this.clans;
|
||||
}
|
||||
|
||||
getClanCount(): number {
|
||||
return this.clans.length;
|
||||
}
|
||||
|
||||
getClanByTitle(title: string): ClanViewModel | undefined {
|
||||
return this.clans.find(clan => clan.getTitle() === title);
|
||||
}
|
||||
|
||||
getClansByCountry(country: string): ClanViewModel[] {
|
||||
return this.clans.filter(clan => clan.getCountry() === country);
|
||||
}
|
||||
|
||||
getClansByServer(server: string): ClanViewModel[] {
|
||||
return this.clans.filter(clan => clan.getServer() === server);
|
||||
}
|
||||
|
||||
getClansByLevel(level: string): ClanViewModel[] {
|
||||
return this.clans.filter(clan => clan.getLevel() === level);
|
||||
}
|
||||
|
||||
getDisbandingClans(): ClanViewModel[] {
|
||||
return this.clans.filter(clan => clan.getDisbanding());
|
||||
}
|
||||
|
||||
getActiveDisbands(): ClanViewModel[] {
|
||||
return this.clans.filter(clan => !clan.getDisbanding());
|
||||
}
|
||||
|
||||
getClansByOwnerId(ownerId: string): ClanViewModel[] {
|
||||
return this.clans.filter(clan => clan.getOwnerId() === ownerId);
|
||||
}
|
||||
|
||||
getClansByMinLevel(minLevel: string): ClanViewModel[] {
|
||||
return this.clans.filter(clan => clan.getMinLevel() === minLevel);
|
||||
}
|
||||
|
||||
getAverageTopActivity(): number {
|
||||
if (this.clans.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
const totalActivity = this.clans.reduce((sum, clan) => {
|
||||
const activity = clan.getTopActivity() || 0;
|
||||
return sum + activity;
|
||||
}, 0);
|
||||
return totalActivity / this.clans.length;
|
||||
}
|
||||
|
||||
getAverageTopDungeon(): number {
|
||||
if (this.clans.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
const totalDungeon = this.clans.reduce((sum, clan) => {
|
||||
const dungeon = clan.getTopDungeon() || 0;
|
||||
return sum + dungeon;
|
||||
}, 0);
|
||||
return totalDungeon / this.clans.length;
|
||||
}
|
||||
|
||||
getClansByCountryAndServer(country: string, server: string): ClanViewModel[] {
|
||||
return this.clans.filter(clan => clan.getCountry() === country && clan.getServer() === server);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './clan.viewmodel';
|
||||
export * from './members.viewmodel';
|
||||
@@ -0,0 +1,209 @@
|
||||
import {
|
||||
HWMember, HWMemberStat, HWWeekStat,
|
||||
HWGuildRaid, HWMemberHeroes, HWMemberTitans
|
||||
} from '@models';
|
||||
|
||||
export class MemberViewModel {
|
||||
member: HWMember;
|
||||
|
||||
constructor(member: HWMember) {
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
return this.member.id;
|
||||
}
|
||||
|
||||
getName(): string {
|
||||
return this.member.name;
|
||||
}
|
||||
|
||||
getClanTitle(): string {
|
||||
return this.member.clanTitle;
|
||||
}
|
||||
|
||||
getServerId(): string {
|
||||
return this.member.serverId;
|
||||
}
|
||||
|
||||
getLastLoginTime(): string {
|
||||
return this.member.lastLoginTime;
|
||||
}
|
||||
|
||||
getLevel(): string {
|
||||
return this.member.level;
|
||||
}
|
||||
|
||||
getAllowPm(): string {
|
||||
return this.member.allowPm;
|
||||
}
|
||||
|
||||
getAvatarId(): string {
|
||||
return this.member.avatarId;
|
||||
}
|
||||
|
||||
getClanIcon() {
|
||||
return this.member.clanIcon;
|
||||
}
|
||||
|
||||
getClanId(): string {
|
||||
return this.member.clanId;
|
||||
}
|
||||
|
||||
getClanRole(): string {
|
||||
return this.member.clanRole;
|
||||
}
|
||||
|
||||
isCommander(): boolean {
|
||||
return this.member.commander;
|
||||
}
|
||||
|
||||
getFrameId(): number {
|
||||
return this.member.frameId;
|
||||
}
|
||||
|
||||
isChatModerator(): boolean {
|
||||
return this.member.isChatModerator;
|
||||
}
|
||||
|
||||
getLeagueId(): number {
|
||||
return this.member.leagueId;
|
||||
}
|
||||
|
||||
canShowProfile(): boolean {
|
||||
return this.member.showProfile;
|
||||
}
|
||||
|
||||
isChampion(): boolean {
|
||||
return this.member.champion;
|
||||
}
|
||||
|
||||
getMemberHeroes(): HWMemberHeroes {
|
||||
return this.member.heroes;
|
||||
}
|
||||
|
||||
getMemberTitans(): HWMemberTitans {
|
||||
return this.member.titans;
|
||||
}
|
||||
|
||||
getStat(): HWMemberStat {
|
||||
return this.member.stat;
|
||||
}
|
||||
|
||||
getInactivity() {
|
||||
return this.member.inactivity;
|
||||
}
|
||||
|
||||
getAdventureSum(): number {
|
||||
return this.member.adventureSum;
|
||||
}
|
||||
|
||||
getClanGiftsSum(): number {
|
||||
return this.member.clanGiftsSum;
|
||||
}
|
||||
|
||||
getClanWarSum(): number {
|
||||
return this.member.clanWarSum;
|
||||
}
|
||||
|
||||
getWeekStat(): HWWeekStat {
|
||||
return this.member.weekStat;
|
||||
}
|
||||
|
||||
getScore(): number {
|
||||
return this.member.score;
|
||||
}
|
||||
|
||||
getScoreGifts(): number {
|
||||
return this.member.scoreGifts;
|
||||
}
|
||||
|
||||
getWarGifts(): number {
|
||||
return this.member.warGifts;
|
||||
}
|
||||
|
||||
getRewards(): number {
|
||||
return this.member.rewards;
|
||||
}
|
||||
|
||||
getRaids(): HWGuildRaid[] {
|
||||
return this.member.raids;
|
||||
}
|
||||
|
||||
getRaidsInfo() {
|
||||
return this.member.raidsInfo;
|
||||
}
|
||||
}
|
||||
|
||||
export class MembersViewModel {
|
||||
members: MemberViewModel[];
|
||||
|
||||
constructor(members: HWMember[]) {
|
||||
this.members = members.map(member => new MemberViewModel(member));
|
||||
}
|
||||
|
||||
getMembers(): MemberViewModel[] {
|
||||
return this.members;
|
||||
}
|
||||
|
||||
getMemberCount(): number {
|
||||
return this.members.length;
|
||||
}
|
||||
|
||||
getMemberById(id: string): MemberViewModel | undefined {
|
||||
return this.members.find(member => member.getId() === id);
|
||||
}
|
||||
|
||||
getMemberByName(name: string): MemberViewModel | undefined {
|
||||
return this.members.find(member => member.getName() === name);
|
||||
}
|
||||
|
||||
getMembersByClanRole(clanRole: string): MemberViewModel[] {
|
||||
return this.members.filter(member => member.getClanRole() === clanRole);
|
||||
}
|
||||
|
||||
getCommandeurs(): MemberViewModel[] {
|
||||
return this.members.filter(member => member.isCommander());
|
||||
}
|
||||
|
||||
getChampions(): MemberViewModel[] {
|
||||
return this.members.filter(member => member.isChampion());
|
||||
}
|
||||
|
||||
getMembersByLevel(level: string): MemberViewModel[] {
|
||||
return this.members.filter(member => member.getLevel() === level);
|
||||
}
|
||||
|
||||
getMembersWithLowestScore(): MemberViewModel[] {
|
||||
if (this.members.length === 0) return [];
|
||||
const minScore = Math.min(...this.members.map(m => m.getScore()));
|
||||
return this.members.filter(member => member.getScore() === minScore);
|
||||
}
|
||||
|
||||
getMembersWithHighestScore(): MemberViewModel[] {
|
||||
if (this.members.length === 0) return [];
|
||||
const maxScore = Math.max(...this.members.map(m => m.getScore()));
|
||||
return this.members.filter(member => member.getScore() === maxScore);
|
||||
}
|
||||
|
||||
getTotalScore(): number {
|
||||
return this.members.reduce((sum, member) => sum + member.getScore(), 0);
|
||||
}
|
||||
|
||||
getAverageScore(): number {
|
||||
if (this.members.length === 0) return 0;
|
||||
return this.getTotalScore() / this.members.length;
|
||||
}
|
||||
|
||||
getTotalAdventureSum(): number {
|
||||
return this.members.reduce((sum, member) => sum + member.getAdventureSum(), 0);
|
||||
}
|
||||
|
||||
getTotalClanWarSum(): number {
|
||||
return this.members.reduce((sum, member) => sum + member.getClanWarSum(), 0);
|
||||
}
|
||||
|
||||
getTotalClanGiftsSum(): number {
|
||||
return this.members.reduce((sum, member) => sum + member.getClanGiftsSum(), 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './herowars/';
|
||||
Reference in New Issue
Block a user