Skip to content

Commit

Permalink
fix: about page updated
Browse files Browse the repository at this point in the history
  • Loading branch information
raronpxcsw committed Sep 10, 2024
1 parent 0c63548 commit c21771c
Show file tree
Hide file tree
Showing 22 changed files with 221 additions and 225 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Dockerfile to build server and client parts
FROM node:lts-alpine3.19 AS build
FROM node:alpine3.19 AS build
WORKDIR /usr/src/app
COPY . .
# RUN apk add g++ make py3-pip
RUN npm install
RUN node --no-warnings --loader ts-node/esm create-app-info.ts
RUN npm run build

FROM node:lts-alpine3.19 AS aasportal
FROM node:alpine3.19 AS aasportal
RUN apk upgrade --update-cache --available && apk add openssl && rm -rf /var/cache/apk/*
WORKDIR /usr/src/app
COPY projects/aas-server/package.json package.json
Expand Down
19 changes: 10 additions & 9 deletions create-app-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,17 @@ await main();

async function main(): Promise<void> {
const project: Package = await read(resolve(__dirname, 'package.json'));
const file = resolve(__dirname, 'projects/aas-server/src/assets/app-info.json');
const appInfo = await read<ApplicationInfo>(file);
appInfo.name = project.name;
appInfo.version = project.version;
appInfo.description = project.description;
appInfo.author = project.author;
appInfo.homepage = project.homepage;
appInfo.license = project.license;
appInfo.libraries = await readLibrariesAsync(project);
const appInfo: ApplicationInfo = {
name: project.name,
version: project.version,
description: project.description,
author: project.author,
homepage: project.homepage,
license: project.license,
libraries: await readLibrariesAsync(project),
};

const file = resolve(__dirname, 'projects/aas-server/src/assets/app-info.json');
await write(file, appInfo);
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions projects/aas-core/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export interface LiveRequest {
nodes: LiveNode[];
}

export interface PackageInfo {
/** Provides information about the current application. */
export interface AppInfo {
name: string;
version: string;
author: string;
Expand All @@ -148,6 +149,16 @@ export interface PackageInfo {
libraries: Library[];
}

/** Provides information about a 3rd-party package. */
export interface Library {
name: string;
version: string;
description: string;
license: string;
licenseText: string;
homepage?: string;
}

export type DirEntry = {
type: 'file' | 'dir';
name: string;
Expand All @@ -166,16 +177,6 @@ export interface ErrorData {
args: unknown[];
}

/** Provides information about a 3rd-party package. */
export interface Library {
name: string;
version: string;
description: string;
license: string;
licenseText: string;
homepage?: string;
}

/** Defines the message types. */
export type MessageType = 'Error' | 'Warning' | 'Info';

Expand Down
24 changes: 0 additions & 24 deletions projects/aas-lib/src/lib/library-table/library-table.component.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
!
!---------------------------------------------------------------------------->

<div>
@for (library of libraries(); track library.name) {
<h3>{{library.name}}</h3>
<pre>{{library.licenseText}}</pre>
}
<button type="button" class="btn btn-primary mb-2" (click)="collapse.toggle()">{{isCollapsed() ?
('CMD_SHOW_LICENSE_TEXT' | translate) : ('CMD_HIDE_LICENSE_TEXT' | translate)}}</button>
<div #collapse="ngbCollapse" [(ngbCollapse)]="isCollapsed">
<pre class="font-monospace" style="white-space: pre-line;">{{text()}}</pre>
</div>
64 changes: 64 additions & 0 deletions projects/aas-lib/src/lib/license-info/license-info.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/******************************************************************************
*
* Copyright (c) 2019-2024 Fraunhofer IOSB-INA Lemgo,
* eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft
* zur Foerderung der angewandten Forschung e.V.
*
*****************************************************************************/

import { ChangeDetectionStrategy, Component, computed, input, signal } from '@angular/core';
import { NgbCollapseModule, NgbPagination } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
import { Library } from 'aas-core';

@Component({
selector: 'fhg-license-info',
templateUrl: './license-info.component.html',
styleUrls: ['./license-info.component.scss'],
standalone: true,
imports: [NgbPagination, NgbCollapseModule, TranslateModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LicenseInfoComponent {
public readonly libraries = input<Library[]>([]);

public readonly isCollapsed = signal(true);

public readonly text = computed(() => {
return this.generateLicensesText(this.libraries());
});

private generateLicensesText(libraries: Library[]): string {
const licenses = new Map<string, Library[]>();
for (const library of libraries) {
let value = licenses.get(library.licenseText);
if (!value) {
value = [library];
licenses.set(library.licenseText, value);
} else {
value.push(library);
}
}

let text = '';
for (const [key, value] of licenses) {
if (value.length === 1) {
text += 'The following npm package may be included in this product:\n\n';
text += ` - ${value[0].name}@${value[0].version}\n\n`;
text += 'This package contains the following license and notice below:\n\n';
} else if (value.length > 1) {
text += 'The following npm packages may be included in this product:\n\n';
for (const item of value) {
text += ` - ${item.name}@${value[0].version}\n`;
}

text += '\nThese packages each contain the following license and notice below:\n\n';
}

text += key;
text += '\n-----------\n\n';
}

return text;
}
}
2 changes: 1 addition & 1 deletion projects/aas-lib/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export * from './lib/auth/login-form/login-form.component';
export * from './lib/auth/profile-form/profile-form.component';
export * from './lib/auth/register-form/register-form.component';

export * from './lib/library-table/library-table.component';
export * from './lib/license-info/license-info.component';

export * from './lib/submodel-template/submodel-template';

Expand Down

This file was deleted.

Loading

0 comments on commit c21771c

Please sign in to comment.