Skip to content

Commit

Permalink
Merge branch 'main' into devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSchlachter authored Jan 22, 2024
2 parents 00af87d + dc8d9a8 commit 1836da0
Show file tree
Hide file tree
Showing 35 changed files with 586 additions and 1,109 deletions.
8 changes: 3 additions & 5 deletions app/incidents/annotations.cds
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using ProcessorService as service from '../../srv/processor-service';
using ProcessorService as service from '../../srv/services';
using from '../../db/schema';

annotate service.Customers with @title : '{i18n>Customer}';
annotate service.Incidents with @title : '{i18n>Incident}';
annotate service.Incidents with @odata.draft.enabled;

annotate service.Incidents with @(
UI.LineItem : [
Expand Down Expand Up @@ -161,11 +162,8 @@ annotate service.Incidents with {
![@UI.TextArrangement] : #TextOnly,
}
};
annotate ProcessorService.Incidents.conversation with @(
UI.LineItem #i18nConversation : [
]
);
annotate service.Incidents.conversation with @(
title : '{i18n>Conversation}',
UI.LineItem #i18nConversation1 : [
{
$Type : 'UI.DataField',
Expand Down
13 changes: 0 additions & 13 deletions app/incidents/package-lock.json

This file was deleted.

2 changes: 1 addition & 1 deletion app/incidents/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</style>
<script
id="sap-ui-bootstrap"
src="https://sapui5.hana.ondemand.com/1.120.0/resources/sap-ui-core.js"
src="https://ui5.sap.com/1.120.4/resources/sap-ui-core.js"
data-sap-ui-theme="sap_horizon"
data-sap-ui-resourceroots='{
"ns.incidents": "./"
Expand Down
747 changes: 0 additions & 747 deletions app/incidents/webapp/localService/metadata.xml

This file was deleted.

39 changes: 0 additions & 39 deletions app/launchpage.html

This file was deleted.

6 changes: 2 additions & 4 deletions cds-plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const cds = require('@sap/cds')

// Add routes to UIs from imported packages
const cds = require("@sap/cds");
cds.once('bootstrap', (app) => {
app.serve('/incidents').from('@capire/incidents', 'app/incidents/webapp')
app.serve('/incidents/app').from(__dirname,'/app/incidents/webapp')
})
60 changes: 31 additions & 29 deletions db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@ namespace sap.capire.incidents;
* Customers can create support Incidents.
*/
entity Customers : cuid, managed {
firstName : String;
lastName : String;
email : EMailAddress;
phone : PhoneNumber;
creditCardNo : String(16) @assert.format: '^[1-9]\d{15}$';
addresses : Composition of many Addresses on addresses.customer = $self;
incidents : Association to many Incidents on incidents.customer = $self;
firstName : String;
lastName : String;
name : String = firstName ||' '|| lastName;
email : EMailAddress;
phone : PhoneNumber;
creditCardNo : String(16) @assert.format: '^[1-9]\d{15}$';
addresses : Composition of many Addresses on addresses.customer = $self;
incidents : Association to many Incidents on incidents.customer = $self;
}

entity Addresses : cuid, managed {
customer : Association to Customers;
city : String;
postCode : String;
streetAddress : String;
customer : Association to Customers;
city : String;
postCode : String;
streetAddress : String;
}


/**
* Incidents created by Customers.
*/
entity Incidents : cuid, managed {
customer : Association to Customers;
title : String @title: 'Title';
urgency : Association to Urgency default 'M';
status : Association to Status default 'N';
conversation : Composition of many {
customer : Association to Customers;
title : String @title: 'Title';
urgency : Association to Urgency default 'M';
status : Association to Status default 'N';
conversation : Composition of many {
key ID : UUID;
timestamp : type of managed:createdAt;
author : type of managed:createdBy;
Expand All @@ -40,23 +42,23 @@ entity Incidents : cuid, managed {
}

entity Status : CodeList {
key code : String enum {
new = 'N';
assigned = 'A';
in_process = 'I';
on_hold = 'H';
resolved = 'R';
closed = 'C';
};
criticality : Integer;
key code : String enum {
new = 'N';
assigned = 'A';
in_process = 'I';
on_hold = 'H';
resolved = 'R';
closed = 'C';
};
criticality : Integer;
}

entity Urgency : CodeList {
key code : String enum {
high = 'H';
medium = 'M';
low = 'L';
};
high = 'H';
medium = 'M';
low = 'L';
};
}

type EMailAddress : String;
Expand Down
4 changes: 0 additions & 4 deletions index.cds

This file was deleted.

59 changes: 24 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,56 @@
{
"name": "@capire/incidents",
"version": "1.0.0",
"calesi": {
"@cap-js/audit-logging": "*",
"@cap-js/change-tracking": "*",
"@cap-js/notifications": "*",
"@cap-js/attachments": "*",
"@cap-js/telemetry": "*",
"@sap/ams": "*",
"@sap/ams-dev": "*",
"dummy": 0
},
"dependencies": {
"@sap/cds": ">=7",
"express": "^4",
"@sap/cds-hana": "^2",
"@sap/xssec": "^3",
"passport": "^0"
"express": "^4"
},
"devDependencies": {
"@cap-js/sqlite": "^1.0.1",
"@sap/ux-specification": "^1.108.4",
"axios": "^1.4.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.6.0",
"jest": "^29.5.0",
"@cap-js/sqlite":"^1.0.1"
"chai-subset": "^1.6.0"
},
"scripts": {
"watch": "cds watch",
"start": "cds-serve",
"test": "npx jest --silent"
},
"private": true,
"sapux": [
"app/incidents"
],
"cds": {
"requires": {
"incidents-app": {
"model": "@capire/incidents"
},
"[production]": {
"db": {
"kind": "hana-cloud"
},
"auth": {
"kind": "xsuaa"
},
"approuter": {
"kind": "cloudfoundry"
}
},
"[development]": {
"auth": {
"kind": "mocked",
"auth": {
"[development]": {
"users": {
"[email protected]": {
"password": "initial",
"roles": ["support"]
},
"alice": {
"roles": ["support", "admin"]
"roles": [
"support",
"admin"
]
},
"bob": {
"roles": ["support"]
"roles": [
"support"
]
}
}
}
},
"db": {
"kind": "sql"
}
}
}
},
"private": true
}
78 changes: 27 additions & 51 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,58 @@
# Incident Management

## Overview
Welcome to the Incident Management reference sample application for CAP and development recommendations provided by the SAP BTP Developer Guide.

Welcome to the Incident Management reference sample application for CAP and development recommendations provided by the SAP BTP Developer Guide.
This sample application has already been shown at these events:
## Domain Model

- TechEd keynote demo 2019
- [TechEd hands-on sessions 2022](https://github.com/SAP-samples/teched2022-AD264/wiki)
- at the recap conference 2023
The application support team members to create and process incidents on behalf of registered customers. The basic domain model is depicted below.

## Business Scenario
![domain drawio](xmpls/schema.drawio.svg)

ACME, a manufacturer of washing machines engages the service of call center to process and manage the incidents reported by its customers. A call center employee (Processor) receives a phone call from the customer of ACME and based on the complaint, he/she creates the new Incident on behalf of customer and adds the conversation.

These are assumptions that are used in this sample scenario:
- Customer details are already existing within the Customer entity.
- Incidents are always created by the Call Center employee (Processor).

## Domain

The application allows customers to create incidents, processed by support team members.
Both add comments to a conversation.
## Setup

![domain drawio](https://github.com/SAP-samples/cap-sample-incidents-mgmt/assets/12186013/a1de9cf1-1346-427d-b5a2-55a14428e8f5)
Assumed you prepared for CAP development as documented in capire's *[Getting Started > Jumpstart](https://cap.cloud.sap/docs/get-started/jumpstart)* page, ...

## Run the Incidents Management Application

1. Clone the Incident Management application repository:
Clone the repository and install dependencies:

```sh
git clone https://github.com/cap-js/incidents-app
cd incidents-app
```

Navigate to the project root folder and edit the value of `name` in `package.json` file to `incidents-app`

```sh
npm i
npm install
```

2. Run the application:

```sh
cds w
```
3. Test the application:

## Run

Run the application locally:

```sh
npm t
cds watch
```
4. Display the user interface of the application.
Then open http://localhost:4004 and navigate to [/incidents/webapp](http://localhost:4004/incidents/webapp/index.html). <br>
(login as `alice`, no password required).

<details>
<summary> Troubleshooting </summary>
If you get a 403 Forbidden Error and the logon popup doesn't show, try to open a browser in an incognito mode or clear the browser cache.
</details>

1. Start the application with `cds w`.
2. In a browser, open the server URL: `http://localhost:4004`.
3. There are two URLs under web applications:

- /launchpage.html uses a [local launchpage](!https://pages.github.tools.sap/cap/golden-path/develop/Launchpage/Launchpage)
- /incidents/webapp/index.html uses the index.html from [ui5 app](!https://pages.github.tools.sap/cap/golden-path/develop/btp-app-create-ui-fiori-elements/btp-app-create-ui-fiori-elements)

4. When you are prompted to authenticate, use the following credentials:

- Username: `[email protected]`
- Password: `initial`

Alternatively, `bob` or `alice` can be used as well. They both hold the required `support` role to execute the app. Additionally, `alice` is an `admin`.

**Note:** if you get the 403 Forbidden Error and the popup doesn't show, try to open a browser in an incognito mode or clear the browser cache.

## Deploy the Incident Management Application

The code base in this repository can be deployed in both SAP BTP, Cloud Foundry runtime and SAP BTP, Kyma runtime.
Follow these steps to deploy the application in the resepective runtime:
## Test

- [Deploy incident management app to SAP BTP Cloud Foundry Runtime](https://help.sap.com/docs/btp/btp-developers-guide/deploy-cap#deploy-in-cloud-foundry-runtime)
- [Deploy incident management app to SAP BTP Kyma Runtime](https://help.sap.com/docs/btp/btp-developers-guide/deploy-cap#deploy-in-kyma-runtime)
Run enclosed tests with:

## SAP BTP Developer Guide
```sh
npm test
```

The Incident Management application is used as a reference for the SAP BTP Developer guidance. The SAP BTP Developer Guide provides a curated learning journey and best practices for Pro Code developers. The tutorials will walk you through selected guides of the guide with the goal to build and deploy a full-stack application.

## Deploy

See: *[BTP Developer Guidelines Deployment Guides](https://help.sap.com/docs/btp/btp-developers-guide/deploy-cap)*
8 changes: 0 additions & 8 deletions srv/admin-service.cds

This file was deleted.

Loading

0 comments on commit 1836da0

Please sign in to comment.