diff --git a/package.json b/package.json index 4ec734d..cbe99d2 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,7 @@ "test": "npx jest --silent", "add-change-tracking": "npm add @cap-js/change-tracking && cp xmpls/change-tracking.cds ./srv && cp xmpls/change-tracking.test.js ./test", "add-telemetry": "npm add @cap-js/telemetry", - "clone-and-add-attachments": "git clone https://github.com/cap-js/attachments.git && npm add ./attachments && npm run add-attachments", - "add-attachments": "cp -r xmpls/attachments/ ./", + "add-attachments": "npm add @cap-js/attachments && cp -r xmpls/attachments.cds ./db", "add-notifications": "npm add @cap-js/notifications && cp xmpls/alert-notifications.js ./srv && cp xmpls/notification-types.json ./srv", "add-audit-log": "npm add @cap-js/audit-logging && cp xmpls/data-privacy.cds ./srv && cp xmpls/audit-log.test.js ./test", "add-remote-service": "cp -r xmpls/remote-service/* .", diff --git a/xmpls/attachments/db/attachments.cds b/xmpls/attachments.cds similarity index 55% rename from xmpls/attachments/db/attachments.cds rename to xmpls/attachments.cds index 5efebdb..f58acd5 100644 --- a/xmpls/attachments/db/attachments.cds +++ b/xmpls/attachments.cds @@ -1,11 +1,7 @@ using { sap.capire.incidents as my } from './schema'; -using { Image, Attachments } from '@cap-js/attachments'; +using { Attachments } from '@cap-js/attachments'; extend my.Incidents with { attachments: Composition of many Attachments; -} - -extend my.Customers with { - avatar: Image; } \ No newline at end of file diff --git a/xmpls/attachments/app/avatars.cds b/xmpls/attachments/app/avatars.cds deleted file mode 100644 index dfd038a..0000000 --- a/xmpls/attachments/app/avatars.cds +++ /dev/null @@ -1,6 +0,0 @@ -using from './services'; -using from '../db/attachments'; - -annotate ProcessorService.Incidents with @(UI.HeaderInfo: { - TypeImageUrl: customer.avatar.url -}); diff --git a/xmpls/attachments/db/content/Broken Solar Panel.jpg b/xmpls/attachments/db/content/Broken Solar Panel.jpg deleted file mode 100644 index bbc7042..0000000 Binary files a/xmpls/attachments/db/content/Broken Solar Panel.jpg and /dev/null differ diff --git a/xmpls/attachments/db/content/Customer Avatars.jpg b/xmpls/attachments/db/content/Customer Avatars.jpg deleted file mode 100644 index 7ce2864..0000000 Binary files a/xmpls/attachments/db/content/Customer Avatars.jpg and /dev/null differ diff --git a/xmpls/attachments/db/content/Daniel Watts.png b/xmpls/attachments/db/content/Daniel Watts.png deleted file mode 100644 index 7ecd679..0000000 Binary files a/xmpls/attachments/db/content/Daniel Watts.png and /dev/null differ diff --git a/xmpls/attachments/db/content/INVERTER FAULT REPORT.pdf b/xmpls/attachments/db/content/INVERTER FAULT REPORT.pdf deleted file mode 100644 index 254e795..0000000 Binary files a/xmpls/attachments/db/content/INVERTER FAULT REPORT.pdf and /dev/null differ diff --git a/xmpls/attachments/db/content/Inverter-error-logs.txt b/xmpls/attachments/db/content/Inverter-error-logs.txt deleted file mode 100644 index 3bef59e..0000000 --- a/xmpls/attachments/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/xmpls/attachments/db/content/No_current.xlsx b/xmpls/attachments/db/content/No_current.xlsx deleted file mode 100644 index 3db1d92..0000000 Binary files a/xmpls/attachments/db/content/No_current.xlsx and /dev/null differ diff --git a/xmpls/attachments/db/content/Solar Panel Report.pdf b/xmpls/attachments/db/content/Solar Panel Report.pdf deleted file mode 100644 index 0e29aa2..0000000 Binary files a/xmpls/attachments/db/content/Solar Panel Report.pdf and /dev/null differ diff --git a/xmpls/attachments/db/content/Stormy Weathers.png b/xmpls/attachments/db/content/Stormy Weathers.png deleted file mode 100644 index 07a8318..0000000 Binary files a/xmpls/attachments/db/content/Stormy Weathers.png and /dev/null differ diff --git a/xmpls/attachments/db/content/Sunny Sunshine.png b/xmpls/attachments/db/content/Sunny Sunshine.png deleted file mode 100644 index 704906b..0000000 Binary files a/xmpls/attachments/db/content/Sunny Sunshine.png and /dev/null differ diff --git a/xmpls/attachments/db/content/strange-noise.csv b/xmpls/attachments/db/content/strange-noise.csv deleted file mode 100644 index 1416014..0000000 --- a/xmpls/attachments/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/xmpls/attachments/db/init.js b/xmpls/attachments/db/init.js deleted file mode 100644 index c983378..0000000 --- a/xmpls/attachments/db/init.js +++ /dev/null @@ -1,38 +0,0 @@ -const cds = require('@sap/cds/lib') -module.exports = async function () { - - // this ensures customers are in the db already - cds.once('served', async () => { - const { 'sap.capire.incidents.Customers': Customers } = cds.model.entities - await UPDATE (Customers) .set ('avatar_ID = ID') - }) - - 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' ], - [ '3b23bb4b-4ac7-4a24-ac02-aa10cabd842c', 'Inverter-error-logs.txt', 'application/txt' ], - [ '3a4ede72-244a-4f5f-8efa-b17e032d01ee', 'No_Current.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], - [ '3ccf474c-3881-44b7-99fb-59a2a4668418', 'strange-noise.csv', 'text/csv' ], - [ '3583f982-d7df-4aad-ab26-301d4a157cd7', 'Broken Solar Panel.jpg', 'image/jpeg' ] - ].map(([ up__ID, filename, mimeType ]) => ({ - up__ID, filename, mimeType, - content: createReadStream (join(__dirname, 'content', filename)), - createdAt: new Date (Date.now() - Math.random() * 30*24*60*60*1000), - createdBy: 'alice', - }))) - - const { 'sap.common.Images': Images } = cds.model.entities - await attachments.put (Images, [ - [ '1004155', 'Daniel Watts.png', 'image/png' ], - [ '1004161', 'Stormy Weathers.png', 'image/png' ], - [ '1004100', 'Sunny Sunshine.png', 'image/png' ] - ].map(([ ID, filename, mimeType ]) => ({ - ID, filename, mimeType, - content: createReadStream (join(__dirname, 'content', filename)), - }))) - -} \ No newline at end of file