Skip to content

Commit

Permalink
Dev v1.3.4
Browse files Browse the repository at this point in the history
* added Integration & Migration Assessment apps for dark support

* Added Auto close on pimas & intas apps

* reformats

* Bug fix

* Cpi app separately added

* optional

* Bug-Fix

* v1.3.3.1-patch Fix

* HCI inclusion and more bugfixes

* v1.3.4
  • Loading branch information
Incpi authored Aug 6, 2024
1 parent f603010 commit 556ba85
Show file tree
Hide file tree
Showing 24 changed files with 54,405 additions and 34,357 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
**Desktop (optional information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Addtionally we support SAP BUILD and Theme Designer

The Dark CPI Extension allows you to customize the theme by specifying a URL parameter. This feature enables you to choose from a variety of predefined themes.

### Using the URL Parameter for only SAP CPI (not for SAP BUILD)
### Using the URL Parameter for only SAP CPI (not for SAP BUILD) (Update: Temporary debug purpose , Replaced with UI)

To select a specific theme, append the `darkcpi` parameter to the URL of your SAP CPI environment, followed by the desired theme value. For example:from design page,
`https://your-sap-cpi-environment.ondamand.com/shell/design?darkcpi=theme-value`
Expand All @@ -67,12 +67,16 @@ The extension comes with the following predefined themes:
If you want to create your own custom theme, you can modify the `themeMap` object in the source code. Add a new key-value pair, where the key represents the theme name (to be used in the URL parameter), and the value is an object containing the CSS styles for your custom theme.

## Changelogs
### v1.3.4
- [feature] Added support for addtional **SAP CPI - fka HCI / old Tenents**
- [Bugfix] UI changes fixes.

### v1.3.3
- [Bugfix] SAP UI theme Horizon dark fix (Trace half screnn non visible)
- [Bugfix] Mapping fields are invisible in mmap Files.
- [Bugfix] Simulation error color is not correct.
- [feature] Now supports addtional application such as **SAP Builds workzone** and it's theme designer.
- [feature] Dark theme supports CPI capablities like Integration Assessment & Migration Assessment.
- [improvement] UI changes for popup.

### v1.2.0
Expand Down
13 changes: 4 additions & 9 deletions Whatsnew/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@
*/
const data_updates = {
bugFixes: [
{
description:
"SAP UI theme Horizon dark fix (Trace half screnn non visible)",
author: "Omkar",
},
{ description: "SAP UI theme Horizon dark fix (Trace half screnn non visible)", author: "Omkar", },
{ description: "Mapping fields are invisible in mmap Files." },
{ description: "Simulation error color is not correct." },
],
features: [
{
description:
"Now supports addtional application such as <b>SAP Builds workzone</b> and it's theme designer.",
},
{ description: "Added support for addtional <b>SAP CPI - fka HCI / old Tenents<b>", },
{ description: "Now supports addtional application such as <b>SAP Builds workzone</b> and it's theme designer.", },
{ description: "Dark theme supports CPI capablities like <b>Integration Assessment & Migration Assessment</b>", },
],
improvements: [{ description: "UI improvement: UI changes for popup." }],
};
Expand Down
6 changes: 3 additions & 3 deletions Whatsnew/whatsnew.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#updates {
.modal-box {
max-width: 80vw;
}
.modal-box {
max-width: 80vw;
}
}
6 changes: 1 addition & 5 deletions Whatsnew/whatsnew.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ function loadDynamicContent() {
listItem.innerHTML = item.description;

if (item.author) {
const authorLink = document.createElement("a");
authorLink.href = data_authors[item.author] || "#";
authorLink.innerHTML = `By (${item.author})`;
authorLink.className = "link link-primary";
listItem.appendChild(authorLink);
listItem.insertAdjacentHTML('beforeend', ` by <a class="link link-primary" href="${data_authors[item.author] || "#"}">(${item.author})</a>`);
}

list.appendChild(listItem);
Expand Down
Binary file not shown.
20 changes: 13 additions & 7 deletions common/content/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ h6 {
font-weight: inherit;
}

a {
color: inherit;
text-decoration: inherit;
}

b,
strong {
font-weight: bolder;
Expand Down Expand Up @@ -390,6 +385,17 @@ video {
}

/* End overwrite of default UI */
div#darkcpiglobal a {
padding-inline: 0.5rem;

#darkcpiglobal {
li {
list-style: inside;
}

a {
padding-inline: 0.5rem;
}

b {
color: var(--cpi-custom-color);
}
}
188 changes: 97 additions & 91 deletions common/content/tool.js
Original file line number Diff line number Diff line change
@@ -1,137 +1,143 @@
"use strict";
const hostmap = [
[/(.*)launchpad.cfapps.*.hana.ondemand.com/, "launchpad"],
[/(.*)\.(hci|integrationsuite(-trial)?.*)/, "cpi"]
]

[/(.*)launchpad.cfapps.*.hana.ondemand.com/, "launchpad"],
[/(.*)\.(hci|integrationsuite(-trial)?).*shell/, "cpi"],
[/.*(pimas|intas){1}.*.cfapps.*.hana.ondemand.com/, "cpi_app"],
];

