-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Meer Arfath (MEEA)
committed
Jan 9, 2023
0 parents
commit 480c441
Showing
26 changed files
with
1,142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Cumulocity widget plugin | ||
|
||
This is the Cumulocity module federation plugin. Plugins can be developed like any Cumulocity application, but can be used at runtime by other applications. Therefore, they export an Angular module which can then be imported by any other application. The exports are defined in `package.json`: | ||
|
||
``` | ||
"exports": [ | ||
{ | ||
"name": "Example widget plugin", | ||
"module": "WidgetPluginModule", | ||
"path": "./widget/widget-plugin.module.ts", | ||
"description": "Adds custom widget" | ||
} | ||
] | ||
``` | ||
|
||
**How to start** | ||
Run the command below to scaffold a `widget` plugin. | ||
|
||
``` | ||
c8ycli new <yourPluginName> widget-plugin | ||
``` | ||
|
||
As the app.module is a typical Cumuloctiy application, any new plugin can be tested via the CLI: | ||
|
||
``` | ||
npm start -- --shell cockpit | ||
``` | ||
|
||
In the Module Federation terminology, `widget` plugin is called `remote` and the `cokpit` is called `shell`. Modules provided by this `widget` will be loaded by the `cockpit` application at the runtime. This plugin provides a basic custom widget that can be accessed through the `Add widget` menu. | ||
|
||
> Note that the `--shell` flag creates a proxy to the cockpit application and provides` WidgetPluginModule` as an `remote` via URL options. | ||
Also deploying needs no special handling and can be simply done via `npm run deploy`. As soon as the application has exports it will be uploaded as a plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
describe('Example test', () => { | ||
/*let testComponent; | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ExampleModule] | ||
}); | ||
testComponent = TestBed.createComponent(TestComponent); | ||
});*/ | ||
|
||
test('Always true', () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { RouterModule as ngRouterModule } from '@angular/router'; | ||
import { BootstrapComponent, CoreModule, RouterModule } from '@c8y/ngx-components'; | ||
import { CockpitDashboardModule } from '@c8y/ngx-components/context-dashboard'; | ||
import { BsModalRef } from 'ngx-bootstrap/modal'; | ||
import { GpPowerbiWidgetModule } from './widget/gp-powerbi-widget.module'; | ||
|
||
// Translations | ||
import './locales/de.po'; // <- adding additional strings to the german translation. | ||
|
||
@NgModule({ | ||
imports: [ | ||
BrowserAnimationsModule, | ||
ngRouterModule.forRoot([], { enableTracing: false, useHash: true }), | ||
RouterModule.forRoot(), | ||
CoreModule.forRoot(), | ||
GpPowerbiWidgetModule, | ||
CockpitDashboardModule | ||
], | ||
providers: [BsModalRef], | ||
bootstrap: [BootstrapComponent] | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const {src, dest, series} = require('gulp'); | ||
const zip = require('gulp-zip'); | ||
const del = require('del'); | ||
const pkgJson = require('./package.json'); | ||
|
||
function clean() { | ||
return del(['dist']); | ||
} | ||
|
||
const bundle = series( | ||
function createZip() { | ||
return src(`./dist/apps/${pkgJson.c8y.application.contextPath}/**/*`) | ||
.pipe(zip(`${pkgJson.c8y.application.contextPath}-${pkgJson.version}.zip`)) | ||
.pipe(dest('dist/')) | ||
} | ||
) | ||
|
||
exports.clean = clean; | ||
exports.bundle = bundle; | ||
exports.default = series(bundle, async function success() { | ||
console.log("Build Finished Successfully!"); | ||
console.log(`PluginOutput (Install in the browser): dist/${pkgJson.c8y.application.contextPath}-${pkgJson.version}.zip`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Internationalizing files in po format (https://en.wikipedia.org/wiki/Gettext#Translating) | ||
* You can always add additional strings by adding your own po file. All po files are | ||
* combined to one JSON file per language and are loaded if the specific language is needed. | ||
*/ | ||
import './locales/de.po'; // <- adding additional strings to the german translation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import './polyfills'; | ||
import './i18n'; | ||
|
||
import { enableProdMode } from '@angular/core'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { AppModule } from './app.module'; | ||
|
||
declare const __MODE__: string; | ||
if (__MODE__ === 'production') { | ||
enableProdMode(); | ||
} | ||
|
||
export function bootstrap() { | ||
platformBrowserDynamic() | ||
.bootstrapModule(AppModule) | ||
.catch(err => console.log(err)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// jest.config.js | ||
module.exports = { | ||
preset: 'jest-preset-angular', | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'], | ||
transformIgnorePatterns: ['/!node_modules\\/lodash-es/'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: c8y.plugin\n" | ||
"Language: de\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
||
msgid "Module Federation widget" | ||
msgstr "Modul Federation Dingsbums" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"name": "cumulocity-power-bi-widget-plugin", | ||
"version": "1.0.1-beta", | ||
"description": "This is the Cumulocity module federation plugin. Plugins can be developed like any Cumulocity application, but can be used at runtime by other applications. Therefore, they export an Angular module which can then be imported by any other application. The exports are defined in `package.json`:", | ||
"scripts": { | ||
"start": "c8ycli server", | ||
"build": "c8ycli build --env.mode=development", | ||
"deploy": "c8ycli deploy", | ||
"postinstall": "ngcc", | ||
"prebuild": " gulp clean", | ||
"postbuild": " gulp bundle" | ||
}, | ||
"keywords": [], | ||
"author": "Meer Arfath- Software AG, Global Presales", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@angular/animations": "14.0.6", | ||
"@angular/cdk": "14.1.2", | ||
"@angular/common": "14.0.6", | ||
"@angular/compiler": "14.0.6", | ||
"@angular/core": "14.0.6", | ||
"@angular/forms": "14.0.6", | ||
"@angular/platform-browser": "14.0.6", | ||
"@angular/platform-browser-dynamic": "14.0.6", | ||
"@angular/router": "14.0.6", | ||
"@angular/upgrade": "14.0.6", | ||
"@c8y/client": "1016.0.84", | ||
"@c8y/ngx-components": "1016.0.84", | ||
"@c8y/style": "1016.0.84", | ||
"@ngx-translate/core": "14.0.0", | ||
"powerbi-client": "^2.19.1", | ||
"rxjs": "~6.6.3", | ||
"zone.js": "~0.11.7" | ||
}, | ||
"devDependencies": { | ||
"@angular-devkit/build-angular": "14.0.6", | ||
"@angular/compiler-cli": "14.0.6", | ||
"@angular/language-service": "14.0.6", | ||
"@angular/localize": "14.0.6", | ||
"@angular/service-worker": "14.0.6", | ||
"@c8y/cli": "1016.0.84", | ||
"@types/babel__core": "^7.1.20", | ||
"@types/jest": "^28.1.6", | ||
"@types/webpack": "^5.28.0", | ||
"del": "^6.1.1", | ||
"file-loader": "^6.2.0", | ||
"gulp": "^4.0.2", | ||
"gulp-zip": "^5.0.1", | ||
"html-loader": "4.1.0", | ||
"jest": "^28.1.3", | ||
"jest-preset-angular": "^12.2.0", | ||
"style-loader": "3.3.1", | ||
"typescript": "4.7.4" | ||
}, | ||
"c8y": { | ||
"application": { | ||
"name": "Cumulocity Power BI Widget Plugin", | ||
"description": "Cumulocity Power BI widget with module federation", | ||
"contextPath": "powerbi-runtime-widget", | ||
"key": "powerbi-runtime-widget-application-key", | ||
"globalTitle": "Cumulocity PowerBI widget with Module Federation", | ||
"tabsHorizontal": true, | ||
"isPackage": true, | ||
"noAppSwitcher": true, | ||
"package": "plugin", | ||
"requiredPlatformVersion": ">=1016.0.0", | ||
"exports": [ | ||
{ | ||
"name": "Cumulocity Power BI Widget Plugin", | ||
"module": "GpPowerbiWidgetModule", | ||
"path": "./widget/gp-powerbi-widget.module.ts", | ||
"description": "This widget displays the PowerBI reports created from Datahub offloading." | ||
} | ||
], | ||
"remotes": { | ||
"widget-plugin": [ | ||
"GpPowerbiWidgetModule" | ||
] | ||
} | ||
}, | ||
"cli": {} | ||
}, | ||
"browserslist": [ | ||
"last 2 major versions" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* This file includes polyfills needed by Angular and is loaded before the app. | ||
* You can add your own extra polyfills to this file. | ||
* | ||
* This file is divided into 2 sections: | ||
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. | ||
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main | ||
* 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. | ||
* | ||
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html | ||
*/ | ||
|
||
/*************************************************************************************************** | ||
* BROWSER POLYFILLS | ||
*/ | ||
|
||
/** | ||
* By default, zone.js will patch all possible macroTask and DomEvents | ||
* user can disable parts of macroTask/DomEvents patch by setting following flags | ||
*/ | ||
|
||
(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__BLACK_LISTED_EVENTS = ['scroll', 'mousemove', 'message']; | ||
|
||
/*************************************************************************************************** | ||
* Zone JS is required by default for Angular itself. | ||
*/ | ||
import 'zone.js/dist/zone'; // Included with Angular CLI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'jest-preset-angular/setup-jest'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compileOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"outDir": "./dist/out-tsc", | ||
"sourceMap": true, | ||
"declaration": false, | ||
"moduleResolution": "node", | ||
"experimentalDecorators": true, | ||
"target": "es6", | ||
"module": "es2020", | ||
"lib": ["dom", "es2015", "es2016"] | ||
}, | ||
"angularCompilerOptions": { | ||
"enableIvy": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./out-tsc/spec", | ||
"types": ["jest"], | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.configSection { | ||
display: grid; | ||
border: 1px solid rgba(0, 0, 0, 0.3); | ||
border-radius: 4px; | ||
margin: 0.25em; | ||
padding: 0.25em; | ||
} | ||
|
||
.row{ | ||
padding: 0.5em; | ||
} |
Oops, something went wrong.