Linting
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { CanActivateFn, Router } from '@angular/router';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
|
||||
import { UserService } from 'src/app/core/services';
|
||||
|
||||
export const adminGuard: CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
|
||||
export const adminGuard: CanActivateFn = () => {
|
||||
const router = inject(Router);
|
||||
const userService = inject(UserService);
|
||||
return userService.currentUser.pipe(take(1)).pipe(map(data => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { CanActivateFn, Router } from '@angular/router';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
|
||||
import { UserService } from 'src/app/core/services';
|
||||
|
||||
export const authGuard: CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
|
||||
export const authGuard: CanActivateFn = () => {
|
||||
const router = inject(Router);
|
||||
const userService = inject(UserService);
|
||||
return userService.isAuthenticated.pipe(take(1)).pipe(map(data => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { CanActivateFn } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
|
||||
import { UserService } from 'src/app/core/services';
|
||||
|
||||
export const noauthGuard: CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> => {
|
||||
export const noauthGuard: CanActivateFn = (): Observable<boolean> => {
|
||||
/*
|
||||
const router = inject(Router);
|
||||
const userService = inject(UserService);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { Application } from './application.model';
|
||||
|
||||
export interface ApplicationList {
|
||||
applications: Array<Application>;
|
||||
applicationsCount: number;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
export interface CanopySize {
|
||||
id: string;
|
||||
key: any;
|
||||
value: any;
|
||||
doc?: CanopySizeDoc;
|
||||
}
|
||||
export interface CanopySizeDoc {
|
||||
_id: string;
|
||||
_rev: string;
|
||||
type: string;
|
||||
weight: number;
|
||||
values: [];
|
||||
}
|
||||
@@ -3,27 +3,27 @@ import { ChartConfiguration, ChartOptions } from 'chart.js';
|
||||
export interface BarConfig {
|
||||
barChartData: ChartConfiguration<'bar'>['data'],
|
||||
barChartOptions: ChartConfiguration<'bar'>['options'],
|
||||
barChartPlugins: any[],
|
||||
barChartPlugins: ChartConfiguration<'bar'>['plugins'],
|
||||
barChartLegend: boolean
|
||||
}
|
||||
|
||||
export interface CircleConfig {
|
||||
circleChartLabels: string[],
|
||||
circleChartDatasets: ChartConfiguration<'doughnut'>['data']['datasets'],
|
||||
circleChartOptions: ChartConfiguration<'doughnut'>['options'],
|
||||
circleChartPlugins: ChartConfiguration<'doughnut'>['plugins'],
|
||||
circleChartOptions: ChartConfiguration<'doughnut'>['options'],
|
||||
circleChartPlugins: ChartConfiguration<'doughnut'>['plugins'],
|
||||
circleChartLegend: boolean
|
||||
}
|
||||
|
||||
export interface DoughnutConfig {
|
||||
doughnutChartLabels: string[],
|
||||
doughnutChartDatasets: ChartConfiguration<'doughnut'>['data']['datasets'],
|
||||
doughnutChartOptions: ChartConfiguration<'doughnut'>['options'],
|
||||
doughnutChartOptions: ChartConfiguration<'doughnut'>['options'],
|
||||
doughnutChartLegend: boolean
|
||||
}
|
||||
|
||||
export interface LineConfig {
|
||||
lineChartData: ChartConfiguration<'line'>['data'],
|
||||
lineChartOptions: ChartOptions<'line'>,
|
||||
lineChartOptions: ChartOptions<'line'>,
|
||||
lineChartLegend: boolean
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
export * from './aeronef.model';
|
||||
export * from './aeronef-list.model';
|
||||
export * from './application.model';
|
||||
export * from './application-list.model';
|
||||
export * from './application-list-config.model';
|
||||
export * from './calculator.model';
|
||||
export * from './canopy.model';
|
||||
export * from './canopysize.model';
|
||||
export * from './chart.model';
|
||||
export * from './dropzone.model';
|
||||
export * from './errors.model';
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
//import { environment } from 'src/environments/environment';
|
||||
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,7 +3,7 @@ import { HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { ApiService } from './api.service';
|
||||
import { Application, ApplicationListConfig, ApplicationListFilters } from 'src/app/core/models';
|
||||
import { Application, ApplicationList, ApplicationListConfig, ApplicationListFilters } from 'src/app/core/models';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@@ -12,7 +12,7 @@ export class ApplicationsService {
|
||||
private apiService: ApiService
|
||||
) { }
|
||||
|
||||
query(config: ApplicationListConfig): Observable<{ applications: Application[], applicationsCount: number }> {
|
||||
query(config: ApplicationListConfig): Observable<ApplicationList> {
|
||||
// Convert any filters over to Angular's URLSearchParams
|
||||
const params: ApplicationListFilters = {
|
||||
apikey: config.filters.apikey,
|
||||
@@ -34,8 +34,8 @@ export class ApplicationsService {
|
||||
.pipe(map(data => data.application));
|
||||
}
|
||||
|
||||
destroy(slug: string) {
|
||||
return this.apiService.delete(`/applications/${slug}`);
|
||||
destroy(slug: string): Observable<boolean> {
|
||||
return this.apiService.delete(`/applications/${slug}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(application: Application): Observable<Application> {
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { Jump } from 'src/app/core/models';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
export interface JumpDoc {
|
||||
_id?: string;
|
||||
_rev?: string;
|
||||
type: string;
|
||||
date: string;
|
||||
numero: number,
|
||||
lieu?: string;
|
||||
oaci?: string;
|
||||
aeronef?: string;
|
||||
imat?: string;
|
||||
hauteur?: number,
|
||||
voile?: string;
|
||||
taille?: number,
|
||||
categorie?: string;
|
||||
module?: string;
|
||||
participants?: number,
|
||||
programme?: string;
|
||||
accessoires?: string;
|
||||
zone?: string;
|
||||
dossier?: string;
|
||||
video?: string;
|
||||
}
|
||||
|
||||
export interface JumpViewResults {
|
||||
rows: Array<Jump>;
|
||||
total_rows: number;
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class BackendService {
|
||||
private _couchdbUrl = environment.couchdbUrl;
|
||||
private _couchdbDatabase = environment.couchdbDatabase;
|
||||
private _couchdbDesign = environment.couchdbDesign;
|
||||
private _couchdbCredential = environment.couchdbCredential;
|
||||
//private _couchdbUrl = "http://couchdb.unespace.com/material_grow/_design/netgrowing_app/_view/allDevices";
|
||||
|
||||
httpOptions = {
|
||||
headers: new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Basic ' + this._couchdbCredential
|
||||
})
|
||||
}
|
||||
|
||||
constructor(private _http: HttpClient) { }
|
||||
|
||||
writeDoc(doc: Object): Promise<Object | undefined> {
|
||||
const url = this._couchdbUrl + '/' + this._couchdbDatabase;
|
||||
return this._http.post<Object>(url, doc, this.httpOptions).toPromise();
|
||||
}
|
||||
|
||||
updateDoc(doc: JumpDoc): Promise<Object | undefined> {
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/${doc._id}`;
|
||||
return this._http.put<Object>(url, doc, this.httpOptions).toPromise();
|
||||
}
|
||||
|
||||
deleteDoc(id: string, rev: string): Promise<Object | undefined> {
|
||||
//const url = this._couchdbUrl + '/' + this._couchdbDatabase + '/' + id + '?rev=' + rev;
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/${id}?rev=${rev}`;
|
||||
return this._http.delete(url, this.httpOptions).toPromise();
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'allJumps' */
|
||||
getJumps(): Observable<JumpViewResults> {
|
||||
//const url = this._couchdbUrl + '/' + this._couchdbDatabase + '/_design/' + this._couchdbDesign + '/_view/allJumps/';
|
||||
//return this._http.get(url, this.httpOptions);
|
||||
const payload = {
|
||||
"include_docs": false,
|
||||
"reduce": false,
|
||||
"descending": false
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/allJumps/`;
|
||||
return this._http.post<JumpViewResults>(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'allJumpsByDate' */
|
||||
getJumpsByDate(level: number): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true,
|
||||
"group_level": level
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/allJumpsByDate/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'filterAeronef' */
|
||||
getAeronefs(): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/filterAeronef/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'filterAeronefByDate' */
|
||||
getAeronefsByDate(level: number): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true,
|
||||
"group_level": level
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/filterAeronefByDate/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'filterCanopyModel' */
|
||||
getCanopyModels(): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/filterCanopyModel/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'filterCanopyModelByDate' */
|
||||
getCanopyModelsByDate(level: number): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true,
|
||||
"group_level": level
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/filterCanopyModelByDate/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'filterCanopySize' */
|
||||
getCanopySizes(): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/filterCanopySize/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'filterCanopySizeByDate' */
|
||||
getCanopySizesByDate(level: number): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true,
|
||||
"group_level": level
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/filterCanopySizeByDate/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'allDropZones' */
|
||||
getDropZones(): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/allDropZones/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'allDropZonesByDate' */
|
||||
getDropZonesByDate(level: number): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true,
|
||||
"group_level": level
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/allDropZonesByDate/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'allJumps' */
|
||||
getTotalJumps(): Observable<Object> {
|
||||
const payload = {
|
||||
"reduce": true,
|
||||
"group": true,
|
||||
"group_level": 1
|
||||
}
|
||||
const url = `${this._couchdbUrl}/${this._couchdbDatabase}/_design/${this._couchdbDesign}/_view/allJumps/`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'allDevices' */
|
||||
getDeviceActivities(deviceId: string, limit: number, start: number, end: number): Observable<Object> {
|
||||
const payload = {
|
||||
"selector": {
|
||||
"type": {
|
||||
"$eq": "activity"
|
||||
},
|
||||
"device_id": {
|
||||
"$eq": deviceId
|
||||
},
|
||||
"created_time": {
|
||||
"$gte": start,
|
||||
"$lte": end
|
||||
}
|
||||
},
|
||||
"fields": [
|
||||
"created_time",
|
||||
"device_id",
|
||||
"values"
|
||||
],
|
||||
"sort": [
|
||||
{
|
||||
"created_time": "desc"
|
||||
}
|
||||
],
|
||||
"limit": limit
|
||||
}
|
||||
//const url = this._couchdbUrl + '/' + this._couchdbDatabase + '/_find';
|
||||
const url = `${this._couchdbUrl}/material_grow/_find`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
/* get all docs from couchDB view 'getDevicesActivities' */
|
||||
getDevicesActivities(key: string, limit: number, start: any, end: any): Observable<Object> {
|
||||
/*
|
||||
const payload = {
|
||||
"start_key": [deviceId, end],
|
||||
"end_key": [deviceId, start],
|
||||
"descending": true,
|
||||
"limit": limit,
|
||||
"reduce": false
|
||||
}
|
||||
const url = this._couchdbUrl + '/' + this._couchdbDatabase + '/_design/' + this._couchdbDesign + '/_view/allActivitiesByDevice/';
|
||||
*/
|
||||
const payload = {
|
||||
"start_key": [key, 1, start],
|
||||
"end_key": [key, 1, end],
|
||||
"limit": limit,
|
||||
"descending": true,
|
||||
"include_docs": true,
|
||||
"reduce": false
|
||||
}
|
||||
const url = `${this._couchdbUrl}/netgrowing/_design/app/_view/getDevicesActivities`;
|
||||
return this._http.post(url, payload, this.httpOptions);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
export * from './aeronefs.service';
|
||||
export * from './api.service';
|
||||
export * from './applications.service';
|
||||
export * from './backend.service';
|
||||
export * from './calculator.service';
|
||||
export * from './canopies.service';
|
||||
export * from './dropzones.service';
|
||||
|
||||
@@ -111,8 +111,8 @@ export class JumpsService {
|
||||
return this.apiService.put(`/jumps/${jump.slug}`, { jump: jump }).pipe(map(data => data.jump));
|
||||
}
|
||||
|
||||
destroy(slug: string) {
|
||||
return this.apiService.delete(`/jumps/${slug}`);
|
||||
destroy(slug: string): Observable<boolean> {
|
||||
return this.apiService.delete(`/jumps/${slug}`).pipe(map(data => data.deleted));
|
||||
}
|
||||
|
||||
save(jump: Jump): Observable<Jump> {
|
||||
|
||||
Reference in New Issue
Block a user