diff --git a/.eslintrc.json b/.eslintrc.json index c23e0ec..491f2b5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,9 @@ "node_modules/**", "src/app/generated/**", "src/app/api/*", - "src/app/model/*" + "src/app/model/*", + "src/**/*.ico", + "src/**/*.svg" ], "overrides": [ { diff --git a/karma.conf.js b/karma.conf.js index 974669e..fcdd1d0 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -11,7 +11,6 @@ module.exports = function (config) { require('karma-coverage'), require('karma-jasmine'), require('karma-jasmine-html-reporter'), - require('karma-junit-reporter'), require('karma-sonarqube-unit-reporter'), require('@angular-devkit/build-angular/plugins/karma') ], @@ -27,15 +26,6 @@ module.exports = function (config) { jasmineHtmlReporter: { suppressAll: true // removes the duplicated traces }, - junitReporter: { - outputDir: 'reports/unit-test-results', // results will be saved as $outputDir/$browserName.xml - outputFile: 'results-junit-tests.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile - suite: 'models', // suite will become the package name attribute in xml testsuite element - useBrowserName: false, // add browser name to report and classes names - nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element - classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element - properties: {} // key value pair of properties to add to the section of the report - }, sonarqubeReporter: { basePath: 'src/app', // test files folder filePattern: '**/*.spec.ts', // test files glob pattern @@ -55,9 +45,9 @@ module.exports = function (config) { includeAllSources: true, dir: 'reports', subdir: 'coverage', - reporters: [{ type: 'html' }, { type: 'text-summary' }, { type: 'lcov' }] + reporters: [{ type: 'html' }, { type: 'text-summary' }] }, - reporters: ['progress', 'kjhtml', 'coverage', 'sonarqubeUnit', 'junit'], + reporters: ['progress', 'kjhtml', 'coverage', 'sonarqubeUnit'], preprocessors: { 'src/**/*.js': ['coverage'] }, port: 9876, colors: true, diff --git a/sonar-local-project.properties b/sonar-local-project.properties index 963c743..c8e1694 100644 --- a/sonar-local-project.properties +++ b/sonar-local-project.properties @@ -1,16 +1,14 @@ # sonar.verbose=true -sonar.host.url=http://localhost:9000 -#sonar.token= -sonar.token=sqp_4f516f122209fad902530dc69bf59664457ab48e +# sonar.host.url=http://localhost:9000 +# sonar.token= # remote -#sonar.host.url=https://sonarcloud.io +sonar.host.url=https://sonarcloud.io sonar.organization=onecx sonar.projectKey=onecx-theme-ui sonar.projectName=onecx-theme-ui sonar.javascript.coveragePlugin=lcov sonar.javascript.lcov.reportPaths=reports/coverage/lcov.info sonar.testExecutionReportPaths=reports/sonarqube_report.xml -#sonar.eslint.reportPaths=eslint_report sonar.sourceEncoding=UTF-8 sonar.sources=src/app sonar.working.directory=dist/sonar diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index f2846fb..96e818c 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -52,7 +52,9 @@ export const basePathProvider = (mfeInfo: MfeInfo) => { } export function HttpLoaderFactory(http: HttpClient, mfeInfo: MfeInfo) { - console.log(`Configuring translation loader ${mfeInfo?.remoteBaseUrl}`) + if (mfeInfo) { + console.log(`Configuring translation loader ${mfeInfo?.remoteBaseUrl}`) + } // if running standalone then load the app assets directly from remote base URL const appAssetPrefix = mfeInfo && mfeInfo.remoteBaseUrl ? mfeInfo.remoteBaseUrl : './' return new TranslateCombinedLoader( diff --git a/src/app/theme/theme-import/theme-import.component.ts b/src/app/theme/theme-import/theme-import.component.ts index 050f0f1..db28bd7 100644 --- a/src/app/theme/theme-import/theme-import.component.ts +++ b/src/app/theme/theme-import/theme-import.component.ts @@ -4,7 +4,7 @@ import { TranslateService } from '@ngx-translate/core' import { ActivatedRoute, Router } from '@angular/router' import { ThemesAPIService } from './../../generated/api/themes.service' -import { CreateThemeDTO, ThemeDTO } from '../../generated' +import { Theme, ThemeSnapshot } from '../../generated' import { PortalMessageService } from '@onecx/portal-integration-angular' @Component({ @@ -17,11 +17,11 @@ export class ThemeImportComponent implements OnInit { @Output() public displayThemeImportChange = new EventEmitter() @Output() public uploadEmitter = new EventEmitter() - private themes!: ThemeDTO[] + private themes!: Theme[] public themeName = '' public themeNameExists = false public themeImportError = false - public themeImportRequestDTO: ThemeDTO | null = null + public themeSnapshot: ThemeSnapshot | null = null public httpHeaders!: HttpHeaders public properties: any = null @@ -41,13 +41,15 @@ export class ThemeImportComponent implements OnInit { public onImportThemeSelect(event: { files: FileList }): void { event.files[0].text().then((text) => { - this.themeImportRequestDTO = null + this.themeSnapshot = null try { - const themeImportRequestDTO = JSON.parse(text) - if (this.isThemeImportRequestDTO(themeImportRequestDTO)) { - this.themeImportRequestDTO = themeImportRequestDTO + const themeSnapshot = JSON.parse(text) + if (this.isThemeImportRequestDTO(themeSnapshot)) { + this.themeSnapshot = themeSnapshot this.themeImportError = false - this.properties = themeImportRequestDTO.properties + if (themeSnapshot.themes !== undefined) { + this.properties = themeSnapshot?.themes[0].properties + } this.checkThemeExistence() } else { console.error('Theme Import Error: not valid data ') @@ -62,7 +64,7 @@ export class ThemeImportComponent implements OnInit { public checkThemeExistence() { this.themeNameExists = false for (const { name } of this.themes) { - if (name === this.themeImportRequestDTO?.name) { + if (name === this.themeSnapshot?.themes) { this.themeNameExists = true } } @@ -72,36 +74,38 @@ export class ThemeImportComponent implements OnInit { this.displayThemeImportChange.emit(false) } public onImportThemeClear(): void { - this.themeImportRequestDTO = null + this.themeSnapshot = null this.themeImportError = false } public onThemeUpload(): void { this.themeApi - .createNewTheme({ - createThemeDTO: this.themeImportRequestDTO as CreateThemeDTO + .importThemes({ + themeSnapshot: this.themeSnapshot as ThemeSnapshot }) .subscribe({ next: (data) => { - this.msgService.success({ summaryKey: 'PORTAL_IMPORT.IMPORT_THEME_SUCCESS' }) + this.msgService.success({ summaryKey: 'THEME.IMPORT.IMPORT_THEME_SUCCESS' }) this.onImportThemeClear() this.displayThemeImport = false this.uploadEmitter.emit() this.router.navigate([`./${data.id}`], { relativeTo: this.route }) }, error: () => { - this.msgService.error({ summaryKey: 'PORTAL_IMPORT.IMPORT_THEME_FAIL' }) + this.msgService.error({ summaryKey: 'THEME.IMPORT.IMPORT_THEME_FAIL' }) } }) } - private isThemeImportRequestDTO(obj: unknown): obj is ThemeDTO { - const dto = obj as ThemeDTO - return !!(typeof dto === 'object' && dto && dto.name) + private isThemeImportRequestDTO(obj: unknown): obj is ThemeSnapshot { + const dto = obj as ThemeSnapshot + return !!(typeof dto === 'object' && dto) } private getThemes(emit: boolean): void { - this.themeApi.getThemes().subscribe((themes) => { - this.themes = themes + this.themeApi.getThemes({}).subscribe((themes) => { + if (themes.stream) { + this.themes = themes.stream + } if (emit) this.uploadEmitter.emit() }) }