dash-button-web 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dash-button.cjs.entry.js +18 -4
- package/dist/cjs/dash-button.cjs.entry.js.map +1 -1
- package/dist/collection/services/menu.js +18 -4
- package/dist/collection/services/menu.js.map +1 -1
- package/dist/components/dash-button.js +18 -4
- package/dist/components/dash-button.js.map +1 -1
- package/dist/esm/dash-button.entry.js +18 -4
- package/dist/esm/dash-button.entry.js.map +1 -1
- package/dist/web-compnont/p-ad318f06.entry.js +10 -0
- package/dist/web-compnont/{p-fc02a292.entry.js.map → p-ad318f06.entry.js.map} +1 -1
- package/dist/web-compnont/web-compnont.esm.js +1 -1
- package/package.json +1 -1
- package/readme.md +22 -19
- package/dist/web-compnont/p-fc02a292.entry.js +0 -10
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
// const getRootDomain = (hostOrUrl: string): string => {
|
|
2
|
+
// // Ensure we can parse it with URL
|
|
3
|
+
// const url = hostOrUrl.startsWith("http") ? new URL(hostOrUrl) : new URL(`https://${hostOrUrl}`);
|
|
4
|
+
// const hostname = url.hostname;
|
|
5
|
+
// const port = url.port ? `:${url.port}` : "";
|
|
6
|
+
// const parts = hostname.split(".");
|
|
7
|
+
// // localhost → return with port
|
|
8
|
+
// if (hostname === "localhost") return hostname + port;
|
|
9
|
+
// // sslip.io → keep last 3 parts
|
|
10
|
+
// if (hostname.endsWith(".sslip.io")) return parts.slice(-5).join(".") + port;
|
|
11
|
+
// // Normal domains → remove first label
|
|
12
|
+
// return parts.slice(1).join(".") + port;
|
|
13
|
+
// };
|
|
1
14
|
const getRootDomain = (hostOrUrl) => {
|
|
2
|
-
|
|
3
|
-
|
|
15
|
+
const url = hostOrUrl.startsWith("http")
|
|
16
|
+
? new URL(hostOrUrl)
|
|
17
|
+
: new URL(`https://${hostOrUrl}`);
|
|
4
18
|
const hostname = url.hostname;
|
|
5
19
|
const port = url.port ? `:${url.port}` : "";
|
|
6
20
|
const parts = hostname.split(".");
|
|
@@ -10,8 +24,8 @@ const getRootDomain = (hostOrUrl) => {
|
|
|
10
24
|
// sslip.io → keep last 3 parts
|
|
11
25
|
if (hostname.endsWith(".sslip.io"))
|
|
12
26
|
return parts.slice(-5).join(".") + port;
|
|
13
|
-
//
|
|
14
|
-
return
|
|
27
|
+
// Keep full hostname
|
|
28
|
+
return hostname + port;
|
|
15
29
|
};
|
|
16
30
|
const getUrlProtocol = (url, defaultProtocol = "https://") => {
|
|
17
31
|
if (!url)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/services/menu.ts"],"names":[],"mappings":"AAyBA,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/services/menu.ts"],"names":[],"mappings":"AAyBA,yDAAyD;AACzD,yCAAyC;AACzC,uGAAuG;AACvG,qCAAqC;AACrC,mDAAmD;AACnD,yCAAyC;AAEzC,sCAAsC;AACtC,4DAA4D;AAE5D,sCAAsC;AACtC,mFAAmF;AAEnF,6CAA6C;AAC7C,8CAA8C;AAC9C,KAAK;AAEL,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAU,EAAE;IAClD,MAAM,GAAG,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC;QACtC,CAAC,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC;QACpB,CAAC,CAAC,IAAI,GAAG,CAAC,WAAW,SAAS,EAAE,CAAC,CAAC;IAEpC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAA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I,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,GAAG,CAAC;QACb,CAAC;QAED,6BAA6B;QAC7B,OAAO,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAQ;QACzB,MAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAC5D,6CAA6C;QAC7C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAE1C,8CAA8C;QAC9C,MAAM,CAAC,QAAQ,GAAG,2BAA2B,MAAM,CAAC,QAAQ,EAAE,CAAC;QAE/D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,6BAA6B,CAAC,CAAC;QAEzF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;;YAChB,MAAM,iBAAiB,GAAG,MAAA,CAAC,CAAC,QAAQ,0CAAE,iBAAiB,CAAC;YAExD,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;YAC3C,MAAM,YAAY,GAAG,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG,iBAAiB,IAAI,UAAU,EAAE,CAAC;YAErF,OAAO;gBACL,IAAI,EAAE,CAAC,CAAC,gBAAgB;gBACxB,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;gBAC1C,QAAQ,EAAE,MAAA,MAAA,CAAC,CAAC,QAAQ,0CAAE,QAAQ,mCAAI,EAAE;aACrC,CAAC;QACN,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC","sourcesContent":["export interface InstalledChartMetadata {\n category?: string;\n frontendUrlPrefix?: string;\n}\n\nexport interface InstalledChart {\n id: number;\n installChartName: string;\n metadata: InstalledChartMetadata;\n}\n\nexport interface PaginatedInstalledChartsResponse {\n data: InstalledChart[];\n total: number;\n page: number;\n perPage: number;\n totalPages: number;\n}\n\nexport interface MenuLink {\n name: string;\n url: string;\n category?: string;\n}\n\n// const getRootDomain = (hostOrUrl: string): string => {\n// // Ensure we can parse it with URL\n// const url = hostOrUrl.startsWith(\"http\") ? new URL(hostOrUrl) : new URL(`https://${hostOrUrl}`);\n// const hostname = url.hostname;\n// const port = url.port ? `:${url.port}` : \"\";\n// const parts = hostname.split(\".\");\n\n// // localhost → return with port\n// if (hostname === \"localhost\") return hostname + port;\n\n// // sslip.io → keep last 3 parts\n// if (hostname.endsWith(\".sslip.io\")) return parts.slice(-5).join(\".\") + port;\n\n// // Normal domains → remove first label\n// return parts.slice(1).join(\".\") + port;\n// };\n\nconst getRootDomain = (hostOrUrl: string): string => {\n const url = hostOrUrl.startsWith(\"http\")\n ? new URL(hostOrUrl)\n : new URL(`https://${hostOrUrl}`);\n\n const hostname = url.hostname;\n const port = url.port ? `:${url.port}` : \"\";\n const parts = hostname.split(\".\");\n\n // localhost → return with port\n if (hostname === \"localhost\") return hostname + port;\n\n // sslip.io → keep last 3 parts\n if (hostname.endsWith(\".sslip.io\")) return parts.slice(-5).join(\".\") + port;\n\n // Keep full hostname\n return hostname + port;\n};\n\n\nconst getUrlProtocol = (url: string, defaultProtocol = \"https://\"): string => {\n if (!url) return defaultProtocol;\n\n const trimmed = url.trim();\n\n // Match protocol (http:// or https://)\n const match = trimmed.match(/^(https?:\\/\\/)/i);\n return match ? match[1] : defaultProtocol;\n};\n\nclass MenuService {\n\n async getMenuConfig(url): Promise<PaginatedInstalledChartsResponse> {\n try {\n const res = await fetch(url);\n if (!res.ok) throw new Error('API error');\n return await res.json();\n } catch {\n return { data: [], total: 0, page: 1, perPage: 0, totalPages: 0 };\n }\n }\n\n private setDefaultProtocol(url: string): string {\n // If protocol already exists (http:// or https://), keep it\n if (/^https?:\\/\\//i.test(url)) {\n return url;\n }\n\n // Otherwise default to https\n return `https://${url}`;\n }\n\n async getMenuLinks(BASE_URL): Promise<MenuLink[]> {\n const normalizedBaseUrl = this.setDefaultProtocol(BASE_URL);\n // Create a URL object from normalizedBaseUrl\n const urlObj = new URL(normalizedBaseUrl);\n\n // Add the 'containerisationbackend' subdomain\n urlObj.hostname = `containerisationbackend.${urlObj.hostname}`;\n \n const { data } = await this.getMenuConfig(`${urlObj.origin}/developer/charts/installed`);\n\n return data.map(d => {\n const frontendUrlPrefix = d.metadata?.frontendUrlPrefix;\n\n const rootDomain = getRootDomain(BASE_URL);\n const generatedUrl = `${getUrlProtocol(BASE_URL)}${frontendUrlPrefix}.${rootDomain}`;\n \n return {\n name: d.installChartName,\n url: frontendUrlPrefix ? generatedUrl : \"\",\n category: d.metadata?.category ?? \"\",\n };\n });\n }\n}\n\nexport const menuService = new MenuService();"]}
|
|
@@ -3930,9 +3930,23 @@ class ConfigService {
|
|
|
3930
3930
|
}
|
|
3931
3931
|
const configService = ConfigService.getInstance();
|
|
3932
3932
|
|
|
3933
|
+
// const getRootDomain = (hostOrUrl: string): string => {
|
|
3934
|
+
// // Ensure we can parse it with URL
|
|
3935
|
+
// const url = hostOrUrl.startsWith("http") ? new URL(hostOrUrl) : new URL(`https://${hostOrUrl}`);
|
|
3936
|
+
// const hostname = url.hostname;
|
|
3937
|
+
// const port = url.port ? `:${url.port}` : "";
|
|
3938
|
+
// const parts = hostname.split(".");
|
|
3939
|
+
// // localhost → return with port
|
|
3940
|
+
// if (hostname === "localhost") return hostname + port;
|
|
3941
|
+
// // sslip.io → keep last 3 parts
|
|
3942
|
+
// if (hostname.endsWith(".sslip.io")) return parts.slice(-5).join(".") + port;
|
|
3943
|
+
// // Normal domains → remove first label
|
|
3944
|
+
// return parts.slice(1).join(".") + port;
|
|
3945
|
+
// };
|
|
3933
3946
|
const getRootDomain = (hostOrUrl) => {
|
|
3934
|
-
|
|
3935
|
-
|
|
3947
|
+
const url = hostOrUrl.startsWith("http")
|
|
3948
|
+
? new URL(hostOrUrl)
|
|
3949
|
+
: new URL(`https://${hostOrUrl}`);
|
|
3936
3950
|
const hostname = url.hostname;
|
|
3937
3951
|
const port = url.port ? `:${url.port}` : "";
|
|
3938
3952
|
const parts = hostname.split(".");
|
|
@@ -3942,8 +3956,8 @@ const getRootDomain = (hostOrUrl) => {
|
|
|
3942
3956
|
// sslip.io → keep last 3 parts
|
|
3943
3957
|
if (hostname.endsWith(".sslip.io"))
|
|
3944
3958
|
return parts.slice(-5).join(".") + port;
|
|
3945
|
-
//
|
|
3946
|
-
return
|
|
3959
|
+
// Keep full hostname
|
|
3960
|
+
return hostname + port;
|
|
3947
3961
|
};
|
|
3948
3962
|
const getUrlProtocol = (url, defaultProtocol = "https://") => {
|
|
3949
3963
|
if (!url)
|