Skip to content

Commit 7e8a7e9

Browse files
authored
Merge pull request #62 from ck-c8y/feat-migration-1020
feat: migrate ui to c8y version 1020
2 parents 11eef70 + cea0229 commit 7e8a7e9

20 files changed

+8081
-12962
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ tests/data/apps/app4.tar.gz
2020

2121
# MacOS
2222
.DS_Store
23+
.angular
24+
25+
# test files
26+
attic

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/.browserslistrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 2 Chrome versions
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR

ui/angular.json

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"tedge-container-plugin-ui": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:component": {
10+
"style": "less"
11+
}
12+
},
13+
"root": "",
14+
"sourceRoot": "src",
15+
"prefix": "app",
16+
"architect": {
17+
"build": {
18+
"builder": "@c8y/devkit:build",
19+
"options": {
20+
"outputPath": "dist/tedge-container-plugin-ui",
21+
"main": "./main.ts",
22+
"polyfills": ["zone.js"],
23+
"tsConfig": "tsconfig.json",
24+
"inlineStyleLanguage": "less",
25+
"assets": ["src/favicon.ico", "src/assets"],
26+
"styles": ["src/styles.less"],
27+
"scripts": [],
28+
"aot": false,
29+
"allowedCommonJsDependencies": [
30+
"regenerator-runtime/runtime",
31+
"@cordobo/qrcode",
32+
"zone.js",
33+
"chroma-js"
34+
]
35+
},
36+
"configurations": {
37+
"production": {
38+
"budgets": [
39+
{
40+
"type": "initial",
41+
"maximumWarning": "500kb",
42+
"maximumError": "1mb"
43+
},
44+
{
45+
"type": "anyComponentStyle",
46+
"maximumWarning": "2kb",
47+
"maximumError": "4kb"
48+
}
49+
],
50+
"outputHashing": "all",
51+
"buildOptimizer": false
52+
},
53+
"development": {
54+
"buildOptimizer": false,
55+
"optimization": false,
56+
"vendorChunk": true,
57+
"extractLicenses": false,
58+
"sourceMap": true,
59+
"namedChunks": true
60+
}
61+
},
62+
"defaultConfiguration": "production"
63+
},
64+
"serve": {
65+
"builder": "@c8y/devkit:dev-server",
66+
"configurations": {
67+
"production": {
68+
"buildTarget": "tedge-container-plugin-ui:build:production"
69+
},
70+
"development": {
71+
"buildTarget": "tedge-container-plugin-ui:build:development"
72+
}
73+
},
74+
"defaultConfiguration": "development"
75+
},
76+
"extract-i18n": {
77+
"builder": "@c8y/devkit:extract-i18n"
78+
},
79+
"test": {
80+
"builder": "@angular-devkit/build-angular:karma",
81+
"options": {
82+
"polyfills": ["zone.js", "zone.js/testing"],
83+
"tsConfig": "tsconfig.spec.json",
84+
"inlineStyleLanguage": "less",
85+
"assets": ["src/favicon.ico", "src/assets"],
86+
"styles": ["src/styles.less"],
87+
"scripts": []
88+
}
89+
},
90+
"deploy": {
91+
"builder": "@c8y/devkit:deploy",
92+
"configurations": {
93+
"production": {
94+
"buildTarget": "tedge-container-plugin-ui:build:production"
95+
},
96+
"development": {
97+
"buildTarget": "tedge-container-plugin-ui:build:development"
98+
}
99+
},
100+
"defaultConfiguration": "production"
101+
},
102+
"compile-i18n": {
103+
"builder": "@c8y/devkit:compile-i18n"
104+
}
105+
}
106+
}
107+
},
108+
"cli": {
109+
"analytics": "7d223acb-751a-477e-88d3-2b250d6465dd"
110+
}
111+
}

ui/app.module.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { NgModule } from '@angular/core';
22
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3-
import { BootstrapComponent, CoreModule, RouterModule } from '@c8y/ngx-components';
4-
import { CockpitDashboardModule } from '@c8y/ngx-components/context-dashboard';
3+
import {
4+
BootstrapComponent,
5+
CoreModule,
6+
RouterModule,
7+
} from '@c8y/ngx-components';
58

69
@NgModule({
710
imports: [
811
BrowserAnimationsModule,
912
RouterModule.forRoot([]),
1013
CoreModule.forRoot(),
1114
],
12-
bootstrap: [BootstrapComponent]
15+
bootstrap: [BootstrapComponent],
1316
})
1417
export class AppModule {}

