Skip to content

Commit

Permalink
Update files to match tailormap-viewer repo
Browse files Browse the repository at this point in the history
  • Loading branch information
matthijsln committed Sep 26, 2024
1 parent 4cf1273 commit a1351b3
Show file tree
Hide file tree
Showing 12 changed files with 664 additions and 31 deletions.
26 changes: 18 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
],
"plugins": [
"rxjs",
"import"
"import",
"@stylistic/ts"
],
"extends": [
"eslint:recommended",
Expand All @@ -30,7 +31,16 @@
]
},
"rules": {
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "tm",
"style": "kebab-case"
}
],
"@typescript-eslint/no-explicit-any": "off",
"@stylistic/ts/no-explicit-any": "off",
"@angular-eslint/directive-selector": [
"error",
{
Expand Down Expand Up @@ -62,7 +72,7 @@
"always"
],
"comma-dangle": "off",
"@typescript-eslint/comma-dangle": [
"@stylistic/ts/comma-dangle": [
"error",
"always-multiline"
],
Expand All @@ -73,8 +83,8 @@
"import/order": "off",
"arrow-body-style": "off",
"semi": "off",
"@typescript-eslint/semi": "error",
"@typescript-eslint/member-ordering": "off",
"@stylistic/ts/semi": "error",
"@stylistic/ts/member-ordering": "off",
"@typescript-eslint/naming-convention": [
"error",
{
Expand All @@ -98,7 +108,7 @@
}
],
"space-before-function-paren": "off",
"@typescript-eslint/space-before-function-paren": [
"@stylistic/ts/space-before-function-paren": [
"error",
{
"anonymous": "always",
Expand Down Expand Up @@ -152,7 +162,7 @@
"variables": true
}
],
"@typescript-eslint/member-delimiter-style": [
"@stylistic/ts/member-delimiter-style": [
"error",
{
"multiline": {
Expand All @@ -179,8 +189,8 @@
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"rxjs/finnish": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-function": "off"
"@stylistic/ts/ban-ts-comment": "off",
"@stylistic/ts/no-empty-function": "off"
}
},
{
Expand Down
17 changes: 15 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
"node_modules/@tailormap-viewer/shared/assets/locale/messages.shared.nl.xlf",
"node_modules/@tailormap-admin/admin-core/assets/locale/messages.admin-core.nl.xlf"
]
},
"de": {
"translation": [
"node_modules/@tailormap-viewer/core/assets/locale/messages.core.de.xlf",
"node_modules/@tailormap-viewer/shared/assets/locale/messages.shared.de.xlf",
"node_modules/@tailormap-admin/admin-core/assets/locale/messages.admin-core.de.xlf"
]
}
}
},
Expand All @@ -38,7 +45,7 @@
"outputPath": "dist/app",
"index": "projects/app/src/index.html",
"main": "projects/app/src/main.ts",
"polyfills": ["projects/app/src/polyfills.ts"],
"polyfills": ["projects/app/src/polyfills.ts", "@angular/localize/init"],
"tsConfig": "projects/app/tsconfig.app.json",
"assets": [
{
Expand Down Expand Up @@ -79,7 +86,10 @@
"earcut",
"svgpath",
"lerc",
"color-name"
"color-name",
"localforage",
"fastpriorityqueue",
"color-convert"
],
"i18nMissingTranslation": "error"
},
Expand Down Expand Up @@ -134,6 +144,9 @@
},
"nl": {
"buildTarget": "app:build:development,nl"
},
"de": {
"buildTarget": "app:build:development,de"
}
},
"options": {
Expand Down
4 changes: 3 additions & 1 deletion jest.base.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
process.env.TZ = 'GMT';

module.exports = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/../../setup-jest.ts'],
Expand All @@ -11,5 +13,5 @@ module.exports = {
},
],
},
transformIgnorePatterns: ['node_modules/(?!(.*\\.mjs$|ol|observable-fns|quick-lru|nanoid))'],
transformIgnorePatterns: ['node_modules/(?!(.*\\.mjs$|ol|observable-fns|quick-lru|nanoid|earcut|pbf|rbush|@tinyhttp/|@stardazed|color-(space|parse|rgba|name)/))'],
};
14 changes: 12 additions & 2 deletions projects/app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,32 @@ import { CoreModule } from "@tailormap-viewer/core";
import { SharedModule } from "@tailormap-viewer/shared";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { environment } from '../environments/environment';
import { provideHttpClient, withInterceptorsFromDi, withXsrfConfiguration } from '@angular/common/http';
import { TailormapApiConstants } from '@tailormap-viewer/api';

@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
CoreModule.forRoot({
production: environment.production,
viewerBaseUrl: environment.viewerBaseUrl,
}),
BrowserAnimationsModule,
SharedModule,
...environment.imports,
],
providers: [],
providers: [
provideHttpClient(
withInterceptorsFromDi(),
withXsrfConfiguration({
cookieName: TailormapApiConstants.XSRF_COOKIE_NAME,
headerName: TailormapApiConstants.XSRF_HEADER_NAME,
}),
),
],
bootstrap: [AppComponent],
})
export class AppModule { }
52 changes: 49 additions & 3 deletions projects/app/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,58 @@
import { enableProdMode } from '@angular/core';
import { enableProdMode, ErrorHandler } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

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

const SENTRY_DSN: string = (window as any).SENTRY_DSN;

const setupSentryProviders = async () => {
if (SENTRY_DSN === '@SENTRY_DSN@' || SENTRY_DSN === '') {
return [];
}
const sentry = await import('@sentry/angular');
let version: { version: string } | undefined;
fetch('/version.json')
.then(response => {
if (!response.ok) {
throw new Error('version.json could not be fetched');
}
return response.json();
})
.then(v => version = v)
.catch(() => {/* ignore error for now, unable to get version */});
sentry.init({
dsn: SENTRY_DSN,
release: version?.version,
environment: environment.production ? 'production' : 'development',
integrations: [
sentry.browserTracingIntegration({
shouldCreateSpanForRequest: (url) => {
// Do not create spans for outgoing requests to a `api` endpoint
return !/\/api\//.test(url);
},
}),
],
// Capture 1% of traces in production
tracesSampleRate: environment.production ? 0.01 : 1.0,
autoSessionTracking: false,
});
return [
{ provide: ErrorHandler, useValue: sentry.createErrorHandler({ showDialog: false }) },
];
};

const main = async () => {
try {
const sentryProviders = await setupSentryProviders();
await platformBrowserDynamic(sentryProviders).bootstrapModule(AppModule);
} catch (error) {
console.error(error);
}
};

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

platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
main();
7 changes: 3 additions & 4 deletions projects/app/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/***************************************************************************************************
* Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.
*/
import '@angular/localize/init';
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
Expand Down Expand Up @@ -55,3 +51,6 @@ import 'zone.js'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

// Drag-drop polyfill to support HTML5 drag and drop on touch devices. Used to reorder tree nodes.
import './polyfills/drag-drop-touch/DragDropTouch.js';
Loading

0 comments on commit a1351b3

Please sign in to comment.