function application() {
let artifactType = undefined
const url = location.href;
for (const dataRegexp of hostmap) {
if (dataRegexp[0].test(url) === true) {
artifactType = dataRegexp[1];
}
let artifactType = undefined;
const url = location.href;
for (const dataRegexp of hostmap) {
if (dataRegexp[0].test(url) === true) {
artifactType = dataRegexp[1];
}
return artifactType;
};
}
return artifactType;
}

function getHost() {
let tempHost = location.href.match(/\/\/([A-z0-9_-]+)?./)[1]+ "_" + application();
console.log("Temp Host:", tempHost);
return tempHost;
};
let tempHost =
location.href.match(/\/\/([A-z0-9_-]+)?./)[1] + "_" + application();
console.log("Temp Host:", tempHost);
return tempHost;
}
const internalHostname = getHost();
// Storage-related functions
async function getStorageData() {
return new Promise((resolve, reject) => {
chrome.storage.sync.get([internalHostname], function (result) {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
} else {
resolve(result[internalHostname] || {});
}
});
return new Promise((resolve, reject) => {
chrome.storage.sync.get([internalHostname], function (result) {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
} else {
resolve(result[internalHostname] || {});
}
});
});
}

async function setStorageData(data) {
return new Promise((resolve, reject) => {
let storageData = {};
storageData[internalHostname] = data;
chrome.storage.sync.set(storageData, function () {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
} else {
resolve();
}
});
return new Promise((resolve, reject) => {
let storageData = {};
storageData[internalHostname] = data;
chrome.storage.sync.set(storageData, function () {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
} else {
resolve();
}
});
});
}

// Getter function to get specific property for the internal hostname
async function getProperty(property) {
try {
const data = await getStorageData();
return data[property];
} catch (error) {
console.error("Error getting property:", error);
}
try {
const data = await getStorageData();
return data[property];
} catch (error) {
console.error("Error getting property:", error);
}
}

// Setter function to set specific property for the internal hostname
async function setProperty(property, value) {
try {
const data = await getStorageData();
data[property] = value;
await setStorageData(data);
} catch (error) {
console.error("Error setting property:", error);
}
try {
const data = await getStorageData();
data[property] = value;
await setStorageData(data);
} catch (error) {
console.error("Error setting property:", error);
}
}
function tagCreate(value = 0) {
const metaTag = document.createElement("meta");
metaTag.name = "SapDarkCPITheme";
metaTag.content = value;
document.head.appendChild(metaTag);
const metaTag = document.createElement("meta");
metaTag.name = "SapDarkCPITheme";
metaTag.content = value;
document.head.appendChild(metaTag);
}

