diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6319573a..c571a5c6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,6 +22,16 @@ Should you wish to work on an issue, please claim it first by commenting on the If you have questions about one of the issues, please comment on them, and one of the maintainers will clarify. +## Local development setup + +`./tests/incidents-app/` contains a working sample with which the plugin can be locally tested and which is used by the integration tests. + +`cd ./tests/incidents-app/` into the app and run `cds watch` within the folder to have the Incidents app running but with the local version of the plugin. + +If you want to test your implementation against the BTP Object Store or the Malware Scanning Service, use [`cds bind`](https://cap.cloud.sap/docs/advanced/hybrid-testing) and run with `cds watch --profile hybrid` to test those changes. + +If you are prompted locally for authentication use CAPs local development mock values of "alice" and "1234". + ## Contributing Code or Documentation You are welcome to contribute code in order to fix a bug or to implement a new feature that is logged as an issue. diff --git a/README.md b/README.md index bc4cd10e..d5bfa71e 100755 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ We can try out the scenarios where the attachments contents are stored locally i 3. The `Attachments` type has generated an out-of-the-box Attachments table (see 1) at the bottom of the Object page: Attachments Table -4. **Upload a file** by going into Edit mode and either using the **Upload** button on the Attachments table or by drag/drop. Then click the **Save** button to have that file stored that file in the dedicated resource (database, S3 bucket, etc.). We demonstrate this by uploading the PDF file from [_xmpl/db/content/Solar Panel Report.pdf_](./xmpl/db/content/Solar%20Panel%20Report.pdf): +4. **Upload a file** by going into Edit mode and either using the **Upload** button on the Attachments table or by drag/drop. Then click the **Save** button to have that file stored that file in the dedicated resource (database, S3 bucket, etc.). We demonstrate this by uploading the PDF file from [_tests/integration/content/sample.pdf_](./tests/integration/content/sample.pdf): Upload an attachment 6. **Delete a file** by going into Edit mode and selecting the file(s) and by using the **Delete** button on the Attachments table. Then click the **Save** button to have that file deleted from the resource (database, S3 bucket, etc.). We demonstrate this by deleting the previously uploaded PDF file: `Solar Panel Report.pdf` @@ -189,7 +189,7 @@ To ensure tenant identification when using a shared object store instance, the p ## Contributing -This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/attachments/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md). +This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/attachments/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, the **local development setup**, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md). ## Code of Conduct diff --git a/package.json b/package.json index 68a451cc..f8009c59 100644 --- a/package.json +++ b/package.json @@ -90,5 +90,8 @@ } } } - } + }, + "workspaces": [ + "tests/incidents-app/" + ] } \ No newline at end of file diff --git a/tests/incidents-app/app/incidents/webapp/manifest.json b/tests/incidents-app/app/incidents/webapp/manifest.json index beb63f8b..880edcd9 100644 --- a/tests/incidents-app/app/incidents/webapp/manifest.json +++ b/tests/incidents-app/app/incidents/webapp/manifest.json @@ -124,7 +124,7 @@ } } }, - "initialLoad": "Enabled", + "liveMode": true, "controlConfiguration": { "@com.sap.vocabularies.UI.v1.LineItem": { "tableSettings": { diff --git a/xmpl/.gitignore b/xmpl/.gitignore deleted file mode 100644 index b92ceaa2..00000000 --- a/xmpl/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# added by cds -.cdsrc-private.json diff --git a/xmpl/README.md b/xmpl/README.md deleted file mode 100644 index 54444c44..00000000 --- a/xmpl/README.md +++ /dev/null @@ -1,13 +0,0 @@ -### Attachments sample - -This repository contains a sample CDS model extensions to demonstrate the CDS plugin [@cap-js/attachments](https://github.com/cap-js/attachments) on the [Incidents Management](https://github.com/cap-js/incidents-app) reference app for the new reuse types `Attachments`. - - -### References - -#### Incident Attachments: -- Image by vecstock - - broken solar panel - -- All other sample data in attachments have been generated byusing [ChatGPT-3.5](https://www.openai.com/). diff --git a/xmpl/db/attachments.cds b/xmpl/db/attachments.cds deleted file mode 100644 index c2b281cb..00000000 --- a/xmpl/db/attachments.cds +++ /dev/null @@ -1,7 +0,0 @@ - -using { sap.capire.incidents as my } from '@capire/incidents/db/schema'; -using { Attachments } from '@cap-js/attachments'; - -extend my.Incidents with { - attachments: Composition of many Attachments; -} diff --git a/xmpl/db/content/Broken Solar Panel.jpg b/xmpl/db/content/Broken Solar Panel.jpg deleted file mode 100644 index bbc70420..00000000 Binary files a/xmpl/db/content/Broken Solar Panel.jpg and /dev/null differ diff --git a/xmpl/db/content/INVERTER FAULT REPORT.pdf b/xmpl/db/content/INVERTER FAULT REPORT.pdf deleted file mode 100644 index 254e795b..00000000 Binary files a/xmpl/db/content/INVERTER FAULT REPORT.pdf and /dev/null differ diff --git a/xmpl/db/content/Inverter-error-logs.txt b/xmpl/db/content/Inverter-error-logs.txt deleted file mode 100644 index 3bef59e6..00000000 --- a/xmpl/db/content/Inverter-error-logs.txt +++ /dev/null @@ -1,24 +0,0 @@ -Timestamp: 2023-11-28 09:15:00 -Log: ERROR - Inverter malfunction detected. Output voltage is fluctuating outside normal range. -Details: Voltage: 180V - 250V, Expected: 220V. -Action taken: System shut down for safety. Investigating root cause. - -Timestamp: 2023-11-28 12:30:00 -Log: WARNING - Inverter temperature exceeding safe limits. -Details: Temperature: 80°C, Safe limit: 60°C. -Action taken: Reduced load to cool down the inverter. Monitoring closely. - -Timestamp: 2023-11-28 15:45:00 -Log: CRITICAL - Inverter failure. Complete loss of power. -Details: No output voltage detected. -Action taken: Emergency shutdown. Contacting maintenance for immediate inspection. - -Timestamp: 2023-11-29 08:00:00 -Log: ERROR - Inverter restart failure. -Details: Attempted to restart the inverter, but unsuccessful. -Action taken: Engaging maintenance team for on-site inspection and repairs. - -Timestamp: 2023-11-29 11:20:00 -Log: WARNING - Inverter communication error. -Details: Loss of communication with the control system. -Action taken: Reestablishing communication. Investigating possible control board issues. \ No newline at end of file diff --git a/xmpl/db/content/No_current.xlsx b/xmpl/db/content/No_current.xlsx deleted file mode 100644 index 3db1d929..00000000 Binary files a/xmpl/db/content/No_current.xlsx and /dev/null differ diff --git a/xmpl/db/content/Solar Panel Report.pdf b/xmpl/db/content/Solar Panel Report.pdf deleted file mode 100644 index 0e29aa2b..00000000 Binary files a/xmpl/db/content/Solar Panel Report.pdf and /dev/null differ diff --git a/xmpl/db/content/strange-noise.csv b/xmpl/db/content/strange-noise.csv deleted file mode 100644 index 1416014b..00000000 --- a/xmpl/db/content/strange-noise.csv +++ /dev/null @@ -1,11 +0,0 @@ -Timestamp,Noise_Level,Noise_Type -2023-11-28 08:00:00,75,Unknown -2023-11-28 08:05:00,82,Unusual Humming -2023-11-28 08:10:00,90,Mysterious Clicking -2023-11-28 08:15:00,78,Strange Whirring -2023-11-28 08:20:00,85,Unidentified Screech -2023-11-28 08:25:00,88,Odd Pulsating -2023-11-28 08:30:00,92,Eerie Rumbling -2023-11-28 08:35:00,79,Abnormal Hissing -2023-11-28 08:40:00,87,Unexplained Thumping -2023-11-28 08:45:00,95,Bizarre Chirping \ No newline at end of file diff --git a/xmpl/db/init.js b/xmpl/db/init.js deleted file mode 100644 index 3f5514e5..00000000 --- a/xmpl/db/init.js +++ /dev/null @@ -1,22 +0,0 @@ -const cds = require('@sap/cds/lib') -module.exports = async function () { - - const attachments = await cds.connect.to('attachments') - const { join } = cds.utils.path - const { createReadStream } = cds.utils.fs - - const { 'sap.capire.incidents.Incidents.attachments': Attachments } = cds.model.entities - await attachments.put (Attachments, [ - [ '3b23bb4b-4ac7-4a24-ac02-aa10cabd842c', 'INVERTER FAULT REPORT.pdf', 'application/pdf', cds.utils.uuid(),cds.utils.uuid(), 'Unscanned'], - [ '3b23bb4b-4ac7-4a24-ac02-aa10cabd842c', 'Inverter-error-logs.txt', 'application/txt' , cds.utils.uuid(), cds.utils.uuid(),'Clean'], - [ '3a4ede72-244a-4f5f-8efa-b17e032d01ee', 'No_Current.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', cds.utils.uuid(), cds.utils.uuid(),'Scanning'], - [ '3ccf474c-3881-44b7-99fb-59a2a4668418', 'strange-noise.csv', 'text/csv', cds.utils.uuid(), cds.utils.uuid(),'Malware Detected'], - [ '3583f982-d7df-4aad-ab26-301d4a157cd7', 'Broken Solar Panel.jpg', 'image/jpeg', cds.utils.uuid(), cds.utils.uuid(),'Clean'], - ].map(([ up__ID, filename, mimeType, url, ID , status]) => ({ - up__ID, filename, mimeType, url, ID, status, - content: createReadStream (join(__dirname, 'content', filename)), - createdAt: new Date (Date.now() - Math.random() * 30*24*60*60*1000), - createdBy: 'alice', - }))) - -} diff --git a/xmpl/package.json b/xmpl/package.json deleted file mode 100644 index 2b09bebe..00000000 --- a/xmpl/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@capire/attachments-sample", - "version": "1.0.0", - "dependencies": { - "@cap-js/attachments": "*", - "@capire/incidents": "*", - "@sap/cds": "*" - }, - "devDependencies": { - "@cap-js/sqlite": "*" - }, - "private": true -} \ No newline at end of file diff --git a/xmpl/srv/service.cds b/xmpl/srv/service.cds deleted file mode 100644 index 58d217d0..00000000 --- a/xmpl/srv/service.cds +++ /dev/null @@ -1 +0,0 @@ -using from '@capire/incidents/app/services'; \ No newline at end of file