2021-03-15 03:53:16 +00:00
|
|
|
/* eslint-disable no-console */
|
2021-01-20 06:42:45 +00:00
|
|
|
import "../../less/hostedexplorer.less";
|
2021-03-15 03:53:16 +00:00
|
|
|
import { DataExplorerInputsFrame } from "../../src/Contracts/ViewModels";
|
|
|
|
import { updateUserContext } from "../../src/UserContext";
|
2021-05-21 02:34:29 +01:00
|
|
|
import { get, listKeys } from "../../src/Utils/arm/generatedClients/cosmos/databaseAccounts";
|
2020-11-19 17:29:38 +00:00
|
|
|
|
2021-03-15 03:53:16 +00:00
|
|
|
const urlSearchParams = new URLSearchParams(window.location.search);
|
2024-05-29 17:56:27 +01:00
|
|
|
const resourceGroup = urlSearchParams.get("resourceGroup") || process.env.RESOURCE_GROUP || "";
|
|
|
|
const subscriptionId = urlSearchParams.get("subscriptionId") || process.env.SUBSCRIPTION_ID || "";
|
2022-05-05 02:24:34 +01:00
|
|
|
const accountName = urlSearchParams.get("accountName") || "portal-sql-runner-west-us";
|
2021-03-15 03:53:16 +00:00
|
|
|
const selfServeType = urlSearchParams.get("selfServeType") || "example";
|
|
|
|
const iframeSrc = urlSearchParams.get("iframeSrc") || "explorer.html?platform=Portal&disablePortalInitCache";
|
2024-04-09 18:55:08 +01:00
|
|
|
const token = urlSearchParams.get("token");
|
2021-02-08 17:42:16 +00:00
|
|
|
|
2021-03-15 03:53:16 +00:00
|
|
|
console.log("Resource Group:", resourceGroup);
|
|
|
|
console.log("Subcription: ", subscriptionId);
|
|
|
|
console.log("Account Name: ", accountName);
|
2020-11-19 17:29:38 +00:00
|
|
|
|
|
|
|
const initTestExplorer = async (): Promise<void> => {
|
2021-03-15 03:53:16 +00:00
|
|
|
updateUserContext({
|
|
|
|
authorizationToken: `bearer ${token}`,
|
|
|
|
});
|
|
|
|
const databaseAccount = await get(subscriptionId, resourceGroup, accountName);
|
|
|
|
const keys = await listKeys(subscriptionId, resourceGroup, accountName);
|
2020-11-19 17:29:38 +00:00
|
|
|
|
2024-06-05 20:46:32 +01:00
|
|
|
// Disable the quickstart carousel.
|
|
|
|
if (databaseAccount?.id) {
|
|
|
|
localStorage.setItem(databaseAccount.id, "true");
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:29:38 +00:00
|
|
|
const initTestExplorerContent = {
|
|
|
|
inputs: {
|
|
|
|
databaseAccount: databaseAccount,
|
2021-03-15 03:53:16 +00:00
|
|
|
subscriptionId,
|
|
|
|
resourceGroup,
|
2020-11-19 17:29:38 +00:00
|
|
|
authorizationToken: `Bearer ${token}`,
|
2021-02-17 20:52:47 +00:00
|
|
|
features: {},
|
2020-11-19 17:29:38 +00:00
|
|
|
hasWriteAccess: true,
|
|
|
|
csmEndpoint: "https://management.azure.com",
|
|
|
|
dnsSuffix: "documents.azure.com",
|
|
|
|
serverId: "prod1",
|
|
|
|
extensionEndpoint: "/proxy",
|
2024-04-11 23:43:46 +01:00
|
|
|
portalBackendEndpoint: "https://cdb-ms-mpac-pbe.cosmos.azure.com",
|
|
|
|
mongoProxyEndpoint: "https://cdb-ms-mpac-mp.cosmos.azure.com",
|
|
|
|
cassandraProxyEndpoint: "https://cdb-ms-mpac-cp.cosmos.azure.com",
|
2020-11-19 17:29:38 +00:00
|
|
|
subscriptionType: 3,
|
|
|
|
quotaId: "Internal_2014-09-01",
|
|
|
|
isTryCosmosDBSubscription: false,
|
2021-03-15 03:53:16 +00:00
|
|
|
masterKey: keys.primaryMasterKey,
|
2020-11-19 17:29:38 +00:00
|
|
|
loadDatabaseAccountTimestamp: 1604663109836,
|
|
|
|
dataExplorerVersion: "1.0.1",
|
|
|
|
sharedThroughputMinimum: 400,
|
|
|
|
sharedThroughputMaximum: 1000000,
|
|
|
|
sharedThroughputDefault: 400,
|
|
|
|
defaultCollectionThroughput: {
|
|
|
|
storage: "100",
|
2021-01-20 15:15:01 +00:00
|
|
|
throughput: { fixed: 400, unlimited: 400, unlimitedmax: 100000, unlimitedmin: 400, shared: 400 },
|
2020-11-19 17:29:38 +00:00
|
|
|
},
|
|
|
|
// add UI test only when feature is not dependent on flights anymore
|
2021-01-20 06:42:45 +00:00
|
|
|
flights: [],
|
2021-01-25 19:56:15 +00:00
|
|
|
selfServeType,
|
2021-03-15 03:53:16 +00:00
|
|
|
} as DataExplorerInputsFrame,
|
2020-11-19 17:29:38 +00:00
|
|
|
};
|
|
|
|
|
2021-01-25 19:56:15 +00:00
|
|
|
const iframe = document.createElement("iframe");
|
|
|
|
window.addEventListener(
|
|
|
|
"message",
|
|
|
|
(event) => {
|
|
|
|
// After we have received the "ready" message from the child iframe we can post configuration
|
|
|
|
// This simulates the same action that happens in the portal
|
|
|
|
console.dir(event.data);
|
2021-03-19 03:41:43 +00:00
|
|
|
if (event.data?.kind === "ready") {
|
2024-06-05 20:46:32 +01:00
|
|
|
if (!iframe.contentWindow || !iframe.contentDocument) {
|
|
|
|
throw new Error("iframe is not loaded");
|
|
|
|
}
|
|
|
|
|
2021-01-25 19:56:15 +00:00
|
|
|
iframe.contentWindow.postMessage(
|
|
|
|
{
|
|
|
|
signature: "pcIframe",
|
|
|
|
data: initTestExplorerContent,
|
|
|
|
},
|
2023-10-03 16:13:24 +01:00
|
|
|
iframe.contentDocument.referrer || window.location.href,
|
2021-01-25 19:56:15 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2023-10-03 16:13:24 +01:00
|
|
|
false,
|
2021-01-25 19:56:15 +00:00
|
|
|
);
|
|
|
|
iframe.id = "explorerMenu";
|
|
|
|
iframe.name = "explorer";
|
2024-06-05 20:46:32 +01:00
|
|
|
iframe.setAttribute("data-test", "DataExplorerFrame");
|
2021-01-25 19:56:15 +00:00
|
|
|
iframe.classList.add("iframe");
|
|
|
|
iframe.title = "explorer";
|
2021-03-15 03:53:16 +00:00
|
|
|
iframe.src = iframeSrc;
|
2021-01-25 19:56:15 +00:00
|
|
|
document.body.appendChild(iframe);
|
2020-11-19 17:29:38 +00:00
|
|
|
};
|
|
|
|
|
2021-01-25 19:56:15 +00:00
|
|
|
initTestExplorer();
|