function insertElementWithId(id, classname = "") {
const newElement = document.createElement("div");
newElement.id = id;
newElement.className = classname;
newElement.innerHTML = `<dialog id="updates" class="modal">
const newElement = document.createElement("div");
newElement.id = id;
newElement.className = classname;
newElement.innerHTML = `<dialog id="updates" class="modal">
<div class="modal-box">
<form method="dialog"><button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button></form>
<h2 class="text-2xl font-semibold text-primary mb-4">What's New in Dark CPI v:${chrome.runtime.getManifest().version.toString()}</h2>
<h2 class="text-2xl font-semibold text-primary mb-4">What's New in Dark CPI v:${chrome.runtime
.getManifest()
.version.toString()}</h2>
<div id="dynamicContent" class="mb-4"></div>
<div role="alert" class="alert">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-info shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<span>Press <kbd class="kbd kbd-sm">Esc</kbd> or Close <kbd class="kbd kbd-sm">X</kbd> Icon to Close this popup.</span>
</div>
</div>
</dialog>`;
document.body.appendChild(newElement);
document.body.appendChild(newElement);
}

setInterval(async () => {
let metaTag = document.querySelector('meta[name="SapDarkCPITheme"]');
let global = document.querySelector("#darkcpiglobal");
let metaTag = document.querySelector('meta[name="SapDarkCPITheme"]');
let global = document.querySelector("#darkcpiglobal");

if (!metaTag) {
console.log("Meta tag not found. Getting sync value...");
getProperty("SapDarkCPITheme").then((value) => tagCreate(value));
}
if (!metaTag) {
console.log("Meta tag not found. Getting sync value...");
getProperty("SapDarkCPITheme").then((value) => tagCreate(value));
}

if (!global) {
console.log("Global element not found. Inserting element...");
insertElementWithId("darkcpiglobal", "darkcpiglobal");
document
.querySelector("#darkcpiglobal")
.setAttribute("data-theme", (await getProperty("SapDarkCPITheme")) === "1" ? "dark" : "light");
}
}, 3000);
if (!global) {
console.log("Global element not found. Inserting element...");
insertElementWithId("darkcpiglobal", "darkcpiglobal");
document
.querySelector("#darkcpiglobal")
.setAttribute(
"data-theme",
(await getProperty("SapDarkCPITheme")) === "1" ? "dark" : "light"
);
}
}, 4000);

chrome.storage.onChanged.addListener(function (changes, namespace) {
for (let key in changes) {
if (key === internalHostname) {
const storageChange = changes[key].newValue.SapDarkCPITheme;
console.log("Value of SapDarkCPITheme has changed:", storageChange);
let metaTag = document.querySelector('meta[name="SapDarkCPITheme"]');
document
.querySelector("#darkcpiglobal")
.setAttribute("data-theme", (storageChange === "1" ? "dark" : "light"));
try {
if (!metaTag) {
console.log("Meta tag not found. Creating meta tag...");
tagCreate(storageChange);
} else {
console.log("Updating meta tag content...");
metaTag.content = storageChange;
}
} catch (error) {
console.error("Error updating meta tag:", error);
}
for (let key in changes) {
if (key === internalHostname) {
const storageChange = changes[key].newValue.SapDarkCPITheme;
console.log("Value of SapDarkCPITheme has changed:", storageChange);
let metaTag = document.querySelector('meta[name="SapDarkCPITheme"]');
document
.querySelector("#darkcpiglobal")
.setAttribute("data-theme", storageChange === "1" ? "dark" : "light");
try {
if (!metaTag) {
console.log("Meta tag not found. Creating meta tag...");
tagCreate(storageChange);
} else {
console.log("Updating meta tag content...");
metaTag.content = storageChange;
}
} catch (error) {
console.error("Error updating meta tag:", error);
}
}
});
}
});
Loading

0 comments on commit 556ba85

Please sign in to comment.