Commit 87abe92e authored by PECQUOT's avatar PECQUOT

[enh] use account, person, department models and service of sumaris-lib

[enh] add resizable capability for a table
parent dab5996e
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config
It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.
We recommend eventually switching this configuration to extend from
the recommended rulesets in typescript-eslint.
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
Happy linting! 💖
*/
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"eslint-plugin-import",
"@angular-eslint/eslint-plugin",
"@typescript-eslint",
"@typescript-eslint/tslint"
],
"rules": {
"@angular-eslint/directive-class-suffix": "error",
"@angular-eslint/no-input-rename": "error",
"@angular-eslint/no-output-on-prefix": "error",
"@angular-eslint/no-output-rename": "error",
"@angular-eslint/use-pipe-transform-interface": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/naming-convention": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-inferrable-types": [
"error",
{
"ignoreParameters": true
}
],
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/semi": [
"error",
"always"
],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"arrow-body-style": "error",
"brace-style": [
"off",
"off"
],
"constructor-super": "error",
"curly": "off",
"eol-last": "error",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-blacklist": "off",
"id-match": "off",
"import/no-deprecated": "warn",
"no-bitwise": "error",
"no-caller": "error",
"no-console": [
"error",
{
"allow": [
"warn",
"dir",
"timeLog",
"assert",
"clear",
"count",
"countReset",
"group",
"groupEnd",
"table",
"debug",
"info",
"dirxml",
"error",
"groupCollapsed",
"Console",
"profile",
"profileEnd",
"timeStamp",
"context"
]
}
],
"no-debugger": "error",
"no-empty": "off",
"no-eval": "error",
"no-fallthrough": "error",
"no-new-wrappers": "error",
"no-restricted-imports": [
"error",
"rxjs/Rx"
],
"no-shadow": [
"off",
{
"hoist": "all"
}
],
"no-throw-literal": "error",
"no-trailing-spaces": "off",
"no-undef-init": "off",
"no-underscore-dangle": "off",
"no-var": "error",
"prefer-const": "error",
"radix": "off",
"@typescript-eslint/tslint/config": [
"error",
{
"rules": {
"use-host-property-decorator": true,
"use-input-property-decorator": true,
"use-life-cycle-interface": true,
"use-output-property-decorator": true,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}
]
}
};
......@@ -101,8 +101,7 @@
"includePaths": [
"src/theme"
]
},
"preserveSymlinks": true
}
},
"configurations": {
"production": {
......
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {HomePage} from "sumaris-lib/app/core/home/home";
import {AuthGuardService} from "./core/services/auth-guard.service";
import {SHARED_ROUTE_OPTIONS, SharedRoutingModule} from "./shared/shared-routing.module";
// import {HomePage} from 'sumaris-lib';
// import {RegisterConfirmPage} from './core/register/confirm/confirm';
// import {AccountPage} from './core/account/account';
// import {SettingsPage} from "./core/settings/settings.page";
// import {AuthGuardService} from "./core/services/auth-guard.service";
// import {SHARED_ROUTE_OPTIONS, SharedRoutingModule} from "./shared/shared-routing.module";
import {AuthGuardService, SHARED_ROUTE_OPTIONS, SharedRoutingModule} from "sumaris-lib";
import {HomePage} from "@app/core/home/home";
const routes: Routes = [
// Core path
......@@ -48,21 +41,26 @@ const routes: Routes = [
},
// Test module (disable in menu, by default - can be enable by the Pod configuration page)
// {
// path: 'testing',
// children: [
// {
// path: '',
// pathMatch: 'full',
// redirectTo: 'shared',
// },
// // Shared module
// {
// path: 'shared',
// loadChildren: () => import('./shared/shared.testing.module').then(m => m.SharedTestingModule)
// },
// ]
// },
{
path: 'testing',
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'shared',
},
// Shared module
{
path: 'shared',
loadChildren: () => import('./testing/quadrige.testing.module').then(m => m.QuadrigeTestingModule)
},
// Table
{
path: 'table',
loadChildren: () => import('./testing/table.testing.module').then(m => m.WrappingTestingModule)
}
]
},
// Other route redirection (should at the end of the array)
{
......
import {Component, Inject} from '@angular/core';
import {DOCUMENT} from "@angular/common";
import {throttleTime} from "rxjs/operators";
import {AccountService} from "./core/services/account.service";
import {ReferentialRefService} from "./referential/services/referential-ref.service";
import {MatIconRegistry} from "@angular/material/icon";
import {DomSanitizer} from "@angular/platform-browser";
import {PlatformService} from "sumaris-lib/app/core/services/platform.service";
import {LocalSettingsService} from "sumaris-lib/app/core/services/local-settings.service";
import {getColorContrast, getColorShade, getColorTint, hexToRgbArray, mixHex} from "sumaris-lib/app/shared/graph/colors.utils";
import {changeCaseToUnderscore, isNotNil, joinPropertiesPath} from "sumaris-lib/app/shared/functions";
import {FormFieldDefinition} from "sumaris-lib/app/shared/form/field.model";
import {
AccountService,
changeCaseToUnderscore,
FormFieldDefinition,
getColorContrast,
getColorShade,
getColorTint,
hexToRgbArray,
isNotNil,
joinPropertiesPath,
LocalSettingsService,
mixHex,
PlatformService
} from "sumaris-lib";
@Component({
selector: 'app-root',
......@@ -96,7 +104,7 @@ export class AppComponent {
// }
// }
protected updateTheme(options: { colors?: { [color: string]: string; } }) {
protected updateTheme(options: { colors?: { [color: string]: string } }) {
if (!options) return;
......@@ -194,8 +202,7 @@ export class AppComponent {
// Configurable fields, with label and name
['department', 'location', 'qualitativeValue', 'taxonGroup', 'taxonName', 'gear']
// Map into option definition
.map(fieldName => {
return {
.map(fieldName => ({
key: `quadrige3.field.${fieldName}.attributes`,
label: `SETTINGS.FIELDS.${changeCaseToUnderscore(fieldName).toUpperCase()}`,
type: 'enum',
......@@ -205,8 +212,7 @@ export class AppComponent {
{key: 'name,label', value: 'SETTINGS.FIELDS.ATTRIBUTES.NAME_LABEL'},
{key: 'label', value: 'SETTINGS.FIELDS.ATTRIBUTES.LABEL'}
]
} as FormFieldDefinition;
}));
} as FormFieldDefinition)));
this.settings.registerAdditionalField({
key: 'quadrige3.field.vesselSnapshot.attributes',
......
import "./vendor";
import {APP_BASE_HREF} from "@angular/common";
import {BrowserModule, HammerModule} from "@angular/platform-browser";
import {BrowserModule, HAMMER_GESTURE_CONFIG, HammerModule} from "@angular/platform-browser";
import {CUSTOM_ELEMENTS_SCHEMA, NgModule, SecurityContext} from "@angular/core";
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from "@angular/material/core";
import {MomentDateAdapter} from '@angular/material-moment-adapter';
......@@ -13,7 +13,6 @@ import {Vibration} from '@ionic-native/vibration/ngx';
// App modules
import {AppComponent} from "./app.component";
import {AppRoutingModule} from "./app-routing.module";
import {environment} from "../environments/environment";
import {HttpClient, HttpClientModule} from "@angular/common/http";
import {Camera} from "@ionic-native/camera/ngx";
import {Network} from "@ionic-native/network/ngx";
......@@ -25,11 +24,25 @@ import {IonicModule} from "@ionic/angular";
import {CacheModule} from "ionic-cache";
import {TranslateLoader, TranslateModule} from "@ngx-translate/core";
import {MarkdownModule, MarkedOptions} from "ngx-markdown";
import {SharedModule} from "sumaris-lib";
import {HttpTranslateLoaderFactory, DATE_ISO_PATTERN} from "sumaris-lib";
import {APP_HOME_BUTTONS} from "sumaris-lib/app/core/home/home";
import {APP_MENU_ITEMS} from "sumaris-lib/app/core/menu/menu.component";
import {CoreModule} from "./core/core.module";
import {QuadrigeCoreModule} from "./core/quadrige.core.module";
import {
APP_CONFIG_OPTIONS,
APP_GRAPHQL_TYPE_POLICIES,
APP_HOME_BUTTONS,
APP_LOCAL_SETTINGS_OPTIONS,
APP_MENU_ITEMS,
APP_TESTING_PAGES,
AppGestureConfig,
ConfigOptions,
DATE_ISO_PATTERN,
LocalSettings,
SocialModule,
TestingPage
} from "sumaris-lib";
import {TypePolicies} from "@apollo/client";
import {QuadrigeSharedModule} from "./shared/quadrige.shared.module";
import {TranslateHttpLoader} from "@ngx-translate/http-loader";
import {environment} from "@environments/environment";
@NgModule({
......@@ -49,7 +62,13 @@ import {CoreModule} from "./core/core.module";
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpTranslateLoaderFactory,
useFactory: (httpClient) => {
if (environment.production) {
// This is need to force a reload, after an app update
return new TranslateHttpLoader(httpClient, './assets/i18n/', `-${environment.version}.json`);
}
return new TranslateHttpLoader(httpClient, './assets/i18n/', `.json`);
},
deps: [HttpClient]
}
}),
......@@ -69,8 +88,9 @@ import {CoreModule} from "./core/core.module";
}),
// functional modules
CoreModule.forRoot(),
SharedModule.forRoot(),
QuadrigeCoreModule.forRoot(),
QuadrigeSharedModule,
SocialModule.forRoot(),
HammerModule,
AppRoutingModule
],
......@@ -104,15 +124,15 @@ import {CoreModule} from "./core/core.module";
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE, MAT_DATE_FORMATS]},
// Configure hammer gesture
// {provide: HAMMER_GESTURE_CONFIG, useClass: AppGestureConfig},
{provide: HAMMER_GESTURE_CONFIG, useClass: AppGestureConfig},
// { provide: APP_LOCAL_SETTINGS_OPTIONS, useValue: {
// pageHistoryMaxSize: 3
// } as LocalSettings
// },
{ provide: APP_LOCAL_SETTINGS_OPTIONS, useValue: {
pageHistoryMaxSize: 3
} as LocalSettings
},
// Config options (Core + trip)
// { provide: APP_CONFIG_OPTIONS, useValue: {...ConfigOptions}},
{ provide: APP_CONFIG_OPTIONS, useValue: {...ConfigOptions}},
// Menu items
{ provide: APP_MENU_ITEMS, useValue: [
......@@ -179,46 +199,33 @@ import {CoreModule} from "./core/core.module";
]
},
// // Entities Apollo cache options
// { provide: APP_GRAPHQL_TYPE_POLICIES, useValue: <TypePolicies>{
// 'MetierVO': {
// keyFields: ['entityName', 'id']
// },
// 'PmfmVO': {
// keyFields: ['entityName', 'id']
// },
// 'TaxonGroupVO': {
// keyFields: ['entityName', 'id']
// },
// 'TaxonNameVO': {
// keyFields: ['entityName', 'id']
// },
// 'LocationVO': {
// keyFields: ['entityName', 'id']
// },
// 'ReferentialVO': {
// keyFields: ['entityName', 'id']
// },
// 'MeasurementVO': {
// keyFields: ['entityName', 'id']
// },
// 'TaxonGroupStrategyVO': {
// keyFields: ['__typename', 'strategyId', 'taxonGroup', ['entityName', 'id']]
// },
// 'TaxonNameStrategyVO': {
// keyFields: ['__typename', 'strategyId', 'taxonName', ['entityName', 'id']]
// }
// }
// },
//
// // Entities options
// { provide: APP_LOCAL_STORAGE_TYPE_POLICIES, useValue: { ...TRIP_STORAGE_TYPE_POLICIES}},
// Entities Apollo cache options
{ provide: APP_GRAPHQL_TYPE_POLICIES, useValue: <TypePolicies>{
// 'PmfmVO': {
// keyFields: ['entityName', 'id']
// },
// 'TaxonGroupVO': {
// keyFields: ['entityName', 'id']
// },
// 'TaxonNameVO': {
// keyFields: ['entityName', 'id']
// },
// 'LocationVO': {
// keyFields: ['entityName', 'id']
// },
'ReferentialVO': {
keyFields: ['entityName', 'id']
}
}
},
// Entities options
// { provide: APP_LOCAL_STORAGE_TYPE_POLICIES, useValue: { ...TRIP_STORAGE_TYPE_POLICIES}},
// Test pages
// { provide: APP_TESTING_PAGES, useValue: <TestingPage[]>[
// {label: 'Batch tree', page: '/testing/trip/batchTree'}
// ]},
// Test pages link
{ provide: APP_TESTING_PAGES, useValue: <TestingPage[]>[
{label: 'Batch tree', page: '/testing/trip/batchTree'}
]},
],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
......
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, OnInit, Output} from "@angular/core";
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Inject, OnInit, Output} from "@angular/core";
import {FormBuilder, Validators} from "@angular/forms";
import {ModalController} from "@ionic/angular";
import {AuthData} from "../../services/account.service";
import {environment} from "../../../../environments/environment";
import {DateAdapter} from "@angular/material/core";
import {Moment} from "moment";
import {debounceTime} from "rxjs/operators";
import {slideUpDownAnimation} from "sumaris-lib/app/shared/material/material.animations";
import {AppForm} from "sumaris-lib/app/core/form/form.class";
import {PlatformService} from "sumaris-lib/app/core/services/platform.service";
import {LocalSettingsService} from "sumaris-lib/app/core/services/local-settings.service";
import {NetworkService} from "sumaris-lib/app/core/services/network.service";
import {AuthData, EnvironmentService, slideUpDownAnimation} from "sumaris-lib";
import {AppForm} from "sumaris-lib";
import {PlatformService} from "sumaris-lib";
import {LocalSettingsService} from "sumaris-lib";
import {NetworkService} from "sumaris-lib";
@Component({
selector: 'app-form-auth',
selector: 'app-quadrige-form-auth',
templateUrl: 'form-auth.html',
styleUrls: ['./form-auth.scss'],
animations: [slideUpDownAnimation],
......@@ -45,11 +43,12 @@ export class AuthForm extends AppForm<AuthData> implements OnInit {
settings: LocalSettingsService,
private modalCtrl: ModalController,
public network: NetworkService,
private cd: ChangeDetectorRef
private cd: ChangeDetectorRef,
@Inject(EnvironmentService) protected environment
) {
super(dateAdapter,
formBuilder.group({
username: [null, Validators.compose([Validators.required, Validators.email])],
username: [null, Validators.required],
password: [null, Validators.required],
offline: [network.offline]
}), settings);
......@@ -62,10 +61,10 @@ export class AuthForm extends AppForm<AuthData> implements OnInit {
ngOnInit() {
super.ngOnInit();
// For DEV only
if (environment.production === false) {
if (this.environment.production === false) {
this.form.patchValue({
username: 'admin@sumaris.net',
password: 'admin'
username: 'tstq2',
password: 'q22006'
});
}
}
......
......@@ -23,8 +23,8 @@
</ion-header>
<ion-content>
<app-form-auth (onSubmit)="doSubmit()" (onCancel)="cancel()" #form>
</app-form-auth>
<app-quadrige-form-auth (onSubmit)="doSubmit()" (onCancel)="cancel()" #form>
</app-quadrige-form-auth>
</ion-content>
<ion-footer hidden-xs hidden-sm hidden-mobile>
......
import {Component, ViewChild} from '@angular/core';
import {ModalController} from '@ionic/angular';
import {AccountService} from "../../services/account.service";
import {AuthForm} from '../form/form-auth';
import {firstNotNilPromise} from "sumaris-lib/app/shared/observables";
import {AccountService, firstNotNilPromise} from "sumaris-lib";
@Component({
templateUrl: 'modal-auth.html',
......
import {ModuleWithProviders, NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {AuthForm} from './auth/form/form-auth';
import {AuthModal} from './auth/modal/modal-auth';
import {IonicStorageModule} from '@ionic/storage';
import {HttpClientModule} from '@angular/common/http';