diff --git a/bookstore/cds-plugin.js b/bookstore/cds-plugin.js deleted file mode 100644 index d979763a..00000000 --- a/bookstore/cds-plugin.js +++ /dev/null @@ -1,18 +0,0 @@ -const cds = require ('@sap/cds') - -// Add routes to UIs from imported packages -cds.once('bootstrap',(app)=>{ - app.serve ('/admin-authors') .from ('@capire/fiori','app/admin-authors') - app.serve ('/admin-books') .from ('@capire/fiori','app/admin-books') - app.serve ('/browse-books') .from ('@capire/fiori','app/browse') -}) - -// Add mashup logic -cds.once('served', require('./srv/mashup')) - -// Add Swagger UI -require('./srv/swagger-ui') - -// For didactic reasons in capire -const { ReviewsService, OrdersService } = cds.requires -if (!ReviewsService?.credentials && !OrdersService?.credentials) cds.requires.messaging = false \ No newline at end of file diff --git a/compose/app/appconfig/fioriSandboxConfig.json b/compose/app/appconfig/fioriSandboxConfig.json new file mode 100644 index 00000000..1bc4eb93 --- /dev/null +++ b/compose/app/appconfig/fioriSandboxConfig.json @@ -0,0 +1,168 @@ +{ + "services": { + "LaunchPage": { + "adapter": { + "config": { + "catalogs": [], + "groups": [ + { + "id": "Bookshop", + "title": "Bookshop", + "isPreset": true, + "isVisible": true, + "isGroupLocked": false, + "tiles": [ + { + "id": "BrowseBooks", + "tileType": "sap.ushell.ui.tile.StaticTile", + "properties": { + "title": "Browse Books", + "targetURL": "#Books-display" + } + }, + { + "id": "BrowseGenres", + "tileType": "sap.ushell.ui.tile.StaticTile", + "properties": { + "title": "Browse Genres (OData v2)", + "targetURL": "#Genres-display" + } + } + ] + }, + { + "id": "Administration", + "title": "Administration", + "isPreset": true, + "isVisible": true, + "isGroupLocked": false, + "tiles": [ + { + "id": "ManageBooks", + "tileType": "sap.ushell.ui.tile.StaticTile", + "properties": { + "title": "Manage Books", + "targetURL": "#Books-manage" + } + }, + { + "id": "ManageAuthors", + "tileType": "sap.ushell.ui.tile.StaticTile", + "properties": { + "title": "Manage Authors", + "targetURL": "#Authors-display" + } + }, + { + "id": "ManageOrders", + "tileType": "sap.ushell.ui.tile.StaticTile", + "properties": { + "title": "Manage Orders", + "targetURL": "#Orders-manage" + } + } + ] + } + ] + } + } + }, + "NavTargetResolution": { + "config": { + "enableClientSideTargetResolution": true + } + }, + "ClientSideTargetResolution": { + "adapter": { + "config": { + "inbounds": { + "BrowseBooks": { + "semanticObject": "Books", + "action": "display", + "title": "Browse Books", + "signature": { + "parameters": { + "Books.ID": { + "renameTo": "ID" + }, + "Authors.books.ID": { + "renameTo": "ID" + } + }, + "additionalParameters": "ignored" + }, + "resolutionResult": { + "applicationType": "SAPUI5", + "additionalInformation": "SAPUI5.Component=bookshop", + "url": "/browse/webapp" + } + }, + "BrowseAuthors": { + "semanticObject": "Authors", + "action": "display", + "title": "Browse Authors", + "signature": { + "parameters": { + "Books.author.ID":{ + "renameTo": "ID" + } + }, + "additionalParameters": "ignored" + }, + "resolutionResult": { + "applicationType": "SAPUI5", + "additionalInformation": "SAPUI5.Component=authors", + "url": "/admin-authors/webapp" + } + }, + "BrowseGenres": { + "semanticObject": "Genres", + "action": "display", + "title": "Browse Genres", + "signature": { + "parameters": { + "Genre.ID": { + "renameTo": "ID" + } + }, + "additionalParameters": "ignored" + }, + "resolutionResult": { + "applicationType": "SAPUI5", + "additionalInformation": "SAPUI5.Component=genres", + "url": "/genres/webapp" + } + }, + "ManageBooks": { + "semanticObject": "Books", + "action": "manage", + "title": "Manage Books", + "signature": { + "parameters": {}, + "additionalParameters": "allowed" + }, + "resolutionResult": { + "applicationType": "SAPUI5", + "additionalInformation": "SAPUI5.Component=books", + "url": "/admin-books/webapp" + } + }, + "ManageOrders": { + "semanticObject": "Orders", + "action": "manage", + "signature": { + "parameters": {}, + "additionalParameters": "allowed" + }, + "resolutionResult": { + "applicationType": "SAPUI5", + "additionalInformation": "SAPUI5.Component=orders", + "url": "/orders/webapp" + } + } + } + } + } + } + } +} diff --git a/compose/package.json b/compose/package.json index f0f32d7b..ab876b88 100644 --- a/compose/package.json +++ b/compose/package.json @@ -4,6 +4,7 @@ "dependencies": { "@capire/bookshop": "*", "@capire/reviews": "*", + "@capire/fiori": "*", "@capire/orders": "*", "@sap/cds": ">=5", "express": "^4.17.1" diff --git a/compose/server.js b/compose/server.js new file mode 100644 index 00000000..c042da63 --- /dev/null +++ b/compose/server.js @@ -0,0 +1,8 @@ +const cds = require ('@sap/cds') + +// Add Swagger UI +require('./srv/swagger-ui') + +// For didactic reasons in capire +const { ReviewsService, OrdersService } = cds.requires +if (!ReviewsService?.credentials && !OrdersService?.credentials) cds.requires.messaging = false diff --git a/compose/srv/swagger-ui.js b/compose/srv/swagger-ui.js new file mode 100644 index 00000000..22fe3a18 --- /dev/null +++ b/compose/srv/swagger-ui.js @@ -0,0 +1,10 @@ + +// ----------------------------------------------------------------------- +// Adding Swagger UI - see https://cap.cloud.sap/docs/advanced/openapi +const cds = require ('@sap/cds') +try { + const cds_swagger = require ('cds-swagger-ui-express') + cds.once ('bootstrap', app => app.use (cds_swagger()) ) +} catch (err) { + if (err.code !== 'MODULE_NOT_FOUND') throw err +} diff --git a/fiori/cds-plugin.js b/fiori/cds-plugin.js index 2b975351..d9b38430 100644 --- a/fiori/cds-plugin.js +++ b/fiori/cds-plugin.js @@ -2,5 +2,8 @@ const cds = require("@sap/cds") const proxy = require('@cap-js-community/odata-v2-adapter') const opts = global.it ? { target:'auto' } : {} // for tests, set 'auto' to detect port dynamically -cds.on('bootstrap', app => app.use(proxy(opts))) // install proxy -// cds.log('cov2ap','silent') // suppress anoying log outpout, e.g. for `npm run mocha -- --reporter nyan` \ No newline at end of file +cds.once('bootstrap', app => { + app.use(proxy(opts)) // install proxy + // cds.log('cov2ap','silent') // suppress anoying log outpout, e.g. for `npm run mocha -- --reporter nyan` + app.serve ('/fiori-apps') .from ('@capire/fiori','app/fiori-apps.html') +}) diff --git a/package-lock.json b/package-lock.json index 1599da8a..c7bdd582 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,6 +52,7 @@ "@capire/bookshop": "*", "@capire/common": "*", "@capire/data-viewer": "*", + "@capire/fiori": "*", "@capire/orders": "*", "@capire/reviews": "*", "@sap/cds": ">=5",