Commit f550ad29 authored by tiven wang's avatar tiven wang 🤞

UI5 App

parent 197eb625
......@@ -2,3 +2,4 @@ node_modules
dist
deployment
.env
package-lock.json
\ No newline at end of file
node_modules
.env
.tscache
\ No newline at end of file
.tscache
package-lock.json
\ No newline at end of file
......@@ -40,4 +40,19 @@ applications:
random-route: true
services:
- hdi_db
- my-xsuaa
- name: ui5-app
path: wang.tiven.myUI5App/dist
random-route: true
env:
destinations: >
[
{
"name":"xs-backend",
"url":"https://xsjs-fluent-elephant.cfapps.eu10.hana.ondemand.com/",
"forwardAuthToken": true
}
]
services:
- my-xsuaa
\ No newline at end of file
# see http://editorconfig.org
root = true
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
# npm is using 2 spaces when modifying package.json
[package.json]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
{
"env": {
"browser": true
},
"globals": {
"sap": true,
"jQuery": true
},
"rules": {
"block-scoped-var": 1,
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"consistent-this": 2,
"no-div-regex": 2,
"no-floating-decimal": 2,
"no-self-compare": 2,
"no-mixed-spaces-and-tabs": [2, true],
"no-nested-ternary": 2,
"no-unused-vars": [2, {"vars":"all", "args":"none"}],
"radix": 2,
"keyword-spacing": 2,
"space-unary-ops": 2,
"wrap-iife": [2, "any"],
"camelcase": 1,
"consistent-return": 1,
"max-nested-callbacks": [1, 3],
"new-cap": 1,
"no-extra-boolean-cast": 1,
"no-lonely-if": 1,
"no-new": 1,
"no-new-wrappers": 1,
"no-redeclare": 1,
"no-unused-expressions": 1,
"no-use-before-define": [1, "nofunc"],
"no-warning-comments": 1,
"strict": 1,
"valid-jsdoc": [1, {
"requireReturn": false
}],
"default-case": 1,
"dot-notation": 0,
"eol-last": 0,
"eqeqeq": 0,
"no-trailing-spaces": 0,
"no-underscore-dangle": 0,
"quotes": 0,
"key-spacing": 0,
"comma-spacing": 0,
"no-multi-spaces": 0,
"no-shadow": 0,
"no-irregular-whitespace": 0
}
}
node_modules/
.idea/
.mta/
*.mtar
dist/
package-lock.json
@sap:registry=https://npm.sap.com/
{
"generator-easy-ui5": {
"projectname": "myUI5App",
"namespace": "wang.tiven",
"viewtype": "XML",
"viewname": "MainView"
}
}
\ No newline at end of file
version=0.0.1
ifndef p
$(error platform flag is expected. e.g. use make -f makefile.mta p=cf)
endif
target_provided=true
ifndef t
t="$(CURDIR)"
target_provided=false
endif
ifndef strict
strict=true
endif
ifndef mtar
mtar="*"
endif
modules := $(shell mbt provide modules -d=dev)
modules := $(subst ],,$(subst [,,$(modules)))
# List of all the recipes to be executed during the build process
.PHONY: all pre_validate pre_build validate $(modules) post_build meta mtar cleanup
# Default target compile all
all: pre_validate pre_build validate $(modules) post_build meta mtar cleanup
cores:
# Determine OS cores
NPROCS = $(shell echo %NUMBER_OF_PROCESSORS%)
MAKEFLAGS += -j
# Validate mta.yaml
pre_validate:
@mbt validate -r=${strict} -e="paths"
pre_build: pre_validate
@mbt project build -p=pre
# Execute module build
define build_rule
$(1): validate
@mbt module build -m=$(1) -p=${p} -t=${t}
endef
$(foreach mod,$(modules),$(eval $(call build_rule,$(mod))))# Create META-INF folder with MANIFEST.MF & mtad.yaml
meta: $(modules) post_build
@mbt gen meta -p=${p} -t=${t}
post_build: $(modules)
@mbt project build -p=post
# Validate mta.yaml
validate: pre_build
@mbt validate -r=${strict}
# Pack as MTAR artifact
mtar: $(modules) meta
@mbt gen mtar -t=${t} --mtar=${mtar} --target_provided=${target_provided}
cleanup: mtar
# Remove tmp folder
@mbt clean -t=${t}
\ No newline at end of file
{
"name": "myUI5App",
"version": "0.0.1",
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
},
"dependencies": {
"@sap/approuter": "^6.0.0"
}
}
{
"welcomeFile": "/index.html",
"authenticationMethod": "route",
"logout": {
"logoutEndpoint": "/do/logout"
},
"routes": [
{
"source": "^/xs/(.*)$",
"target": "$1",
"destination": "xs-backend",
"authenticationType": "xsuaa"
},
{
"source": "^/(.*)$",
"target": "$1",
"localDir": ".",
"authenticationType": "xsuaa"
}
]
}
module.exports = function(config) {
require("./karma.conf")(config);
config.set({
// test results reporter to use
// possible values: 'dots', 'progress', 'coverage'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeHeadless'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
});
};
module.exports = function(config) {
config.set({
frameworks: ["ui5"],
browsers: ["Chrome"],
browserConsoleLogOptions: {
level: "error"
}
});
};
ID: myUI5App
_schema-version: 3.2.0
description: Enter description here
version: 0.0.1
modules:
- name: myUI5App
type: nodejs
path: dist
parameters:
disk-quota: 512M
memory: 512M
requires:
- name: my-destination
- name: my-xsuaa
resources:
- name: my-destination
parameters:
service-plan: lite
service: destination
type: org.cloudfoundry.managed-service
- name: my-xsuaa
parameters:
service-plan: application
service: xsuaa
type: org.cloudfoundry.managed-service
\ No newline at end of file
{
"name": "myUI5App",
"version": "0.0.1",
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"start": "ui5 serve -o index.html",
"serve": "ui5 serve",
"test": "npm run lint && npm run karma",
"karma-ci": "karma start karma-ci.conf.js",
"karma": "rimraf coverage && npm run karma-ci",
"lint": "eslint webapp",
"build:ui": "rimraf dist && ui5 build --a",
"build:cf": "npm run build:ui && shx cp cf_deployment_resources/package.json dist/package.json && shx cp cf_deployment_resources/xs-app.json dist/xs-app.json && mbt init && make -f Makefile.mta p=cf",
"deploy:cf": "npm run build:cf && cross-var cf deploy mta_archives/myUI5App_$npm_package_version.mtar"
},
"dependencies": {
"@openui5/sap.m": "^1.66.1",
"@openui5/sap.ui.core": "^1.66.1",
"@openui5/sap.ui.layout": "^1.66.1",
"@openui5/themelib_sap_belize": "^1.66.1",
"shx": "^0.3.2"
},
"devDependencies": {
"@ui5/cli": "^1.4.4",
"rimraf": "^2.6.3",
"karma": "^4.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
"karma-ui5": "^1.0.0",
"cross-var": "^1.1.0",
"eslint": "^5.16.0"
}
}
# myUI5App
Insert the purpose of this project and some intersting infos here
## Usage
### Local developement
```
npm start
```
### Deploy to Cloud Foundry
Please make sure you installed the [Cloud Foundry CLI](https://github.com/cloudfoundry/cli) cli and your are signed in ``cf login``
```
npm run deploy:cf
```
## Credits
This project has been generated with 💙 and [easy-ui5](https://github.com/SAP)
[SAP Cloud Foundry Node.js - Develop SAPUI5 Web App on Local](http://tiven.wang/articles/sap-cloudfoundry-node-ui5/)
\ No newline at end of file
specVersion: '1.0'
metadata:
name: myUI5App
type: application
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"wang/tiven/myUI5App/model/models"
], function(UIComponent, Device, models) {
"use strict";
return UIComponent.extend("wang.tiven.myUI5App.Component", {
metadata: {
manifest: "json"
},
/**
* The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
* @public
* @override
*/
init: function() {
// call the base component's init function
UIComponent.prototype.init.apply(this, arguments);
// enable routing
this.getRouter().initialize();
// set the device model
this.setModel(models.createDeviceModel(), "device");
}
});
});
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("wang.tiven.myUI5App.controller.MainView", {});
});
/* Enter your custom styles here */
title=myUI5App
appTitle=myUI5App
appDescription=App Description
title=myUI5App
appTitle=myUI5App
appDescription=App Description
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>myUI5App</title>
<script id="sap-ui-bootstrap"
src="resources/sap-ui-core.js"
data-sap-ui-theme="sap_belize"
data-sap-ui-resourceroots='{
"wang.tiven.myUI5App": "./"
}'
data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
data-sap-ui-compatVersion="edge"
data-sap-ui-async="true"
data-sap-ui-frameOptions="trusted">
</script>
</head>
<body class="sapUiBody">
<div data-sap-ui-component data-name="wang.tiven.myUI5App" data-id="container" data-settings='{"id" : "myUI5App"}'></div>
</body>
</html>
{
"_version": "1.12.0",
"sap.app": {
"id": "wang.tiven.myUI5App",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"dataSources": {
"mainService": {
"uri": "/xs/xsodata/purchaseOrder.xsodata/",
"type": "OData",
"settings": {
"odataVersion": "2.0"
}
}
}
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"[email protected]": "",
"tablet": "",
"[email protected]": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
}
},
"sap.ui5": {
"rootView": {
"viewName": "wang.tiven.myUI5App.view.MainView",
"type": "XML",
"async": true,
"id": "app"
},
"dependencies": {
"minUI5Version": "1.60.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "wang.tiven.myUI5App.i18n.i18n"
}
},
"": {
"preload": true,
"dataSource": "mainService",
"settings": {
"defaultBindingMode": "TwoWay",
"defaultCountMode": "Inline",
"refreshAfterChange": false
}
}
},
"resources": {
"css": [{
"uri": "css/style.css"
}]
},
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "wang.tiven.myUI5App.view",
"controlId": "app",
"controlAggregation": "pages",
"async": true
},
"routes": [{
"name": "RouteMainView",
"pattern": "RouteMainView",
"target": ["TargetMainView"]
}],
"targets": {
"TargetMainView": {
"viewType": "XML",
"viewLevel": 1,
"viewName": "MainView"
}
}
}
}
}
sap.ui.define([
"sap/ui/model/json/JSONModel",
"sap/ui/Device"
], function(JSONModel, Device) {
"use strict";
return {
createDeviceModel: function() {
var oModel = new JSONModel(Device);
oModel.setDefaultBindingMode("OneWay");
return oModel;
}
};
});
sap.ui.define([
"sap/ui/test/Opa5",
"wang/tiven/myUI5App/test/integration/arrangements/Startup",
"wang/tiven/myUI5App/test/integration/BasicJourney"
], function(Opa5, Startup) {
"use strict";
Opa5.extendConfig({
arrangements: new Startup(),
pollingInterval: 1
});
});
sap.ui.define([
"sap/ui/test/opaQunit",
"wang/tiven/myUI5App/test/integration/pages/App"
], function (opaTest) {
"use strict";
opaTest("should show correct number of nested pages", function (Given, When, Then) {
// Arrangements
Given.iStartMyApp();
// Assertions
Then.onTheAppPage.iShouldSeePageCount(1);
// Cleanup
Then.iTeardownMyApp();
});
});
sap.ui.define([
"sap/ui/test/Opa5"
], function(Opa5) {
"use strict";
return Opa5.extend("wang.tiven.myUI5App.test.integration.arrangements.Startup", {
iStartMyApp: function () {
this.iStartMyUIComponent({
componentConfig: {
name: "wang.tiven.myUI5App",
async: true,
manifest: true
}
});
}
});
});