refactor: update to Angular 13

This commit is contained in:
Rainer Killinger
2022-03-23 12:57:16 +01:00
parent 7b491ed3bb
commit dac2f5656a
20 changed files with 2723 additions and 6726 deletions

View File

@@ -65,6 +65,7 @@ import {LibraryModule} from './modules/library/library.module';
import {StorageProvider} from './modules/storage/storage.provider';
import {AssessmentsModule} from './modules/assessments/assessments.module';
import {RoutingStackService} from './util/routing-stack.service';
import {SCSettingValue} from '@openstapps/core';
registerLocaleData(localeDe);
@@ -97,7 +98,7 @@ export function initializerFactory(
await settingsProvider.setSettingValue(
'profile',
'language',
translateService.getBrowserLang(),
translateService.getBrowserLang() as SCSettingValue,
);
}
const languageCode = (await settingsProvider.getValue(

View File

@@ -64,6 +64,7 @@ export class AuthHelperService {
key as keyof SCUserConfiguration
] as string,
json: userInfo,
preventEval: true,
})[0];
}

View File

@@ -1,7 +1,6 @@
import {Requestor} from '@openid/appauth';
import {Http, HttpHeaders, HttpResponse} from '@capacitor-community/http';
import {XhrSettings} from 'ionic-appauth/lib/cordova';
import qs from 'qs';
// REQUIRES CAPACITOR PLUGIN
// @capacitor-community/http
@@ -33,7 +32,7 @@ export class CapacitorRequestor extends Requestor {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private async post<T>(url: string, data: any, headers: HttpHeaders) {
return Http.post({url, data: qs.parse(data), headers}).then(
return Http.post({url, data: data, headers}).then(
(response: HttpResponse) => response.data as T,
);
}

View File

@@ -105,7 +105,7 @@ export class CatalogComponent implements OnInit, OnDestroy {
}).compare(a.name, b.name);
});
} catch (error) {
this.logger.error(error.message);
this.logger.error((error as Error).message);
return;
}
}

View File

@@ -86,7 +86,7 @@ describe('ConfigProvider', () => {
try {
await configProvider.fetch();
} catch (error_) {
error = error_;
error = error_ as Error;
}
expect(error).toEqual(new ConfigFetchError());
});
@@ -147,7 +147,7 @@ describe('ConfigProvider', () => {
try {
await configProvider.loadLocal();
} catch (error_) {
error = error_;
error = error_ as Error;
}
expect(error).toEqual(new SavedConfigNotAvailable());
});

View File

@@ -205,7 +205,7 @@ export class SearchPageComponent implements OnInit, OnDestroy {
const alert: HTMLIonAlertElement = await this.alertController.create({
buttons: ['Dismiss'],
header: 'Error',
subHeader: error.message,
subHeader: (error as Error).message,
});
await alert.present();

View File

@@ -76,7 +76,7 @@ export class StAppsWebHttpClient implements HttpClientInterface {
body: response.body || {},
});
} catch (error) {
throw new Error(error);
throw new Error(error as string);
}
}
}

View File

@@ -260,7 +260,7 @@ export class MapPageComponent {
const alert: HTMLIonAlertElement = await this.alertController.create({
buttons: ['Dismiss'],
header: 'Error',
subHeader: error.message,
subHeader: (error as Error).message,
});
await alert.present();

View File

@@ -249,7 +249,7 @@ describe('SettingsProvider', () => {
value as never,
);
} catch (error_) {
error = error_;
error = error_ as Error;
}
expect(error).toBeDefined();

View File

@@ -100,7 +100,7 @@ describe('StorageProvider', () => {
try {
await storageProvider.get('something-else');
} catch (error_) {
error = error_;
error = error_ as Error;
}
expect(error).toEqual(new Error('Value not found.'));
});

View File

@@ -6,6 +6,10 @@
<title>StApps</title>
<base href="/" />
<meta
http-equiv="Content-Security-Policy"
content="script-src 'self' 'unsafe-inline' blob:;object-src 'none';base-uri 'none';style-src 'self' 'unsafe-inline';"
/>
<meta
name="viewport"

View File

@@ -22,54 +22,42 @@
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
* automatically update themselves. This includes recent versions of Safari, Chrome (including
* Opera), Edge on the desktop, and iOS and Chrome on mobile.
*
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/*
* IE9, IE10 and IE11 requires all of the following polyfills.
*/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/weak-map';
// import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following for the Reflect API. */
// import 'core-js/es6/reflect';
/*
* Evergreen browsers require these.
*/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
import 'core-js/es7/reflect';
/**
* Required to support Web Animations `@angular/platform-browser/animations`.
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/***************************************************************************************************
* Zone JS is required by Angular itself.
* Zone JS is required by default for Angular itself.
*/
import 'zone.js'; // Included with Angular CLI.