Skip to content

Commit

Permalink
feat: Add third party sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
longieirl committed Dec 14, 2023
1 parent cdff693 commit 0543ac1
Show file tree
Hide file tree
Showing 41 changed files with 3,644 additions and 0 deletions.
10 changes: 10 additions & 0 deletions thirdpartylibrary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Adding External Library to your Fiori UI application

# Prerequisites

- You’ll need an SAP Business Technology Platform (SAP BTP) account
- You are subscribed to SAP Business Application Studio, follow this [tutorial](https://help.sap.com/products/SAP%20Business%20Application%20Studio/9d1db9835307451daa8c930fbd9ab264/6331319fd9ea4f0ea5331e21df329539.html) for more information
- Sub-account destination `northwind` is available, please see attached `northind` configuration

# Sample Project
A [Fiori tools Freestyle UI application](./ztravelapp/README.md) with an external library `xml-js` enabled.
6 changes: 6 additions & 0 deletions thirdpartylibrary/northwind
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
URL=https\://services.odata.org
Name=northwind
ProxyType=Internet
Type=HTTP
Authentication=NoAuthentication
10 changes: 10 additions & 0 deletions thirdpartylibrary/ztravelapp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules/
dist/
.scp/
.env
Makefile*.mta
mta_archives
mta-*
resources
archive.zip
.*_mta_build_tmp
3 changes: 3 additions & 0 deletions thirdpartylibrary/ztravelapp/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ensure we always use public packages, i.e. avoid using local registries from ~/.npmrc
@sap:registry=https://registry.npmjs.org/
registry=https://registry.npmjs.org/
53 changes: 53 additions & 0 deletions thirdpartylibrary/ztravelapp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Adding External Library to your Fiori UI application

In this sample project, `xml-js` is going to be added as an external library.

# Prerequisites

- You’ll need an SAP Business Technology Platform (SAP BTP) account
- You are subscribed to SAP Business Application Studio, follow this [tutorial](https://help.sap.com/products/SAP%20Business%20Application%20Studio/9d1db9835307451daa8c930fbd9ab264/6331319fd9ea4f0ea5331e21df329539.html) for more information
- Sub-account destination `northwind` is available

# Create SAP Fiori Dev Space

From your SAP BTP cockpit, select Instances and Subscriptions, select SAP Business Application Studio which will open a new tab into your dev space manager. Generate a SAP Fiori dev space.

# Generate a Fiori UI Freestyle Application

Please refer to the following link, [Developing Apps with SAP Fiori Tools](https://sapui5.hana.ondemand.com/sdk/#/topic/a460a7348a6c431a8bd967ab9fb8d918) for more information.

# Tasks

Append third part library to `package.json`;
```bash
npm install xml-js --save-prod
```

Open `View1.controller.js` and append the `xml-js` library;
```JS
sap.ui.define(
["sap/ui/core/mvc/Controller", "xml-js"],
```
Understanding the `sap.ui.defined` JavaScript namespace, please refer to this [link](https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui%23methods/sap.ui.define) paying attention to the `Third Party Modules` section, as this provides guidance on how third party modules are imported and referenced.
Next, update the `function` to reference this library;
```JS
function (Controller, xmljs) {
```
With these changes, you can now consume the library inside your code;
```JS
var xmlToJson = JSON.parse(
xmljs.xml2json(xml, {
compact: true,
spaces: 4,
})
);
console.log(`>>>> xmlToJson ${JSON.stringify(xmlToJson)}`);
```
# Additional Links
* [External libraries in UI5 + CAP + SAP Build Work Zone, Standard Edition](https://blogs.sap.com/2023/11/08/external-libraries-in-ui5-cap-sap-build-work-zone-standard-edition/)
* [Smart templates and SAP Fiori Apps – 57 Tips and Tricks](https://blogs.sap.com/2019/09/20/smart-templates-tips-and-tricks/)
93 changes: 93 additions & 0 deletions thirdpartylibrary/ztravelapp/mta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
_schema-version: "3.2"
ID: reuselibtravelapp
version: 0.0.1
modules:
- name: reuselibtravelapp-destination-content
type: com.sap.application.content
requires:
- name: reuselibtravelapp-destination-service
parameters:
content-target: true
- name: reuselibtravelapp-repo-host
parameters:
service-key:
name: reuselibtravelapp-repo-host-key
- name: reuselibtravelapp-uaa
parameters:
service-key:
name: reuselibtravelapp-uaa-key
parameters:
content:
instance:
destinations:
- Name: reuselibtravelapp_html_repo_host
ServiceInstanceName: reuselibtravelapp-html5-srv
ServiceKeyName: reuselibtravelapp-repo-host-key
sap.cloud.service: reuselibtravelapp
- Authentication: OAuth2UserTokenExchange
Name: reuselibtravelapp_uaa
ServiceInstanceName: reuselibtravelapp-xsuaa-srv
ServiceKeyName: reuselibtravelapp-uaa-key
sap.cloud.service: reuselibtravelapp
existing_destinations_policy: ignore
build-parameters:
no-source: true
- name: reuselibtravelapp-app-content
type: com.sap.application.content
path: .
requires:
- name: reuselibtravelapp-repo-host
parameters:
content-target: true
build-parameters:
build-result: resources
requires:
- artifacts:
- reuselibtravelapp.zip
name: reuselibtravelapp
target-path: resources/
- name: reuselibtravelapp
type: html5
path: .
build-parameters:
build-result: dist
builder: custom
commands:
- npm install
- npm run build:cf
supported-platforms: []
resources:
- name: reuselibtravelapp-destination-service
type: org.cloudfoundry.managed-service
parameters:
config:
HTML5Runtime_enabled: true
init_data:
instance:
destinations:
- Authentication: NoAuthentication
Name: ui5
ProxyType: Internet
Type: HTTP
URL: https://ui5.sap.com
existing_destinations_policy: update
version: 1.0.0
service: destination
service-name: reuselibtravelapp-destination-service
service-plan: lite
- name: reuselibtravelapp-uaa
type: org.cloudfoundry.managed-service
parameters:
path: ./xs-security.json
service: xsuaa
service-name: reuselibtravelapp-xsuaa-srv
service-plan: application
- name: reuselibtravelapp-repo-host
type: org.cloudfoundry.managed-service
parameters:
service: html5-apps-repo
service-name: reuselibtravelapp-html5-srv
service-plan: app-host
parameters:
deploy_mode: html5-repo
enable-parallel-deployments: true
44 changes: 44 additions & 0 deletions thirdpartylibrary/ztravelapp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "ztravel",
"version": "0.0.1",
"private": true,
"description": "A Fiori application.",
"keywords": [
"ui5",
"openui5",
"sapui5"
],
"main": "webapp/index.html",
"dependencies": {
"ui5-tooling-modules": "^3.2.4"
},
"devDependencies": {
"@ui5/cli": "^3.0.0",
"@sap/ux-ui5-tooling": "1",
"@sap-ux/ui5-middleware-fe-mockserver": "2",
"@sap/ui5-builder-webide-extension": "^1.1.8",
"ui5-task-zipper": "^0.5.0",
"mbt": "^1.2.18"
},
"scripts": {
"start": "fiori run --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false#ztestdocapp1ztravel-display\"",
"start-local": "fiori run --config ./ui5-local.yaml --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false#ztestdocapp1ztravel-display\"",
"build": "ui5 build --config=ui5.yaml --clean-dest --dest dist",
"deploy": "fiori verify",
"deploy-config": "fiori add deploy-config",
"start-noflp": "fiori run --open \"index.html?sap-ui-xx-viewCache=false\"",
"start-mock": "fiori run --config ./ui5-mock.yaml --open \"test/flpSandbox.html?sap-ui-xx-viewCache=false#ztestdocapp1ztravel-display\"",
"start-variants-management": "fiori run --open \"preview.html?sap-ui-xx-viewCache=false&fiori-tools-rta-mode=true&sap-ui-rta-skip-flex-validation=true#preview-app\"",
"unit-tests": "fiori run --config ./ui5-mock.yaml --open 'test/unit/unitTests.qunit.html'",
"int-tests": "fiori run --config ./ui5-mock.yaml --open 'test/integration/opaTests.qunit.html'",
"build:cf": "ui5 build preload --clean-dest --config ui5-deploy.yaml --include-task=generateCachebusterInfo"
},
"sapuxLayer": "VENDOR",
"ui5": {
"dependencies": [
"@sap/ui5-builder-webide-extension",
"ui5-task-zipper",
"mbt"
]
}
}
29 changes: 29 additions & 0 deletions thirdpartylibrary/ztravelapp/ui5-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# yaml-language-server: $schema=https://sap.github.io/ui5-tooling/schema/ui5.yaml.json
specVersion: "2.4"
metadata:
name: ztest.docapp1.ztravel
type: application
resources:
configuration:
propertiesFileSourceEncoding: UTF-8
builder:
resources:
excludes:
- "/test/**"
- "/localService/**"
customTasks:
- name: webide-extension-task-updateManifestJson
afterTask: replaceVersion
configuration:
appFolder: webapp
destDir: dist
- name: ui5-task-zipper
afterTask: generateCachebusterInfo
configuration:
archiveName: ztestdocapp1ztravel
additionalFiles:
- xs-app.json
- name: ui5-tooling-modules-task
afterTask: replaceVersion
configuration:
addToNamespace: true
50 changes: 50 additions & 0 deletions thirdpartylibrary/ztravelapp/ui5-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# yaml-language-server: $schema=https://sap.github.io/ui5-tooling/schema/ui5.yaml.json

specVersion: "3.1"
metadata:
name: ztest.docapp1.ztravel
type: application
framework:
name: SAPUI5
version: 1.114.7
libraries:
- name: sap.m
- name: sap.ui.core
- name: sap.f
- name: sap.suite.ui.generic.template
- name: sap.ui.comp
- name: sap.ui.generic.app
- name: sap.ui.table
- name: sap.ushell
- name: themelib_sap_horizon
server:
customMiddleware:
- name: fiori-tools-appreload
afterMiddleware: compression
configuration:
port: 35729
path: webapp
delay: 300
- name: fiori-tools-proxy
afterMiddleware: compression
configuration:
ignoreCertError: false # If set to true, certificate errors will be ignored. E.g. self-signed certificates will be accepted
backend:
- path: /V2/Northwind/Northwind.svc
url: https://services.odata.org
destination: northwind
- name: sap-fe-mockserver
beforeMiddleware: csp
configuration:
mountPath: /
services:
- urlPath: /northwind/V2/Northwind/Northwind.svc/
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
generateMockData: true
annotations: []
- name: fiori-tools-preview
afterMiddleware: fiori-tools-appreload
configuration:
component: ztest.docapp1.ztravel
ui5Theme: sap_horizon
37 changes: 37 additions & 0 deletions thirdpartylibrary/ztravelapp/ui5-mock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# yaml-language-server: $schema=https://sap.github.io/ui5-tooling/schema/ui5.yaml.json

specVersion: "3.1"
metadata:
name: ztest.docapp1.ztravel
type: application
server:
customMiddleware:
- name: fiori-tools-proxy
afterMiddleware: compression
configuration:
ignoreCertError: false # If set to true, certificate errors will be ignored. E.g. self-signed certificates will be accepted
ui5:
path:
- /resources
- /test-resources
url: https://ui5.sap.com
backend:
- path: /V2/Northwind/Northwind.svc
url: https://services.odata.org
destination: northwind
- name: fiori-tools-appreload
afterMiddleware: compression
configuration:
port: 35729
path: webapp
delay: 300
- name: sap-fe-mockserver
beforeMiddleware: csp
configuration:
mountPath: /
services:
- urlPath: /sap/opu/odata/dmo/UI_TRAVEL_A_D_O2
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
generateMockData: true
annotations: []
36 changes: 36 additions & 0 deletions thirdpartylibrary/ztravelapp/ui5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# yaml-language-server: $schema=https://sap.github.io/ui5-tooling/schema/ui5.yaml.json

specVersion: "3.1"
metadata:
name: ztest.docapp1.ztravel
type: application
server:
customMiddleware:
- name: fiori-tools-proxy
afterMiddleware: compression
configuration:
ignoreCertError: false # If set to true, certificate errors will be ignored. E.g. self-signed certificates will be accepted
ui5:
path:
- /resources
- /test-resources
url: https://ui5.sap.com
backend:
- path: /V2/Northwind/Northwind.svc
url: https://services.odata.org
destination: northwind
- name: fiori-tools-appreload
afterMiddleware: compression
configuration:
port: 35729
path: webapp
delay: 300
- name: fiori-tools-preview
afterMiddleware: fiori-tools-appreload
configuration:
component: ztest.docapp1.ztravel
ui5Theme: sap_horizon
- name: ui5-tooling-modules-middleware
afterMiddleware: compression
configuration:
addToNamespace: true
Loading

0 comments on commit 0543ac1

Please sign in to comment.