ui/bootstrap.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import './polyfills';
2+
3+
import { enableProdMode } from '@angular/core';
4+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
5+
import { AppModule } from './app.module';
6+
7+
import './locales/de.po';
8+
9+
declare const __MODE__: string;
10+
if (__MODE__ === 'production') {
11+
enableProdMode();
12+
}
13+
14+
export function bootstrap() {
15+
return platformBrowserDynamic()
16+
.bootstrapModule(AppModule)
17+
.catch(err => console.error(err));
18+
}

ui/cumulocity.config.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { EnvironmentOptions } from '@c8y/devkit/dist/options';
2+
import { author, description, version, license } from './package.json';
3+
4+
const asset = process.env['npm_config_asset'];
5+
const isApp = asset == 'app' ? true : false;
6+
7+
console.log('Building asset:', asset, asset == 'app', isApp);
8+
9+
export default {
10+
runTime: {
11+
author,
12+
description,
13+
license,
14+
version,
15+
name: 'tedge-container-mgmt',
16+
contextPath: 'sag-ps-pkg-tedge-container-mgmt',
17+
key: 'sag-ps-pkg-tedge-container-mgmt-key',
18+
contentSecurityPolicy:
19+
"base-uri 'none'; default-src 'self' 'unsafe-inline' http: https: ws: wss:; connect-src 'self' http: https: ws: wss:; script-src 'self' *.bugherd.com *.twitter.com *.twimg.com *.aptrinsic.com 'unsafe-inline' 'unsafe-eval' data:; style-src * 'unsafe-inline' blob:; img-src * data: blob:; font-src * data:; frame-src *; worker-src 'self' blob:;",
20+
dynamicOptionsUrl: '/apps/public/public-options/options.json',
21+
remotes: {
22+
'container-plugin': ['ContainerManagementModule'],
23+
'Group-plugin': ['GroupManagementModule'],
24+
'Container-Info-plugin': ['ContainerInfoModule'],
25+
},
26+
tabsHorizontal: true,
27+
noAppSwitcher: false,
28+
// comment the following properties to create a standalone app
29+
// comment begin
30+
// package: 'plugin',
31+
// isPackage: !isApp,
32+
package: 'blueprint',
33+
isPackage: true,
34+
exports: [
35+
{
36+
name: 'Container Info Tab',
37+
module: 'ContainerInfoModule',
38+
path: './src/container-info/container-info.module.ts',
39+
description:
40+
'Adds a tab to a container service to display all relevant container information.',
41+
},
42+
{
43+
name: 'Container Management Tab',
44+
module: 'ContainerManagementModule',
45+
path: './src/container-management/container-management.module.ts',
46+
description:
47+
'Adds a tab to a device to monitor the installed containers',
48+
},
49+
{
50+
name: 'Container Group Management Tab',
51+
module: 'GroupManagementModule',
52+
path: './src/group-management/group-management.module.ts',
53+
description:
54+
'Adds a tab to the device to monitor container groups (aka. docker compose).',
55+
},
56+
],
57+
// comment end
58+
},
59+
buildTime: {
60+
federation: [
61+
'@angular/animations',
62+
'@angular/cdk',
63+
'@angular/common',
64+
'@angular/compiler',
65+
'@angular/core',
66+
'@angular/forms',
67+
'@angular/platform-browser',
68+
'@angular/platform-browser-dynamic',
69+
'@angular/router',
70+
'@angular/upgrade',
71+
'@c8y/client',
72+
'@c8y/ngx-components',
73+
'ngx-bootstrap',
74+
'@ngx-translate/core',
75+
'@ngx-formly/core',
76+
],
77+
},
78+
} as const satisfies EnvironmentOptions;

ui/jest.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

ui/main.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import './i18n';
2+
import { applyOptions, loadOptions } from '@c8y/bootstrap';
3+
4+
const barHolder: HTMLElement = document.querySelector('body > .init-load');
5+
export const removeProgress = () =>
6+
barHolder && barHolder.parentNode.removeChild(barHolder);
7+
8+
applicationSetup();
9+
10+
async function applicationSetup() {
11+
const options = await applyOptions({
12+
...(await loadOptions()),
13+
});
14+
15+
const mod = await import(
16+
'./bootstrap'
17+
);
18+
const bootstrapApp =
19+
mod.bootstrap || (window as any).bootstrap || (() => null);
20+
21+
return Promise.resolve(bootstrapApp(options)).then(removeProgress);
22+
}

0 commit comments

Comments
 (0)