mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-06 03:00:23 +00:00
Compare commits
6 Commits
hosted-msa
...
users/lang
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
572d573fdd | ||
|
|
37c64c4a4d | ||
|
|
fc5ffeb7ca | ||
|
|
f39b6accb1 | ||
|
|
64601693b7 | ||
|
|
0c80c45e22 |
@@ -3,11 +3,7 @@ PORTAL_RUNNER_PASSWORD=
|
|||||||
PORTAL_RUNNER_SUBSCRIPTION=
|
PORTAL_RUNNER_SUBSCRIPTION=
|
||||||
PORTAL_RUNNER_RESOURCE_GROUP=
|
PORTAL_RUNNER_RESOURCE_GROUP=
|
||||||
PORTAL_RUNNER_DATABASE_ACCOUNT=
|
PORTAL_RUNNER_DATABASE_ACCOUNT=
|
||||||
PORTAL_RUNNER_DATABASE_ACCOUNT_KEY=
|
|
||||||
PORTAL_RUNNER_CONNECTION_STRING=
|
PORTAL_RUNNER_CONNECTION_STRING=
|
||||||
NOTEBOOKS_TEST_RUNNER_TENANT_ID=
|
|
||||||
NOTEBOOKS_TEST_RUNNER_CLIENT_ID=
|
|
||||||
NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET=
|
|
||||||
CASSANDRA_CONNECTION_STRING=
|
CASSANDRA_CONNECTION_STRING=
|
||||||
MONGO_CONNECTION_STRING=
|
MONGO_CONNECTION_STRING=
|
||||||
TABLES_CONNECTION_STRING=
|
TABLES_CONNECTION_STRING=
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ src/Common/DataAccessUtilityBase.ts
|
|||||||
src/Common/DeleteFeedback.ts
|
src/Common/DeleteFeedback.ts
|
||||||
src/Common/DocumentClientUtilityBase.ts
|
src/Common/DocumentClientUtilityBase.ts
|
||||||
src/Common/EditableUtility.ts
|
src/Common/EditableUtility.ts
|
||||||
|
src/Common/EnvironmentUtility.ts
|
||||||
src/Common/HashMap.test.ts
|
src/Common/HashMap.test.ts
|
||||||
src/Common/HashMap.ts
|
src/Common/HashMap.ts
|
||||||
src/Common/HeadersUtility.test.ts
|
src/Common/HeadersUtility.test.ts
|
||||||
@@ -42,6 +43,7 @@ src/Contracts/ViewModels.ts
|
|||||||
src/Controls/Heatmap/Heatmap.test.ts
|
src/Controls/Heatmap/Heatmap.test.ts
|
||||||
src/Controls/Heatmap/Heatmap.ts
|
src/Controls/Heatmap/Heatmap.ts
|
||||||
src/Controls/Heatmap/HeatmapDatatypes.ts
|
src/Controls/Heatmap/HeatmapDatatypes.ts
|
||||||
|
src/Definitions/adal.d.ts
|
||||||
src/Definitions/datatables.d.ts
|
src/Definitions/datatables.d.ts
|
||||||
src/Definitions/gif.d.ts
|
src/Definitions/gif.d.ts
|
||||||
src/Definitions/globals.d.ts
|
src/Definitions/globals.d.ts
|
||||||
@@ -200,6 +202,8 @@ src/Explorer/Tabs/QueryTab.test.ts
|
|||||||
src/Explorer/Tabs/QueryTab.ts
|
src/Explorer/Tabs/QueryTab.ts
|
||||||
src/Explorer/Tabs/QueryTablesTab.ts
|
src/Explorer/Tabs/QueryTablesTab.ts
|
||||||
src/Explorer/Tabs/ScriptTabBase.ts
|
src/Explorer/Tabs/ScriptTabBase.ts
|
||||||
|
src/Explorer/Tabs/SettingsTab.test.ts
|
||||||
|
src/Explorer/Tabs/SettingsTab.ts
|
||||||
src/Explorer/Tabs/SparkMasterTab.ts
|
src/Explorer/Tabs/SparkMasterTab.ts
|
||||||
src/Explorer/Tabs/StoredProcedureTab.ts
|
src/Explorer/Tabs/StoredProcedureTab.ts
|
||||||
src/Explorer/Tabs/TabComponents.ts
|
src/Explorer/Tabs/TabComponents.ts
|
||||||
@@ -241,6 +245,9 @@ src/Platform/Hosted/Authorization.ts
|
|||||||
src/Platform/Hosted/DataAccessUtility.ts
|
src/Platform/Hosted/DataAccessUtility.ts
|
||||||
src/Platform/Hosted/ExplorerFactory.ts
|
src/Platform/Hosted/ExplorerFactory.ts
|
||||||
src/Platform/Hosted/Helpers/ConnectionStringParser.test.ts
|
src/Platform/Hosted/Helpers/ConnectionStringParser.test.ts
|
||||||
|
src/Platform/Hosted/Helpers/ConnectionStringParser.ts
|
||||||
|
src/Platform/Hosted/HostedUtils.test.ts
|
||||||
|
src/Platform/Hosted/HostedUtils.ts
|
||||||
src/Platform/Hosted/Main.ts
|
src/Platform/Hosted/Main.ts
|
||||||
src/Platform/Hosted/Maint.test.ts
|
src/Platform/Hosted/Maint.test.ts
|
||||||
src/Platform/Hosted/NotificationsClient.ts
|
src/Platform/Hosted/NotificationsClient.ts
|
||||||
@@ -283,6 +290,8 @@ src/Utils/DatabaseAccountUtils.ts
|
|||||||
src/Utils/JunoUtils.ts
|
src/Utils/JunoUtils.ts
|
||||||
src/Utils/MessageValidation.ts
|
src/Utils/MessageValidation.ts
|
||||||
src/Utils/NotebookConfigurationUtils.ts
|
src/Utils/NotebookConfigurationUtils.ts
|
||||||
|
src/Utils/OfferUtils.test.ts
|
||||||
|
src/Utils/OfferUtils.ts
|
||||||
src/Utils/PricingUtils.test.ts
|
src/Utils/PricingUtils.test.ts
|
||||||
src/Utils/QueryUtils.test.ts
|
src/Utils/QueryUtils.test.ts
|
||||||
src/Utils/QueryUtils.ts
|
src/Utils/QueryUtils.ts
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ module.exports = {
|
|||||||
"@typescript-eslint/no-explicit-any": "error",
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
"prefer-arrow/prefer-arrow-functions": ["error", { allowStandaloneDeclarations: true }],
|
"prefer-arrow/prefer-arrow-functions": ["error", { allowStandaloneDeclarations: true }],
|
||||||
eqeqeq: "error",
|
eqeqeq: "error",
|
||||||
"react/display-name": "off",
|
|
||||||
"no-restricted-syntax": [
|
"no-restricted-syntax": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
|
|||||||
38
.github/workflows/ci.yml
vendored
38
.github/workflows/ci.yml
vendored
@@ -101,7 +101,6 @@ jobs:
|
|||||||
PLATFORM: "Emulator"
|
PLATFORM: "Emulator"
|
||||||
NODE_TLS_REJECT_UNAUTHORIZED: 0
|
NODE_TLS_REJECT_UNAUTHORIZED: 0
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
if: failure()
|
|
||||||
with:
|
with:
|
||||||
name: screenshots
|
name: screenshots
|
||||||
path: failed-*
|
path: failed-*
|
||||||
@@ -147,27 +146,19 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
NODE_TLS_REJECT_UNAUTHORIZED: 0
|
NODE_TLS_REJECT_UNAUTHORIZED: 0
|
||||||
PORTAL_RUNNER_SUBSCRIPTION: ${{ secrets.PORTAL_RUNNER_SUBSCRIPTION }}
|
|
||||||
PORTAL_RUNNER_RESOURCE_GROUP: ${{ secrets.PORTAL_RUNNER_RESOURCE_GROUP }}
|
|
||||||
PORTAL_RUNNER_DATABASE_ACCOUNT: ${{ secrets.PORTAL_RUNNER_DATABASE_ACCOUNT }}
|
|
||||||
PORTAL_RUNNER_DATABASE_ACCOUNT_KEY: ${{ secrets.PORTAL_RUNNER_DATABASE_ACCOUNT_KEY }}
|
|
||||||
NOTEBOOKS_TEST_RUNNER_TENANT_ID: ${{ secrets.NOTEBOOKS_TEST_RUNNER_TENANT_ID }}
|
|
||||||
NOTEBOOKS_TEST_RUNNER_CLIENT_ID: ${{ secrets.NOTEBOOKS_TEST_RUNNER_CLIENT_ID }}
|
|
||||||
NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET: ${{ secrets.NOTEBOOKS_TEST_RUNNER_CLIENT_SECRET }}
|
|
||||||
PORTAL_RUNNER_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_SQL }}
|
PORTAL_RUNNER_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_SQL }}
|
||||||
MONGO_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_MONGO }}
|
MONGO_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_MONGO }}
|
||||||
CASSANDRA_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_CASSANDRA }}
|
CASSANDRA_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_CASSANDRA }}
|
||||||
TABLES_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_TABLE }}
|
TABLES_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_TABLE }}
|
||||||
DATA_EXPLORER_ENDPOINT: "https://localhost:1234/hostedExplorer.html"
|
DATA_EXPLORER_ENDPOINT: "https://localhost:1234/hostedExplorer.html"
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
if: failure()
|
|
||||||
with:
|
with:
|
||||||
name: screenshots
|
name: screenshots
|
||||||
path: failed-*
|
path: failed-*
|
||||||
nuget:
|
nuget:
|
||||||
name: Publish Nuget
|
name: Publish Nuget
|
||||||
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
||||||
needs: [lint, format, compile, build, unittest, endtoendemulator, endtoendhosted, accessibility]
|
needs: [lint, format, compile, build, unittest, endtoendemulator, endtoendhosted]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
NUGET_SOURCE: ${{ secrets.NUGET_SOURCE }}
|
NUGET_SOURCE: ${{ secrets.NUGET_SOURCE }}
|
||||||
@@ -191,7 +182,7 @@ jobs:
|
|||||||
nugetmpac:
|
nugetmpac:
|
||||||
name: Publish Nuget MPAC
|
name: Publish Nuget MPAC
|
||||||
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
||||||
needs: [lint, format, compile, build, unittest, endtoendemulator, endtoendhosted, accessibility]
|
needs: [lint, format, compile, build, unittest, endtoendemulator, endtoendhosted]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
NUGET_SOURCE: ${{ secrets.NUGET_SOURCE }}
|
NUGET_SOURCE: ${{ secrets.NUGET_SOURCE }}
|
||||||
@@ -213,28 +204,3 @@ jobs:
|
|||||||
name: packages
|
name: packages
|
||||||
with:
|
with:
|
||||||
path: "*.nupkg"
|
path: "*.nupkg"
|
||||||
nugetie:
|
|
||||||
name: Publish Nuget IE
|
|
||||||
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
|
||||||
needs: [lint, format, compile, build, unittest, endtoendemulator, endtoendhosted, accessibility]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
NUGET_SOURCE: ${{ secrets.NUGET_SOURCE }}
|
|
||||||
AZURE_DEVOPS_PAT: ${{ secrets.AZURE_DEVOPS_PAT }}
|
|
||||||
steps:
|
|
||||||
- uses: nuget/setup-nuget@v1
|
|
||||||
with:
|
|
||||||
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
|
|
||||||
- name: Download Dist Folder
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: dist
|
|
||||||
- run: cp ./configs/prod.json config.json
|
|
||||||
- run: sed -i 's/Azure.Cosmos.DB.Data.Explorer/Azure.Cosmos.DB.Data.Explorer.IE/g' DataExplorer.nuspec
|
|
||||||
- run: nuget sources add -Name "ADO" -Source "$NUGET_SOURCE" -UserName "GitHub" -Password "$AZURE_DEVOPS_PAT"
|
|
||||||
- run: nuget pack -Version "2.0.0-github-${GITHUB_SHA}"
|
|
||||||
- run: nuget push -Source "$NUGET_SOURCE" -ApiKey Az *.nupkg
|
|
||||||
- uses: actions/upload-artifact@v2
|
|
||||||
name: packages
|
|
||||||
with:
|
|
||||||
path: "*.nupkg"
|
|
||||||
|
|||||||
25
.github/workflows/runners.yml
vendored
Normal file
25
.github/workflows/runners.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: Runners
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 * 1 * *"
|
||||||
|
jobs:
|
||||||
|
sqlcreatecollection:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: "SQL | Create Collection"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run test:e2e
|
||||||
|
env:
|
||||||
|
PORTAL_RUNNER_APP_INSIGHTS_KEY: ${{ secrets.PORTAL_RUNNER_APP_INSIGHTS_KEY }}
|
||||||
|
PORTAL_RUNNER_USERNAME: ${{ secrets.PORTAL_RUNNER_USERNAME }}
|
||||||
|
PORTAL_RUNNER_PASSWORD: ${{ secrets.PORTAL_RUNNER_PASSWORD }}
|
||||||
|
PORTAL_RUNNER_SUBSCRIPTION: 69e02f2d-f059-4409-9eac-97e8a276ae2c
|
||||||
|
PORTAL_RUNNER_RESOURCE_GROUP: runners
|
||||||
|
PORTAL_RUNNER_DATABASE_ACCOUNT: portal-sql-runner
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
if: failure()
|
||||||
|
with:
|
||||||
|
name: screenshots
|
||||||
|
path: failure.png
|
||||||
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
37
README.md
37
README.md
@@ -13,18 +13,29 @@ UI for Azure Cosmos DB. Powers the [Azure Portal](https://portal.azure.com/), ht
|
|||||||
|
|
||||||
### Watch mode
|
### Watch mode
|
||||||
|
|
||||||
Run `npm start` to start the development server and automatically rebuild on changes
|
Run `npm run watch` to start the development server and automatically rebuild on changes
|
||||||
|
|
||||||
### Hosted Development (https://cosmos.azure.com)
|
### Specifying Development Platform
|
||||||
|
|
||||||
- Visit: `https://localhost:1234/hostedExplorer.html`
|
Setting the environment variable `PLATFORM` during the build process will force the explorer to load the specified platform. By default in development it will run in `Hosted` mode. Valid options:
|
||||||
- Local sign in via AAD will NOT work. Connection string only in dev mode. Use the Portal if you need AAD auth.
|
|
||||||
- The default webpack dev server configuration will proxy requests to the production portal backend: `https://main.documentdb.ext.azure.com`. This will allow you to use production connection strings on your local machine.
|
- Hosted
|
||||||
|
- Emulator
|
||||||
|
- Portal
|
||||||
|
|
||||||
|
`PLATFORM=Emulator npm run watch`
|
||||||
|
|
||||||
|
### Hosted Development
|
||||||
|
|
||||||
|
The default webpack dev server configuration will proxy requests to the production portal backend: `https://main.documentdb.ext.azure.com`. This will allow you to use production connection strings on your local machine.
|
||||||
|
|
||||||
|
To run pure hosted mode, in `webpack.config.js` change index HtmlWebpackPlugin to use hostedExplorer.html and change entry for index to use HostedExplorer.ts.
|
||||||
|
|
||||||
### Emulator Development
|
### Emulator Development
|
||||||
|
|
||||||
- Start the Cosmos Emulator
|
In a window environment, running `npm run build` will automatically copy the built files from `/dist` over to the default emulator install paths. In a non-windows environment you can specify an alternate endpoint using `EMULATOR_ENDPOINT` and webpack dev server will proxy requests for you.
|
||||||
- Visit: https://localhost:1234/index.html
|
|
||||||
|
`PLATFORM=Emulator EMULATOR_ENDPOINT=https://my-vm.azure.com:8081 npm run watch`
|
||||||
|
|
||||||
#### Setting up a Remote Emulator
|
#### Setting up a Remote Emulator
|
||||||
|
|
||||||
@@ -44,8 +55,16 @@ The Cosmos emulator currently only runs in Windows environments. You can still d
|
|||||||
|
|
||||||
### Portal Development
|
### Portal Development
|
||||||
|
|
||||||
- Visit: https://ms.portal.azure.com/?dataExplorerSource=https%3A%2F%2Flocalhost%3A1234%2Fexplorer.html
|
The Cosmos Portal that consumes this repo is not currently open source. If you have access to this project, `npm run build` will copy the built files over to the portal where they will be loaded by the portal development environment
|
||||||
- You may have to manually visit https://localhost:1234/explorer.html first and click through any SSL certificate warnings
|
|
||||||
|
You can however load a local running instance of data explorer in the production portal.
|
||||||
|
|
||||||
|
1. Turn off browser SSL validation for localhost: chrome://flags/#allow-insecure-localhost OR Install valid SSL certs for localhost (on IE, follow these [instructions](https://www.technipages.com/ie-bypass-problem-with-this-websites-security-certificate) to install the localhost certificate in the right place)
|
||||||
|
2. Allowlist `https://localhost:1234` domain for CORS in the Azure Cosmos DB portal
|
||||||
|
3. Start the project in portal mode: `PLATFORM=Portal npm run watch`
|
||||||
|
4. Load the portal using the following link: https://ms.portal.azure.com/?dataExplorerSource=https%3A%2F%2Flocalhost%3A1234%2Fexplorer.html
|
||||||
|
|
||||||
|
Live reload will occur, but data explorer will not properly integrate again with the parent iframe. You will have to manually reload the page.
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
# Why?
|
|
||||||
|
|
||||||
This adds a mock module for `canvas`. Nteract has a ignored require and undeclared dependency on this module. `cavnas` is a server side node module and is not used in browser side code for nteract.
|
|
||||||
|
|
||||||
Installing it locally (`npm install canvas`) will resolve the problem, but it is a native module so it is flaky depending on the system, node version, processor arch, etc. This module provides a simpler, more robust solution.
|
|
||||||
|
|
||||||
Remove this workaround if [this bug](https://github.com/nteract/any-vega/issues/2) ever gets resolved
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports = {}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "canvas",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC"
|
|
||||||
}
|
|
||||||
1963
externals/adal.js
vendored
Normal file
1963
externals/adal.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3768
less/documentDB.less
3768
less/documentDB.less
File diff suppressed because it is too large
Load Diff
3922
package-lock.json
generated
3922
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@@ -4,12 +4,8 @@
|
|||||||
"description": "Cosmos Explorer",
|
"description": "Cosmos Explorer",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@azure/arm-cosmosdb": "9.1.0",
|
|
||||||
"@azure/cosmos": "3.9.0",
|
"@azure/cosmos": "3.9.0",
|
||||||
"@azure/cosmos-language-service": "0.0.5",
|
"@azure/cosmos-language-service": "0.0.4",
|
||||||
"@azure/identity": "1.1.0",
|
|
||||||
"@azure/msal-browser": "2.8.0",
|
|
||||||
"@azure/msal-react": "1.0.0-alpha.1",
|
|
||||||
"@jupyterlab/services": "6.0.0-rc.2",
|
"@jupyterlab/services": "6.0.0-rc.2",
|
||||||
"@jupyterlab/terminal": "3.0.0-rc.2",
|
"@jupyterlab/terminal": "3.0.0-rc.2",
|
||||||
"@microsoft/applicationinsights-web": "2.5.9",
|
"@microsoft/applicationinsights-web": "2.5.9",
|
||||||
@@ -46,7 +42,7 @@
|
|||||||
"applicationinsights": "1.8.0",
|
"applicationinsights": "1.8.0",
|
||||||
"babel-polyfill": "6.26.0",
|
"babel-polyfill": "6.26.0",
|
||||||
"bootstrap": "3.4.1",
|
"bootstrap": "3.4.1",
|
||||||
"canvas": "file:./canvas",
|
"canvas": "2.6.1",
|
||||||
"clean-webpack-plugin": "0.1.19",
|
"clean-webpack-plugin": "0.1.19",
|
||||||
"copy-webpack-plugin": "6.0.2",
|
"copy-webpack-plugin": "6.0.2",
|
||||||
"crossroads": "0.12.2",
|
"crossroads": "0.12.2",
|
||||||
@@ -70,8 +66,7 @@
|
|||||||
"jquery-ui-dist": "1.12.1",
|
"jquery-ui-dist": "1.12.1",
|
||||||
"knockout": "3.5.1",
|
"knockout": "3.5.1",
|
||||||
"mkdirp": "1.0.4",
|
"mkdirp": "1.0.4",
|
||||||
"monaco-editor": "0.18.1",
|
"monaco-editor": "0.15.6",
|
||||||
"msal": "1.4.4",
|
|
||||||
"object.entries": "1.1.0",
|
"object.entries": "1.1.0",
|
||||||
"office-ui-fabric-react": "7.134.1",
|
"office-ui-fabric-react": "7.134.1",
|
||||||
"p-retry": "4.2.0",
|
"p-retry": "4.2.0",
|
||||||
@@ -86,7 +81,6 @@
|
|||||||
"react-dom": "16.9.0",
|
"react-dom": "16.9.0",
|
||||||
"react-hotkeys": "2.0.0",
|
"react-hotkeys": "2.0.0",
|
||||||
"react-notification-system": "0.2.17",
|
"react-notification-system": "0.2.17",
|
||||||
"react-query": "3.5.5",
|
|
||||||
"react-redux": "7.1.3",
|
"react-redux": "7.1.3",
|
||||||
"redux": "4.0.4",
|
"redux": "4.0.4",
|
||||||
"rx-jupyter": "5.5.12",
|
"rx-jupyter": "5.5.12",
|
||||||
@@ -121,7 +115,7 @@
|
|||||||
"@types/prop-types": "15.5.8",
|
"@types/prop-types": "15.5.8",
|
||||||
"@types/puppeteer": "3.0.1",
|
"@types/puppeteer": "3.0.1",
|
||||||
"@types/q": "1.5.1",
|
"@types/q": "1.5.1",
|
||||||
"@types/react": "16.9.56",
|
"@types/react": "16.9.49",
|
||||||
"@types/react-dom": "16.0.7",
|
"@types/react-dom": "16.0.7",
|
||||||
"@types/react-notification-system": "0.2.39",
|
"@types/react-notification-system": "0.2.39",
|
||||||
"@types/react-redux": "7.1.7",
|
"@types/react-redux": "7.1.7",
|
||||||
@@ -132,6 +126,7 @@
|
|||||||
"@types/webfontloader": "1.6.29",
|
"@types/webfontloader": "1.6.29",
|
||||||
"@typescript-eslint/eslint-plugin": "4.0.1",
|
"@typescript-eslint/eslint-plugin": "4.0.1",
|
||||||
"@typescript-eslint/parser": "4.0.1",
|
"@typescript-eslint/parser": "4.0.1",
|
||||||
|
"adal-angular": "1.0.15",
|
||||||
"axe-puppeteer": "1.1.0",
|
"axe-puppeteer": "1.1.0",
|
||||||
"babel-jest": "24.9.0",
|
"babel-jest": "24.9.0",
|
||||||
"babel-loader": "8.1.0",
|
"babel-loader": "8.1.0",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"offerThroughput": 400,
|
"offerThroughput": 400,
|
||||||
"databaseLevelThroughput": false,
|
"databaseLevelThroughput": false,
|
||||||
"collectionId": "Persons",
|
"collectionId": "Persons",
|
||||||
|
"rupmEnabled": false,
|
||||||
"partitionKey": { "kind": "Hash", "paths": ["/name"] },
|
"partitionKey": { "kind": "Hash", "paths": ["/name"] },
|
||||||
"data": [
|
"data": [
|
||||||
"g.addV('person').property(id, '1').property('name', 'Eva').property('age', 44)",
|
"g.addV('person').property(id, '1').property('name', 'Eva').property('age', 44)",
|
||||||
@@ -12,4 +13,4 @@
|
|||||||
"g.V('1').addE('knows').to(g.V('2')).outV().addE('knows').to(g.V('3'))",
|
"g.V('1').addE('knows').to(g.V('2')).outV().addE('knows').to(g.V('3'))",
|
||||||
"g.V('3').addE('knows').to(g.V('4'))"
|
"g.V('3').addE('knows').to(g.V('4'))"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,5 @@ export enum AuthType {
|
|||||||
AAD = "aad",
|
AAD = "aad",
|
||||||
EncryptedToken = "encryptedtoken",
|
EncryptedToken = "encryptedtoken",
|
||||||
MasterKey = "masterkey",
|
MasterKey = "masterkey",
|
||||||
ResourceToken = "resourcetoken",
|
ResourceToken = "resourcetoken"
|
||||||
ConnectionString = "connectionstring"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,11 +108,13 @@ export class CapabilityNames {
|
|||||||
export class Features {
|
export class Features {
|
||||||
public static readonly cosmosdb = "cosmosdb";
|
public static readonly cosmosdb = "cosmosdb";
|
||||||
public static readonly enableChangeFeedPolicy = "enablechangefeedpolicy";
|
public static readonly enableChangeFeedPolicy = "enablechangefeedpolicy";
|
||||||
|
public static readonly enableRupm = "enablerupm";
|
||||||
public static readonly executeSproc = "dataexplorerexecutesproc";
|
public static readonly executeSproc = "dataexplorerexecutesproc";
|
||||||
public static readonly hostedDataExplorer = "hosteddataexplorerenabled";
|
public static readonly hostedDataExplorer = "hosteddataexplorerenabled";
|
||||||
public static readonly enableTtl = "enablettl";
|
public static readonly enableTtl = "enablettl";
|
||||||
public static readonly enableNotebooks = "enablenotebooks";
|
public static readonly enableNotebooks = "enablenotebooks";
|
||||||
public static readonly enableGalleryPublish = "enablegallerypublish";
|
public static readonly enableGalleryPublish = "enablegallerypublish";
|
||||||
|
public static readonly enableCodeOfConduct = "enablecodeofconduct";
|
||||||
public static readonly enableLinkInjection = "enablelinkinjection";
|
public static readonly enableLinkInjection = "enablelinkinjection";
|
||||||
public static readonly enableSpark = "enablespark";
|
public static readonly enableSpark = "enablespark";
|
||||||
public static readonly livyEndpoint = "livyendpoint";
|
public static readonly livyEndpoint = "livyendpoint";
|
||||||
@@ -179,6 +181,11 @@ export class CassandraBackend {
|
|||||||
public static readonly guestSchemaApi: string = "api/guest/cassandra/schema";
|
public static readonly guestSchemaApi: string = "api/guest/cassandra/schema";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class RUPMStates {
|
||||||
|
public static on: string = "on";
|
||||||
|
public static off: string = "off";
|
||||||
|
}
|
||||||
|
|
||||||
export class Queries {
|
export class Queries {
|
||||||
public static CustomPageOption: string = "custom";
|
public static CustomPageOption: string = "custom";
|
||||||
public static UnlimitedPageOption: string = "unlimited";
|
public static UnlimitedPageOption: string = "unlimited";
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { getCommonQueryOptions } from "./queryDocuments";
|
import { getCommonQueryOptions } from "./DataAccessUtilityBase";
|
||||||
import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "../Shared/StorageUtility";
|
||||||
|
|
||||||
describe("getCommonQueryOptions", () => {
|
describe("getCommonQueryOptions", () => {
|
||||||
it("builds the correct default options objects", () => {
|
it("builds the correct default options objects", () => {
|
||||||
expect(getCommonQueryOptions({})).toMatchSnapshot();
|
expect(getCommonQueryOptions({})).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it("reads from localStorage", () => {
|
it("reads from localStorage", () => {
|
||||||
LocalStorageUtility.setEntryNumber(StorageKey.ActualItemPerPage, 37);
|
LocalStorageUtility.setEntryNumber(StorageKey.ActualItemPerPage, 37);
|
||||||
LocalStorageUtility.setEntryNumber(StorageKey.MaxDegreeOfParellism, 17);
|
LocalStorageUtility.setEntryNumber(StorageKey.MaxDegreeOfParellism, 17);
|
||||||
expect(getCommonQueryOptions({})).toMatchSnapshot();
|
expect(getCommonQueryOptions({})).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
182
src/Common/DataAccessUtilityBase.ts
Normal file
182
src/Common/DataAccessUtilityBase.ts
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
import {
|
||||||
|
ConflictDefinition,
|
||||||
|
FeedOptions,
|
||||||
|
ItemDefinition,
|
||||||
|
OfferDefinition,
|
||||||
|
QueryIterator,
|
||||||
|
Resource
|
||||||
|
} from "@azure/cosmos";
|
||||||
|
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||||
|
import Q from "q";
|
||||||
|
import { configContext, Platform } from "../ConfigContext";
|
||||||
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
|
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
|
import ConflictId from "../Explorer/Tree/ConflictId";
|
||||||
|
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||||
|
import StoredProcedure from "../Explorer/Tree/StoredProcedure";
|
||||||
|
import { LocalStorageUtility, StorageKey } from "../Shared/StorageUtility";
|
||||||
|
import { OfferUtils } from "../Utils/OfferUtils";
|
||||||
|
import * as Constants from "./Constants";
|
||||||
|
import { client } from "./CosmosClient";
|
||||||
|
import * as HeadersUtility from "./HeadersUtility";
|
||||||
|
import { sendCachedDataMessage } from "./MessageHandler";
|
||||||
|
|
||||||
|
export function getCommonQueryOptions(options: FeedOptions): any {
|
||||||
|
const storedItemPerPageSetting: number = LocalStorageUtility.getEntryNumber(StorageKey.ActualItemPerPage);
|
||||||
|
options = options || {};
|
||||||
|
options.populateQueryMetrics = true;
|
||||||
|
options.enableScanInQuery = options.enableScanInQuery || true;
|
||||||
|
if (!options.partitionKey) {
|
||||||
|
options.forceQueryPlan = true;
|
||||||
|
}
|
||||||
|
options.maxItemCount =
|
||||||
|
options.maxItemCount ||
|
||||||
|
(storedItemPerPageSetting !== undefined && storedItemPerPageSetting) ||
|
||||||
|
Constants.Queries.itemsPerPage;
|
||||||
|
options.maxDegreeOfParallelism = LocalStorageUtility.getEntryNumber(StorageKey.MaxDegreeOfParellism);
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function queryDocuments(
|
||||||
|
databaseId: string,
|
||||||
|
containerId: string,
|
||||||
|
query: string,
|
||||||
|
options: any
|
||||||
|
): Q.Promise<QueryIterator<ItemDefinition & Resource>> {
|
||||||
|
options = getCommonQueryOptions(options);
|
||||||
|
const documentsIterator = client()
|
||||||
|
.database(databaseId)
|
||||||
|
.container(containerId)
|
||||||
|
.items.query(query, options);
|
||||||
|
return Q(documentsIterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPartitionKeyHeaderForConflict(conflictId: ConflictId): Object {
|
||||||
|
const partitionKeyDefinition: DataModels.PartitionKey = conflictId.partitionKey;
|
||||||
|
const partitionKeyValue: any = conflictId.partitionKeyValue;
|
||||||
|
|
||||||
|
return getPartitionKeyHeader(partitionKeyDefinition, partitionKeyValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPartitionKeyHeader(partitionKeyDefinition: DataModels.PartitionKey, partitionKeyValue: any): Object {
|
||||||
|
if (!partitionKeyDefinition) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partitionKeyValue === undefined) {
|
||||||
|
return [{}];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [partitionKeyValue];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateDocument(
|
||||||
|
collection: ViewModels.CollectionBase,
|
||||||
|
documentId: DocumentId,
|
||||||
|
newDocument: any
|
||||||
|
): Q.Promise<any> {
|
||||||
|
const partitionKey = documentId.partitionKeyValue;
|
||||||
|
|
||||||
|
return Q(
|
||||||
|
client()
|
||||||
|
.database(collection.databaseId)
|
||||||
|
.container(collection.id())
|
||||||
|
.item(documentId.id(), partitionKey)
|
||||||
|
.replace(newDocument)
|
||||||
|
.then(response => response.resource)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function executeStoredProcedure(
|
||||||
|
collection: ViewModels.Collection,
|
||||||
|
storedProcedure: StoredProcedure,
|
||||||
|
partitionKeyValue: any,
|
||||||
|
params: any[]
|
||||||
|
): Q.Promise<any> {
|
||||||
|
// TODO remove this deferred. Kept it because of timeout code at bottom of function
|
||||||
|
const deferred = Q.defer<any>();
|
||||||
|
|
||||||
|
client()
|
||||||
|
.database(collection.databaseId)
|
||||||
|
.container(collection.id())
|
||||||
|
.scripts.storedProcedure(storedProcedure.id())
|
||||||
|
.execute(partitionKeyValue, params, { enableScriptLogging: true })
|
||||||
|
.then(response =>
|
||||||
|
deferred.resolve({
|
||||||
|
result: response.resource,
|
||||||
|
scriptLogs: response.headers[Constants.HttpHeaders.scriptLogResults]
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.catch(error => deferred.reject(error));
|
||||||
|
|
||||||
|
return deferred.promise.timeout(
|
||||||
|
Constants.ClientDefaults.requestTimeoutMs,
|
||||||
|
`Request timed out while executing stored procedure ${storedProcedure.id()}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createDocument(collection: ViewModels.CollectionBase, newDocument: any): Q.Promise<any> {
|
||||||
|
return Q(
|
||||||
|
client()
|
||||||
|
.database(collection.databaseId)
|
||||||
|
.container(collection.id())
|
||||||
|
.items.create(newDocument)
|
||||||
|
.then(response => response.resource)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Q.Promise<any> {
|
||||||
|
const partitionKey = documentId.partitionKeyValue;
|
||||||
|
|
||||||
|
return Q(
|
||||||
|
client()
|
||||||
|
.database(collection.databaseId)
|
||||||
|
.container(collection.id())
|
||||||
|
.item(documentId.id(), partitionKey)
|
||||||
|
.read()
|
||||||
|
.then(response => response.resource)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Q.Promise<any> {
|
||||||
|
const partitionKey = documentId.partitionKeyValue;
|
||||||
|
|
||||||
|
return Q(
|
||||||
|
client()
|
||||||
|
.database(collection.databaseId)
|
||||||
|
.container(collection.id())
|
||||||
|
.item(documentId.id(), partitionKey)
|
||||||
|
.delete()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteConflict(
|
||||||
|
collection: ViewModels.CollectionBase,
|
||||||
|
conflictId: ConflictId,
|
||||||
|
options: any = {}
|
||||||
|
): Q.Promise<any> {
|
||||||
|
options.partitionKey = options.partitionKey || getPartitionKeyHeaderForConflict(conflictId);
|
||||||
|
|
||||||
|
return Q(
|
||||||
|
client()
|
||||||
|
.database(collection.databaseId)
|
||||||
|
.container(collection.id())
|
||||||
|
.conflict(conflictId.id())
|
||||||
|
.delete(options)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function queryConflicts(
|
||||||
|
databaseId: string,
|
||||||
|
containerId: string,
|
||||||
|
query: string,
|
||||||
|
options: any
|
||||||
|
): Q.Promise<QueryIterator<ConflictDefinition & Resource>> {
|
||||||
|
const documentsIterator = client()
|
||||||
|
.database(databaseId)
|
||||||
|
.container(containerId)
|
||||||
|
.conflicts.query(query, options);
|
||||||
|
return Q(documentsIterator);
|
||||||
|
}
|
||||||
217
src/Common/DocumentClientUtilityBase.ts
Normal file
217
src/Common/DocumentClientUtilityBase.ts
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
import { ConflictDefinition, ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||||
|
import Q from "q";
|
||||||
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
|
import ConflictId from "../Explorer/Tree/ConflictId";
|
||||||
|
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||||
|
import StoredProcedure from "../Explorer/Tree/StoredProcedure";
|
||||||
|
import { logConsoleInfo, logConsoleProgress } from "../Utils/NotificationConsoleUtils";
|
||||||
|
import * as Constants from "./Constants";
|
||||||
|
import * as DataAccessUtilityBase from "./DataAccessUtilityBase";
|
||||||
|
import { MinimalQueryIterator, nextPage } from "./IteratorUtilities";
|
||||||
|
import { handleError } from "./ErrorHandlingUtils";
|
||||||
|
|
||||||
|
// TODO: Log all promise resolutions and errors with verbosity levels
|
||||||
|
export function queryDocuments(
|
||||||
|
databaseId: string,
|
||||||
|
containerId: string,
|
||||||
|
query: string,
|
||||||
|
options: any
|
||||||
|
): Q.Promise<QueryIterator<ItemDefinition & Resource>> {
|
||||||
|
return DataAccessUtilityBase.queryDocuments(databaseId, containerId, query, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function queryConflicts(
|
||||||
|
databaseId: string,
|
||||||
|
containerId: string,
|
||||||
|
query: string,
|
||||||
|
options: any
|
||||||
|
): Q.Promise<QueryIterator<ConflictDefinition & Resource>> {
|
||||||
|
return DataAccessUtilityBase.queryConflicts(databaseId, containerId, query, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getEntityName() {
|
||||||
|
const defaultExperience =
|
||||||
|
window.dataExplorer && window.dataExplorer.defaultExperience && window.dataExplorer.defaultExperience();
|
||||||
|
if (defaultExperience === Constants.DefaultAccountExperience.MongoDB) {
|
||||||
|
return "document";
|
||||||
|
}
|
||||||
|
return "item";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function executeStoredProcedure(
|
||||||
|
collection: ViewModels.Collection,
|
||||||
|
storedProcedure: StoredProcedure,
|
||||||
|
partitionKeyValue: any,
|
||||||
|
params: any[]
|
||||||
|
): Q.Promise<any> {
|
||||||
|
var deferred = Q.defer<any>();
|
||||||
|
|
||||||
|
const clearMessage = logConsoleProgress(`Executing stored procedure ${storedProcedure.id()}`);
|
||||||
|
DataAccessUtilityBase.executeStoredProcedure(collection, storedProcedure, partitionKeyValue, params)
|
||||||
|
.then(
|
||||||
|
(response: any) => {
|
||||||
|
deferred.resolve(response);
|
||||||
|
logConsoleInfo(
|
||||||
|
`Finished executing stored procedure ${storedProcedure.id()} for container ${storedProcedure.collection.id()}`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
handleError(
|
||||||
|
error,
|
||||||
|
"ExecuteStoredProcedure",
|
||||||
|
`Failed to execute stored procedure ${storedProcedure.id()} for container ${storedProcedure.collection.id()}`
|
||||||
|
);
|
||||||
|
deferred.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
clearMessage();
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function queryDocumentsPage(
|
||||||
|
resourceName: string,
|
||||||
|
documentsIterator: MinimalQueryIterator,
|
||||||
|
firstItemIndex: number,
|
||||||
|
options: any
|
||||||
|
): Q.Promise<ViewModels.QueryResults> {
|
||||||
|
var deferred = Q.defer<ViewModels.QueryResults>();
|
||||||
|
const entityName = getEntityName();
|
||||||
|
const clearMessage = logConsoleProgress(`Querying ${entityName} for container ${resourceName}`);
|
||||||
|
Q(nextPage(documentsIterator, firstItemIndex))
|
||||||
|
.then(
|
||||||
|
(result: ViewModels.QueryResults) => {
|
||||||
|
const itemCount = (result.documents && result.documents.length) || 0;
|
||||||
|
logConsoleInfo(`Successfully fetched ${itemCount} ${entityName} for container ${resourceName}`);
|
||||||
|
deferred.resolve(result);
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
handleError(error, "QueryDocumentsPage", `Failed to query ${entityName} for container ${resourceName}`);
|
||||||
|
deferred.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
clearMessage();
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Q.Promise<any> {
|
||||||
|
var deferred = Q.defer<any>();
|
||||||
|
const entityName = getEntityName();
|
||||||
|
const clearMessage = logConsoleProgress(`Reading ${entityName} ${documentId.id()}`);
|
||||||
|
DataAccessUtilityBase.readDocument(collection, documentId)
|
||||||
|
.then(
|
||||||
|
(document: any) => {
|
||||||
|
deferred.resolve(document);
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
handleError(error, "ReadDocument", `Failed to read ${entityName} ${documentId.id()}`);
|
||||||
|
deferred.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
clearMessage();
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateDocument(
|
||||||
|
collection: ViewModels.CollectionBase,
|
||||||
|
documentId: DocumentId,
|
||||||
|
newDocument: any
|
||||||
|
): Q.Promise<any> {
|
||||||
|
var deferred = Q.defer<any>();
|
||||||
|
const entityName = getEntityName();
|
||||||
|
const clearMessage = logConsoleProgress(`Updating ${entityName} ${documentId.id()}`);
|
||||||
|
DataAccessUtilityBase.updateDocument(collection, documentId, newDocument)
|
||||||
|
.then(
|
||||||
|
(updatedDocument: any) => {
|
||||||
|
logConsoleInfo(`Successfully updated ${entityName} ${documentId.id()}`);
|
||||||
|
deferred.resolve(updatedDocument);
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
handleError(error, "UpdateDocument", `Failed to update ${entityName} ${documentId.id()}`);
|
||||||
|
deferred.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
clearMessage();
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createDocument(collection: ViewModels.CollectionBase, newDocument: any): Q.Promise<any> {
|
||||||
|
var deferred = Q.defer<any>();
|
||||||
|
const entityName = getEntityName();
|
||||||
|
const clearMessage = logConsoleProgress(`Creating new ${entityName} for container ${collection.id()}`);
|
||||||
|
DataAccessUtilityBase.createDocument(collection, newDocument)
|
||||||
|
.then(
|
||||||
|
(savedDocument: any) => {
|
||||||
|
logConsoleInfo(`Successfully created new ${entityName} for container ${collection.id()}`);
|
||||||
|
deferred.resolve(savedDocument);
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
handleError(error, "CreateDocument", `Error while creating new ${entityName} for container ${collection.id()}`);
|
||||||
|
deferred.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
clearMessage();
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Q.Promise<any> {
|
||||||
|
var deferred = Q.defer<any>();
|
||||||
|
const entityName = getEntityName();
|
||||||
|
const clearMessage = logConsoleProgress(`Deleting ${entityName} ${documentId.id()}`);
|
||||||
|
DataAccessUtilityBase.deleteDocument(collection, documentId)
|
||||||
|
.then(
|
||||||
|
(response: any) => {
|
||||||
|
logConsoleInfo(`Successfully deleted ${entityName} ${documentId.id()}`);
|
||||||
|
deferred.resolve(response);
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
handleError(error, "DeleteDocument", `Error while deleting ${entityName} ${documentId.id()}`);
|
||||||
|
deferred.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
clearMessage();
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteConflict(
|
||||||
|
collection: ViewModels.CollectionBase,
|
||||||
|
conflictId: ConflictId,
|
||||||
|
options?: any
|
||||||
|
): Q.Promise<any> {
|
||||||
|
var deferred = Q.defer<any>();
|
||||||
|
|
||||||
|
const clearMessage = logConsoleProgress(`Deleting conflict ${conflictId.id()}`);
|
||||||
|
DataAccessUtilityBase.deleteConflict(collection, conflictId, options)
|
||||||
|
.then(
|
||||||
|
(response: any) => {
|
||||||
|
logConsoleInfo(`Successfully deleted conflict ${conflictId.id()}`);
|
||||||
|
deferred.resolve(response);
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
handleError(error, "DeleteConflict", `Error while deleting conflict ${conflictId.id()}`);
|
||||||
|
deferred.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
clearMessage();
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { DefaultAccountExperienceType } from "../DefaultAccountExperienceType";
|
|
||||||
import { userContext } from "../UserContext";
|
|
||||||
|
|
||||||
export const getEntityName = (): string => {
|
|
||||||
if (userContext.defaultExperience === DefaultAccountExperienceType.MongoDB) {
|
|
||||||
return "document";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "item";
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
export function normalizeArmEndpoint(uri: string): string {
|
export default class EnvironmentUtility {
|
||||||
if (uri && uri.slice(-1) !== "/") {
|
public static normalizeArmEndpointUri(uri: string): string {
|
||||||
return `${uri}/`;
|
if (uri && uri.slice(-1) !== "/") {
|
||||||
|
return `${uri}/`;
|
||||||
|
}
|
||||||
|
return uri;
|
||||||
}
|
}
|
||||||
return uri;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
import * as OfferUtility from "./OfferUtility";
|
|
||||||
import { SDKOfferDefinition, Offer } from "../Contracts/DataModels";
|
|
||||||
import { OfferResponse } from "@azure/cosmos";
|
|
||||||
|
|
||||||
describe("parseSDKOfferResponse", () => {
|
|
||||||
it("manual throughput", () => {
|
|
||||||
const mockOfferDefinition = {
|
|
||||||
content: {
|
|
||||||
offerThroughput: 500,
|
|
||||||
collectionThroughputInfo: {
|
|
||||||
minimumRUForCollection: 400,
|
|
||||||
numPhysicalPartitions: 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
id: "test"
|
|
||||||
} as SDKOfferDefinition;
|
|
||||||
|
|
||||||
const mockResponse = {
|
|
||||||
resource: mockOfferDefinition
|
|
||||||
} as OfferResponse;
|
|
||||||
|
|
||||||
const expectedResult: Offer = {
|
|
||||||
manualThroughput: 500,
|
|
||||||
autoscaleMaxThroughput: undefined,
|
|
||||||
minimumThroughput: 400,
|
|
||||||
id: "test",
|
|
||||||
offerDefinition: mockOfferDefinition,
|
|
||||||
offerReplacePending: false
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("autoscale throughput", () => {
|
|
||||||
const mockOfferDefinition = {
|
|
||||||
content: {
|
|
||||||
offerThroughput: 400,
|
|
||||||
collectionThroughputInfo: {
|
|
||||||
minimumRUForCollection: 400,
|
|
||||||
numPhysicalPartitions: 1
|
|
||||||
},
|
|
||||||
offerAutopilotSettings: {
|
|
||||||
maxThroughput: 5000
|
|
||||||
}
|
|
||||||
},
|
|
||||||
id: "test"
|
|
||||||
} as SDKOfferDefinition;
|
|
||||||
|
|
||||||
const mockResponse = {
|
|
||||||
resource: mockOfferDefinition
|
|
||||||
} as OfferResponse;
|
|
||||||
|
|
||||||
const expectedResult: Offer = {
|
|
||||||
manualThroughput: undefined,
|
|
||||||
autoscaleMaxThroughput: 5000,
|
|
||||||
minimumThroughput: 400,
|
|
||||||
id: "test",
|
|
||||||
offerDefinition: mockOfferDefinition,
|
|
||||||
offerReplacePending: false
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import { Offer, SDKOfferDefinition } from "../Contracts/DataModels";
|
|
||||||
import { OfferResponse } from "@azure/cosmos";
|
|
||||||
import { HttpHeaders } from "./Constants";
|
|
||||||
|
|
||||||
export const parseSDKOfferResponse = (offerResponse: OfferResponse): Offer => {
|
|
||||||
const offerDefinition: SDKOfferDefinition = offerResponse?.resource;
|
|
||||||
const offerContent = offerDefinition.content;
|
|
||||||
if (!offerContent) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const minimumThroughput = offerContent.collectionThroughputInfo?.minimumRUForCollection;
|
|
||||||
const autopilotSettings = offerContent.offerAutopilotSettings;
|
|
||||||
|
|
||||||
if (autopilotSettings) {
|
|
||||||
return {
|
|
||||||
id: offerDefinition.id,
|
|
||||||
autoscaleMaxThroughput: autopilotSettings.maxThroughput,
|
|
||||||
manualThroughput: undefined,
|
|
||||||
minimumThroughput,
|
|
||||||
offerDefinition,
|
|
||||||
offerReplacePending: offerResponse.headers?.[HttpHeaders.offerReplacePending] === "true"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: offerDefinition.id,
|
|
||||||
autoscaleMaxThroughput: undefined,
|
|
||||||
manualThroughput: offerContent.offerThroughput,
|
|
||||||
minimumThroughput,
|
|
||||||
offerDefinition,
|
|
||||||
offerReplacePending: offerResponse.headers?.[HttpHeaders.offerReplacePending] === "true"
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -16,7 +16,7 @@ const notificationsPath = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const fetchPortalNotifications = async (): Promise<DataModels.Notification[]> => {
|
export const fetchPortalNotifications = async (): Promise<DataModels.Notification[]> => {
|
||||||
if (configContext.platform === Platform.Emulator || configContext.platform === Platform.Hosted) {
|
if (configContext.platform === Platform.Emulator) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,18 +3,16 @@ import * as _ from "underscore";
|
|||||||
import * as DataModels from "../Contracts/DataModels";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
import Explorer from "../Explorer/Explorer";
|
import Explorer from "../Explorer/Explorer";
|
||||||
|
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
import DocumentsTab from "../Explorer/Tabs/DocumentsTab";
|
import DocumentsTab from "../Explorer/Tabs/DocumentsTab";
|
||||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||||
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
|
||||||
import { QueryUtils } from "../Utils/QueryUtils";
|
import { QueryUtils } from "../Utils/QueryUtils";
|
||||||
import { BackendDefaults, HttpStatusCodes, SavedQueries } from "./Constants";
|
import { BackendDefaults, HttpStatusCodes, SavedQueries } from "./Constants";
|
||||||
import { userContext } from "../UserContext";
|
import { userContext } from "../UserContext";
|
||||||
import { queryDocumentsPage } from "./dataAccess/queryDocumentsPage";
|
import { createDocument, deleteDocument, queryDocuments, queryDocumentsPage } from "./DocumentClientUtilityBase";
|
||||||
import { createCollection } from "./dataAccess/createCollection";
|
import { createCollection } from "./dataAccess/createCollection";
|
||||||
import { handleError } from "./ErrorHandlingUtils";
|
import { handleError } from "./ErrorHandlingUtils";
|
||||||
import { createDocument } from "./dataAccess/createDocument";
|
|
||||||
import { deleteDocument } from "./dataAccess/deleteDocument";
|
|
||||||
import { queryDocuments } from "./dataAccess/queryDocuments";
|
|
||||||
|
|
||||||
export class QueriesClient {
|
export class QueriesClient {
|
||||||
private static readonly PartitionKey: DataModels.PartitionKey = {
|
private static readonly PartitionKey: DataModels.PartitionKey = {
|
||||||
@@ -33,7 +31,10 @@ export class QueriesClient {
|
|||||||
return Promise.resolve(queriesCollection.rawDataModel);
|
return Promise.resolve(queriesCollection.rawDataModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearMessage = NotificationConsoleUtils.logConsoleProgress("Setting up account for saving queries");
|
const id = NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.InProgress,
|
||||||
|
"Setting up account for saving queries"
|
||||||
|
);
|
||||||
return createCollection({
|
return createCollection({
|
||||||
collectionId: SavedQueries.CollectionName,
|
collectionId: SavedQueries.CollectionName,
|
||||||
createNewDatabase: true,
|
createNewDatabase: true,
|
||||||
@@ -44,7 +45,10 @@ export class QueriesClient {
|
|||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
(collection: DataModels.Collection) => {
|
(collection: DataModels.Collection) => {
|
||||||
NotificationConsoleUtils.logConsoleInfo("Successfully set up account for saving queries");
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Info,
|
||||||
|
"Successfully set up account for saving queries"
|
||||||
|
);
|
||||||
return Promise.resolve(collection);
|
return Promise.resolve(collection);
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
@@ -52,14 +56,17 @@ export class QueriesClient {
|
|||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => clearMessage());
|
.finally(() => NotificationConsoleUtils.clearInProgressMessageWithId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async saveQuery(query: DataModels.Query): Promise<void> {
|
public async saveQuery(query: DataModels.Query): Promise<void> {
|
||||||
const queriesCollection = this.findQueriesCollection();
|
const queriesCollection = this.findQueriesCollection();
|
||||||
if (!queriesCollection) {
|
if (!queriesCollection) {
|
||||||
const errorMessage: string = "Account not set up to perform saved query operations";
|
const errorMessage: string = "Account not set up to perform saved query operations";
|
||||||
NotificationConsoleUtils.logConsoleError(`Failed to save query ${query.queryName}: ${errorMessage}`);
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Error,
|
||||||
|
`Failed to save query ${query.queryName}: ${errorMessage}`
|
||||||
|
);
|
||||||
return Promise.reject(errorMessage);
|
return Promise.reject(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,16 +74,25 @@ export class QueriesClient {
|
|||||||
this.validateQuery(query);
|
this.validateQuery(query);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage: string = "Invalid query specified";
|
const errorMessage: string = "Invalid query specified";
|
||||||
NotificationConsoleUtils.logConsoleError(`Failed to save query ${query.queryName}: ${errorMessage}`);
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Error,
|
||||||
|
`Failed to save query ${query.queryName}: ${errorMessage}`
|
||||||
|
);
|
||||||
return Promise.reject(errorMessage);
|
return Promise.reject(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearMessage = NotificationConsoleUtils.logConsoleProgress(`Saving query ${query.queryName}`);
|
const id = NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.InProgress,
|
||||||
|
`Saving query ${query.queryName}`
|
||||||
|
);
|
||||||
query.id = query.queryName;
|
query.id = query.queryName;
|
||||||
return createDocument(queriesCollection, query)
|
return createDocument(queriesCollection, query)
|
||||||
.then(
|
.then(
|
||||||
(savedQuery: DataModels.Query) => {
|
(savedQuery: DataModels.Query) => {
|
||||||
NotificationConsoleUtils.logConsoleInfo(`Successfully saved query ${query.queryName}`);
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Info,
|
||||||
|
`Successfully saved query ${query.queryName}`
|
||||||
|
);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
@@ -87,65 +103,74 @@ export class QueriesClient {
|
|||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => clearMessage());
|
.finally(() => NotificationConsoleUtils.clearInProgressMessageWithId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getQueries(): Promise<DataModels.Query[]> {
|
public async getQueries(): Promise<DataModels.Query[]> {
|
||||||
const queriesCollection = this.findQueriesCollection();
|
const queriesCollection = this.findQueriesCollection();
|
||||||
if (!queriesCollection) {
|
if (!queriesCollection) {
|
||||||
const errorMessage: string = "Account not set up to perform saved query operations";
|
const errorMessage: string = "Account not set up to perform saved query operations";
|
||||||
NotificationConsoleUtils.logConsoleError(`Failed to fetch saved queries: ${errorMessage}`);
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Error,
|
||||||
|
`Failed to fetch saved queries: ${errorMessage}`
|
||||||
|
);
|
||||||
return Promise.reject(errorMessage);
|
return Promise.reject(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const options: any = { enableCrossPartitionQuery: true };
|
const options: any = { enableCrossPartitionQuery: true };
|
||||||
const clearMessage = NotificationConsoleUtils.logConsoleProgress("Fetching saved queries");
|
const id = NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.InProgress, "Fetching saved queries");
|
||||||
const queryIterator: QueryIterator<ItemDefinition & Resource> = queryDocuments(
|
return queryDocuments(SavedQueries.DatabaseName, SavedQueries.CollectionName, this.fetchQueriesQuery(), options)
|
||||||
SavedQueries.DatabaseName,
|
|
||||||
SavedQueries.CollectionName,
|
|
||||||
this.fetchQueriesQuery(),
|
|
||||||
options
|
|
||||||
);
|
|
||||||
const fetchQueries = async (firstItemIndex: number): Promise<ViewModels.QueryResults> =>
|
|
||||||
await queryDocumentsPage(queriesCollection.id(), queryIterator, firstItemIndex);
|
|
||||||
return QueryUtils.queryAllPages(fetchQueries)
|
|
||||||
.then(
|
.then(
|
||||||
(results: ViewModels.QueryResults) => {
|
(queryIterator: QueryIterator<ItemDefinition & Resource>) => {
|
||||||
let queries: DataModels.Query[] = _.map(results.documents, (document: DataModels.Query) => {
|
const fetchQueries = (firstItemIndex: number): Q.Promise<ViewModels.QueryResults> =>
|
||||||
if (!document) {
|
queryDocumentsPage(queriesCollection.id(), queryIterator, firstItemIndex, options);
|
||||||
return undefined;
|
return QueryUtils.queryAllPages(fetchQueries).then(
|
||||||
|
(results: ViewModels.QueryResults) => {
|
||||||
|
let queries: DataModels.Query[] = _.map(results.documents, (document: DataModels.Query) => {
|
||||||
|
if (!document) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const { id, resourceId, query, queryName } = document;
|
||||||
|
const parsedQuery: DataModels.Query = {
|
||||||
|
resourceId: resourceId,
|
||||||
|
queryName: queryName,
|
||||||
|
query: query,
|
||||||
|
id: id
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
this.validateQuery(parsedQuery);
|
||||||
|
return parsedQuery;
|
||||||
|
} catch (error) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
queries = _.reject(queries, (parsedQuery: DataModels.Query) => !parsedQuery);
|
||||||
|
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Info, "Successfully fetched saved queries");
|
||||||
|
return Promise.resolve(queries);
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
handleError(error, "getSavedQueries", "Failed to fetch saved queries");
|
||||||
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
const { id, resourceId, query, queryName } = document;
|
);
|
||||||
const parsedQuery: DataModels.Query = {
|
|
||||||
resourceId: resourceId,
|
|
||||||
queryName: queryName,
|
|
||||||
query: query,
|
|
||||||
id: id
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
this.validateQuery(parsedQuery);
|
|
||||||
return parsedQuery;
|
|
||||||
} catch (error) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
queries = _.reject(queries, (parsedQuery: DataModels.Query) => !parsedQuery);
|
|
||||||
NotificationConsoleUtils.logConsoleInfo("Successfully fetched saved queries");
|
|
||||||
return Promise.resolve(queries);
|
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
|
// should never get into this state but we handle this regardless
|
||||||
handleError(error, "getSavedQueries", "Failed to fetch saved queries");
|
handleError(error, "getSavedQueries", "Failed to fetch saved queries");
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => clearMessage());
|
.finally(() => NotificationConsoleUtils.clearInProgressMessageWithId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteQuery(query: DataModels.Query): Promise<void> {
|
public async deleteQuery(query: DataModels.Query): Promise<void> {
|
||||||
const queriesCollection = this.findQueriesCollection();
|
const queriesCollection = this.findQueriesCollection();
|
||||||
if (!queriesCollection) {
|
if (!queriesCollection) {
|
||||||
const errorMessage: string = "Account not set up to perform saved query operations";
|
const errorMessage: string = "Account not set up to perform saved query operations";
|
||||||
NotificationConsoleUtils.logConsoleError(`Failed to fetch saved queries: ${errorMessage}`);
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Error,
|
||||||
|
`Failed to fetch saved queries: ${errorMessage}`
|
||||||
|
);
|
||||||
return Promise.reject(errorMessage);
|
return Promise.reject(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,10 +178,16 @@ export class QueriesClient {
|
|||||||
this.validateQuery(query);
|
this.validateQuery(query);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage: string = "Invalid query specified";
|
const errorMessage: string = "Invalid query specified";
|
||||||
NotificationConsoleUtils.logConsoleError(`Failed to delete query ${query.queryName}: ${errorMessage}`);
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Error,
|
||||||
|
`Failed to delete query ${query.queryName}: ${errorMessage}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearMessage = NotificationConsoleUtils.logConsoleProgress(`Deleting query ${query.queryName}`);
|
const id = NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.InProgress,
|
||||||
|
`Deleting query ${query.queryName}`
|
||||||
|
);
|
||||||
query.id = query.queryName;
|
query.id = query.queryName;
|
||||||
const documentId = new DocumentId(
|
const documentId = new DocumentId(
|
||||||
{
|
{
|
||||||
@@ -170,7 +201,10 @@ export class QueriesClient {
|
|||||||
return deleteDocument(queriesCollection, documentId)
|
return deleteDocument(queriesCollection, documentId)
|
||||||
.then(
|
.then(
|
||||||
() => {
|
() => {
|
||||||
NotificationConsoleUtils.logConsoleInfo(`Successfully deleted query ${query.queryName}`);
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Info,
|
||||||
|
`Successfully deleted query ${query.queryName}`
|
||||||
|
);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
@@ -178,7 +212,7 @@ export class QueriesClient {
|
|||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => clearMessage());
|
.finally(() => NotificationConsoleUtils.clearInProgressMessageWithId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getResourceId(): string {
|
public getResourceId(): string {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
jest.mock("../../Utils/arm/request");
|
jest.mock("../../Utils/arm/request");
|
||||||
jest.mock("../CosmosClient");
|
jest.mock("../CosmosClient");
|
||||||
|
jest.mock("../DataAccessUtilityBase");
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import { CreateCollectionParams, DatabaseAccount } from "../../Contracts/DataModels";
|
import { CreateCollectionParams, DatabaseAccount } from "../../Contracts/DataModels";
|
||||||
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
import { CollectionBase } from "../../Contracts/ViewModels";
|
|
||||||
import { client } from "../CosmosClient";
|
|
||||||
import { getEntityName } from "../DocumentUtility";
|
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
|
||||||
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
||||||
|
|
||||||
export const createDocument = async (collection: CollectionBase, newDocument: unknown): Promise<unknown> => {
|
|
||||||
const entityName = getEntityName();
|
|
||||||
const clearMessage = logConsoleProgress(`Creating new ${entityName} for container ${collection.id()}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await client()
|
|
||||||
.database(collection.databaseId)
|
|
||||||
.container(collection.id())
|
|
||||||
.items.create(newDocument);
|
|
||||||
|
|
||||||
logConsoleInfo(`Successfully created new ${entityName} for container ${collection.id()}`);
|
|
||||||
return response?.resource;
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, "CreateDocument", `Error while creating new ${entityName} for container ${collection.id()}`);
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
clearMessage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import ConflictId from "../../Explorer/Tree/ConflictId";
|
|
||||||
import { CollectionBase } from "../../Contracts/ViewModels";
|
|
||||||
import { RequestOptions } from "@azure/cosmos";
|
|
||||||
import { client } from "../CosmosClient";
|
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
|
||||||
import { logConsoleProgress, logConsoleInfo } from "../../Utils/NotificationConsoleUtils";
|
|
||||||
|
|
||||||
export const deleteConflict = async (collection: CollectionBase, conflictId: ConflictId): Promise<void> => {
|
|
||||||
const clearMessage = logConsoleProgress(`Deleting conflict ${conflictId.id()}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {
|
|
||||||
partitionKey: getPartitionKeyHeaderForConflict(conflictId)
|
|
||||||
};
|
|
||||||
|
|
||||||
await client()
|
|
||||||
.database(collection.databaseId)
|
|
||||||
.container(collection.id())
|
|
||||||
.conflict(conflictId.id())
|
|
||||||
.delete(options as RequestOptions);
|
|
||||||
logConsoleInfo(`Successfully deleted conflict ${conflictId.id()}`);
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, "DeleteConflict", `Error while deleting conflict ${conflictId.id()}`);
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
clearMessage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getPartitionKeyHeaderForConflict = (conflictId: ConflictId): unknown => {
|
|
||||||
if (!conflictId.partitionKey) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return conflictId.partitionKeyValue === undefined ? [{}] : [conflictId.partitionKeyValue];
|
|
||||||
};
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import { CollectionBase } from "../../Contracts/ViewModels";
|
|
||||||
import { client } from "../CosmosClient";
|
|
||||||
import { getEntityName } from "../DocumentUtility";
|
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
|
||||||
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
||||||
import DocumentId from "../../Explorer/Tree/DocumentId";
|
|
||||||
|
|
||||||
export const deleteDocument = async (collection: CollectionBase, documentId: DocumentId): Promise<void> => {
|
|
||||||
const entityName: string = getEntityName();
|
|
||||||
const clearMessage = logConsoleProgress(`Deleting ${entityName} ${documentId.id()}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
await client()
|
|
||||||
.database(collection.databaseId)
|
|
||||||
.container(collection.id())
|
|
||||||
.item(documentId.id(), documentId.partitionKeyValue)
|
|
||||||
.delete();
|
|
||||||
logConsoleInfo(`Successfully deleted ${entityName} ${documentId.id()}`);
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, "DeleteDocument", `Error while deleting ${entityName} ${documentId.id()}`);
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
clearMessage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
import { Collection } from "../../Contracts/ViewModels";
|
|
||||||
import { ClientDefaults, HttpHeaders } from "../Constants";
|
|
||||||
import { client } from "../CosmosClient";
|
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
|
||||||
import { logConsoleProgress, logConsoleInfo } from "../../Utils/NotificationConsoleUtils";
|
|
||||||
import StoredProcedure from "../../Explorer/Tree/StoredProcedure";
|
|
||||||
|
|
||||||
export interface ExecuteSprocResult {
|
|
||||||
result: StoredProcedure;
|
|
||||||
scriptLogs: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const executeStoredProcedure = async (
|
|
||||||
collection: Collection,
|
|
||||||
storedProcedure: StoredProcedure,
|
|
||||||
partitionKeyValue: string,
|
|
||||||
params: string[]
|
|
||||||
): Promise<ExecuteSprocResult> => {
|
|
||||||
const clearMessage = logConsoleProgress(`Executing stored procedure ${storedProcedure.id()}`);
|
|
||||||
const timeout = setTimeout(() => {
|
|
||||||
throw Error(`Request timed out while executing stored procedure ${storedProcedure.id()}`);
|
|
||||||
}, ClientDefaults.requestTimeoutMs);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await client()
|
|
||||||
.database(collection.databaseId)
|
|
||||||
.container(collection.id())
|
|
||||||
.scripts.storedProcedure(storedProcedure.id())
|
|
||||||
.execute(partitionKeyValue, params, { enableScriptLogging: true });
|
|
||||||
clearTimeout(timeout);
|
|
||||||
logConsoleInfo(
|
|
||||||
`Finished executing stored procedure ${storedProcedure.id()} for container ${storedProcedure.collection.id()}`
|
|
||||||
);
|
|
||||||
return {
|
|
||||||
result: response.resource,
|
|
||||||
scriptLogs: response.headers[HttpHeaders.scriptLogResults] as string
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
handleError(
|
|
||||||
error,
|
|
||||||
"ExecuteStoredProcedure",
|
|
||||||
`Failed to execute stored procedure ${storedProcedure.id()} for container ${storedProcedure.collection.id()}`
|
|
||||||
);
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
clearMessage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
import { AuthType } from "../../AuthType";
|
|
||||||
import { armRequest } from "../../Utils/arm/request";
|
|
||||||
import { configContext } from "../../ConfigContext";
|
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
|
||||||
import { userContext } from "../../UserContext";
|
|
||||||
|
|
||||||
interface TimeSeriesData {
|
|
||||||
data: {
|
|
||||||
timeStamp: string;
|
|
||||||
total: number;
|
|
||||||
}[];
|
|
||||||
metadatavalues: {
|
|
||||||
name: {
|
|
||||||
localizedValue: string;
|
|
||||||
value: string;
|
|
||||||
};
|
|
||||||
value: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MetricsData {
|
|
||||||
displayDescription: string;
|
|
||||||
errorCode: string;
|
|
||||||
id: string;
|
|
||||||
name: {
|
|
||||||
value: string;
|
|
||||||
localizedValue: string;
|
|
||||||
};
|
|
||||||
timeseries: TimeSeriesData[];
|
|
||||||
type: string;
|
|
||||||
unit: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MetricsResponse {
|
|
||||||
cost: number;
|
|
||||||
interval: string;
|
|
||||||
namespace: string;
|
|
||||||
resourceregion: string;
|
|
||||||
timespan: string;
|
|
||||||
value: MetricsData[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getCollectionUsageSizeInKB = async (databaseName: string, containerName: string): Promise<number> => {
|
|
||||||
if (window.authType !== AuthType.AAD) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const subscriptionId = userContext.subscriptionId;
|
|
||||||
const resourceGroup = userContext.resourceGroup;
|
|
||||||
const accountName = userContext.databaseAccount.name;
|
|
||||||
const filter = `DatabaseName eq '${databaseName}' and CollectionName eq '${containerName}'`;
|
|
||||||
const metricNames = "DataUsage,IndexUsage";
|
|
||||||
const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/providers/microsoft.insights/metrics`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const metricsResponse: MetricsResponse = await armRequest({
|
|
||||||
host: configContext.ARM_ENDPOINT,
|
|
||||||
path,
|
|
||||||
method: "GET",
|
|
||||||
apiVersion: "2018-01-01",
|
|
||||||
queryParams: {
|
|
||||||
filter,
|
|
||||||
metricNames
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (metricsResponse?.value?.length !== 2) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const dataUsageData: MetricsData = metricsResponse.value[0];
|
|
||||||
const indexUsagedata: MetricsData = metricsResponse.value[1];
|
|
||||||
const dataUsageSizeInKb: number = getUsageSizeInKb(dataUsageData);
|
|
||||||
const indexUsageSizeInKb: number = getUsageSizeInKb(indexUsagedata);
|
|
||||||
|
|
||||||
return dataUsageSizeInKb + indexUsageSizeInKb;
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, "getCollectionUsageSize");
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getUsageSizeInKb = (metricsData: MetricsData): number => {
|
|
||||||
if (metricsData?.errorCode !== "Success") {
|
|
||||||
throw Error(`Get collection usage size failed: ${metricsData.errorCode}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const timeSeriesData: TimeSeriesData = metricsData?.timeseries?.[0];
|
|
||||||
const usageSizeInBytes: number = timeSeriesData?.data?.[0]?.total;
|
|
||||||
|
|
||||||
return usageSizeInBytes ? usageSizeInBytes / 1024 : 0;
|
|
||||||
};
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { ConflictDefinition, FeedOptions, QueryIterator, Resource } from "@azure/cosmos";
|
|
||||||
import { client } from "../CosmosClient";
|
|
||||||
|
|
||||||
export const queryConflicts = (
|
|
||||||
databaseId: string,
|
|
||||||
containerId: string,
|
|
||||||
query: string,
|
|
||||||
options: FeedOptions
|
|
||||||
): QueryIterator<ConflictDefinition & Resource> => {
|
|
||||||
return client()
|
|
||||||
.database(databaseId)
|
|
||||||
.container(containerId)
|
|
||||||
.conflicts.query(query, options);
|
|
||||||
};
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import { Queries } from "../Constants";
|
|
||||||
import { FeedOptions, ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
|
||||||
import { LocalStorageUtility, StorageKey } from "../../Shared/StorageUtility";
|
|
||||||
import { client } from "../CosmosClient";
|
|
||||||
|
|
||||||
export const queryDocuments = (
|
|
||||||
databaseId: string,
|
|
||||||
containerId: string,
|
|
||||||
query: string,
|
|
||||||
options: FeedOptions
|
|
||||||
): QueryIterator<ItemDefinition & Resource> => {
|
|
||||||
options = getCommonQueryOptions(options);
|
|
||||||
return client()
|
|
||||||
.database(databaseId)
|
|
||||||
.container(containerId)
|
|
||||||
.items.query(query, options);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getCommonQueryOptions = (options: FeedOptions): FeedOptions => {
|
|
||||||
const storedItemPerPageSetting: number = LocalStorageUtility.getEntryNumber(StorageKey.ActualItemPerPage);
|
|
||||||
options = options || {};
|
|
||||||
options.populateQueryMetrics = true;
|
|
||||||
options.enableScanInQuery = options.enableScanInQuery || true;
|
|
||||||
if (!options.partitionKey) {
|
|
||||||
options.forceQueryPlan = true;
|
|
||||||
}
|
|
||||||
options.maxItemCount =
|
|
||||||
options.maxItemCount ||
|
|
||||||
(storedItemPerPageSetting !== undefined && storedItemPerPageSetting) ||
|
|
||||||
Queries.itemsPerPage;
|
|
||||||
options.maxDegreeOfParallelism = LocalStorageUtility.getEntryNumber(StorageKey.MaxDegreeOfParellism);
|
|
||||||
|
|
||||||
return options;
|
|
||||||
};
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import { QueryResults } from "../../Contracts/ViewModels";
|
|
||||||
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
||||||
import { MinimalQueryIterator, nextPage } from "../IteratorUtilities";
|
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
|
||||||
import { getEntityName } from "../DocumentUtility";
|
|
||||||
|
|
||||||
export const queryDocumentsPage = async (
|
|
||||||
resourceName: string,
|
|
||||||
documentsIterator: MinimalQueryIterator,
|
|
||||||
firstItemIndex: number
|
|
||||||
): Promise<QueryResults> => {
|
|
||||||
const entityName = getEntityName();
|
|
||||||
const clearMessage = logConsoleProgress(`Querying ${entityName} for container ${resourceName}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result: QueryResults = await nextPage(documentsIterator, firstItemIndex);
|
|
||||||
const itemCount = (result.documents && result.documents.length) || 0;
|
|
||||||
logConsoleInfo(`Successfully fetched ${itemCount} ${entityName} for container ${resourceName}`);
|
|
||||||
return result;
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, "QueryDocumentsPage", `Failed to query ${entityName} for container ${resourceName}`);
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
clearMessage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
||||||
import { Offer, ReadCollectionOfferParams } from "../../Contracts/DataModels";
|
import { HttpHeaders } from "../Constants";
|
||||||
|
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||||
|
import { client } from "../CosmosClient";
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
import { handleError } from "../ErrorHandlingUtils";
|
||||||
import { getSqlContainerThroughput } from "../../Utils/arm/generatedClients/2020-04-01/sqlResources";
|
import { getSqlContainerThroughput } from "../../Utils/arm/generatedClients/2020-04-01/sqlResources";
|
||||||
import { getMongoDBCollectionThroughput } from "../../Utils/arm/generatedClients/2020-04-01/mongoDBResources";
|
import { getMongoDBCollectionThroughput } from "../../Utils/arm/generatedClients/2020-04-01/mongoDBResources";
|
||||||
@@ -8,22 +11,50 @@ import { getCassandraTableThroughput } from "../../Utils/arm/generatedClients/20
|
|||||||
import { getGremlinGraphThroughput } from "../../Utils/arm/generatedClients/2020-04-01/gremlinResources";
|
import { getGremlinGraphThroughput } from "../../Utils/arm/generatedClients/2020-04-01/gremlinResources";
|
||||||
import { getTableThroughput } from "../../Utils/arm/generatedClients/2020-04-01/tableResources";
|
import { getTableThroughput } from "../../Utils/arm/generatedClients/2020-04-01/tableResources";
|
||||||
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||||
import { readOfferWithSDK } from "./readOfferWithSDK";
|
import { readOffers } from "./readOffers";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
|
||||||
export const readCollectionOffer = async (params: ReadCollectionOfferParams): Promise<Offer> => {
|
export const readCollectionOffer = async (
|
||||||
|
params: DataModels.ReadCollectionOfferParams
|
||||||
|
): Promise<DataModels.OfferWithHeaders> => {
|
||||||
const clearMessage = logConsoleProgress(`Querying offer for collection ${params.collectionId}`);
|
const clearMessage = logConsoleProgress(`Querying offer for collection ${params.collectionId}`);
|
||||||
|
let offerId = params.offerId;
|
||||||
|
if (!offerId) {
|
||||||
|
if (window.authType === AuthType.AAD && !userContext.useSDKOperations) {
|
||||||
|
try {
|
||||||
|
offerId = await getCollectionOfferIdWithARM(params.databaseId, params.collectionId);
|
||||||
|
} catch (error) {
|
||||||
|
clearMessage();
|
||||||
|
if (error.code !== "NotFound") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
offerId = await getCollectionOfferIdWithSDK(params.collectionResourceId);
|
||||||
|
if (!offerId) {
|
||||||
|
clearMessage();
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const options: RequestOptions = {
|
||||||
|
initialHeaders: {
|
||||||
|
[HttpHeaders.populateCollectionThroughputInfo]: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (
|
const response = await client()
|
||||||
window.authType === AuthType.AAD &&
|
.offer(offerId)
|
||||||
!userContext.useSDKOperations &&
|
.read(options);
|
||||||
userContext.defaultExperience !== DefaultAccountExperienceType.Table
|
return (
|
||||||
) {
|
response && {
|
||||||
return await readCollectionOfferWithARM(params.databaseId, params.collectionId);
|
...response.resource,
|
||||||
}
|
headers: response.headers
|
||||||
|
}
|
||||||
return await readOfferWithSDK(params.offerId, params.collectionResourceId);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, "ReadCollectionOffer", `Error while querying offer for collection ${params.collectionId}`);
|
handleError(error, "ReadCollectionOffer", `Error while querying offer for collection ${params.collectionId}`);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -32,92 +63,61 @@ export const readCollectionOffer = async (params: ReadCollectionOfferParams): Pr
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const readCollectionOfferWithARM = async (databaseId: string, collectionId: string): Promise<Offer> => {
|
const getCollectionOfferIdWithARM = async (databaseId: string, collectionId: string): Promise<string> => {
|
||||||
|
let rpResponse;
|
||||||
const subscriptionId = userContext.subscriptionId;
|
const subscriptionId = userContext.subscriptionId;
|
||||||
const resourceGroup = userContext.resourceGroup;
|
const resourceGroup = userContext.resourceGroup;
|
||||||
const accountName = userContext.databaseAccount.name;
|
const accountName = userContext.databaseAccount.name;
|
||||||
const defaultExperience = userContext.defaultExperience;
|
const defaultExperience = userContext.defaultExperience;
|
||||||
|
switch (defaultExperience) {
|
||||||
let rpResponse;
|
case DefaultAccountExperienceType.DocumentDB:
|
||||||
try {
|
rpResponse = await getSqlContainerThroughput(
|
||||||
switch (defaultExperience) {
|
subscriptionId,
|
||||||
case DefaultAccountExperienceType.DocumentDB:
|
resourceGroup,
|
||||||
rpResponse = await getSqlContainerThroughput(
|
accountName,
|
||||||
subscriptionId,
|
databaseId,
|
||||||
resourceGroup,
|
collectionId
|
||||||
accountName,
|
);
|
||||||
databaseId,
|
break;
|
||||||
collectionId
|
case DefaultAccountExperienceType.MongoDB:
|
||||||
);
|
rpResponse = await getMongoDBCollectionThroughput(
|
||||||
break;
|
subscriptionId,
|
||||||
case DefaultAccountExperienceType.MongoDB:
|
resourceGroup,
|
||||||
rpResponse = await getMongoDBCollectionThroughput(
|
accountName,
|
||||||
subscriptionId,
|
databaseId,
|
||||||
resourceGroup,
|
collectionId
|
||||||
accountName,
|
);
|
||||||
databaseId,
|
break;
|
||||||
collectionId
|
case DefaultAccountExperienceType.Cassandra:
|
||||||
);
|
rpResponse = await getCassandraTableThroughput(
|
||||||
break;
|
subscriptionId,
|
||||||
case DefaultAccountExperienceType.Cassandra:
|
resourceGroup,
|
||||||
rpResponse = await getCassandraTableThroughput(
|
accountName,
|
||||||
subscriptionId,
|
databaseId,
|
||||||
resourceGroup,
|
collectionId
|
||||||
accountName,
|
);
|
||||||
databaseId,
|
break;
|
||||||
collectionId
|
case DefaultAccountExperienceType.Graph:
|
||||||
);
|
rpResponse = await getGremlinGraphThroughput(
|
||||||
break;
|
subscriptionId,
|
||||||
case DefaultAccountExperienceType.Graph:
|
resourceGroup,
|
||||||
rpResponse = await getGremlinGraphThroughput(
|
accountName,
|
||||||
subscriptionId,
|
databaseId,
|
||||||
resourceGroup,
|
collectionId
|
||||||
accountName,
|
);
|
||||||
databaseId,
|
break;
|
||||||
collectionId
|
case DefaultAccountExperienceType.Table:
|
||||||
);
|
rpResponse = await getTableThroughput(subscriptionId, resourceGroup, accountName, collectionId);
|
||||||
break;
|
break;
|
||||||
case DefaultAccountExperienceType.Table:
|
default:
|
||||||
rpResponse = await getTableThroughput(subscriptionId, resourceGroup, accountName, collectionId);
|
throw new Error(`Unsupported default experience type: ${defaultExperience}`);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unsupported default experience type: ${defaultExperience}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code !== "NotFound") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const resource = rpResponse?.properties?.resource;
|
return rpResponse?.name;
|
||||||
if (resource) {
|
};
|
||||||
const offerId: string = rpResponse.name;
|
|
||||||
const minimumThroughput: number =
|
const getCollectionOfferIdWithSDK = async (collectionResourceId: string): Promise<string> => {
|
||||||
typeof resource.minimumThroughput === "string"
|
const offers = await readOffers();
|
||||||
? parseInt(resource.minimumThroughput)
|
const offer = offers.find(offer => offer.resource === collectionResourceId);
|
||||||
: resource.minimumThroughput;
|
return offer?.id;
|
||||||
const autoscaleSettings = resource.autoscaleSettings;
|
|
||||||
|
|
||||||
if (autoscaleSettings) {
|
|
||||||
return {
|
|
||||||
id: offerId,
|
|
||||||
autoscaleMaxThroughput: autoscaleSettings.maxThroughput,
|
|
||||||
manualThroughput: undefined,
|
|
||||||
minimumThroughput,
|
|
||||||
offerReplacePending: resource.offerReplacePending === "true"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: offerId,
|
|
||||||
autoscaleMaxThroughput: undefined,
|
|
||||||
manualThroughput: resource.throughput,
|
|
||||||
minimumThroughput,
|
|
||||||
offerReplacePending: resource.offerReplacePending === "true"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
};
|
};
|
||||||
|
|||||||
45
src/Common/dataAccess/readCollectionQuotaInfo.ts
Normal file
45
src/Common/dataAccess/readCollectionQuotaInfo.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
|
import * as HeadersUtility from "../HeadersUtility";
|
||||||
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
|
import { ContainerDefinition, Resource } from "@azure/cosmos";
|
||||||
|
import { HttpHeaders } from "../Constants";
|
||||||
|
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||||
|
import { client } from "../CosmosClient";
|
||||||
|
import { handleError } from "../ErrorHandlingUtils";
|
||||||
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||||
|
|
||||||
|
interface ResourceWithStatistics {
|
||||||
|
statistics: DataModels.Statistic[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const readCollectionQuotaInfo = async (
|
||||||
|
collection: ViewModels.Collection
|
||||||
|
): Promise<DataModels.CollectionQuotaInfo> => {
|
||||||
|
const clearMessage = logConsoleProgress(`Querying containers for database ${collection.id}`);
|
||||||
|
const options: RequestOptions = {};
|
||||||
|
options.populateQuotaInfo = true;
|
||||||
|
options.initialHeaders = options.initialHeaders || {};
|
||||||
|
options.initialHeaders[HttpHeaders.populatePartitionStatistics] = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await client()
|
||||||
|
.database(collection.databaseId)
|
||||||
|
.container(collection.id())
|
||||||
|
.read(options);
|
||||||
|
const quota: DataModels.CollectionQuotaInfo = HeadersUtility.getQuota(response.headers);
|
||||||
|
const resource = response.resource as ContainerDefinition & Resource & ResourceWithStatistics;
|
||||||
|
quota["usageSizeInKB"] = resource.statistics.reduce(
|
||||||
|
(previousValue: number, currentValue: DataModels.Statistic) => previousValue + currentValue.sizeInKB,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
quota["numPartitions"] = resource.statistics.length;
|
||||||
|
quota["uniqueKeyPolicy"] = collection.uniqueKeyPolicy; // TODO: Remove after refactoring (#119617)
|
||||||
|
|
||||||
|
return quota;
|
||||||
|
} catch (error) {
|
||||||
|
handleError(error, "ReadCollectionQuotaInfo", `Error while querying quota info for container ${collection.id}`);
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
clearMessage();
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,28 +1,51 @@
|
|||||||
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
||||||
import { Offer, ReadDatabaseOfferParams } from "../../Contracts/DataModels";
|
import { HttpHeaders } from "../Constants";
|
||||||
|
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||||
|
import { client } from "../CosmosClient";
|
||||||
import { getSqlDatabaseThroughput } from "../../Utils/arm/generatedClients/2020-04-01/sqlResources";
|
import { getSqlDatabaseThroughput } from "../../Utils/arm/generatedClients/2020-04-01/sqlResources";
|
||||||
import { getMongoDBDatabaseThroughput } from "../../Utils/arm/generatedClients/2020-04-01/mongoDBResources";
|
import { getMongoDBDatabaseThroughput } from "../../Utils/arm/generatedClients/2020-04-01/mongoDBResources";
|
||||||
import { getCassandraKeyspaceThroughput } from "../../Utils/arm/generatedClients/2020-04-01/cassandraResources";
|
import { getCassandraKeyspaceThroughput } from "../../Utils/arm/generatedClients/2020-04-01/cassandraResources";
|
||||||
import { getGremlinDatabaseThroughput } from "../../Utils/arm/generatedClients/2020-04-01/gremlinResources";
|
import { getGremlinDatabaseThroughput } from "../../Utils/arm/generatedClients/2020-04-01/gremlinResources";
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
import { handleError } from "../ErrorHandlingUtils";
|
||||||
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||||
import { readOfferWithSDK } from "./readOfferWithSDK";
|
import { readOffers } from "./readOffers";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
|
||||||
export const readDatabaseOffer = async (params: ReadDatabaseOfferParams): Promise<Offer> => {
|
export const readDatabaseOffer = async (
|
||||||
|
params: DataModels.ReadDatabaseOfferParams
|
||||||
|
): Promise<DataModels.OfferWithHeaders> => {
|
||||||
const clearMessage = logConsoleProgress(`Querying offer for database ${params.databaseId}`);
|
const clearMessage = logConsoleProgress(`Querying offer for database ${params.databaseId}`);
|
||||||
|
let offerId = params.offerId;
|
||||||
|
if (!offerId) {
|
||||||
|
offerId = await (window.authType === AuthType.AAD &&
|
||||||
|
!userContext.useSDKOperations &&
|
||||||
|
userContext.defaultExperience !== DefaultAccountExperienceType.Table
|
||||||
|
? getDatabaseOfferIdWithARM(params.databaseId)
|
||||||
|
: getDatabaseOfferIdWithSDK(params.databaseResourceId));
|
||||||
|
if (!offerId) {
|
||||||
|
clearMessage();
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const options: RequestOptions = {
|
||||||
|
initialHeaders: {
|
||||||
|
[HttpHeaders.populateCollectionThroughputInfo]: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (
|
const response = await client()
|
||||||
window.authType === AuthType.AAD &&
|
.offer(offerId)
|
||||||
!userContext.useSDKOperations &&
|
.read(options);
|
||||||
userContext.defaultExperience !== DefaultAccountExperienceType.Table
|
return (
|
||||||
) {
|
response && {
|
||||||
return await readDatabaseOfferWithARM(params.databaseId);
|
...response.resource,
|
||||||
}
|
headers: response.headers
|
||||||
|
}
|
||||||
return await readOfferWithSDK(params.offerId, params.databaseResourceId);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, "ReadDatabaseOffer", `Error while querying offer for database ${params.databaseId}`);
|
handleError(error, "ReadDatabaseOffer", `Error while querying offer for database ${params.databaseId}`);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -31,13 +54,13 @@ export const readDatabaseOffer = async (params: ReadDatabaseOfferParams): Promis
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const readDatabaseOfferWithARM = async (databaseId: string): Promise<Offer> => {
|
const getDatabaseOfferIdWithARM = async (databaseId: string): Promise<string> => {
|
||||||
|
let rpResponse;
|
||||||
const subscriptionId = userContext.subscriptionId;
|
const subscriptionId = userContext.subscriptionId;
|
||||||
const resourceGroup = userContext.resourceGroup;
|
const resourceGroup = userContext.resourceGroup;
|
||||||
const accountName = userContext.databaseAccount.name;
|
const accountName = userContext.databaseAccount.name;
|
||||||
const defaultExperience = userContext.defaultExperience;
|
const defaultExperience = userContext.defaultExperience;
|
||||||
|
|
||||||
let rpResponse;
|
|
||||||
try {
|
try {
|
||||||
switch (defaultExperience) {
|
switch (defaultExperience) {
|
||||||
case DefaultAccountExperienceType.DocumentDB:
|
case DefaultAccountExperienceType.DocumentDB:
|
||||||
@@ -55,41 +78,18 @@ const readDatabaseOfferWithARM = async (databaseId: string): Promise<Offer> => {
|
|||||||
default:
|
default:
|
||||||
throw new Error(`Unsupported default experience type: ${defaultExperience}`);
|
throw new Error(`Unsupported default experience type: ${defaultExperience}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rpResponse?.name;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== "NotFound") {
|
if (error.code !== "NotFound") {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
const resource = rpResponse?.properties?.resource;
|
|
||||||
if (resource) {
|
const getDatabaseOfferIdWithSDK = async (databaseResourceId: string): Promise<string> => {
|
||||||
const offerId: string = rpResponse.name;
|
const offers = await readOffers();
|
||||||
const minimumThroughput: number =
|
const offer = offers.find(offer => offer.resource === databaseResourceId);
|
||||||
typeof resource.minimumThroughput === "string"
|
return offer?.id;
|
||||||
? parseInt(resource.minimumThroughput)
|
|
||||||
: resource.minimumThroughput;
|
|
||||||
const autoscaleSettings = resource.autoscaleSettings;
|
|
||||||
|
|
||||||
if (autoscaleSettings) {
|
|
||||||
return {
|
|
||||||
id: offerId,
|
|
||||||
autoscaleMaxThroughput: autoscaleSettings.maxThroughput,
|
|
||||||
manualThroughput: undefined,
|
|
||||||
minimumThroughput,
|
|
||||||
offerReplacePending: resource.offerReplacePending === "true"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: offerId,
|
|
||||||
autoscaleMaxThroughput: undefined,
|
|
||||||
manualThroughput: resource.throughput,
|
|
||||||
minimumThroughput,
|
|
||||||
offerReplacePending: resource.offerReplacePending === "true"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import { Item } from "@azure/cosmos";
|
|
||||||
import { CollectionBase } from "../../Contracts/ViewModels";
|
|
||||||
import { client } from "../CosmosClient";
|
|
||||||
import { getEntityName } from "../DocumentUtility";
|
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
|
||||||
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
||||||
import DocumentId from "../../Explorer/Tree/DocumentId";
|
|
||||||
|
|
||||||
export const readDocument = async (collection: CollectionBase, documentId: DocumentId): Promise<Item> => {
|
|
||||||
const entityName = getEntityName();
|
|
||||||
const clearMessage = logConsoleProgress(`Reading ${entityName} ${documentId.id()}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await client()
|
|
||||||
.database(collection.databaseId)
|
|
||||||
.container(collection.id())
|
|
||||||
.item(documentId.id(), documentId.partitionKeyValue)
|
|
||||||
.read();
|
|
||||||
|
|
||||||
return response?.resource;
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, "ReadDocument", `Failed to read ${entityName} ${documentId.id()}`);
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
clearMessage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import { HttpHeaders } from "../Constants";
|
|
||||||
import { Offer } from "../../Contracts/DataModels";
|
|
||||||
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
|
||||||
import { client } from "../CosmosClient";
|
|
||||||
import { parseSDKOfferResponse } from "../OfferUtility";
|
|
||||||
import { readOffers } from "./readOffers";
|
|
||||||
|
|
||||||
export const readOfferWithSDK = async (offerId: string, resourceId: string): Promise<Offer> => {
|
|
||||||
if (!offerId) {
|
|
||||||
const offers = await readOffers();
|
|
||||||
const offer = offers.find(offer => offer.resource === resourceId);
|
|
||||||
|
|
||||||
if (!offer) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
offerId = offer.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: RequestOptions = {
|
|
||||||
initialHeaders: {
|
|
||||||
[HttpHeaders.populateCollectionThroughputInfo]: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const response = await client()
|
|
||||||
.offer(offerId)
|
|
||||||
.read(options);
|
|
||||||
|
|
||||||
return parseSDKOfferResponse(response);
|
|
||||||
};
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { SDKOfferDefinition } from "../../Contracts/DataModels";
|
import { Offer } from "../../Contracts/DataModels";
|
||||||
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||||
import { client } from "../CosmosClient";
|
import { client } from "../CosmosClient";
|
||||||
import { handleError, getErrorMessage } from "../ErrorHandlingUtils";
|
import { handleError, getErrorMessage } from "../ErrorHandlingUtils";
|
||||||
|
|
||||||
export const readOffers = async (): Promise<SDKOfferDefinition[]> => {
|
export const readOffers = async (): Promise<Offer[]> => {
|
||||||
const clearMessage = logConsoleProgress(`Querying offers`);
|
const clearMessage = logConsoleProgress(`Querying offers`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import { CollectionBase } from "../../Contracts/ViewModels";
|
|
||||||
import { Item } from "@azure/cosmos";
|
|
||||||
import { client } from "../CosmosClient";
|
|
||||||
import { getEntityName } from "../DocumentUtility";
|
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
|
||||||
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
||||||
import DocumentId from "../../Explorer/Tree/DocumentId";
|
|
||||||
|
|
||||||
export const updateDocument = async (
|
|
||||||
collection: CollectionBase,
|
|
||||||
documentId: DocumentId,
|
|
||||||
newDocument: Item
|
|
||||||
): Promise<Item> => {
|
|
||||||
const entityName = getEntityName();
|
|
||||||
const clearMessage = logConsoleProgress(`Updating ${entityName} ${documentId.id()}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await client()
|
|
||||||
.database(collection.databaseId)
|
|
||||||
.container(collection.id())
|
|
||||||
.item(documentId.id(), documentId.partitionKeyValue)
|
|
||||||
.replace(newDocument);
|
|
||||||
|
|
||||||
logConsoleInfo(`Successfully updated ${entityName} ${documentId.id()}`);
|
|
||||||
return response?.resource;
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, "UpdateDocument", `Failed to update ${entityName} ${documentId.id()}`);
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
clearMessage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
||||||
import { HttpHeaders } from "../Constants";
|
import { HttpHeaders } from "../Constants";
|
||||||
import { Offer, SDKOfferDefinition, UpdateOfferParams } from "../../Contracts/DataModels";
|
import { Offer, UpdateOfferParams } from "../../Contracts/DataModels";
|
||||||
import { OfferDefinition } from "@azure/cosmos";
|
import { OfferDefinition } from "@azure/cosmos";
|
||||||
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||||
import { ThroughputSettingsUpdateParameters } from "../../Utils/arm/generatedClients/2020-04-01/types";
|
import { ThroughputSettingsUpdateParameters } from "../../Utils/arm/generatedClients/2020-04-01/types";
|
||||||
import { client } from "../CosmosClient";
|
import { client } from "../CosmosClient";
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
import { handleError } from "../ErrorHandlingUtils";
|
||||||
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||||
import { parseSDKOfferResponse } from "../OfferUtility";
|
|
||||||
import { readCollectionOffer } from "./readCollectionOffer";
|
import { readCollectionOffer } from "./readCollectionOffer";
|
||||||
import { readDatabaseOffer } from "./readDatabaseOffer";
|
import { readDatabaseOffer } from "./readDatabaseOffer";
|
||||||
import {
|
import {
|
||||||
@@ -374,21 +373,21 @@ const createUpdateOfferBody = (params: UpdateOfferParams): ThroughputSettingsUpd
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateOfferWithSDK = async (params: UpdateOfferParams): Promise<Offer> => {
|
const updateOfferWithSDK = async (params: UpdateOfferParams): Promise<Offer> => {
|
||||||
const sdkOfferDefinition = params.currentOffer.offerDefinition;
|
const currentOffer = params.currentOffer;
|
||||||
const newOffer: SDKOfferDefinition = {
|
const newOffer: Offer = {
|
||||||
content: {
|
content: {
|
||||||
offerThroughput: undefined,
|
offerThroughput: undefined,
|
||||||
offerIsRUPerMinuteThroughputEnabled: false
|
offerIsRUPerMinuteThroughputEnabled: false
|
||||||
},
|
},
|
||||||
_etag: undefined,
|
_etag: undefined,
|
||||||
_ts: undefined,
|
_ts: undefined,
|
||||||
_rid: sdkOfferDefinition._rid,
|
_rid: currentOffer._rid,
|
||||||
_self: sdkOfferDefinition._self,
|
_self: currentOffer._self,
|
||||||
id: sdkOfferDefinition.id,
|
id: currentOffer.id,
|
||||||
offerResourceId: sdkOfferDefinition.offerResourceId,
|
offerResourceId: currentOffer.offerResourceId,
|
||||||
offerVersion: sdkOfferDefinition.offerVersion,
|
offerVersion: currentOffer.offerVersion,
|
||||||
offerType: sdkOfferDefinition.offerType,
|
offerType: currentOffer.offerType,
|
||||||
resource: sdkOfferDefinition.resource
|
resource: currentOffer.resource
|
||||||
};
|
};
|
||||||
|
|
||||||
if (params.autopilotThroughput) {
|
if (params.autopilotThroughput) {
|
||||||
@@ -416,6 +415,5 @@ const updateOfferWithSDK = async (params: UpdateOfferParams): Promise<Offer> =>
|
|||||||
.offer(params.currentOffer.id)
|
.offer(params.currentOffer.id)
|
||||||
// TODO Remove casting when SDK types are fixed (https://github.com/Azure/azure-sdk-for-js/issues/10660)
|
// TODO Remove casting when SDK types are fixed (https://github.com/Azure/azure-sdk-for-js/issues/10660)
|
||||||
.replace((newOffer as unknown) as OfferDefinition, options);
|
.replace((newOffer as unknown) as OfferDefinition, options);
|
||||||
|
return sdkResponse?.resource;
|
||||||
return parseSDKOfferResponse(sdkResponse);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { updateOfferThroughputBeyondLimit } from "./updateOfferThroughputBeyondLimit";
|
||||||
|
|
||||||
|
describe("updateOfferThroughputBeyondLimit", () => {
|
||||||
|
it("should call fetch", async () => {
|
||||||
|
window.fetch = jest.fn(() => {
|
||||||
|
return {
|
||||||
|
ok: true
|
||||||
|
};
|
||||||
|
});
|
||||||
|
window.dataExplorer = {
|
||||||
|
logConsoleData: jest.fn(),
|
||||||
|
deleteInProgressConsoleDataWithId: jest.fn()
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
} as any;
|
||||||
|
await updateOfferThroughputBeyondLimit({
|
||||||
|
subscriptionId: "foo",
|
||||||
|
resourceGroup: "foo",
|
||||||
|
databaseAccountName: "foo",
|
||||||
|
databaseName: "foo",
|
||||||
|
throughput: 1000000000,
|
||||||
|
offerIsRUPerMinuteThroughputEnabled: false
|
||||||
|
});
|
||||||
|
expect(window.fetch).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
57
src/Common/dataAccess/updateOfferThroughputBeyondLimit.ts
Normal file
57
src/Common/dataAccess/updateOfferThroughputBeyondLimit.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import { Platform, configContext } from "../../ConfigContext";
|
||||||
|
import { getAuthorizationHeader } from "../../Utils/AuthorizationUtils";
|
||||||
|
import { AutoPilotOfferSettings } from "../../Contracts/DataModels";
|
||||||
|
import { logConsoleProgress, logConsoleInfo } from "../../Utils/NotificationConsoleUtils";
|
||||||
|
import { HttpHeaders } from "../Constants";
|
||||||
|
import { handleError } from "../ErrorHandlingUtils";
|
||||||
|
|
||||||
|
interface UpdateOfferThroughputRequest {
|
||||||
|
subscriptionId: string;
|
||||||
|
resourceGroup: string;
|
||||||
|
databaseAccountName: string;
|
||||||
|
databaseName: string;
|
||||||
|
collectionName?: string;
|
||||||
|
throughput: number;
|
||||||
|
offerIsRUPerMinuteThroughputEnabled: boolean;
|
||||||
|
offerAutopilotSettings?: AutoPilotOfferSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateOfferThroughputBeyondLimit(request: UpdateOfferThroughputRequest): Promise<void> {
|
||||||
|
if (configContext.platform !== Platform.Portal) {
|
||||||
|
throw new Error("Updating throughput beyond specified limit is not supported on this platform");
|
||||||
|
}
|
||||||
|
|
||||||
|
const resourceDescriptionInfo = request.collectionName
|
||||||
|
? `database ${request.databaseName} and container ${request.collectionName}`
|
||||||
|
: `database ${request.databaseName}`;
|
||||||
|
|
||||||
|
const clearMessage = logConsoleProgress(
|
||||||
|
`Requesting increase in throughput to ${request.throughput} for ${resourceDescriptionInfo}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const url = `${configContext.BACKEND_ENDPOINT}/api/offerthroughputrequest/updatebeyondspecifiedlimit`;
|
||||||
|
const authorizationHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
|
const response = await fetch(url, {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(request),
|
||||||
|
headers: { [authorizationHeader.header]: authorizationHeader.token, [HttpHeaders.contentType]: "application/json" }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
logConsoleInfo(
|
||||||
|
`Successfully requested an increase in throughput to ${request.throughput} for ${resourceDescriptionInfo}`
|
||||||
|
);
|
||||||
|
clearMessage();
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const error = await response.json();
|
||||||
|
handleError(
|
||||||
|
error,
|
||||||
|
"updateOfferThroughputBeyondLimit",
|
||||||
|
`Failed to request an increase in throughput for ${request.throughput}`
|
||||||
|
);
|
||||||
|
clearMessage();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
@@ -208,21 +208,12 @@ export interface QueryMetrics {
|
|||||||
vmExecutionTime: any;
|
vmExecutionTime: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Offer {
|
export interface Offer extends Resource {
|
||||||
id: string;
|
|
||||||
autoscaleMaxThroughput: number;
|
|
||||||
manualThroughput: number;
|
|
||||||
minimumThroughput: number;
|
|
||||||
offerDefinition?: SDKOfferDefinition;
|
|
||||||
offerReplacePending: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SDKOfferDefinition extends Resource {
|
|
||||||
offerVersion?: string;
|
offerVersion?: string;
|
||||||
offerType?: string;
|
offerType?: string;
|
||||||
content?: {
|
content?: {
|
||||||
offerThroughput: number;
|
offerThroughput: number;
|
||||||
offerIsRUPerMinuteThroughputEnabled?: boolean;
|
offerIsRUPerMinuteThroughputEnabled: boolean;
|
||||||
collectionThroughputInfo?: OfferThroughputInfo;
|
collectionThroughputInfo?: OfferThroughputInfo;
|
||||||
offerAutopilotSettings?: AutoPilotOfferSettings;
|
offerAutopilotSettings?: AutoPilotOfferSettings;
|
||||||
};
|
};
|
||||||
@@ -230,6 +221,22 @@ export interface SDKOfferDefinition extends Resource {
|
|||||||
offerResourceId?: string;
|
offerResourceId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OfferWithHeaders extends Offer {
|
||||||
|
headers: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CollectionQuotaInfo {
|
||||||
|
storedProcedures: number;
|
||||||
|
triggers: number;
|
||||||
|
functions: number;
|
||||||
|
documentsSize: number;
|
||||||
|
collectionSize: number;
|
||||||
|
documentsCount: number;
|
||||||
|
usageSizeInKB: number;
|
||||||
|
numPartitions: number;
|
||||||
|
uniqueKeyPolicy?: UniqueKeyPolicy; // TODO: This should ideally not be a part of the collection quota. Remove after refactoring. (#119617)
|
||||||
|
}
|
||||||
|
|
||||||
export interface OfferThroughputInfo {
|
export interface OfferThroughputInfo {
|
||||||
minimumRUForCollection: number;
|
minimumRUForCollection: number;
|
||||||
numPhysicalPartitions: number;
|
numPhysicalPartitions: number;
|
||||||
@@ -248,6 +255,7 @@ export interface CreateDatabaseAndCollectionRequest {
|
|||||||
collectionId: string;
|
collectionId: string;
|
||||||
offerThroughput: number;
|
offerThroughput: number;
|
||||||
databaseLevelThroughput: boolean;
|
databaseLevelThroughput: boolean;
|
||||||
|
rupmEnabled?: boolean;
|
||||||
partitionKey?: PartitionKey;
|
partitionKey?: PartitionKey;
|
||||||
indexingPolicy?: IndexingPolicy;
|
indexingPolicy?: IndexingPolicy;
|
||||||
uniqueKeyPolicy?: UniqueKeyPolicy;
|
uniqueKeyPolicy?: UniqueKeyPolicy;
|
||||||
@@ -587,3 +595,11 @@ export interface MemoryUsageInfo {
|
|||||||
freeKB: number;
|
freeKB: number;
|
||||||
totalKB: number;
|
totalKB: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface resourceTokenConnectionStringProperties {
|
||||||
|
accountEndpoint: string;
|
||||||
|
collectionId: string;
|
||||||
|
databaseId: string;
|
||||||
|
partitionKey?: string;
|
||||||
|
resourceToken: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ export enum MessageTypes {
|
|||||||
GetArcadiaToken,
|
GetArcadiaToken,
|
||||||
CreateWorkspace,
|
CreateWorkspace,
|
||||||
CreateSparkPool,
|
CreateSparkPool,
|
||||||
RefreshDatabaseAccount,
|
RefreshDatabaseAccount
|
||||||
InitTestExplorer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Versions, ActionContracts, Diagnostics };
|
export { Versions, ActionContracts, Diagnostics };
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export interface Collection extends CollectionBase {
|
|||||||
requestSchema?: () => void;
|
requestSchema?: () => void;
|
||||||
indexingPolicy: ko.Observable<DataModels.IndexingPolicy>;
|
indexingPolicy: ko.Observable<DataModels.IndexingPolicy>;
|
||||||
uniqueKeyPolicy: DataModels.UniqueKeyPolicy;
|
uniqueKeyPolicy: DataModels.UniqueKeyPolicy;
|
||||||
usageSizeInKB: ko.Observable<number>;
|
quotaInfo: ko.Observable<DataModels.CollectionQuotaInfo>;
|
||||||
offer: ko.Observable<DataModels.Offer>;
|
offer: ko.Observable<DataModels.Offer>;
|
||||||
conflictResolutionPolicy: ko.Observable<DataModels.ConflictResolutionPolicy>;
|
conflictResolutionPolicy: ko.Observable<DataModels.ConflictResolutionPolicy>;
|
||||||
changeFeedPolicy: ko.Observable<DataModels.ChangeFeedPolicy>;
|
changeFeedPolicy: ko.Observable<DataModels.ChangeFeedPolicy>;
|
||||||
@@ -362,7 +362,7 @@ export enum CollectionTabKind {
|
|||||||
Gallery = 17,
|
Gallery = 17,
|
||||||
NotebookViewer = 18,
|
NotebookViewer = 18,
|
||||||
Schema = 19,
|
Schema = 19,
|
||||||
SettingsV2 = 20
|
SettingsV2 = 19
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum TerminalKind {
|
export enum TerminalKind {
|
||||||
|
|||||||
383
src/Definitions/adal.d.ts
vendored
Normal file
383
src/Definitions/adal.d.ts
vendored
Normal file
@@ -0,0 +1,383 @@
|
|||||||
|
// Type definitions for adal-angular 1.0.1.1
|
||||||
|
// Project: https://github.com/AzureAD/azure-activedirectory-library-for-js#readme
|
||||||
|
// Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
|
||||||
|
// Anthony Ciccarello <https://github.com/aciccarello>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
|
//This is a customized version of adal on top of version 1.0.1 which does not support multi tenant
|
||||||
|
// Customized version add tenantId to stored tokens so when tenant change, adal will refetch instead of read from sessionStorage
|
||||||
|
|
||||||
|
// In module contexts the class constructor function is the exported object
|
||||||
|
// export = AuthenticationContext;
|
||||||
|
|
||||||
|
// This class is defined globally in not in a module context
|
||||||
|
declare class AuthenticationContext {
|
||||||
|
instance: string;
|
||||||
|
config: AuthenticationContext.Options;
|
||||||
|
callback: AuthenticationContext.TokenCallback;
|
||||||
|
popUp: boolean;
|
||||||
|
isAngular: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum for request type
|
||||||
|
*/
|
||||||
|
REQUEST_TYPE: AuthenticationContext.RequestType;
|
||||||
|
RESPONSE_TYPE: AuthenticationContext.ResponseType;
|
||||||
|
CONSTANTS: AuthenticationContext.Constants;
|
||||||
|
|
||||||
|
constructor(options: AuthenticationContext.Options);
|
||||||
|
/**
|
||||||
|
* Initiates the login process by redirecting the user to Azure AD authorization endpoint.
|
||||||
|
*/
|
||||||
|
login(): void;
|
||||||
|
/**
|
||||||
|
* Returns whether a login is in progress.
|
||||||
|
*/
|
||||||
|
loginInProgress(): boolean;
|
||||||
|
/**
|
||||||
|
* Gets token for the specified resource from the cache.
|
||||||
|
* @param resource A URI that identifies the resource for which the token is requested.
|
||||||
|
* @param tenantId tenant Id.
|
||||||
|
*/
|
||||||
|
getCachedToken(resource: string, tenantId: string): string;
|
||||||
|
/**
|
||||||
|
* If user object exists, returns it. Else creates a new user object by decoding `id_token` from the cache.
|
||||||
|
*/
|
||||||
|
getCachedUser(): AuthenticationContext.UserInfo;
|
||||||
|
/**
|
||||||
|
* Adds the passed callback to the array of callbacks for the specified resource.
|
||||||
|
* @param resource A URI that identifies the resource for which the token is requested.
|
||||||
|
* @param expectedState A unique identifier (guid).
|
||||||
|
* @param callback The callback provided by the caller. It will be called with token or error.
|
||||||
|
*/
|
||||||
|
registerCallback(
|
||||||
|
expectedState: string,
|
||||||
|
resource: string,
|
||||||
|
callback: AuthenticationContext.TokenCallback,
|
||||||
|
tenantId: string
|
||||||
|
): void;
|
||||||
|
/**
|
||||||
|
* Acquires token from the cache if it is not expired. Otherwise sends request to AAD to obtain a new token.
|
||||||
|
* @param resource Resource URI identifying the target resource.
|
||||||
|
* @param callback The callback provided by the caller. It will be called with token or error.
|
||||||
|
*/
|
||||||
|
acquireToken(resource: string, tenantId: string, callback: AuthenticationContext.TokenCallback): void;
|
||||||
|
/**
|
||||||
|
* Acquires token (interactive flow using a popup window) by sending request to AAD to obtain a new token.
|
||||||
|
* @param resource Resource URI identifying the target resource.
|
||||||
|
* @param extraQueryParameters Query parameters to add to the authentication request.
|
||||||
|
* @param claims Claims to add to the authentication request.
|
||||||
|
* @param callback The callback provided by the caller. It will be called with token or error.
|
||||||
|
*/
|
||||||
|
acquireTokenPopup(
|
||||||
|
resource: string,
|
||||||
|
tenantId: string,
|
||||||
|
extraQueryParameters: string | null | undefined,
|
||||||
|
claims: string | null | undefined,
|
||||||
|
callback: AuthenticationContext.TokenCallback
|
||||||
|
): void;
|
||||||
|
/**
|
||||||
|
* Acquires token (interactive flow using a redirect) by sending request to AAD to obtain a new token. In this case the callback passed in the authentication request constructor will be called.
|
||||||
|
* @param resource Resource URI identifying the target resource.
|
||||||
|
* @param extraQueryParameters Query parameters to add to the authentication request.
|
||||||
|
* @param claims Claims to add to the authentication request.
|
||||||
|
*/
|
||||||
|
acquireTokenRedirect(
|
||||||
|
resource: string,
|
||||||
|
tenantId: string,
|
||||||
|
extraQueryParameters?: string | null,
|
||||||
|
claims?: string | null
|
||||||
|
): void;
|
||||||
|
/**
|
||||||
|
* Redirects the browser to Azure AD authorization endpoint.
|
||||||
|
* @param urlNavigate URL of the authorization endpoint.
|
||||||
|
*/
|
||||||
|
promptUser(urlNavigate: string): void;
|
||||||
|
/**
|
||||||
|
* Clears cache items.
|
||||||
|
*/
|
||||||
|
clearCache(): void;
|
||||||
|
/**
|
||||||
|
* Clears cache items for a given resource.
|
||||||
|
* @param resource Resource URI identifying the target resource.
|
||||||
|
*/
|
||||||
|
clearCacheForResource(resource: string): void;
|
||||||
|
/**
|
||||||
|
* Redirects user to logout endpoint. After logout, it will redirect to `postLogoutRedirectUri` if added as a property on the config object.
|
||||||
|
*/
|
||||||
|
logOut(): void;
|
||||||
|
/**
|
||||||
|
* Calls the passed in callback with the user object or error message related to the user.
|
||||||
|
* @param callback The callback provided by the caller. It will be called with user or error.
|
||||||
|
*/
|
||||||
|
getUser(callback: AuthenticationContext.UserCallback): void;
|
||||||
|
/**
|
||||||
|
* Checks if the URL fragment contains access token, id token or error description.
|
||||||
|
* @param hash Hash passed from redirect page.
|
||||||
|
*/
|
||||||
|
isCallback(hash: string): boolean;
|
||||||
|
/**
|
||||||
|
* Gets login error.
|
||||||
|
*/
|
||||||
|
getLoginError(): string;
|
||||||
|
/**
|
||||||
|
* Creates a request info object from the URL fragment and returns it.
|
||||||
|
*/
|
||||||
|
getRequestInfo(hash: string): AuthenticationContext.RequestInfo;
|
||||||
|
/**
|
||||||
|
* Saves token or error received in the response from AAD in the cache. In case of `id_token`, it also creates the user object.
|
||||||
|
*/
|
||||||
|
saveTokenFromHash(requestInfo: AuthenticationContext.RequestInfo): void;
|
||||||
|
/**
|
||||||
|
* Gets resource for given endpoint if mapping is provided with config.
|
||||||
|
* @param endpoint Resource URI identifying the target resource.
|
||||||
|
*/
|
||||||
|
getResourceForEndpoint(resource: string): string;
|
||||||
|
/**
|
||||||
|
* This method must be called for processing the response received from AAD. It extracts the hash, processes the token or error, saves it in the cache and calls the callbacks with the result.
|
||||||
|
* @param hash Hash fragment of URL. Defaults to `window.location.hash`.
|
||||||
|
*/
|
||||||
|
handleWindowCallback(hash?: string): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the logging Level, constructs the log message and logs it. Users need to implement/override this method to turn on logging.
|
||||||
|
* @param level Level can be set 0, 1, 2 and 3 which turns on 'error', 'warning', 'info' or 'verbose' level logging respectively.
|
||||||
|
* @param message Message to log.
|
||||||
|
* @param error Error to log.
|
||||||
|
*/
|
||||||
|
log(level: AuthenticationContext.LoggingLevel, message: string, error: any): void;
|
||||||
|
/**
|
||||||
|
* Logs messages when logging level is set to 0.
|
||||||
|
* @param message Message to log.
|
||||||
|
* @param error Error to log.
|
||||||
|
*/
|
||||||
|
error(message: string, error: any): void;
|
||||||
|
/**
|
||||||
|
* Logs messages when logging level is set to 1.
|
||||||
|
* @param message Message to log.
|
||||||
|
*/
|
||||||
|
warn(message: string): void;
|
||||||
|
/**
|
||||||
|
* Logs messages when logging level is set to 2.
|
||||||
|
* @param message Message to log.
|
||||||
|
*/
|
||||||
|
info(message: string): void;
|
||||||
|
/**
|
||||||
|
* Logs messages when logging level is set to 3.
|
||||||
|
* @param message Message to log.
|
||||||
|
*/
|
||||||
|
verbose(message: string): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs Pii messages when Logging Level is set to 0 and window.piiLoggingEnabled is set to true.
|
||||||
|
* @param message Message to log.
|
||||||
|
* @param error Error to log.
|
||||||
|
*/
|
||||||
|
errorPii(message: string, error: any): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs Pii messages when Logging Level is set to 1 and window.piiLoggingEnabled is set to true.
|
||||||
|
* @param message Message to log.
|
||||||
|
*/
|
||||||
|
warnPii(message: string): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs messages when Logging Level is set to 2 and window.piiLoggingEnabled is set to true.
|
||||||
|
* @param message Message to log.
|
||||||
|
*/
|
||||||
|
infoPii(message: string): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs messages when Logging Level is set to 3 and window.piiLoggingEnabled is set to true.
|
||||||
|
* @param message Message to log.
|
||||||
|
*/
|
||||||
|
verbosePii(message: string): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare namespace AuthenticationContext {
|
||||||
|
function inject(config: Options): AuthenticationContext;
|
||||||
|
|
||||||
|
type LoggingLevel = 0 | 1 | 2 | 3;
|
||||||
|
|
||||||
|
type RequestType = "LOGIN" | "RENEW_TOKEN" | "UNKNOWN";
|
||||||
|
|
||||||
|
type ResponseType = "id_token token" | "token";
|
||||||
|
|
||||||
|
interface RequestInfo {
|
||||||
|
/**
|
||||||
|
* Object comprising of fields such as id_token/error, session_state, state, e.t.c.
|
||||||
|
*/
|
||||||
|
parameters: any;
|
||||||
|
/**
|
||||||
|
* Request type.
|
||||||
|
*/
|
||||||
|
requestType: RequestType;
|
||||||
|
/**
|
||||||
|
* Whether state is valid.
|
||||||
|
*/
|
||||||
|
stateMatch: boolean;
|
||||||
|
/**
|
||||||
|
* Unique guid used to match the response with the request.
|
||||||
|
*/
|
||||||
|
stateResponse: string;
|
||||||
|
/**
|
||||||
|
* Whether `requestType` contains `id_token`, `access_token` or error.
|
||||||
|
*/
|
||||||
|
valid: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UserInfo {
|
||||||
|
/**
|
||||||
|
* Username assigned from UPN or email.
|
||||||
|
*/
|
||||||
|
userName: string;
|
||||||
|
/**
|
||||||
|
* Properties parsed from `id_token`.
|
||||||
|
*/
|
||||||
|
profile: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
type TokenCallback = (errorDesc: string | null, token: string | null, error: any) => void;
|
||||||
|
|
||||||
|
type UserCallback = (errorDesc: string | null, user: UserInfo | null) => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration options for Authentication Context
|
||||||
|
*/
|
||||||
|
interface Options {
|
||||||
|
/**
|
||||||
|
* Client ID assigned to your app by Azure Active Directory.
|
||||||
|
*/
|
||||||
|
clientId: string;
|
||||||
|
/**
|
||||||
|
* Endpoint at which you expect to receive tokens.Defaults to `window.location.href`.
|
||||||
|
*/
|
||||||
|
redirectUri?: string;
|
||||||
|
/**
|
||||||
|
* Azure Active Directory instance. Defaults to `https://login.microsoftonline.com/`.
|
||||||
|
*/
|
||||||
|
instance?: string;
|
||||||
|
/**
|
||||||
|
* Your target tenant. Defaults to `common`.
|
||||||
|
*/
|
||||||
|
tenant?: string;
|
||||||
|
/**
|
||||||
|
* Query parameters to add to the authentication request.
|
||||||
|
*/
|
||||||
|
extraQueryParameter?: string;
|
||||||
|
/**
|
||||||
|
* Unique identifier used to map the request with the response. Defaults to RFC4122 version 4 guid (128 bits).
|
||||||
|
*/
|
||||||
|
correlationId?: string;
|
||||||
|
/**
|
||||||
|
* User defined function of handling the navigation to Azure AD authorization endpoint in case of login.
|
||||||
|
*/
|
||||||
|
displayCall?: (url: string) => void;
|
||||||
|
/**
|
||||||
|
* Set this to true to enable login in a popup winodow instead of a full redirect. Defaults to `false`.
|
||||||
|
*/
|
||||||
|
popUp?: boolean;
|
||||||
|
/**
|
||||||
|
* Set this to the resource to request on login. Defaults to `clientId`.
|
||||||
|
*/
|
||||||
|
loginResource?: string;
|
||||||
|
/**
|
||||||
|
* Set this to redirect the user to a custom login page.
|
||||||
|
*/
|
||||||
|
localLoginUrl?: string;
|
||||||
|
/**
|
||||||
|
* Redirects to start page after login. Defaults to `true`.
|
||||||
|
*/
|
||||||
|
navigateToLoginRequestUrl?: boolean;
|
||||||
|
/**
|
||||||
|
* Set this to redirect the user to a custom logout page.
|
||||||
|
*/
|
||||||
|
logOutUri?: string;
|
||||||
|
/**
|
||||||
|
* Redirects the user to postLogoutRedirectUri after logout. Defaults to `redirectUri`.
|
||||||
|
*/
|
||||||
|
postLogoutRedirectUri?: string;
|
||||||
|
/**
|
||||||
|
* Sets browser storage to either 'localStorage' or sessionStorage'. Defaults to `sessionStorage`.
|
||||||
|
*/
|
||||||
|
cacheLocation?: "localStorage" | "sessionStorage";
|
||||||
|
/**
|
||||||
|
* Array of keywords or URIs. Adal will attach a token to outgoing requests that have these keywords or URIs.
|
||||||
|
*/
|
||||||
|
endpoints?: { [resource: string]: string };
|
||||||
|
/**
|
||||||
|
* Array of keywords or URIs. Adal will not attach a token to outgoing requests that have these keywords or URIs.
|
||||||
|
*/
|
||||||
|
anonymousEndpoints?: string[];
|
||||||
|
/**
|
||||||
|
* If the cached token is about to be expired in the expireOffsetSeconds (in seconds), Adal will renew the token instead of using the cached token. Defaults to 300 seconds.
|
||||||
|
*/
|
||||||
|
expireOffsetSeconds?: number;
|
||||||
|
/**
|
||||||
|
* The number of milliseconds of inactivity before a token renewal response from AAD should be considered timed out. Defaults to 6 seconds.
|
||||||
|
*/
|
||||||
|
loadFrameTimeout?: number;
|
||||||
|
/**
|
||||||
|
* Callback to be invoked when a token is acquired.
|
||||||
|
*/
|
||||||
|
callback?: TokenCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LoggingConfig {
|
||||||
|
level: LoggingLevel;
|
||||||
|
log: (message: string) => void;
|
||||||
|
piiLoggingEnabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum for storage constants
|
||||||
|
*/
|
||||||
|
interface Constants {
|
||||||
|
ACCESS_TOKEN: "access_token";
|
||||||
|
EXPIRES_IN: "expires_in";
|
||||||
|
ID_TOKEN: "id_token";
|
||||||
|
ERROR_DESCRIPTION: "error_description";
|
||||||
|
SESSION_STATE: "session_state";
|
||||||
|
STORAGE: {
|
||||||
|
TOKEN_KEYS: "adal.token.keys";
|
||||||
|
ACCESS_TOKEN_KEY: "adal.access.token.key";
|
||||||
|
EXPIRATION_KEY: "adal.expiration.key";
|
||||||
|
STATE_LOGIN: "adal.state.login";
|
||||||
|
STATE_RENEW: "adal.state.renew";
|
||||||
|
NONCE_IDTOKEN: "adal.nonce.idtoken";
|
||||||
|
SESSION_STATE: "adal.session.state";
|
||||||
|
USERNAME: "adal.username";
|
||||||
|
IDTOKEN: "adal.idtoken";
|
||||||
|
ERROR: "adal.error";
|
||||||
|
ERROR_DESCRIPTION: "adal.error.description";
|
||||||
|
LOGIN_REQUEST: "adal.login.request";
|
||||||
|
LOGIN_ERROR: "adal.login.error";
|
||||||
|
RENEW_STATUS: "adal.token.renew.status";
|
||||||
|
};
|
||||||
|
RESOURCE_DELIMETER: "|";
|
||||||
|
LOADFRAME_TIMEOUT: "6000";
|
||||||
|
TOKEN_RENEW_STATUS_CANCELED: "Canceled";
|
||||||
|
TOKEN_RENEW_STATUS_COMPLETED: "Completed";
|
||||||
|
TOKEN_RENEW_STATUS_IN_PROGRESS: "In Progress";
|
||||||
|
LOGGING_LEVEL: {
|
||||||
|
ERROR: 0;
|
||||||
|
WARN: 1;
|
||||||
|
INFO: 2;
|
||||||
|
VERBOSE: 3;
|
||||||
|
};
|
||||||
|
LEVEL_STRING_MAP: {
|
||||||
|
0: "ERROR:";
|
||||||
|
1: "WARNING:";
|
||||||
|
2: "INFO:";
|
||||||
|
3: "VERBOSE:";
|
||||||
|
};
|
||||||
|
POPUP_WIDTH: 483;
|
||||||
|
POPUP_HEIGHT: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// declare global {
|
||||||
|
// interface Window {
|
||||||
|
// Logging: AuthenticationContext.LoggingConfig;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
@@ -44,6 +44,10 @@ describe("Component Registerer", () => {
|
|||||||
expect(ko.components.isRegistered("user-defined-function-tab")).toBe(true);
|
expect(ko.components.isRegistered("user-defined-function-tab")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should register settings-tab component", () => {
|
||||||
|
expect(ko.components.isRegistered("settings-tab")).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("should register settings-tab-v2 component", () => {
|
it("should register settings-tab-v2 component", () => {
|
||||||
expect(ko.components.isRegistered("settings-tab-v2")).toBe(true);
|
expect(ko.components.isRegistered("settings-tab-v2")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,11 +26,12 @@ ko.components.register("throughput-input-autopilot-v3", ThroughputInputComponent
|
|||||||
ko.components.register("tabs-manager", TabsManagerKOComponent());
|
ko.components.register("tabs-manager", TabsManagerKOComponent());
|
||||||
|
|
||||||
// Collection Tabs
|
// Collection Tabs
|
||||||
ko.components.register("documents-tab", new TabComponents.DocumentsTab());
|
ko.components.register("documents-tab", new TabComponents.MongoDocumentsTabV2());
|
||||||
ko.components.register("mongo-documents-tab", new TabComponents.MongoDocumentsTab());
|
ko.components.register("mongo-documents-tab", new TabComponents.MongoDocumentsTab());
|
||||||
ko.components.register("stored-procedure-tab", new TabComponents.StoredProcedureTab());
|
ko.components.register("stored-procedure-tab", new TabComponents.StoredProcedureTab());
|
||||||
ko.components.register("trigger-tab", new TabComponents.TriggerTab());
|
ko.components.register("trigger-tab", new TabComponents.TriggerTab());
|
||||||
ko.components.register("user-defined-function-tab", new TabComponents.UserDefinedFunctionTab());
|
ko.components.register("user-defined-function-tab", new TabComponents.UserDefinedFunctionTab());
|
||||||
|
ko.components.register("settings-tab", new TabComponents.SettingsTab());
|
||||||
ko.components.register("settings-tab-v2", new TabComponents.SettingsTabV2());
|
ko.components.register("settings-tab-v2", new TabComponents.SettingsTabV2());
|
||||||
ko.components.register("query-tab", new TabComponents.QueryTab());
|
ko.components.register("query-tab", new TabComponents.QueryTab());
|
||||||
ko.components.register("tables-query-tab", new TabComponents.QueryTablesTab());
|
ko.components.register("tables-query-tab", new TabComponents.QueryTablesTab());
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { shallow, mount } from "enzyme";
|
||||||
|
import { AccountSwitchComponent, AccountSwitchComponentProps } from "./AccountSwitchComponent";
|
||||||
|
import { AuthType } from "../../../AuthType";
|
||||||
|
import { DatabaseAccount, Subscription } from "../../../Contracts/DataModels";
|
||||||
|
import { AccountKind } from "../../../Common/Constants";
|
||||||
|
|
||||||
|
const createBlankProps = (): AccountSwitchComponentProps => {
|
||||||
|
return {
|
||||||
|
authType: null,
|
||||||
|
displayText: "",
|
||||||
|
accounts: [],
|
||||||
|
selectedAccountName: null,
|
||||||
|
isLoadingAccounts: false,
|
||||||
|
onAccountChange: jest.fn(),
|
||||||
|
subscriptions: [],
|
||||||
|
selectedSubscriptionId: null,
|
||||||
|
isLoadingSubscriptions: false,
|
||||||
|
onSubscriptionChange: jest.fn()
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const createBlankAccount = (): DatabaseAccount => {
|
||||||
|
return {
|
||||||
|
id: "",
|
||||||
|
kind: AccountKind.Default,
|
||||||
|
name: "",
|
||||||
|
properties: null,
|
||||||
|
location: "",
|
||||||
|
tags: null,
|
||||||
|
type: ""
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const createBlankSubscription = (): Subscription => {
|
||||||
|
return {
|
||||||
|
subscriptionId: "",
|
||||||
|
displayName: "",
|
||||||
|
authorizationSource: "",
|
||||||
|
state: "",
|
||||||
|
subscriptionPolicies: null,
|
||||||
|
tenantId: "",
|
||||||
|
uniqueDisplayName: ""
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const createFullProps = (): AccountSwitchComponentProps => {
|
||||||
|
const props = createBlankProps();
|
||||||
|
props.authType = AuthType.AAD;
|
||||||
|
const account1 = createBlankAccount();
|
||||||
|
account1.name = "account1";
|
||||||
|
const account2 = createBlankAccount();
|
||||||
|
account2.name = "account2";
|
||||||
|
const account3 = createBlankAccount();
|
||||||
|
account3.name = "superlongaccountnamestringtest";
|
||||||
|
props.accounts = [account1, account2, account3];
|
||||||
|
props.selectedAccountName = "account2";
|
||||||
|
|
||||||
|
const sub1 = createBlankSubscription();
|
||||||
|
sub1.displayName = "sub1";
|
||||||
|
sub1.subscriptionId = "a6062a74-5d53-4b20-9545-000b95f22297";
|
||||||
|
const sub2 = createBlankSubscription();
|
||||||
|
sub2.displayName = "subsubsubsubsubsubsub2";
|
||||||
|
sub2.subscriptionId = "b20b3e93-0185-4326-8a9c-d44bac276b6b";
|
||||||
|
props.subscriptions = [sub1, sub2];
|
||||||
|
props.selectedSubscriptionId = "a6062a74-5d53-4b20-9545-000b95f22297";
|
||||||
|
|
||||||
|
return props;
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("test render", () => {
|
||||||
|
it("renders no auth type -> handle error in code", () => {
|
||||||
|
const props = createBlankProps();
|
||||||
|
|
||||||
|
const wrapper = shallow(<AccountSwitchComponent {...props} />);
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Encrypted Token
|
||||||
|
it("renders auth security token, with selected account name", () => {
|
||||||
|
const props = createBlankProps();
|
||||||
|
props.authType = AuthType.EncryptedToken;
|
||||||
|
props.selectedAccountName = "testaccount";
|
||||||
|
|
||||||
|
const wrapper = shallow(<AccountSwitchComponent {...props} />);
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
// AAD
|
||||||
|
it("renders auth aad, with all information", () => {
|
||||||
|
const props = createFullProps();
|
||||||
|
const wrapper = shallow(<AccountSwitchComponent {...props} />);
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders auth aad all dropdown menus", () => {
|
||||||
|
const props = createFullProps();
|
||||||
|
const wrapper = mount(<AccountSwitchComponent {...props} />);
|
||||||
|
|
||||||
|
expect(wrapper.exists("div.accountSwitchContextualMenu")).toBe(false);
|
||||||
|
wrapper.find("button.accountSwitchButton").simulate("click");
|
||||||
|
expect(wrapper.exists("div.accountSwitchContextualMenu")).toBe(true);
|
||||||
|
|
||||||
|
expect(wrapper.exists("div.accountSwitchSubscriptionDropdown")).toBe(true);
|
||||||
|
wrapper.find("DropdownBase.accountSwitchSubscriptionDropdown").simulate("click");
|
||||||
|
// Click will dismiss the first contextual menu in enzyme. Need to dig deeper to achieve below test
|
||||||
|
|
||||||
|
// expect(wrapper.exists("div.accountSwitchSubscriptionDropdownMenu")).toBe(true);
|
||||||
|
// expect(wrapper.find("button.ms-Dropdown-item").length).toBe(2);
|
||||||
|
// wrapper.find("div.accountSwitchSubscriptionDropdown").simulate("click");
|
||||||
|
// expect(wrapper.exists("div.accountSwitchSubscriptionDropdownMenu")).toBe(false);
|
||||||
|
|
||||||
|
// expect(wrapper.exists("div.accountSwitchAccountDropdown")).toBe(true);
|
||||||
|
// wrapper.find("div.accountSwitchAccountDropdown").simulate("click");
|
||||||
|
// expect(wrapper.exists("div.accountSwitchAccountDropdownMenu")).toBe(true);
|
||||||
|
// expect(wrapper.find("button.ms-Dropdown-item").length).toBe(3);
|
||||||
|
// wrapper.find("div.accountSwitchAccountDropdown").simulate("click");
|
||||||
|
// expect(wrapper.exists("div.accountSwitchAccountDropdownMenu")).toBe(false);
|
||||||
|
|
||||||
|
// wrapper.find("button.accountSwitchButton").simulate("click");
|
||||||
|
// expect(wrapper.exists("div.accountSwitchContextualMenu")).toBe(false);
|
||||||
|
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// describe("test function", () => {
|
||||||
|
// it("switch subscription function", () => {
|
||||||
|
// const props = createFullProps();
|
||||||
|
// const wrapper = mount(<AccountSwitchComponent {...props} />);
|
||||||
|
|
||||||
|
// wrapper.find("button.accountSwitchButton").simulate("click");
|
||||||
|
// wrapper.find("div.accountSwitchSubscriptionDropdown").simulate("click");
|
||||||
|
// wrapper
|
||||||
|
// .find("button.ms-Dropdown-item")
|
||||||
|
// .at(1)
|
||||||
|
// .simulate("click");
|
||||||
|
// expect(props.onSubscriptionChange).toBeCalled();
|
||||||
|
// expect(props.onSubscriptionChange).toHaveBeenCalled();
|
||||||
|
|
||||||
|
// wrapper.unmount();
|
||||||
|
// });
|
||||||
|
|
||||||
|
// it("switch account", () => {
|
||||||
|
// const props = createFullProps();
|
||||||
|
// const wrapper = mount(<AccountSwitchComponent {...props} />);
|
||||||
|
|
||||||
|
// wrapper.find("button.accountSwitchButton").simulate("click");
|
||||||
|
// wrapper.find("div.accountSwitchAccountDropdown").simulate("click");
|
||||||
|
// wrapper
|
||||||
|
// .find("button.ms-Dropdown-item")
|
||||||
|
// .at(0)
|
||||||
|
// .simulate("click");
|
||||||
|
// expect(props.onAccountChange).toBeCalled();
|
||||||
|
// expect(props.onAccountChange).toHaveBeenCalled();
|
||||||
|
|
||||||
|
// wrapper.unmount();
|
||||||
|
// });
|
||||||
|
// });
|
||||||
177
src/Explorer/Controls/AccountSwitch/AccountSwitchComponent.tsx
Normal file
177
src/Explorer/Controls/AccountSwitch/AccountSwitchComponent.tsx
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
import { AuthType } from "../../../AuthType";
|
||||||
|
import { StyleConstants } from "../../../Common/Constants";
|
||||||
|
import { DatabaseAccount, Subscription } from "../../../Contracts/DataModels";
|
||||||
|
|
||||||
|
import * as React from "react";
|
||||||
|
import { DefaultButton, IButtonStyles, IButtonProps } from "office-ui-fabric-react/lib/Button";
|
||||||
|
import { IContextualMenuProps } from "office-ui-fabric-react/lib/ContextualMenu";
|
||||||
|
import { Dropdown, IDropdownOption, IDropdownProps } from "office-ui-fabric-react/lib/Dropdown";
|
||||||
|
|
||||||
|
export interface AccountSwitchComponentProps {
|
||||||
|
authType: AuthType;
|
||||||
|
selectedAccountName: string;
|
||||||
|
accounts: DatabaseAccount[];
|
||||||
|
isLoadingAccounts: boolean;
|
||||||
|
onAccountChange: (newAccount: DatabaseAccount) => void;
|
||||||
|
selectedSubscriptionId: string;
|
||||||
|
subscriptions: Subscription[];
|
||||||
|
isLoadingSubscriptions: boolean;
|
||||||
|
onSubscriptionChange: (newSubscription: Subscription) => void;
|
||||||
|
displayText?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AccountSwitchComponent extends React.Component<AccountSwitchComponentProps> {
|
||||||
|
public render(): JSX.Element {
|
||||||
|
return this.props.authType === AuthType.AAD ? this._renderSwitchDropDown() : this._renderAccountName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _renderSwitchDropDown(): JSX.Element {
|
||||||
|
const { displayText, selectedAccountName } = this.props;
|
||||||
|
|
||||||
|
const menuProps: IContextualMenuProps = {
|
||||||
|
directionalHintFixed: true,
|
||||||
|
className: "accountSwitchContextualMenu",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
key: "switchSubscription",
|
||||||
|
onRender: this._renderSubscriptionDropdown.bind(this)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "switchAccount",
|
||||||
|
onRender: this._renderAccountDropDown.bind(this)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonStyles: IButtonStyles = {
|
||||||
|
root: {
|
||||||
|
fontSize: StyleConstants.DefaultFontSize,
|
||||||
|
height: 40,
|
||||||
|
padding: 0,
|
||||||
|
paddingLeft: 10,
|
||||||
|
marginRight: 5,
|
||||||
|
backgroundColor: StyleConstants.BaseDark,
|
||||||
|
color: StyleConstants.BaseLight
|
||||||
|
},
|
||||||
|
rootHovered: {
|
||||||
|
backgroundColor: StyleConstants.BaseHigh,
|
||||||
|
color: StyleConstants.BaseLight
|
||||||
|
},
|
||||||
|
rootFocused: {
|
||||||
|
backgroundColor: StyleConstants.BaseHigh,
|
||||||
|
color: StyleConstants.BaseLight
|
||||||
|
},
|
||||||
|
rootPressed: {
|
||||||
|
backgroundColor: StyleConstants.BaseHigh,
|
||||||
|
color: StyleConstants.BaseLight
|
||||||
|
},
|
||||||
|
rootExpanded: {
|
||||||
|
backgroundColor: StyleConstants.BaseHigh,
|
||||||
|
color: StyleConstants.BaseLight
|
||||||
|
},
|
||||||
|
textContainer: {
|
||||||
|
flexGrow: "initial"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonProps: IButtonProps = {
|
||||||
|
text: displayText || selectedAccountName,
|
||||||
|
menuProps: menuProps,
|
||||||
|
styles: buttonStyles,
|
||||||
|
className: "accountSwitchButton",
|
||||||
|
id: "accountSwitchButton"
|
||||||
|
};
|
||||||
|
|
||||||
|
return <DefaultButton {...buttonProps} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _renderSubscriptionDropdown(): JSX.Element {
|
||||||
|
const { subscriptions, selectedSubscriptionId, isLoadingSubscriptions } = this.props;
|
||||||
|
const options: IDropdownOption[] = subscriptions.map(sub => {
|
||||||
|
return {
|
||||||
|
key: sub.subscriptionId,
|
||||||
|
text: sub.displayName,
|
||||||
|
data: sub
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const placeHolderText = isLoadingSubscriptions
|
||||||
|
? "Loading subscriptions"
|
||||||
|
: !options || !options.length
|
||||||
|
? "No subscriptions found in current directory"
|
||||||
|
: "Select subscription from list";
|
||||||
|
|
||||||
|
const dropdownProps: IDropdownProps = {
|
||||||
|
label: "Subscription",
|
||||||
|
className: "accountSwitchSubscriptionDropdown",
|
||||||
|
options: options,
|
||||||
|
onChange: this._onSubscriptionDropdownChange,
|
||||||
|
defaultSelectedKey: selectedSubscriptionId,
|
||||||
|
placeholder: placeHolderText,
|
||||||
|
styles: {
|
||||||
|
callout: "accountSwitchSubscriptionDropdownMenu"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return <Dropdown {...dropdownProps} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onSubscriptionDropdownChange = (e: React.FormEvent<HTMLDivElement>, option: IDropdownOption): void => {
|
||||||
|
if (!option) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.props.onSubscriptionChange(option.data);
|
||||||
|
};
|
||||||
|
|
||||||
|
private _renderAccountDropDown(): JSX.Element {
|
||||||
|
const { accounts, selectedAccountName, isLoadingAccounts } = this.props;
|
||||||
|
const options: IDropdownOption[] = accounts.map(account => {
|
||||||
|
return {
|
||||||
|
key: account.name,
|
||||||
|
text: account.name,
|
||||||
|
data: account
|
||||||
|
};
|
||||||
|
});
|
||||||
|
// Fabric UI will also try to select the first non-disabled option from dropdown.
|
||||||
|
// Add a option to prevent pop the message when user click on dropdown on first time.
|
||||||
|
options.unshift({
|
||||||
|
key: "select from list",
|
||||||
|
text: "Select Cosmos DB account from list",
|
||||||
|
data: undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
const placeHolderText = isLoadingAccounts
|
||||||
|
? "Loading Cosmos DB accounts"
|
||||||
|
: !options || !options.length
|
||||||
|
? "No Cosmos DB accounts found"
|
||||||
|
: "Select Cosmos DB account from list";
|
||||||
|
|
||||||
|
const dropdownProps: IDropdownProps = {
|
||||||
|
label: "Cosmos DB Account Name",
|
||||||
|
className: "accountSwitchAccountDropdown",
|
||||||
|
options: options,
|
||||||
|
onChange: this._onAccountDropdownChange,
|
||||||
|
defaultSelectedKey: selectedAccountName,
|
||||||
|
placeholder: placeHolderText,
|
||||||
|
styles: {
|
||||||
|
callout: "accountSwitchAccountDropdownMenu"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return <Dropdown {...dropdownProps} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onAccountDropdownChange = (e: React.FormEvent<HTMLDivElement>, option: IDropdownOption): void => {
|
||||||
|
if (!option) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.props.onAccountChange(option.data);
|
||||||
|
};
|
||||||
|
|
||||||
|
private _renderAccountName(): JSX.Element {
|
||||||
|
const { displayText, selectedAccountName } = this.props;
|
||||||
|
return <span className="accountNameHeader">{displayText || selectedAccountName}</span>;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import { ReactAdapter } from "../../../Bindings/ReactBindingHandler";
|
||||||
|
import { AccountSwitchComponent, AccountSwitchComponentProps } from "./AccountSwitchComponent";
|
||||||
|
|
||||||
|
export class AccountSwitchComponentAdapter implements ReactAdapter {
|
||||||
|
public parameters: ko.Observable<AccountSwitchComponentProps>;
|
||||||
|
|
||||||
|
public renderComponent(): JSX.Element {
|
||||||
|
return <AccountSwitchComponent {...this.parameters()} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`test render renders auth aad, with all information 1`] = `
|
||||||
|
<CustomizedDefaultButton
|
||||||
|
className="accountSwitchButton"
|
||||||
|
id="accountSwitchButton"
|
||||||
|
menuProps={
|
||||||
|
Object {
|
||||||
|
"className": "accountSwitchContextualMenu",
|
||||||
|
"directionalHintFixed": true,
|
||||||
|
"items": Array [
|
||||||
|
Object {
|
||||||
|
"key": "switchSubscription",
|
||||||
|
"onRender": [Function],
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"key": "switchAccount",
|
||||||
|
"onRender": [Function],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
styles={
|
||||||
|
Object {
|
||||||
|
"root": Object {
|
||||||
|
"backgroundColor": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
"fontSize": undefined,
|
||||||
|
"height": 40,
|
||||||
|
"marginRight": 5,
|
||||||
|
"padding": 0,
|
||||||
|
"paddingLeft": 10,
|
||||||
|
},
|
||||||
|
"rootExpanded": Object {
|
||||||
|
"backgroundColor": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
},
|
||||||
|
"rootFocused": Object {
|
||||||
|
"backgroundColor": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
},
|
||||||
|
"rootHovered": Object {
|
||||||
|
"backgroundColor": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
},
|
||||||
|
"rootPressed": Object {
|
||||||
|
"backgroundColor": undefined,
|
||||||
|
"color": undefined,
|
||||||
|
},
|
||||||
|
"textContainer": Object {
|
||||||
|
"flexGrow": "initial",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text="account2"
|
||||||
|
/>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`test render renders auth security token, with selected account name 1`] = `
|
||||||
|
<span
|
||||||
|
className="accountNameHeader"
|
||||||
|
>
|
||||||
|
testaccount
|
||||||
|
</span>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`test render renders no auth type -> handle error in code 1`] = `
|
||||||
|
<span
|
||||||
|
className="accountNameHeader"
|
||||||
|
/>
|
||||||
|
`;
|
||||||
@@ -38,7 +38,7 @@ export interface CommandButtonComponentProps {
|
|||||||
/**
|
/**
|
||||||
* Label for the button
|
* Label for the button
|
||||||
*/
|
*/
|
||||||
commandButtonLabel?: string;
|
commandButtonLabel: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if this button opens a tab or pane, false otherwise.
|
* True if this button opens a tab or pane, false otherwise.
|
||||||
|
|||||||
@@ -44,10 +44,12 @@ export const FeaturePanelComponent: React.FunctionComponent = () => {
|
|||||||
onChange?: (_?: React.FormEvent<HTMLElement | HTMLInputElement>, checked?: boolean) => void;
|
onChange?: (_?: React.FormEvent<HTMLElement | HTMLInputElement>, checked?: boolean) => void;
|
||||||
}[] = [
|
}[] = [
|
||||||
{ key: "feature.enablechangefeedpolicy", label: "Enable change feed policy", value: "true" },
|
{ key: "feature.enablechangefeedpolicy", label: "Enable change feed policy", value: "true" },
|
||||||
|
{ key: "feature.enablerupm", label: "Enable RUPM", value: "true" },
|
||||||
{ key: "feature.dataexplorerexecutesproc", label: "Execute stored procedure", value: "true" },
|
{ key: "feature.dataexplorerexecutesproc", label: "Execute stored procedure", value: "true" },
|
||||||
{ key: "feature.hosteddataexplorerenabled", label: "Hosted Data Explorer (deprecated?)", value: "true" },
|
{ key: "feature.hosteddataexplorerenabled", label: "Hosted Data Explorer (deprecated?)", value: "true" },
|
||||||
{ key: "feature.enablettl", label: "Enable TTL", value: "true" },
|
{ key: "feature.enablettl", label: "Enable TTL", value: "true" },
|
||||||
{ key: "feature.enablegallerypublish", label: "Enable Notebook Gallery Publishing", value: "true" },
|
{ key: "feature.enablegallerypublish", label: "Enable Notebook Gallery Publishing", value: "true" },
|
||||||
|
{ key: "feature.enablecodeofconduct", label: "Enable Code Of Conduct Acknowledgement", value: "true" },
|
||||||
{
|
{
|
||||||
key: "feature.enableLinkInjection",
|
key: "feature.enableLinkInjection",
|
||||||
label: "Enable Injecting Notebook Viewer Link into the first cell",
|
label: "Enable Injecting Notebook Viewer Link into the first cell",
|
||||||
|
|||||||
@@ -131,6 +131,12 @@ exports[`Feature panel renders all flags 1`] = `
|
|||||||
label="Enable change feed policy"
|
label="Enable change feed policy"
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
/>
|
/>
|
||||||
|
<StyledCheckboxBase
|
||||||
|
checked={false}
|
||||||
|
key="feature.enablerupm"
|
||||||
|
label="Enable RUPM"
|
||||||
|
onChange={[Function]}
|
||||||
|
/>
|
||||||
<StyledCheckboxBase
|
<StyledCheckboxBase
|
||||||
checked={false}
|
checked={false}
|
||||||
key="feature.dataexplorerexecutesproc"
|
key="feature.dataexplorerexecutesproc"
|
||||||
@@ -157,14 +163,14 @@ exports[`Feature panel renders all flags 1`] = `
|
|||||||
/>
|
/>
|
||||||
<StyledCheckboxBase
|
<StyledCheckboxBase
|
||||||
checked={false}
|
checked={false}
|
||||||
key="feature.enableLinkInjection"
|
key="feature.enablecodeofconduct"
|
||||||
label="Enable Injecting Notebook Viewer Link into the first cell"
|
label="Enable Code Of Conduct Acknowledgement"
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
/>
|
/>
|
||||||
<StyledCheckboxBase
|
<StyledCheckboxBase
|
||||||
checked={false}
|
checked={false}
|
||||||
key="feature.canexceedmaximumvalue"
|
key="feature.enableLinkInjection"
|
||||||
label="Can exceed max value"
|
label="Enable Injecting Notebook Viewer Link into the first cell"
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -172,6 +178,12 @@ exports[`Feature panel renders all flags 1`] = `
|
|||||||
className="checkboxRow"
|
className="checkboxRow"
|
||||||
horizontalAlign="space-between"
|
horizontalAlign="space-between"
|
||||||
>
|
>
|
||||||
|
<StyledCheckboxBase
|
||||||
|
checked={false}
|
||||||
|
key="feature.canexceedmaximumvalue"
|
||||||
|
label="Can exceed max value"
|
||||||
|
onChange={[Function]}
|
||||||
|
/>
|
||||||
<StyledCheckboxBase
|
<StyledCheckboxBase
|
||||||
checked={false}
|
checked={false}
|
||||||
key="feature.enablefixedcollectionwithsharedthroughput"
|
key="feature.enablefixedcollectionwithsharedthroughput"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Dropdown,
|
Dropdown,
|
||||||
FocusZone,
|
FocusZone,
|
||||||
FontIcon,
|
|
||||||
FontWeights,
|
FontWeights,
|
||||||
IDropdownOption,
|
IDropdownOption,
|
||||||
IPageSpecification,
|
IPageSpecification,
|
||||||
@@ -17,7 +16,7 @@ import {
|
|||||||
Text
|
Text
|
||||||
} from "office-ui-fabric-react";
|
} from "office-ui-fabric-react";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { IGalleryItem, IJunoResponse, IPublicGalleryData, JunoClient } from "../../../Juno/JunoClient";
|
import { IGalleryItem, JunoClient, IJunoResponse, IPublicGalleryData } from "../../../Juno/JunoClient";
|
||||||
import * as GalleryUtils from "../../../Utils/GalleryUtils";
|
import * as GalleryUtils from "../../../Utils/GalleryUtils";
|
||||||
import { DialogComponent, DialogProps } from "../DialogReactComponent/DialogComponent";
|
import { DialogComponent, DialogProps } from "../DialogReactComponent/DialogComponent";
|
||||||
import { GalleryCardComponent, GalleryCardComponentProps } from "./Cards/GalleryCardComponent";
|
import { GalleryCardComponent, GalleryCardComponentProps } from "./Cards/GalleryCardComponent";
|
||||||
@@ -137,7 +136,7 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
|
|||||||
}
|
}
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
const tabs: GalleryTabInfo[] = [this.createSamplesTab(GalleryTab.OfficialSamples, this.state.sampleNotebooks)];
|
const tabs: GalleryTabInfo[] = [this.createTab(GalleryTab.OfficialSamples, this.state.sampleNotebooks)];
|
||||||
|
|
||||||
if (this.props.container?.isGalleryPublishEnabled()) {
|
if (this.props.container?.isGalleryPublishEnabled()) {
|
||||||
tabs.push(
|
tabs.push(
|
||||||
@@ -147,7 +146,7 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
|
|||||||
this.state.isCodeOfConductAccepted
|
this.state.isCodeOfConductAccepted
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
tabs.push(this.createFavoritesTab(GalleryTab.Favorites, this.state.favoriteNotebooks));
|
tabs.push(this.createTab(GalleryTab.Favorites, this.state.favoriteNotebooks));
|
||||||
|
|
||||||
// explicitly checking if isCodeOfConductAccepted is not false, as it is initially undefined.
|
// explicitly checking if isCodeOfConductAccepted is not false, as it is initially undefined.
|
||||||
// Displaying code of conduct component on gallery load should not be the default behavior.
|
// Displaying code of conduct component on gallery load should not be the default behavior.
|
||||||
@@ -184,27 +183,6 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private isEmptyData = (data: IGalleryItem[]): boolean => {
|
|
||||||
return !data || data.length === 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
private createEmptyTabContent = (iconName: string, line1: string, line2: string): JSX.Element => {
|
|
||||||
return (
|
|
||||||
<Stack horizontalAlign="center" tokens={{ childrenGap: 10 }}>
|
|
||||||
<FontIcon iconName={iconName} style={{ fontSize: 100, color: "lightgray", marginTop: 20 }} />
|
|
||||||
<Text styles={{ root: { fontWeight: FontWeights.semibold } }}>{line1}</Text>
|
|
||||||
<Text>{line2}</Text>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
private createSamplesTab = (tab: GalleryTab, data: IGalleryItem[]): GalleryTabInfo => {
|
|
||||||
return {
|
|
||||||
tab,
|
|
||||||
content: this.createSearchBarHeader(this.createCardsTabContent(data))
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
private createPublicGalleryTab(
|
private createPublicGalleryTab(
|
||||||
tab: GalleryTab,
|
tab: GalleryTab,
|
||||||
data: IGalleryItem[],
|
data: IGalleryItem[],
|
||||||
@@ -216,29 +194,17 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private createFavoritesTab(tab: GalleryTab, data: IGalleryItem[]): GalleryTabInfo {
|
private createTab(tab: GalleryTab, data: IGalleryItem[]): GalleryTabInfo {
|
||||||
return {
|
return {
|
||||||
tab,
|
tab,
|
||||||
content: this.isEmptyData(data)
|
content: this.createSearchBarHeader(this.createCardsTabContent(data))
|
||||||
? this.createEmptyTabContent(
|
|
||||||
"ContactHeart",
|
|
||||||
"You have not liked anything",
|
|
||||||
"Like any notebook from Official Samples or Public gallery"
|
|
||||||
)
|
|
||||||
: this.createSearchBarHeader(this.createCardsTabContent(data))
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private createPublishedNotebooksTab = (tab: GalleryTab, data: IGalleryItem[]): GalleryTabInfo => {
|
private createPublishedNotebooksTab = (tab: GalleryTab, data: IGalleryItem[]): GalleryTabInfo => {
|
||||||
return {
|
return {
|
||||||
tab,
|
tab,
|
||||||
content: this.isEmptyData(data)
|
content: this.createPublishedNotebooksTabContent(data)
|
||||||
? this.createEmptyTabContent(
|
|
||||||
"Contact",
|
|
||||||
"You have not published anything",
|
|
||||||
"Publish your sample notebooks to share your published work with others"
|
|
||||||
)
|
|
||||||
: this.createPublishedNotebooksTabContent(data)
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -398,9 +364,9 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
|
|||||||
private async loadPublicNotebooks(searchText: string, sortBy: SortBy, offline: boolean): Promise<void> {
|
private async loadPublicNotebooks(searchText: string, sortBy: SortBy, offline: boolean): Promise<void> {
|
||||||
if (!offline) {
|
if (!offline) {
|
||||||
try {
|
try {
|
||||||
let response: IJunoResponse<IGalleryItem[]> | IJunoResponse<IPublicGalleryData>;
|
let response: IJunoResponse<IPublicGalleryData> | IJunoResponse<IGalleryItem[]>;
|
||||||
if (this.props.container) {
|
if (this.props.container.isCodeOfConductEnabled()) {
|
||||||
response = await this.props.junoClient.getPublicGalleryData();
|
response = await this.props.junoClient.fetchPublicNotebooks();
|
||||||
this.isCodeOfConductAccepted = response.data?.metadata.acceptedCodeOfConduct;
|
this.isCodeOfConductAccepted = response.data?.metadata.acceptedCodeOfConduct;
|
||||||
this.publicNotebooks = response.data?.notebooksData;
|
this.publicNotebooks = response.data?.notebooksData;
|
||||||
} else {
|
} else {
|
||||||
@@ -602,7 +568,7 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
|
|||||||
|
|
||||||
private deleteItem = async (data: IGalleryItem): Promise<void> => {
|
private deleteItem = async (data: IGalleryItem): Promise<void> => {
|
||||||
GalleryUtils.deleteItem(this.props.container, this.props.junoClient, data, item => {
|
GalleryUtils.deleteItem(this.props.container, this.props.junoClient, data, item => {
|
||||||
this.publishedNotebooks = this.publishedNotebooks?.filter(notebook => item.id !== notebook.id);
|
this.publishedNotebooks = this.publishedNotebooks.filter(notebook => item.id !== notebook.id);
|
||||||
this.refreshSelectedTab(item);
|
this.refreshSelectedTab(item);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -89,12 +89,12 @@ describe("SettingsComponent", () => {
|
|||||||
it("auto pilot helper functions pass on correct value", () => {
|
it("auto pilot helper functions pass on correct value", () => {
|
||||||
const newCollection = { ...collection };
|
const newCollection = { ...collection };
|
||||||
newCollection.offer = ko.observable<DataModels.Offer>({
|
newCollection.offer = ko.observable<DataModels.Offer>({
|
||||||
autoscaleMaxThroughput: 10000,
|
content: {
|
||||||
manualThroughput: undefined,
|
offerAutopilotSettings: {
|
||||||
minimumThroughput: 400,
|
maxThroughput: 10000
|
||||||
id: "test",
|
}
|
||||||
offerReplacePending: false
|
}
|
||||||
});
|
} as DataModels.Offer);
|
||||||
|
|
||||||
const props = { ...baseProps };
|
const props = { ...baseProps };
|
||||||
props.settingsTab.collection = newCollection;
|
props.settingsTab.collection = newCollection;
|
||||||
@@ -187,6 +187,21 @@ describe("SettingsComponent", () => {
|
|||||||
expect(settingsComponentInstance.hasConflictResolution()).toEqual(true);
|
expect(settingsComponentInstance.hasConflictResolution()).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("isOfferReplacePending", () => {
|
||||||
|
let settingsComponentInstance = new SettingsComponent(baseProps);
|
||||||
|
expect(settingsComponentInstance.isOfferReplacePending()).toEqual(undefined);
|
||||||
|
|
||||||
|
const newCollection = { ...collection };
|
||||||
|
newCollection.offer = ko.observable({
|
||||||
|
headers: { "x-ms-offer-replace-pending": true }
|
||||||
|
} as DataModels.OfferWithHeaders);
|
||||||
|
const props = { ...baseProps };
|
||||||
|
props.settingsTab.collection = newCollection;
|
||||||
|
|
||||||
|
settingsComponentInstance = new SettingsComponent(props);
|
||||||
|
expect(settingsComponentInstance.isOfferReplacePending()).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("save calls updateCollection, updateMongoDBCollectionThroughRP and updateOffer", async () => {
|
it("save calls updateCollection, updateMongoDBCollectionThroughRP and updateOffer", async () => {
|
||||||
const wrapper = shallow(<SettingsComponent {...baseProps} />);
|
const wrapper = shallow(<SettingsComponent {...baseProps} />);
|
||||||
wrapper.setState({ isSubSettingsSaveable: true, isScaleSaveable: true, isMongoIndexingPolicySaveable: true });
|
wrapper.setState({ isSubSettingsSaveable: true, isScaleSaveable: true, isMongoIndexingPolicySaveable: true });
|
||||||
|
|||||||
@@ -2,23 +2,28 @@ import * as React from "react";
|
|||||||
import * as AutoPilotUtils from "../../../Utils/AutoPilotUtils";
|
import * as AutoPilotUtils from "../../../Utils/AutoPilotUtils";
|
||||||
import * as Constants from "../../../Common/Constants";
|
import * as Constants from "../../../Common/Constants";
|
||||||
import * as DataModels from "../../../Contracts/DataModels";
|
import * as DataModels from "../../../Contracts/DataModels";
|
||||||
|
import * as SharedConstants from "../../../Shared/Constants";
|
||||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import DiscardIcon from "../../../../images/discard.svg";
|
import DiscardIcon from "../../../../images/discard.svg";
|
||||||
import SaveIcon from "../../../../images/save-cosmos.svg";
|
import SaveIcon from "../../../../images/save-cosmos.svg";
|
||||||
import { traceStart, traceFailure, traceSuccess, trace } from "../../../Shared/Telemetry/TelemetryProcessor";
|
import { traceStart, traceFailure, traceSuccess, trace } from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||||
|
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||||
import Explorer from "../../Explorer";
|
import Explorer from "../../Explorer";
|
||||||
import { updateOffer } from "../../../Common/dataAccess/updateOffer";
|
import { updateOffer } from "../../../Common/dataAccess/updateOffer";
|
||||||
import { updateCollection, updateMongoDBCollectionThroughRP } from "../../../Common/dataAccess/updateCollection";
|
import { updateCollection, updateMongoDBCollectionThroughRP } from "../../../Common/dataAccess/updateCollection";
|
||||||
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
import { CommandButtonComponentProps } from "../../Controls/CommandButton/CommandButtonComponent";
|
||||||
|
import { userContext } from "../../../UserContext";
|
||||||
|
import { updateOfferThroughputBeyondLimit } from "../../../Common/dataAccess/updateOfferThroughputBeyondLimit";
|
||||||
import SettingsTab from "../../Tabs/SettingsTabV2";
|
import SettingsTab from "../../Tabs/SettingsTabV2";
|
||||||
import { mongoIndexingPolicyAADError } from "./SettingsRenderUtils";
|
import { throughputUnit } from "./SettingsRenderUtils";
|
||||||
import { ScaleComponent, ScaleComponentProps } from "./SettingsSubComponents/ScaleComponent";
|
import { ScaleComponent, ScaleComponentProps } from "./SettingsSubComponents/ScaleComponent";
|
||||||
import {
|
import {
|
||||||
MongoIndexingPolicyComponent,
|
MongoIndexingPolicyComponent,
|
||||||
MongoIndexingPolicyComponentProps
|
MongoIndexingPolicyComponentProps
|
||||||
} from "./SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent";
|
} from "./SettingsSubComponents/MongoIndexingPolicy/MongoIndexingPolicyComponent";
|
||||||
import {
|
import {
|
||||||
|
getMaxRUs,
|
||||||
hasDatabaseSharedThroughput,
|
hasDatabaseSharedThroughput,
|
||||||
GeospatialConfigType,
|
GeospatialConfigType,
|
||||||
TtlType,
|
TtlType,
|
||||||
@@ -44,7 +49,6 @@ import { MongoDBCollectionResource, MongoIndex } from "../../../Utils/arm/genera
|
|||||||
import { readMongoDBCollectionThroughRP } from "../../../Common/dataAccess/readMongoDBCollection";
|
import { readMongoDBCollectionThroughRP } from "../../../Common/dataAccess/readMongoDBCollection";
|
||||||
import { getIndexTransformationProgress } from "../../../Common/dataAccess/getIndexTransformationProgress";
|
import { getIndexTransformationProgress } from "../../../Common/dataAccess/getIndexTransformationProgress";
|
||||||
import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUtils";
|
import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUtils";
|
||||||
import { isEmpty } from "underscore";
|
|
||||||
|
|
||||||
interface SettingsV2TabInfo {
|
interface SettingsV2TabInfo {
|
||||||
tab: SettingsV2TabTypes;
|
tab: SettingsV2TabTypes;
|
||||||
@@ -223,6 +227,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
|
|
||||||
public loadMongoIndexes = async (): Promise<void> => {
|
public loadMongoIndexes = async (): Promise<void> => {
|
||||||
if (
|
if (
|
||||||
|
this.container.isMongoIndexEditorEnabled() &&
|
||||||
this.container.isPreferredApiMongoDB() &&
|
this.container.isPreferredApiMongoDB() &&
|
||||||
this.container.isEnableMongoCapabilityPresent() &&
|
this.container.isEnableMongoCapabilityPresent() &&
|
||||||
this.container.databaseAccount()
|
this.container.databaseAccount()
|
||||||
@@ -270,14 +275,19 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
};
|
};
|
||||||
|
|
||||||
private setAutoPilotStates = (): void => {
|
private setAutoPilotStates = (): void => {
|
||||||
const autoscaleMaxThroughput = this.collection?.offer()?.autoscaleMaxThroughput;
|
const offer = this.collection?.offer && this.collection.offer();
|
||||||
|
const offerAutopilotSettings = offer?.content?.offerAutopilotSettings;
|
||||||
|
|
||||||
if (autoscaleMaxThroughput && AutoPilotUtils.isValidAutoPilotThroughput(autoscaleMaxThroughput)) {
|
if (
|
||||||
|
offerAutopilotSettings &&
|
||||||
|
offerAutopilotSettings.maxThroughput &&
|
||||||
|
AutoPilotUtils.isValidAutoPilotThroughput(offerAutopilotSettings.maxThroughput)
|
||||||
|
) {
|
||||||
this.setState({
|
this.setState({
|
||||||
isAutoPilotSelected: true,
|
isAutoPilotSelected: true,
|
||||||
wasAutopilotOriginallySet: true,
|
wasAutopilotOriginallySet: true,
|
||||||
autoPilotThroughput: autoscaleMaxThroughput,
|
autoPilotThroughput: offerAutopilotSettings.maxThroughput,
|
||||||
autoPilotThroughputBaseline: autoscaleMaxThroughput
|
autoPilotThroughputBaseline: offerAutopilotSettings.maxThroughput
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -295,7 +305,12 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
!!this.collection.conflictResolutionPolicy();
|
!!this.collection.conflictResolutionPolicy();
|
||||||
|
|
||||||
public isOfferReplacePending = (): boolean => {
|
public isOfferReplacePending = (): boolean => {
|
||||||
return this.collection?.offer()?.offerReplacePending;
|
const offer = this.collection?.offer && this.collection.offer();
|
||||||
|
return (
|
||||||
|
offer &&
|
||||||
|
Object.keys(offer).find(value => value === "headers") &&
|
||||||
|
!!(offer as DataModels.OfferWithHeaders).headers[Constants.HttpHeaders.offerReplacePending]
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
public onSaveClick = async (): Promise<void> => {
|
public onSaveClick = async (): Promise<void> => {
|
||||||
@@ -433,33 +448,102 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.isScaleSaveable) {
|
if (this.state.isScaleSaveable) {
|
||||||
const updateOfferParams: DataModels.UpdateOfferParams = {
|
const newThroughput = this.state.throughput;
|
||||||
databaseId: this.collection.databaseId,
|
const newOffer: DataModels.Offer = { ...this.collection.offer() };
|
||||||
collectionId: this.collection.id(),
|
const originalThroughputValue: number = this.state.throughput;
|
||||||
currentOffer: this.collection.offer(),
|
|
||||||
autopilotThroughput: this.state.isAutoPilotSelected ? this.state.autoPilotThroughput : undefined,
|
if (newOffer.content) {
|
||||||
manualThroughput: this.state.isAutoPilotSelected ? undefined : this.state.throughput
|
newOffer.content.offerThroughput = newThroughput;
|
||||||
};
|
} else {
|
||||||
if (this.hasProvisioningTypeChanged()) {
|
newOffer.content = {
|
||||||
if (this.state.isAutoPilotSelected) {
|
offerThroughput: newThroughput,
|
||||||
updateOfferParams.migrateToAutoPilot = true;
|
offerIsRUPerMinuteThroughputEnabled: false
|
||||||
} else {
|
};
|
||||||
updateOfferParams.migrateToManual = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams);
|
|
||||||
this.collection.offer(updatedOffer);
|
const headerOptions: RequestOptions = { initialHeaders: {} };
|
||||||
this.setState({ isScaleSaveable: false, isScaleDiscardable: false });
|
|
||||||
if (this.state.isAutoPilotSelected) {
|
if (this.state.isAutoPilotSelected) {
|
||||||
this.setState({
|
newOffer.content.offerAutopilotSettings = {
|
||||||
autoPilotThroughput: updatedOffer.autoscaleMaxThroughput,
|
maxThroughput: this.state.autoPilotThroughput
|
||||||
autoPilotThroughputBaseline: updatedOffer.autoscaleMaxThroughput
|
};
|
||||||
});
|
|
||||||
|
// user has changed from provisioned --> autoscale
|
||||||
|
if (this.hasProvisioningTypeChanged()) {
|
||||||
|
headerOptions.initialHeaders[Constants.HttpHeaders.migrateOfferToAutopilot] = "true";
|
||||||
|
delete newOffer.content.offerAutopilotSettings;
|
||||||
|
} else {
|
||||||
|
delete newOffer.content.offerThroughput;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
throughput: updatedOffer.manualThroughput,
|
isAutoPilotSelected: false
|
||||||
throughputBaseline: updatedOffer.manualThroughput
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// user has changed from autoscale --> provisioned
|
||||||
|
if (this.hasProvisioningTypeChanged()) {
|
||||||
|
headerOptions.initialHeaders[Constants.HttpHeaders.migrateOfferToManualThroughput] = "true";
|
||||||
|
} else {
|
||||||
|
delete newOffer.content.offerAutopilotSettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
getMaxRUs(this.collection, this.container) <=
|
||||||
|
SharedConstants.CollectionCreation.DefaultCollectionRUs1Million &&
|
||||||
|
newThroughput > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million &&
|
||||||
|
this.container
|
||||||
|
) {
|
||||||
|
const requestPayload = {
|
||||||
|
subscriptionId: userContext.subscriptionId,
|
||||||
|
databaseAccountName: userContext.databaseAccount.name,
|
||||||
|
resourceGroup: userContext.resourceGroup,
|
||||||
|
databaseName: this.collection.databaseId,
|
||||||
|
collectionName: this.collection.id(),
|
||||||
|
throughput: newThroughput,
|
||||||
|
offerIsRUPerMinuteThroughputEnabled: false
|
||||||
|
};
|
||||||
|
|
||||||
|
await updateOfferThroughputBeyondLimit(requestPayload);
|
||||||
|
this.collection.offer().content.offerThroughput = originalThroughputValue;
|
||||||
|
this.setState({
|
||||||
|
isScaleSaveable: false,
|
||||||
|
isScaleDiscardable: false,
|
||||||
|
throughput: originalThroughputValue,
|
||||||
|
throughputBaseline: originalThroughputValue,
|
||||||
|
initialNotification: {
|
||||||
|
description: `Throughput update for ${newThroughput} ${throughputUnit}`
|
||||||
|
} as DataModels.Notification
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const updateOfferParams: DataModels.UpdateOfferParams = {
|
||||||
|
databaseId: this.collection.databaseId,
|
||||||
|
collectionId: this.collection.id(),
|
||||||
|
currentOffer: this.collection.offer(),
|
||||||
|
autopilotThroughput: this.state.isAutoPilotSelected ? this.state.autoPilotThroughput : undefined,
|
||||||
|
manualThroughput: this.state.isAutoPilotSelected ? undefined : newThroughput
|
||||||
|
};
|
||||||
|
if (this.hasProvisioningTypeChanged()) {
|
||||||
|
if (this.state.isAutoPilotSelected) {
|
||||||
|
updateOfferParams.migrateToAutoPilot = true;
|
||||||
|
} else {
|
||||||
|
updateOfferParams.migrateToManual = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams);
|
||||||
|
this.collection.offer(updatedOffer);
|
||||||
|
this.setState({ isScaleSaveable: false, isScaleDiscardable: false });
|
||||||
|
if (this.state.isAutoPilotSelected) {
|
||||||
|
this.setState({
|
||||||
|
autoPilotThroughput: updatedOffer.content.offerAutopilotSettings.maxThroughput,
|
||||||
|
autoPilotThroughputBaseline: updatedOffer.content.offerAutopilotSettings.maxThroughput
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
throughput: updatedOffer.content.offerThroughput,
|
||||||
|
throughputBaseline: updatedOffer.content.offerThroughput
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.container.isRefreshingExplorer(false);
|
this.container.isRefreshingExplorer(false);
|
||||||
@@ -725,7 +809,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const offerThroughput = this.collection.offer()?.manualThroughput;
|
const offerThroughput = this.collection?.offer && this.collection.offer()?.content?.offerThroughput;
|
||||||
const changeFeedPolicy = this.collection.rawDataModel?.changeFeedPolicy
|
const changeFeedPolicy = this.collection.rawDataModel?.changeFeedPolicy
|
||||||
? ChangeFeedPolicyState.On
|
? ChangeFeedPolicyState.On
|
||||||
: ChangeFeedPolicyState.Off;
|
: ChangeFeedPolicyState.Off;
|
||||||
@@ -916,18 +1000,15 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
tab: SettingsV2TabTypes.IndexingPolicyTab,
|
tab: SettingsV2TabTypes.IndexingPolicyTab,
|
||||||
content: <IndexingPolicyComponent {...indexingPolicyComponentProps} />
|
content: <IndexingPolicyComponent {...indexingPolicyComponentProps} />
|
||||||
});
|
});
|
||||||
} else if (this.container.isPreferredApiMongoDB()) {
|
} else if (
|
||||||
if (isEmpty(this.container.features())) {
|
this.container.isMongoIndexEditorEnabled() &&
|
||||||
tabs.push({
|
this.container.isPreferredApiMongoDB() &&
|
||||||
tab: SettingsV2TabTypes.IndexingPolicyTab,
|
this.container.isEnableMongoCapabilityPresent()
|
||||||
content: mongoIndexingPolicyAADError
|
) {
|
||||||
});
|
tabs.push({
|
||||||
} else if (this.container.isEnableMongoCapabilityPresent()) {
|
tab: SettingsV2TabTypes.IndexingPolicyTab,
|
||||||
tabs.push({
|
content: <MongoIndexingPolicyComponent {...mongoIndexingPolicyComponentProps} />
|
||||||
tab: SettingsV2TabTypes.IndexingPolicyTab,
|
});
|
||||||
content: <MongoIndexingPolicyComponent {...mongoIndexingPolicyComponentProps} />
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasConflictResolution()) {
|
if (this.hasConflictResolution()) {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { shallow } from "enzyme";
|
import { shallow } from "enzyme";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { IColumn, Text } from "office-ui-fabric-react";
|
|
||||||
import {
|
import {
|
||||||
getAutoPilotV3SpendElement,
|
getAutoPilotV3SpendElement,
|
||||||
getEstimatedSpendingElement,
|
getEstimatedSpendElement,
|
||||||
|
getEstimatedAutoscaleSpendElement,
|
||||||
manualToAutoscaleDisclaimerElement,
|
manualToAutoscaleDisclaimerElement,
|
||||||
ttlWarning,
|
ttlWarning,
|
||||||
indexingPolicynUnsavedWarningMessage,
|
indexingPolicynUnsavedWarningMessage,
|
||||||
@@ -19,37 +19,11 @@ import {
|
|||||||
mongoIndexingPolicyDisclaimer,
|
mongoIndexingPolicyDisclaimer,
|
||||||
mongoIndexingPolicyAADError,
|
mongoIndexingPolicyAADError,
|
||||||
mongoIndexTransformationRefreshingMessage,
|
mongoIndexTransformationRefreshingMessage,
|
||||||
renderMongoIndexTransformationRefreshMessage,
|
renderMongoIndexTransformationRefreshMessage
|
||||||
ManualEstimatedSpendingDisplayProps,
|
|
||||||
PriceBreakdown,
|
|
||||||
getRuPriceBreakdown
|
|
||||||
} from "./SettingsRenderUtils";
|
} from "./SettingsRenderUtils";
|
||||||
|
|
||||||
class SettingsRenderUtilsTestComponent extends React.Component {
|
class SettingsRenderUtilsTestComponent extends React.Component {
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
const estimatedSpendingColumns: IColumn[] = [
|
|
||||||
{ key: "costType", name: "", fieldName: "costType", minWidth: 100, maxWidth: 200, isResizable: true },
|
|
||||||
{ key: "hourly", name: "Hourly", fieldName: "hourly", minWidth: 100, maxWidth: 200, isResizable: true },
|
|
||||||
{ key: "daily", name: "Daily", fieldName: "daily", minWidth: 100, maxWidth: 200, isResizable: true },
|
|
||||||
{ key: "monthly", name: "Monthly", fieldName: "monthly", minWidth: 100, maxWidth: 200, isResizable: true }
|
|
||||||
];
|
|
||||||
const estimatedSpendingItems: ManualEstimatedSpendingDisplayProps[] = [
|
|
||||||
{
|
|
||||||
costType: <Text>Current Cost</Text>,
|
|
||||||
hourly: <Text>$ 1.02</Text>,
|
|
||||||
daily: <Text>$ 24.48</Text>,
|
|
||||||
monthly: <Text>$ 744.6</Text>
|
|
||||||
}
|
|
||||||
];
|
|
||||||
const priceBreakdown: PriceBreakdown = {
|
|
||||||
hourlyPrice: 1.02,
|
|
||||||
dailyPrice: 24.48,
|
|
||||||
monthlyPrice: 744.6,
|
|
||||||
pricePerRu: 0.00051,
|
|
||||||
currency: "RMB",
|
|
||||||
currencySign: "¥"
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{getAutoPilotV3SpendElement(1000, false)}
|
{getAutoPilotV3SpendElement(1000, false)}
|
||||||
@@ -57,7 +31,9 @@ class SettingsRenderUtilsTestComponent extends React.Component {
|
|||||||
{getAutoPilotV3SpendElement(1000, true)}
|
{getAutoPilotV3SpendElement(1000, true)}
|
||||||
{getAutoPilotV3SpendElement(undefined, true)}
|
{getAutoPilotV3SpendElement(undefined, true)}
|
||||||
|
|
||||||
{getEstimatedSpendingElement(estimatedSpendingColumns, estimatedSpendingItems, 1000, 2, priceBreakdown, false)}
|
{getEstimatedSpendElement(1000, "mooncake", 2, false, true)}
|
||||||
|
|
||||||
|
{getEstimatedAutoscaleSpendElement(1000, "mooncake", 2, false)}
|
||||||
|
|
||||||
{manualToAutoscaleDisclaimerElement}
|
{manualToAutoscaleDisclaimerElement}
|
||||||
{ttlWarning}
|
{ttlWarning}
|
||||||
@@ -66,7 +42,7 @@ class SettingsRenderUtilsTestComponent extends React.Component {
|
|||||||
{updateThroughputDelayedApplyWarningMessage}
|
{updateThroughputDelayedApplyWarningMessage}
|
||||||
|
|
||||||
{getThroughputApplyDelayedMessage(false, 1000, "RU/s", "sampleDb", "sampleCollection", 2000)}
|
{getThroughputApplyDelayedMessage(false, 1000, "RU/s", "sampleDb", "sampleCollection", 2000)}
|
||||||
{getThroughputApplyShortDelayMessage(false, 1000, "RU/s", "sampleDb", "sampleCollection")}
|
{getThroughputApplyShortDelayMessage(false, 1000, "RU/s", "sampleDb", "sampleCollection", 2000)}
|
||||||
{getThroughputApplyLongDelayMessage(false, 1000, "RU/s", "sampleDb", "sampleCollection", 2000)}
|
{getThroughputApplyLongDelayMessage(false, 1000, "RU/s", "sampleDb", "sampleCollection", 2000)}
|
||||||
|
|
||||||
{getToolTipContainer(<span>Sample Text</span>)}
|
{getToolTipContainer(<span>Sample Text</span>)}
|
||||||
@@ -93,14 +69,4 @@ describe("SettingsUtils functions", () => {
|
|||||||
const wrapper = shallow(<SettingsRenderUtilsTestComponent />);
|
const wrapper = shallow(<SettingsRenderUtilsTestComponent />);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return correct price breakdown for a manual RU setting of 500, 1 region, multimaster disabled", () => {
|
|
||||||
const prices = getRuPriceBreakdown(500, "", 1, false, false);
|
|
||||||
expect(prices.hourlyPrice).toBe(0.04);
|
|
||||||
expect(prices.dailyPrice).toBe(0.96);
|
|
||||||
expect(prices.monthlyPrice).toBe(29.2);
|
|
||||||
expect(prices.pricePerRu).toBe(0.00008);
|
|
||||||
expect(prices.currency).toBe("USD");
|
|
||||||
expect(prices.currencySign).toBe("$");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ import * as AutoPilotUtils from "../../../Utils/AutoPilotUtils";
|
|||||||
import { AutopilotDocumentation, hoursInAMonth } from "../../../Shared/Constants";
|
import { AutopilotDocumentation, hoursInAMonth } from "../../../Shared/Constants";
|
||||||
import { Urls, StyleConstants } from "../../../Common/Constants";
|
import { Urls, StyleConstants } from "../../../Common/Constants";
|
||||||
import {
|
import {
|
||||||
|
computeAutoscaleUsagePriceHourly,
|
||||||
getPriceCurrency,
|
getPriceCurrency,
|
||||||
getCurrencySign,
|
getCurrencySign,
|
||||||
getAutoscalePricePerRu,
|
getAutoscalePricePerRu,
|
||||||
getMultimasterMultiplier,
|
getMultimasterMultiplier,
|
||||||
computeRUUsagePriceHourly,
|
computeRUUsagePriceHourly,
|
||||||
getPricePerRu,
|
getPricePerRu,
|
||||||
estimatedCostDisclaimer
|
calculateEstimateNumber
|
||||||
} from "../../../Utils/PricingUtils";
|
} from "../../../Utils/PricingUtils";
|
||||||
import {
|
import {
|
||||||
ITextFieldStyles,
|
ITextFieldStyles,
|
||||||
@@ -31,41 +32,10 @@ import {
|
|||||||
MessageBarType,
|
MessageBarType,
|
||||||
Stack,
|
Stack,
|
||||||
Spinner,
|
Spinner,
|
||||||
SpinnerSize,
|
SpinnerSize
|
||||||
DetailsList,
|
|
||||||
IColumn,
|
|
||||||
SelectionMode,
|
|
||||||
DetailsListLayoutMode,
|
|
||||||
IDetailsRowProps,
|
|
||||||
DetailsRow,
|
|
||||||
IDetailsColumnStyles
|
|
||||||
} from "office-ui-fabric-react";
|
} from "office-ui-fabric-react";
|
||||||
import { isDirtyTypes, isDirty } from "./SettingsUtils";
|
import { isDirtyTypes, isDirty } from "./SettingsUtils";
|
||||||
|
|
||||||
export interface EstimatedSpendingDisplayProps {
|
|
||||||
costType: JSX.Element;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ManualEstimatedSpendingDisplayProps extends EstimatedSpendingDisplayProps {
|
|
||||||
hourly: JSX.Element;
|
|
||||||
daily: JSX.Element;
|
|
||||||
monthly: JSX.Element;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AutoscaleEstimatedSpendingDisplayProps extends EstimatedSpendingDisplayProps {
|
|
||||||
minPerMonth: JSX.Element;
|
|
||||||
maxPerMonth: JSX.Element;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PriceBreakdown {
|
|
||||||
hourlyPrice: number;
|
|
||||||
dailyPrice: number;
|
|
||||||
monthlyPrice: number;
|
|
||||||
pricePerRu: number;
|
|
||||||
currency: string;
|
|
||||||
currencySign: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const infoAndToolTipTextStyle: ITextStyles = { root: { fontSize: 12 } };
|
export const infoAndToolTipTextStyle: ITextStyles = { root: { fontSize: 12 } };
|
||||||
|
|
||||||
export const noLeftPaddingCheckBoxStyle: ICheckboxStyles = {
|
export const noLeftPaddingCheckBoxStyle: ICheckboxStyles = {
|
||||||
@@ -134,16 +104,6 @@ export const transparentDetailsRowStyles: Partial<IDetailsRowStyles> = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const transparentDetailsHeaderStyle: Partial<IDetailsColumnStyles> = {
|
|
||||||
root: {
|
|
||||||
selectors: {
|
|
||||||
":hover": {
|
|
||||||
background: "transparent"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const customDetailsListStyles: Partial<IDetailsListStyles> = {
|
export const customDetailsListStyles: Partial<IDetailsListStyles> = {
|
||||||
root: {
|
root: {
|
||||||
selectors: {
|
selectors: {
|
||||||
@@ -170,10 +130,6 @@ export const messageBarStyles: Partial<IMessageBarStyles> = { root: { marginTop:
|
|||||||
|
|
||||||
export const throughputUnit = "RU/s";
|
export const throughputUnit = "RU/s";
|
||||||
|
|
||||||
export function onRenderRow(props: IDetailsRowProps): JSX.Element {
|
|
||||||
return <DetailsRow {...props} styles={transparentDetailsRowStyles} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getAutoPilotV3SpendElement = (
|
export const getAutoPilotV3SpendElement = (
|
||||||
maxAutoPilotThroughputSet: number,
|
maxAutoPilotThroughputSet: number,
|
||||||
isDatabaseThroughput: boolean,
|
isDatabaseThroughput: boolean,
|
||||||
@@ -209,61 +165,64 @@ export const getAutoPilotV3SpendElement = (
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRuPriceBreakdown = (
|
export const getEstimatedAutoscaleSpendElement = (
|
||||||
throughput: number,
|
throughput: number,
|
||||||
serverId: string,
|
serverId: string,
|
||||||
numberOfRegions: number,
|
regions: number,
|
||||||
isMultimaster: boolean,
|
multimaster: boolean
|
||||||
isAutoscale: boolean
|
): JSX.Element => {
|
||||||
): PriceBreakdown => {
|
const hourlyPrice: number = computeAutoscaleUsagePriceHourly(serverId, throughput, regions, multimaster);
|
||||||
const hourlyPrice: number = computeRUUsagePriceHourly({
|
const monthlyPrice: number = hourlyPrice * hoursInAMonth;
|
||||||
serverId: serverId,
|
const currency: string = getPriceCurrency(serverId);
|
||||||
requestUnits: throughput,
|
const currencySign: string = getCurrencySign(serverId);
|
||||||
numberOfRegions: numberOfRegions,
|
const pricePerRu =
|
||||||
multimasterEnabled: isMultimaster,
|
getAutoscalePricePerRu(serverId, getMultimasterMultiplier(regions, multimaster)) *
|
||||||
isAutoscale: isAutoscale
|
getMultimasterMultiplier(regions, multimaster);
|
||||||
});
|
|
||||||
const basePricePerRu: number = isAutoscale
|
return (
|
||||||
? getAutoscalePricePerRu(serverId, getMultimasterMultiplier(numberOfRegions, isMultimaster))
|
<Text id="autoscaleSpendElement">
|
||||||
: getPricePerRu(serverId);
|
Estimated monthly cost ({currency}) is{" "}
|
||||||
return {
|
<b>
|
||||||
hourlyPrice: hourlyPrice,
|
{currencySign}
|
||||||
dailyPrice: hourlyPrice * 24,
|
{calculateEstimateNumber(monthlyPrice / 10)}
|
||||||
monthlyPrice: hourlyPrice * hoursInAMonth,
|
{` - `}
|
||||||
pricePerRu: basePricePerRu * getMultimasterMultiplier(numberOfRegions, isMultimaster),
|
{currencySign}
|
||||||
currency: getPriceCurrency(serverId),
|
{calculateEstimateNumber(monthlyPrice)}{" "}
|
||||||
currencySign: getCurrencySign(serverId)
|
</b>
|
||||||
};
|
({"regions: "} {regions}, {throughput / 10} - {throughput} RU/s, {currencySign}
|
||||||
|
{pricePerRu}/RU)
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getEstimatedSpendingElement = (
|
export const getEstimatedSpendElement = (
|
||||||
estimatedSpendingColumns: IColumn[],
|
|
||||||
estimatedSpendingItems: EstimatedSpendingDisplayProps[],
|
|
||||||
throughput: number,
|
throughput: number,
|
||||||
numberOfRegions: number,
|
serverId: string,
|
||||||
priceBreakdown: PriceBreakdown,
|
regions: number,
|
||||||
isAutoscale: boolean
|
multimaster: boolean,
|
||||||
|
rupmEnabled: boolean
|
||||||
): JSX.Element => {
|
): JSX.Element => {
|
||||||
const ruRange: string = isAutoscale ? throughput / 10 + " RU/s - " : "";
|
const hourlyPrice: number = computeRUUsagePriceHourly(serverId, rupmEnabled, throughput, regions, multimaster);
|
||||||
|
const dailyPrice: number = hourlyPrice * 24;
|
||||||
|
const monthlyPrice: number = hourlyPrice * hoursInAMonth;
|
||||||
|
const currency: string = getPriceCurrency(serverId);
|
||||||
|
const currencySign: string = getCurrencySign(serverId);
|
||||||
|
const pricePerRu = getPricePerRu(serverId) * getMultimasterMultiplier(regions, multimaster);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack {...addMongoIndexStackProps} styles={mediumWidthStackStyles}>
|
<Text id="throughputSpendElement">
|
||||||
<DetailsList
|
Estimated cost ({currency}):{" "}
|
||||||
disableSelectionZone
|
<b>
|
||||||
items={estimatedSpendingItems}
|
{currencySign}
|
||||||
columns={estimatedSpendingColumns}
|
{calculateEstimateNumber(hourlyPrice)} hourly {` / `}
|
||||||
selectionMode={SelectionMode.none}
|
{currencySign}
|
||||||
layoutMode={DetailsListLayoutMode.justified}
|
{calculateEstimateNumber(dailyPrice)} daily {` / `}
|
||||||
onRenderRow={onRenderRow}
|
{currencySign}
|
||||||
/>
|
{calculateEstimateNumber(monthlyPrice)} monthly{" "}
|
||||||
<Text id="throughputSpendElement">
|
</b>
|
||||||
({"regions: "} {numberOfRegions}, {ruRange}
|
({"regions: "} {regions}, {throughput}RU/s, {currencySign}
|
||||||
{throughput} RU/s, {priceBreakdown.currencySign}
|
{pricePerRu}/RU)
|
||||||
{priceBreakdown.pricePerRu}/RU)
|
</Text>
|
||||||
</Text>
|
|
||||||
<Text>
|
|
||||||
<em>{estimatedCostDisclaimer}</em>
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -307,13 +266,6 @@ export const updateThroughputDelayedApplyWarningMessage: JSX.Element = (
|
|||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const saveThroughputWarningMessage: JSX.Element = (
|
|
||||||
<Text styles={infoAndToolTipTextStyle}>
|
|
||||||
Your bill will be affected as you update your throughput settings. Please review the updated cost estimate below
|
|
||||||
before saving your changes
|
|
||||||
</Text>
|
|
||||||
);
|
|
||||||
|
|
||||||
const getCurrentThroughput = (
|
const getCurrentThroughput = (
|
||||||
isAutoscale: boolean,
|
isAutoscale: boolean,
|
||||||
throughput: number,
|
throughput: number,
|
||||||
@@ -367,13 +319,14 @@ export const getThroughputApplyShortDelayMessage = (
|
|||||||
throughput: number,
|
throughput: number,
|
||||||
throughputUnit: string,
|
throughputUnit: string,
|
||||||
databaseName: string,
|
databaseName: string,
|
||||||
collectionName: string
|
collectionName: string,
|
||||||
|
targetThroughput: number
|
||||||
): JSX.Element => (
|
): JSX.Element => (
|
||||||
<Text styles={infoAndToolTipTextStyle} id="throughputApplyShortDelayMessage">
|
<Text styles={infoAndToolTipTextStyle} id="throughputApplyShortDelayMessage">
|
||||||
A request to increase the throughput is currently in progress. This operation will take some time to complete.
|
A request to increase the throughput is currently in progress. This operation will take some time to complete.
|
||||||
<br />
|
<br />
|
||||||
Database: {databaseName}, Container: {collectionName}{" "}
|
Database: {databaseName}, Container: {collectionName}{" "}
|
||||||
{getCurrentThroughput(isAutoscale, throughput, throughputUnit)}
|
{getCurrentThroughput(isAutoscale, throughput, throughputUnit, targetThroughput)}
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import {
|
|||||||
IconButton,
|
IconButton,
|
||||||
Text,
|
Text,
|
||||||
SelectionMode,
|
SelectionMode,
|
||||||
|
IDetailsRowProps,
|
||||||
|
DetailsRow,
|
||||||
IColumn,
|
IColumn,
|
||||||
MessageBar,
|
MessageBar,
|
||||||
MessageBarType,
|
MessageBarType,
|
||||||
@@ -19,11 +21,12 @@ import {
|
|||||||
mongoIndexingPolicyDisclaimer,
|
mongoIndexingPolicyDisclaimer,
|
||||||
mediumWidthStackStyles,
|
mediumWidthStackStyles,
|
||||||
subComponentStackProps,
|
subComponentStackProps,
|
||||||
|
transparentDetailsRowStyles,
|
||||||
createAndAddMongoIndexStackProps,
|
createAndAddMongoIndexStackProps,
|
||||||
separatorStyles,
|
separatorStyles,
|
||||||
|
mongoIndexingPolicyAADError,
|
||||||
indexingPolicynUnsavedWarningMessage,
|
indexingPolicynUnsavedWarningMessage,
|
||||||
infoAndToolTipTextStyle,
|
infoAndToolTipTextStyle
|
||||||
onRenderRow
|
|
||||||
} from "../../SettingsRenderUtils";
|
} from "../../SettingsRenderUtils";
|
||||||
import { MongoIndex } from "../../../../../Utils/arm/generatedClients/2020-04-01/types";
|
import { MongoIndex } from "../../../../../Utils/arm/generatedClients/2020-04-01/types";
|
||||||
import {
|
import {
|
||||||
@@ -37,6 +40,7 @@ import {
|
|||||||
} from "../../SettingsUtils";
|
} from "../../SettingsUtils";
|
||||||
import { AddMongoIndexComponent } from "./AddMongoIndexComponent";
|
import { AddMongoIndexComponent } from "./AddMongoIndexComponent";
|
||||||
import { CollapsibleSectionComponent } from "../../../CollapsiblePanel/CollapsibleSectionComponent";
|
import { CollapsibleSectionComponent } from "../../../CollapsiblePanel/CollapsibleSectionComponent";
|
||||||
|
import { AuthType } from "../../../../../AuthType";
|
||||||
import { IndexingPolicyRefreshComponent } from "../IndexingPolicyRefresh/IndexingPolicyRefreshComponent";
|
import { IndexingPolicyRefreshComponent } from "../IndexingPolicyRefresh/IndexingPolicyRefreshComponent";
|
||||||
|
|
||||||
export interface MongoIndexingPolicyComponentProps {
|
export interface MongoIndexingPolicyComponentProps {
|
||||||
@@ -138,6 +142,10 @@ export class MongoIndexingPolicyComponent extends React.Component<MongoIndexingP
|
|||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onRenderRow = (props: IDetailsRowProps): JSX.Element => {
|
||||||
|
return <DetailsRow {...props} styles={transparentDetailsRowStyles} />;
|
||||||
|
};
|
||||||
|
|
||||||
private getActionButton = (arrayPosition: number, isCurrentIndex: boolean): JSX.Element => {
|
private getActionButton = (arrayPosition: number, isCurrentIndex: boolean): JSX.Element => {
|
||||||
return isCurrentIndex ? (
|
return isCurrentIndex ? (
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -247,7 +255,7 @@ export class MongoIndexingPolicyComponent extends React.Component<MongoIndexingP
|
|||||||
items={initialIndexes}
|
items={initialIndexes}
|
||||||
columns={this.initialIndexesColumns}
|
columns={this.initialIndexesColumns}
|
||||||
selectionMode={SelectionMode.none}
|
selectionMode={SelectionMode.none}
|
||||||
onRenderRow={onRenderRow}
|
onRenderRow={this.onRenderRow}
|
||||||
layoutMode={DetailsListLayoutMode.justified}
|
layoutMode={DetailsListLayoutMode.justified}
|
||||||
/>
|
/>
|
||||||
{this.renderIndexesToBeAdded()}
|
{this.renderIndexesToBeAdded()}
|
||||||
@@ -273,7 +281,7 @@ export class MongoIndexingPolicyComponent extends React.Component<MongoIndexingP
|
|||||||
items={indexesToBeDropped}
|
items={indexesToBeDropped}
|
||||||
columns={this.indexesToBeDroppedColumns}
|
columns={this.indexesToBeDroppedColumns}
|
||||||
selectionMode={SelectionMode.none}
|
selectionMode={SelectionMode.none}
|
||||||
onRenderRow={onRenderRow}
|
onRenderRow={this.onRenderRow}
|
||||||
layoutMode={DetailsListLayoutMode.justified}
|
layoutMode={DetailsListLayoutMode.justified}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -313,7 +321,7 @@ export class MongoIndexingPolicyComponent extends React.Component<MongoIndexingP
|
|||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return <Spinner size={SpinnerSize.large} />;
|
return window.authType !== AuthType.AAD ? mongoIndexingPolicyAADError : <Spinner size={SpinnerSize.large} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ describe("ScaleComponent", () => {
|
|||||||
} as DataModels.Notification
|
} as DataModels.Notification
|
||||||
};
|
};
|
||||||
|
|
||||||
it("renders with correct initial notification", () => {
|
it("renders with correct intiial notification", () => {
|
||||||
let wrapper = shallow(<ScaleComponent {...baseProps} />);
|
let wrapper = shallow(<ScaleComponent {...baseProps} />);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
expect(wrapper.exists(ThroughputInputAutoPilotV3Component)).toEqual(true);
|
expect(wrapper.exists(ThroughputInputAutoPilotV3Component)).toEqual(true);
|
||||||
@@ -54,13 +54,16 @@ describe("ScaleComponent", () => {
|
|||||||
|
|
||||||
const newCollection = { ...collection };
|
const newCollection = { ...collection };
|
||||||
const maxThroughput = 5000;
|
const maxThroughput = 5000;
|
||||||
|
const targetMaxThroughput = 50000;
|
||||||
newCollection.offer = ko.observable({
|
newCollection.offer = ko.observable({
|
||||||
manualThroughput: undefined,
|
content: {
|
||||||
autoscaleMaxThroughput: maxThroughput,
|
offerAutopilotSettings: {
|
||||||
minimumThroughput: 400,
|
maxThroughput: maxThroughput,
|
||||||
id: "offer",
|
targetMaxThroughput: targetMaxThroughput
|
||||||
offerReplacePending: true
|
}
|
||||||
});
|
},
|
||||||
|
headers: { "x-ms-offer-replace-pending": true }
|
||||||
|
} as DataModels.OfferWithHeaders);
|
||||||
const newProps = {
|
const newProps = {
|
||||||
...baseProps,
|
...baseProps,
|
||||||
initialNotification: undefined as DataModels.Notification,
|
initialNotification: undefined as DataModels.Notification,
|
||||||
@@ -70,6 +73,7 @@ describe("ScaleComponent", () => {
|
|||||||
expect(wrapper.exists("#throughputApplyShortDelayMessage")).toEqual(true);
|
expect(wrapper.exists("#throughputApplyShortDelayMessage")).toEqual(true);
|
||||||
expect(wrapper.exists("#throughputApplyLongDelayMessage")).toEqual(false);
|
expect(wrapper.exists("#throughputApplyLongDelayMessage")).toEqual(false);
|
||||||
expect(wrapper.find("#throughputApplyShortDelayMessage").html()).toContain(maxThroughput);
|
expect(wrapper.find("#throughputApplyShortDelayMessage").html()).toContain(maxThroughput);
|
||||||
|
expect(wrapper.find("#throughputApplyShortDelayMessage").html()).toContain(targetMaxThroughput);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("autoScale disabled", () => {
|
it("autoScale disabled", () => {
|
||||||
@@ -105,6 +109,11 @@ describe("ScaleComponent", () => {
|
|||||||
expect(scaleComponent.isAutoScaleEnabled()).toEqual(true);
|
expect(scaleComponent.isAutoScaleEnabled()).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("getMaxRUThroughputInputLimit", () => {
|
||||||
|
const scaleComponent = new ScaleComponent(baseProps);
|
||||||
|
expect(scaleComponent.getMaxRUThroughputInputLimit()).toEqual(40000);
|
||||||
|
});
|
||||||
|
|
||||||
it("getThroughputTitle", () => {
|
it("getThroughputTitle", () => {
|
||||||
let scaleComponent = new ScaleComponent(baseProps);
|
let scaleComponent = new ScaleComponent(baseProps);
|
||||||
expect(scaleComponent.getThroughputTitle()).toEqual("Throughput (6,000 - unlimited RU/s)");
|
expect(scaleComponent.getThroughputTitle()).toEqual("Throughput (6,000 - unlimited RU/s)");
|
||||||
@@ -129,8 +138,14 @@ describe("ScaleComponent", () => {
|
|||||||
|
|
||||||
it("getThroughputWarningMessage", () => {
|
it("getThroughputWarningMessage", () => {
|
||||||
const throughputBeyondLimit = SharedConstants.CollectionCreation.DefaultCollectionRUs1Million + 1000;
|
const throughputBeyondLimit = SharedConstants.CollectionCreation.DefaultCollectionRUs1Million + 1000;
|
||||||
|
const throughputBeyondMaxRus = SharedConstants.CollectionCreation.DefaultCollectionRUs1Million - 1000;
|
||||||
|
|
||||||
const newProps = { ...baseProps, container: nonNationalCloudContainer, throughput: throughputBeyondLimit };
|
const newProps = { ...baseProps, container: nonNationalCloudContainer, throughput: throughputBeyondLimit };
|
||||||
const scaleComponent = new ScaleComponent(newProps);
|
let scaleComponent = new ScaleComponent(newProps);
|
||||||
expect(scaleComponent.getThroughputWarningMessage().props.id).toEqual("updateThroughputBeyondLimitWarningMessage");
|
expect(scaleComponent.getThroughputWarningMessage().props.id).toEqual("updateThroughputBeyondLimitWarningMessage");
|
||||||
|
|
||||||
|
newProps.throughput = throughputBeyondMaxRus;
|
||||||
|
scaleComponent = new ScaleComponent(newProps);
|
||||||
|
expect(scaleComponent.getThroughputWarningMessage().props.id).toEqual("updateThroughputDelayedApplyWarningMessage");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ import {
|
|||||||
throughputUnit,
|
throughputUnit,
|
||||||
getThroughputApplyLongDelayMessage,
|
getThroughputApplyLongDelayMessage,
|
||||||
getThroughputApplyShortDelayMessage,
|
getThroughputApplyShortDelayMessage,
|
||||||
updateThroughputBeyondLimitWarningMessage
|
updateThroughputBeyondLimitWarningMessage,
|
||||||
|
updateThroughputDelayedApplyWarningMessage
|
||||||
} from "../SettingsRenderUtils";
|
} from "../SettingsRenderUtils";
|
||||||
import { hasDatabaseSharedThroughput } from "../SettingsUtils";
|
import { getMaxRUs, getMinRUs, hasDatabaseSharedThroughput } from "../SettingsUtils";
|
||||||
import * as AutoPilotUtils from "../../../../Utils/AutoPilotUtils";
|
import * as AutoPilotUtils from "../../../../Utils/AutoPilotUtils";
|
||||||
import { Text, TextField, Stack, Label, MessageBar, MessageBarType } from "office-ui-fabric-react";
|
import { Text, TextField, Stack, Label, MessageBar, MessageBarType } from "office-ui-fabric-react";
|
||||||
import { configContext, Platform } from "../../../../ConfigContext";
|
import { configContext, Platform } from "../../../../ConfigContext";
|
||||||
@@ -61,7 +62,11 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private getStorageCapacityTitle = (): JSX.Element => {
|
private getStorageCapacityTitle = (): JSX.Element => {
|
||||||
const capacity: string = this.props.isFixedContainer ? "Fixed" : "Unlimited";
|
// Mongo container with system partition key still treat as "Fixed"
|
||||||
|
const isFixed =
|
||||||
|
!this.props.collection.partitionKey ||
|
||||||
|
(this.props.container.isPreferredApiMongoDB() && this.props.collection.partitionKey.systemKey);
|
||||||
|
const capacity: string = isFixed ? "Fixed" : "Unlimited";
|
||||||
return (
|
return (
|
||||||
<Stack {...titleAndInputStackProps}>
|
<Stack {...titleAndInputStackProps}>
|
||||||
<Label>Storage capacity</Label>
|
<Label>Storage capacity</Label>
|
||||||
@@ -70,26 +75,12 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
public getMaxRUs = (): number => {
|
public getMaxRUThroughputInputLimit = (): number => {
|
||||||
if (this.props.container?.isTryCosmosDBSubscription()) {
|
if (configContext.platform === Platform.Hosted && this.props.collection.partitionKey) {
|
||||||
return Constants.TryCosmosExperience.maxRU;
|
return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.isFixedContainer) {
|
return getMaxRUs(this.props.collection, this.props.container);
|
||||||
return SharedConstants.CollectionCreation.MaxRUPerPartition;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SharedConstants.CollectionCreation.DefaultCollectionRUs1Million;
|
|
||||||
};
|
|
||||||
|
|
||||||
public getMinRUs = (): number => {
|
|
||||||
if (this.props.container?.isTryCosmosDBSubscription()) {
|
|
||||||
return SharedConstants.CollectionCreation.DefaultCollectionRUs400;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
this.props.collection.offer()?.minimumThroughput || SharedConstants.CollectionCreation.DefaultCollectionRUs400
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public getThroughputTitle = (): string => {
|
public getThroughputTitle = (): string => {
|
||||||
@@ -97,8 +88,11 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
|
|||||||
return AutoPilotUtils.getAutoPilotHeaderText();
|
return AutoPilotUtils.getAutoPilotHeaderText();
|
||||||
}
|
}
|
||||||
|
|
||||||
const minThroughput: string = this.getMinRUs().toLocaleString();
|
const minThroughput: string = getMinRUs(this.props.collection, this.props.container).toLocaleString();
|
||||||
const maxThroughput: string = !this.props.isFixedContainer ? "unlimited" : this.getMaxRUs().toLocaleString();
|
const maxThroughput: string =
|
||||||
|
this.canThroughputExceedMaximumValue() && !this.props.isFixedContainer
|
||||||
|
? "unlimited"
|
||||||
|
: getMaxRUs(this.props.collection, this.props.container).toLocaleString();
|
||||||
return `Throughput (${minThroughput} - ${maxThroughput} RU/s)`;
|
return `Throughput (${minThroughput} - ${maxThroughput} RU/s)`;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -115,15 +109,26 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
|
|||||||
return this.getLongDelayMessage();
|
return this.getLongDelayMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
const offer = this.props.collection?.offer();
|
const offer = this.props.collection?.offer && this.props.collection.offer();
|
||||||
if (offer?.offerReplacePending) {
|
if (
|
||||||
const throughput = offer.manualThroughput || offer.autoscaleMaxThroughput;
|
offer &&
|
||||||
|
Object.keys(offer).find(value => {
|
||||||
|
return value === "headers";
|
||||||
|
}) &&
|
||||||
|
!!(offer as DataModels.OfferWithHeaders).headers[Constants.HttpHeaders.offerReplacePending]
|
||||||
|
) {
|
||||||
|
const throughput = offer?.content?.offerAutopilotSettings?.maxThroughput;
|
||||||
|
|
||||||
|
const targetThroughput =
|
||||||
|
offer.content?.offerAutopilotSettings?.targetMaxThroughput || offer?.content?.offerThroughput;
|
||||||
|
|
||||||
return getThroughputApplyShortDelayMessage(
|
return getThroughputApplyShortDelayMessage(
|
||||||
this.props.isAutoPilotSelected,
|
this.props.isAutoPilotSelected,
|
||||||
throughput,
|
throughput,
|
||||||
throughputUnit,
|
throughputUnit,
|
||||||
this.props.collection.databaseId,
|
this.props.collection.databaseId,
|
||||||
this.props.collection.id()
|
this.props.collection.id(),
|
||||||
|
targetThroughput
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,12 +138,21 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
|
|||||||
public getThroughputWarningMessage = (): JSX.Element => {
|
public getThroughputWarningMessage = (): JSX.Element => {
|
||||||
const throughputExceedsBackendLimits: boolean =
|
const throughputExceedsBackendLimits: boolean =
|
||||||
this.canThroughputExceedMaximumValue() &&
|
this.canThroughputExceedMaximumValue() &&
|
||||||
|
getMaxRUs(this.props.collection, this.props.container) <=
|
||||||
|
SharedConstants.CollectionCreation.DefaultCollectionRUs1Million &&
|
||||||
this.props.throughput > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million;
|
this.props.throughput > SharedConstants.CollectionCreation.DefaultCollectionRUs1Million;
|
||||||
|
|
||||||
if (throughputExceedsBackendLimits && !!this.props.collection.partitionKey && !this.props.isFixedContainer) {
|
if (throughputExceedsBackendLimits && !!this.props.collection.partitionKey && !this.props.isFixedContainer) {
|
||||||
return updateThroughputBeyondLimitWarningMessage;
|
return updateThroughputBeyondLimitWarningMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const throughputExceedsMaxValue: boolean =
|
||||||
|
!this.isEmulator && this.props.throughput > getMaxRUs(this.props.collection, this.props.container);
|
||||||
|
|
||||||
|
if (throughputExceedsMaxValue && !!this.props.collection.partitionKey && !this.props.isFixedContainer) {
|
||||||
|
return updateThroughputDelayedApplyWarningMessage;
|
||||||
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -169,8 +183,8 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
|
|||||||
throughput={this.props.throughput}
|
throughput={this.props.throughput}
|
||||||
throughputBaseline={this.props.throughputBaseline}
|
throughputBaseline={this.props.throughputBaseline}
|
||||||
onThroughputChange={this.props.onThroughputChange}
|
onThroughputChange={this.props.onThroughputChange}
|
||||||
minimum={this.getMinRUs()}
|
minimum={getMinRUs(this.props.collection, this.props.container)}
|
||||||
maximum={this.getMaxRUs()}
|
maximum={this.getMaxRUThroughputInputLimit()}
|
||||||
isEnabled={!hasDatabaseSharedThroughput(this.props.collection)}
|
isEnabled={!hasDatabaseSharedThroughput(this.props.collection)}
|
||||||
canExceedMaximumValue={this.canThroughputExceedMaximumValue()}
|
canExceedMaximumValue={this.canThroughputExceedMaximumValue()}
|
||||||
label={this.getThroughputTitle()}
|
label={this.getThroughputTitle()}
|
||||||
@@ -186,7 +200,7 @@ export class ScaleComponent extends React.Component<ScaleComponentProps> {
|
|||||||
onScaleSaveableChange={this.props.onScaleSaveableChange}
|
onScaleSaveableChange={this.props.onScaleSaveableChange}
|
||||||
onScaleDiscardableChange={this.props.onScaleDiscardableChange}
|
onScaleDiscardableChange={this.props.onScaleDiscardableChange}
|
||||||
getThroughputWarningMessage={this.getThroughputWarningMessage}
|
getThroughputWarningMessage={this.getThroughputWarningMessage}
|
||||||
usageSizeInKB={this.props.collection.usageSizeInKB()}
|
usageSizeInKB={this.props.collection.quotaInfo().usageSizeInKB}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ describe("ThroughputInputAutoPilotV3Component", () => {
|
|||||||
expect(wrapper.exists("#throughputInput")).toEqual(true);
|
expect(wrapper.exists("#throughputInput")).toEqual(true);
|
||||||
expect(wrapper.exists("#autopilotInput")).toEqual(false);
|
expect(wrapper.exists("#autopilotInput")).toEqual(false);
|
||||||
expect(wrapper.exists("#throughputSpendElement")).toEqual(true);
|
expect(wrapper.exists("#throughputSpendElement")).toEqual(true);
|
||||||
|
expect(wrapper.exists("#autoscaleSpendElement")).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("autopilot input visible", () => {
|
it("autopilot input visible", () => {
|
||||||
@@ -71,7 +72,8 @@ describe("ThroughputInputAutoPilotV3Component", () => {
|
|||||||
|
|
||||||
wrapper.setProps({ wasAutopilotOriginallySet: true });
|
wrapper.setProps({ wasAutopilotOriginallySet: true });
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(wrapper.exists("#throughputSpendElement")).toEqual(true);
|
expect(wrapper.exists("#autoscaleSpendElement")).toEqual(true);
|
||||||
|
expect(wrapper.exists("#throughputSpendElement")).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("spendAck checkbox visible", () => {
|
it("spendAck checkbox visible", () => {
|
||||||
|
|||||||
@@ -8,15 +8,10 @@ import {
|
|||||||
checkBoxAndInputStackProps,
|
checkBoxAndInputStackProps,
|
||||||
getChoiceGroupStyles,
|
getChoiceGroupStyles,
|
||||||
messageBarStyles,
|
messageBarStyles,
|
||||||
getEstimatedSpendingElement,
|
getEstimatedSpendElement,
|
||||||
|
getEstimatedAutoscaleSpendElement,
|
||||||
getAutoPilotV3SpendElement,
|
getAutoPilotV3SpendElement,
|
||||||
manualToAutoscaleDisclaimerElement,
|
manualToAutoscaleDisclaimerElement
|
||||||
saveThroughputWarningMessage,
|
|
||||||
ManualEstimatedSpendingDisplayProps,
|
|
||||||
AutoscaleEstimatedSpendingDisplayProps,
|
|
||||||
PriceBreakdown,
|
|
||||||
getRuPriceBreakdown,
|
|
||||||
transparentDetailsHeaderStyle
|
|
||||||
} from "../../SettingsRenderUtils";
|
} from "../../SettingsRenderUtils";
|
||||||
import {
|
import {
|
||||||
Text,
|
Text,
|
||||||
@@ -28,9 +23,7 @@ import {
|
|||||||
Label,
|
Label,
|
||||||
Link,
|
Link,
|
||||||
MessageBar,
|
MessageBar,
|
||||||
MessageBarType,
|
MessageBarType
|
||||||
FontIcon,
|
|
||||||
IColumn
|
|
||||||
} from "office-ui-fabric-react";
|
} from "office-ui-fabric-react";
|
||||||
import { ToolTipLabelComponent } from "../ToolTipLabelComponent";
|
import { ToolTipLabelComponent } from "../ToolTipLabelComponent";
|
||||||
import { getSanitizedInputValue, IsComponentDirtyResult, isDirty } from "../../SettingsUtils";
|
import { getSanitizedInputValue, IsComponentDirtyResult, isDirty } from "../../SettingsUtils";
|
||||||
@@ -39,7 +32,7 @@ import * as DataModels from "../../../../../Contracts/DataModels";
|
|||||||
import { Int32 } from "../../../../Panes/Tables/Validators/EntityPropertyValidationCommon";
|
import { Int32 } from "../../../../Panes/Tables/Validators/EntityPropertyValidationCommon";
|
||||||
import { userContext } from "../../../../../UserContext";
|
import { userContext } from "../../../../../UserContext";
|
||||||
import { SubscriptionType } from "../../../../../Contracts/SubscriptionType";
|
import { SubscriptionType } from "../../../../../Contracts/SubscriptionType";
|
||||||
import { usageInGB, calculateEstimateNumber } from "../../../../../Utils/PricingUtils";
|
import { usageInGB } from "../../../../../Utils/PricingUtils";
|
||||||
import { Features } from "../../../../../Common/Constants";
|
import { Features } from "../../../../../Common/Constants";
|
||||||
|
|
||||||
export interface ThroughputInputAutoPilotV3Props {
|
export interface ThroughputInputAutoPilotV3Props {
|
||||||
@@ -172,243 +165,34 @@ export class ThroughputInputAutoPilotV3Component extends React.Component<
|
|||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isDirty: boolean = this.IsComponentDirty().isDiscardable;
|
|
||||||
const serverId: string = this.props.serverId;
|
const serverId: string = this.props.serverId;
|
||||||
|
const offerThroughput: number = this.props.throughput;
|
||||||
|
|
||||||
const regions = account?.properties?.readLocations?.length || 1;
|
const regions = account?.properties?.readLocations?.length || 1;
|
||||||
const multimaster = account?.properties?.enableMultipleWriteLocations || false;
|
const multimaster = account?.properties?.enableMultipleWriteLocations || false;
|
||||||
|
|
||||||
let estimatedSpend: JSX.Element;
|
let estimatedSpend: JSX.Element;
|
||||||
|
|
||||||
if (!this.props.isAutoPilotSelected) {
|
if (!this.props.isAutoPilotSelected) {
|
||||||
estimatedSpend = this.getEstimatedManualSpendElement(
|
estimatedSpend = getEstimatedSpendElement(
|
||||||
// if migrating from autoscale to manual, we use the autoscale RUs value as that is what will be set...
|
// if migrating from autoscale to manual, we use the autoscale RUs value as that is what will be set...
|
||||||
this.overrideWithAutoPilotSettings() ? this.props.maxAutoPilotThroughput : this.props.throughputBaseline,
|
this.overrideWithAutoPilotSettings() ? this.props.maxAutoPilotThroughput : offerThroughput,
|
||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
isDirty ? this.props.throughput : undefined
|
false
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
estimatedSpend = this.getEstimatedAutoscaleSpendElement(
|
estimatedSpend = getEstimatedAutoscaleSpendElement(
|
||||||
this.props.maxAutoPilotThroughputBaseline,
|
this.props.maxAutoPilotThroughput,
|
||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster
|
||||||
isDirty ? this.props.maxAutoPilotThroughput : undefined
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return estimatedSpend;
|
return estimatedSpend;
|
||||||
};
|
};
|
||||||
|
|
||||||
private getEstimatedAutoscaleSpendElement = (
|
|
||||||
throughput: number,
|
|
||||||
serverId: string,
|
|
||||||
numberOfRegions: number,
|
|
||||||
isMultimaster: boolean,
|
|
||||||
newThroughput?: number
|
|
||||||
): JSX.Element => {
|
|
||||||
const prices: PriceBreakdown = getRuPriceBreakdown(throughput, serverId, numberOfRegions, isMultimaster, true);
|
|
||||||
const estimatedSpendingColumns: IColumn[] = [
|
|
||||||
{
|
|
||||||
key: "costType",
|
|
||||||
name: "",
|
|
||||||
fieldName: "costType",
|
|
||||||
minWidth: 100,
|
|
||||||
maxWidth: 200,
|
|
||||||
isResizable: true,
|
|
||||||
styles: transparentDetailsHeaderStyle
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "minPerMonth",
|
|
||||||
name: "Min Per Month",
|
|
||||||
fieldName: "minPerMonth",
|
|
||||||
minWidth: 100,
|
|
||||||
maxWidth: 200,
|
|
||||||
isResizable: true,
|
|
||||||
styles: transparentDetailsHeaderStyle
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "maxPerMonth",
|
|
||||||
name: "Max Per Month",
|
|
||||||
fieldName: "maxPerMonth",
|
|
||||||
minWidth: 100,
|
|
||||||
maxWidth: 200,
|
|
||||||
isResizable: true,
|
|
||||||
styles: transparentDetailsHeaderStyle
|
|
||||||
}
|
|
||||||
];
|
|
||||||
const estimatedSpendingItems: AutoscaleEstimatedSpendingDisplayProps[] = [
|
|
||||||
{
|
|
||||||
costType: <Text>Current Cost</Text>,
|
|
||||||
minPerMonth: (
|
|
||||||
<Text>
|
|
||||||
{prices.currencySign} {calculateEstimateNumber(prices.monthlyPrice / 10)}
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
maxPerMonth: (
|
|
||||||
<Text>
|
|
||||||
{prices.currencySign} {calculateEstimateNumber(prices.monthlyPrice)}
|
|
||||||
</Text>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
if (newThroughput) {
|
|
||||||
const newPrices: PriceBreakdown = getRuPriceBreakdown(
|
|
||||||
newThroughput,
|
|
||||||
serverId,
|
|
||||||
numberOfRegions,
|
|
||||||
isMultimaster,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
estimatedSpendingItems.unshift({
|
|
||||||
costType: (
|
|
||||||
<Text>
|
|
||||||
<b>Updated Cost</b>
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
minPerMonth: (
|
|
||||||
<Text>
|
|
||||||
<b>
|
|
||||||
{newPrices.currencySign} {calculateEstimateNumber(newPrices.monthlyPrice / 10)}
|
|
||||||
</b>
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
maxPerMonth: (
|
|
||||||
<Text>
|
|
||||||
<b>
|
|
||||||
{newPrices.currencySign} {calculateEstimateNumber(newPrices.monthlyPrice)}
|
|
||||||
</b>
|
|
||||||
</Text>
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return getEstimatedSpendingElement(
|
|
||||||
estimatedSpendingColumns,
|
|
||||||
estimatedSpendingItems,
|
|
||||||
newThroughput ?? throughput,
|
|
||||||
numberOfRegions,
|
|
||||||
prices,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
private getEstimatedManualSpendElement = (
|
|
||||||
throughput: number,
|
|
||||||
serverId: string,
|
|
||||||
numberOfRegions: number,
|
|
||||||
isMultimaster: boolean,
|
|
||||||
newThroughput?: number
|
|
||||||
): JSX.Element => {
|
|
||||||
const prices: PriceBreakdown = getRuPriceBreakdown(throughput, serverId, numberOfRegions, isMultimaster, false);
|
|
||||||
const estimatedSpendingColumns: IColumn[] = [
|
|
||||||
{
|
|
||||||
key: "costType",
|
|
||||||
name: "",
|
|
||||||
fieldName: "costType",
|
|
||||||
minWidth: 100,
|
|
||||||
maxWidth: 200,
|
|
||||||
isResizable: true,
|
|
||||||
styles: transparentDetailsHeaderStyle
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "hourly",
|
|
||||||
name: "Hourly",
|
|
||||||
fieldName: "hourly",
|
|
||||||
minWidth: 100,
|
|
||||||
maxWidth: 200,
|
|
||||||
isResizable: true,
|
|
||||||
styles: transparentDetailsHeaderStyle
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "daily",
|
|
||||||
name: "Daily",
|
|
||||||
fieldName: "daily",
|
|
||||||
minWidth: 100,
|
|
||||||
maxWidth: 200,
|
|
||||||
isResizable: true,
|
|
||||||
styles: transparentDetailsHeaderStyle
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "monthly",
|
|
||||||
name: "Monthly",
|
|
||||||
fieldName: "monthly",
|
|
||||||
minWidth: 100,
|
|
||||||
maxWidth: 200,
|
|
||||||
isResizable: true,
|
|
||||||
styles: transparentDetailsHeaderStyle
|
|
||||||
}
|
|
||||||
];
|
|
||||||
const estimatedSpendingItems: ManualEstimatedSpendingDisplayProps[] = [
|
|
||||||
{
|
|
||||||
costType: <Text>Current Cost</Text>,
|
|
||||||
hourly: (
|
|
||||||
<Text>
|
|
||||||
{prices.currencySign} {calculateEstimateNumber(prices.hourlyPrice)}
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
daily: (
|
|
||||||
<Text>
|
|
||||||
{prices.currencySign} {calculateEstimateNumber(prices.dailyPrice)}
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
monthly: (
|
|
||||||
<Text>
|
|
||||||
{prices.currencySign} {calculateEstimateNumber(prices.monthlyPrice)}
|
|
||||||
</Text>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
if (newThroughput) {
|
|
||||||
const newPrices: PriceBreakdown = getRuPriceBreakdown(
|
|
||||||
newThroughput,
|
|
||||||
serverId,
|
|
||||||
numberOfRegions,
|
|
||||||
isMultimaster,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
estimatedSpendingItems.unshift({
|
|
||||||
costType: (
|
|
||||||
<Text>
|
|
||||||
<b>Updated Cost</b>
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
hourly: (
|
|
||||||
<Text>
|
|
||||||
<b>
|
|
||||||
{newPrices.currencySign} {calculateEstimateNumber(newPrices.hourlyPrice)}
|
|
||||||
</b>
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
daily: (
|
|
||||||
<Text>
|
|
||||||
<b>
|
|
||||||
{newPrices.currencySign} {calculateEstimateNumber(newPrices.dailyPrice)}
|
|
||||||
</b>
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
monthly: (
|
|
||||||
<Text>
|
|
||||||
<b>
|
|
||||||
{newPrices.currencySign} {calculateEstimateNumber(newPrices.monthlyPrice)}
|
|
||||||
</b>
|
|
||||||
</Text>
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return getEstimatedSpendingElement(
|
|
||||||
estimatedSpendingColumns,
|
|
||||||
estimatedSpendingItems,
|
|
||||||
newThroughput ?? throughput,
|
|
||||||
numberOfRegions,
|
|
||||||
prices,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
private getAutoPilotUsageCost = (): JSX.Element => {
|
private getAutoPilotUsageCost = (): JSX.Element => {
|
||||||
if (!this.props.maxAutoPilotThroughput) {
|
if (!this.props.maxAutoPilotThroughput) {
|
||||||
return <></>;
|
return <></>;
|
||||||
@@ -535,12 +319,6 @@ export class ThroughputInputAutoPilotV3Component extends React.Component<
|
|||||||
|
|
||||||
private renderThroughputInput = (): JSX.Element => (
|
private renderThroughputInput = (): JSX.Element => (
|
||||||
<Stack {...titleAndInputStackProps}>
|
<Stack {...titleAndInputStackProps}>
|
||||||
<Text>
|
|
||||||
Estimate your required throughput with
|
|
||||||
<Link target="_blank" href="https://cosmos.azure.com/capacitycalculator/">
|
|
||||||
{` capacity calculator`} <FontIcon iconName="NavigateExternalInline" />
|
|
||||||
</Link>
|
|
||||||
</Text>
|
|
||||||
<TextField
|
<TextField
|
||||||
required
|
required
|
||||||
type="number"
|
type="number"
|
||||||
@@ -572,24 +350,13 @@ export class ThroughputInputAutoPilotV3Component extends React.Component<
|
|||||||
onChange={this.onSpendAckChecked}
|
onChange={this.onSpendAckChecked}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<br />
|
|
||||||
{this.props.isFixed && <p>When using a collection with fixed storage capacity, you can set up to 10,000 RU/s.</p>}
|
{this.props.isFixed && <p>When using a collection with fixed storage capacity, you can set up to 10,000 RU/s.</p>}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|
||||||
private renderWarningMessage = (): JSX.Element => {
|
|
||||||
let warningMessage: JSX.Element;
|
|
||||||
if (this.IsComponentDirty().isDiscardable) {
|
|
||||||
warningMessage = saveThroughputWarningMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <>{warningMessage && <MessageBar messageBarType={MessageBarType.warning}>{warningMessage}</MessageBar>}</>;
|
|
||||||
};
|
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<Stack {...checkBoxAndInputStackProps}>
|
<Stack {...checkBoxAndInputStackProps}>
|
||||||
{this.renderWarningMessage()}
|
|
||||||
{this.renderThroughputModeChoices()}
|
{this.renderThroughputModeChoices()}
|
||||||
|
|
||||||
{this.props.isAutoPilotSelected ? this.renderAutoPilotInput() : this.renderThroughputInput()}
|
{this.props.isAutoPilotSelected ? this.renderAutoPilotInput() : this.renderThroughputInput()}
|
||||||
|
|||||||
@@ -8,21 +8,6 @@ exports[`ThroughputInputAutoPilotV3Component autopilot input visible 1`] = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StyledMessageBarBase
|
|
||||||
messageBarType={5}
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
styles={
|
|
||||||
Object {
|
|
||||||
"root": Object {
|
|
||||||
"fontSize": 12,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Your bill will be affected as you update your throughput settings. Please review the updated cost estimate below before saving your changes
|
|
||||||
</Text>
|
|
||||||
</StyledMessageBarBase>
|
|
||||||
<Stack>
|
<Stack>
|
||||||
<StyledLabelBase
|
<StyledLabelBase
|
||||||
id="settingsV2RadioButtonLabelId"
|
id="settingsV2RadioButtonLabelId"
|
||||||
@@ -229,19 +214,6 @@ exports[`ThroughputInputAutoPilotV3Component spendAck checkbox visible 1`] = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Text>
|
|
||||||
Estimate your required throughput with
|
|
||||||
<StyledLinkBase
|
|
||||||
href="https://cosmos.azure.com/capacitycalculator/"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
capacity calculator
|
|
||||||
|
|
||||||
<Component
|
|
||||||
iconName="NavigateExternalInline"
|
|
||||||
/>
|
|
||||||
</StyledLinkBase>
|
|
||||||
</Text>
|
|
||||||
<StyledTextFieldBase
|
<StyledTextFieldBase
|
||||||
disabled={false}
|
disabled={false}
|
||||||
id="throughputInput"
|
id="throughputInput"
|
||||||
@@ -267,142 +239,38 @@ exports[`ThroughputInputAutoPilotV3Component spendAck checkbox visible 1`] = `
|
|||||||
type="number"
|
type="number"
|
||||||
value="100"
|
value="100"
|
||||||
/>
|
/>
|
||||||
<Stack
|
<Text
|
||||||
styles={
|
id="throughputSpendElement"
|
||||||
Object {
|
|
||||||
"root": Object {
|
|
||||||
"width": 600,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tokens={
|
|
||||||
Object {
|
|
||||||
"childrenGap": 10,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<StyledWithViewportComponent
|
Estimated cost (
|
||||||
columns={
|
USD
|
||||||
Array [
|
):
|
||||||
Object {
|
|
||||||
"fieldName": "costType",
|
<b>
|
||||||
"isResizable": true,
|
|
||||||
"key": "costType",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "",
|
|
||||||
"styles": Object {
|
|
||||||
"root": Object {
|
|
||||||
"selectors": Object {
|
|
||||||
":hover": Object {
|
|
||||||
"background": "transparent",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"fieldName": "hourly",
|
|
||||||
"isResizable": true,
|
|
||||||
"key": "hourly",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "Hourly",
|
|
||||||
"styles": Object {
|
|
||||||
"root": Object {
|
|
||||||
"selectors": Object {
|
|
||||||
":hover": Object {
|
|
||||||
"background": "transparent",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"fieldName": "daily",
|
|
||||||
"isResizable": true,
|
|
||||||
"key": "daily",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "Daily",
|
|
||||||
"styles": Object {
|
|
||||||
"root": Object {
|
|
||||||
"selectors": Object {
|
|
||||||
":hover": Object {
|
|
||||||
"background": "transparent",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"fieldName": "monthly",
|
|
||||||
"isResizable": true,
|
|
||||||
"key": "monthly",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "Monthly",
|
|
||||||
"styles": Object {
|
|
||||||
"root": Object {
|
|
||||||
"selectors": Object {
|
|
||||||
":hover": Object {
|
|
||||||
"background": "transparent",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
disableSelectionZone={true}
|
|
||||||
items={
|
|
||||||
Array [
|
|
||||||
Object {
|
|
||||||
"costType": <Text>
|
|
||||||
Current Cost
|
|
||||||
</Text>,
|
|
||||||
"daily": <Text>
|
|
||||||
$
|
|
||||||
|
|
||||||
0.19
|
|
||||||
</Text>,
|
|
||||||
"hourly": <Text>
|
|
||||||
$
|
|
||||||
|
|
||||||
0.0080
|
|
||||||
</Text>,
|
|
||||||
"monthly": <Text>
|
|
||||||
$
|
|
||||||
|
|
||||||
5.84
|
|
||||||
</Text>,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
layoutMode={1}
|
|
||||||
onRenderRow={[Function]}
|
|
||||||
selectionMode={0}
|
|
||||||
/>
|
|
||||||
<Text
|
|
||||||
id="throughputSpendElement"
|
|
||||||
>
|
|
||||||
(
|
|
||||||
regions:
|
|
||||||
|
|
||||||
1
|
|
||||||
,
|
|
||||||
100
|
|
||||||
RU/s,
|
|
||||||
$
|
$
|
||||||
0.00008
|
0.0080
|
||||||
/RU)
|
hourly
|
||||||
</Text>
|
/
|
||||||
<Text>
|
$
|
||||||
<em>
|
0.19
|
||||||
*This cost is an estimate and may vary based on the regions where your account is deployed and potential discounts applied to your account
|
daily
|
||||||
</em>
|
/
|
||||||
</Text>
|
$
|
||||||
</Stack>
|
5.84
|
||||||
|
monthly
|
||||||
|
|
||||||
|
</b>
|
||||||
|
(
|
||||||
|
regions:
|
||||||
|
|
||||||
|
1
|
||||||
|
,
|
||||||
|
100
|
||||||
|
RU/s,
|
||||||
|
$
|
||||||
|
0.00008
|
||||||
|
/RU)
|
||||||
|
</Text>
|
||||||
<StyledCheckboxBase
|
<StyledCheckboxBase
|
||||||
checked={false}
|
checked={false}
|
||||||
id="spendAckCheckBox"
|
id="spendAckCheckBox"
|
||||||
@@ -420,7 +288,6 @@ exports[`ThroughputInputAutoPilotV3Component spendAck checkbox visible 1`] = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<br />
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
`;
|
`;
|
||||||
@@ -502,19 +369,6 @@ exports[`ThroughputInputAutoPilotV3Component throughput input visible 1`] = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Text>
|
|
||||||
Estimate your required throughput with
|
|
||||||
<StyledLinkBase
|
|
||||||
href="https://cosmos.azure.com/capacitycalculator/"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
capacity calculator
|
|
||||||
|
|
||||||
<Component
|
|
||||||
iconName="NavigateExternalInline"
|
|
||||||
/>
|
|
||||||
</StyledLinkBase>
|
|
||||||
</Text>
|
|
||||||
<StyledTextFieldBase
|
<StyledTextFieldBase
|
||||||
disabled={false}
|
disabled={false}
|
||||||
id="throughputInput"
|
id="throughputInput"
|
||||||
@@ -540,143 +394,38 @@ exports[`ThroughputInputAutoPilotV3Component throughput input visible 1`] = `
|
|||||||
type="number"
|
type="number"
|
||||||
value="100"
|
value="100"
|
||||||
/>
|
/>
|
||||||
<Stack
|
<Text
|
||||||
styles={
|
id="throughputSpendElement"
|
||||||
Object {
|
|
||||||
"root": Object {
|
|
||||||
"width": 600,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tokens={
|
|
||||||
Object {
|
|
||||||
"childrenGap": 10,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<StyledWithViewportComponent
|
Estimated cost (
|
||||||
columns={
|
USD
|
||||||
Array [
|
):
|
||||||
Object {
|
|
||||||
"fieldName": "costType",
|
<b>
|
||||||
"isResizable": true,
|
|
||||||
"key": "costType",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "",
|
|
||||||
"styles": Object {
|
|
||||||
"root": Object {
|
|
||||||
"selectors": Object {
|
|
||||||
":hover": Object {
|
|
||||||
"background": "transparent",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"fieldName": "hourly",
|
|
||||||
"isResizable": true,
|
|
||||||
"key": "hourly",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "Hourly",
|
|
||||||
"styles": Object {
|
|
||||||
"root": Object {
|
|
||||||
"selectors": Object {
|
|
||||||
":hover": Object {
|
|
||||||
"background": "transparent",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"fieldName": "daily",
|
|
||||||
"isResizable": true,
|
|
||||||
"key": "daily",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "Daily",
|
|
||||||
"styles": Object {
|
|
||||||
"root": Object {
|
|
||||||
"selectors": Object {
|
|
||||||
":hover": Object {
|
|
||||||
"background": "transparent",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"fieldName": "monthly",
|
|
||||||
"isResizable": true,
|
|
||||||
"key": "monthly",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "Monthly",
|
|
||||||
"styles": Object {
|
|
||||||
"root": Object {
|
|
||||||
"selectors": Object {
|
|
||||||
":hover": Object {
|
|
||||||
"background": "transparent",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
disableSelectionZone={true}
|
|
||||||
items={
|
|
||||||
Array [
|
|
||||||
Object {
|
|
||||||
"costType": <Text>
|
|
||||||
Current Cost
|
|
||||||
</Text>,
|
|
||||||
"daily": <Text>
|
|
||||||
$
|
|
||||||
|
|
||||||
0.19
|
|
||||||
</Text>,
|
|
||||||
"hourly": <Text>
|
|
||||||
$
|
|
||||||
|
|
||||||
0.0080
|
|
||||||
</Text>,
|
|
||||||
"monthly": <Text>
|
|
||||||
$
|
|
||||||
|
|
||||||
5.84
|
|
||||||
</Text>,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
layoutMode={1}
|
|
||||||
onRenderRow={[Function]}
|
|
||||||
selectionMode={0}
|
|
||||||
/>
|
|
||||||
<Text
|
|
||||||
id="throughputSpendElement"
|
|
||||||
>
|
|
||||||
(
|
|
||||||
regions:
|
|
||||||
|
|
||||||
1
|
|
||||||
,
|
|
||||||
100
|
|
||||||
RU/s,
|
|
||||||
$
|
$
|
||||||
0.00008
|
0.0080
|
||||||
/RU)
|
hourly
|
||||||
</Text>
|
/
|
||||||
<Text>
|
$
|
||||||
<em>
|
0.19
|
||||||
*This cost is an estimate and may vary based on the regions where your account is deployed and potential discounts applied to your account
|
daily
|
||||||
</em>
|
/
|
||||||
</Text>
|
$
|
||||||
</Stack>
|
5.84
|
||||||
<br />
|
monthly
|
||||||
|
|
||||||
|
</b>
|
||||||
|
(
|
||||||
|
regions:
|
||||||
|
|
||||||
|
1
|
||||||
|
,
|
||||||
|
100
|
||||||
|
RU/s,
|
||||||
|
$
|
||||||
|
0.00008
|
||||||
|
/RU)
|
||||||
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`ScaleComponent renders with correct initial notification 1`] = `
|
exports[`ScaleComponent renders with correct intiial notification 1`] = `
|
||||||
<Stack
|
<Stack
|
||||||
tokens={
|
tokens={
|
||||||
Object {
|
Object {
|
||||||
@@ -48,7 +48,7 @@ exports[`ScaleComponent renders with correct initial notification 1`] = `
|
|||||||
label="Throughput (6,000 - unlimited RU/s)"
|
label="Throughput (6,000 - unlimited RU/s)"
|
||||||
maxAutoPilotThroughput={4000}
|
maxAutoPilotThroughput={4000}
|
||||||
maxAutoPilotThroughputBaseline={4000}
|
maxAutoPilotThroughputBaseline={4000}
|
||||||
maximum={1000000}
|
maximum={40000}
|
||||||
minimum={6000}
|
minimum={6000}
|
||||||
onAutoPilotSelected={[Function]}
|
onAutoPilotSelected={[Function]}
|
||||||
onMaxAutoPilotThroughputChange={[Function]}
|
onMaxAutoPilotThroughputChange={[Function]}
|
||||||
@@ -58,7 +58,6 @@ exports[`ScaleComponent renders with correct initial notification 1`] = `
|
|||||||
spendAckChecked={false}
|
spendAckChecked={false}
|
||||||
throughput={1000}
|
throughput={1000}
|
||||||
throughputBaseline={1000}
|
throughputBaseline={1000}
|
||||||
usageSizeInKB={100}
|
|
||||||
wasAutopilotOriginallySet={true}
|
wasAutopilotOriginallySet={true}
|
||||||
/>
|
/>
|
||||||
<Stack
|
<Stack
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { collection } from "./TestUtils";
|
import { collection, container } from "./TestUtils";
|
||||||
import {
|
import {
|
||||||
|
getMaxRUs,
|
||||||
|
getMinRUs,
|
||||||
getMongoIndexType,
|
getMongoIndexType,
|
||||||
getMongoNotification,
|
getMongoNotification,
|
||||||
getSanitizedInputValue,
|
getSanitizedInputValue,
|
||||||
@@ -21,6 +23,16 @@ import * as ViewModels from "../../../Contracts/ViewModels";
|
|||||||
import ko from "knockout";
|
import ko from "knockout";
|
||||||
|
|
||||||
describe("SettingsUtils", () => {
|
describe("SettingsUtils", () => {
|
||||||
|
it("getMaxRUs", () => {
|
||||||
|
expect(collection.offer().content.collectionThroughputInfo.numPhysicalPartitions).toEqual(4);
|
||||||
|
expect(getMaxRUs(collection, container)).toEqual(40000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("getMinRUs", () => {
|
||||||
|
expect(collection.offer().content.collectionThroughputInfo.numPhysicalPartitions).toEqual(4);
|
||||||
|
expect(getMinRUs(collection, container)).toEqual(6000);
|
||||||
|
});
|
||||||
|
|
||||||
it("hasDatabaseSharedThroughput", () => {
|
it("hasDatabaseSharedThroughput", () => {
|
||||||
expect(hasDatabaseSharedThroughput(collection)).toEqual(undefined);
|
expect(hasDatabaseSharedThroughput(collection)).toEqual(undefined);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import * as DataModels from "../../../Contracts/DataModels";
|
import * as DataModels from "../../../Contracts/DataModels";
|
||||||
import * as Constants from "../../../Common/Constants";
|
import * as Constants from "../../../Common/Constants";
|
||||||
|
import * as SharedConstants from "../../../Shared/Constants";
|
||||||
|
import * as PricingUtils from "../../../Utils/PricingUtils";
|
||||||
|
|
||||||
|
import Explorer from "../../Explorer";
|
||||||
import { MongoIndex } from "../../../Utils/arm/generatedClients/2020-04-01/types";
|
import { MongoIndex } from "../../../Utils/arm/generatedClients/2020-04-01/types";
|
||||||
|
|
||||||
const zeroValue = 0;
|
const zeroValue = 0;
|
||||||
@@ -67,6 +71,57 @@ export const hasDatabaseSharedThroughput = (collection: ViewModels.Collection):
|
|||||||
return database?.isDatabaseShared() && !collection.offer();
|
return database?.isDatabaseShared() && !collection.offer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getMaxRUs = (collection: ViewModels.Collection, container: Explorer): number => {
|
||||||
|
const isTryCosmosDBSubscription = container?.isTryCosmosDBSubscription() || false;
|
||||||
|
if (isTryCosmosDBSubscription) {
|
||||||
|
return Constants.TryCosmosExperience.maxRU;
|
||||||
|
}
|
||||||
|
|
||||||
|
const numPartitionsFromOffer: number =
|
||||||
|
collection?.offer && collection.offer()?.content?.collectionThroughputInfo?.numPhysicalPartitions;
|
||||||
|
|
||||||
|
const numPartitionsFromQuotaInfo: number = collection?.quotaInfo()?.numPartitions;
|
||||||
|
|
||||||
|
const numPartitions = numPartitionsFromOffer ?? numPartitionsFromQuotaInfo ?? 1;
|
||||||
|
|
||||||
|
return SharedConstants.CollectionCreation.MaxRUPerPartition * numPartitions;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getMinRUs = (collection: ViewModels.Collection, container: Explorer): number => {
|
||||||
|
const isTryCosmosDBSubscription = container?.isTryCosmosDBSubscription();
|
||||||
|
if (isTryCosmosDBSubscription) {
|
||||||
|
return SharedConstants.CollectionCreation.DefaultCollectionRUs400;
|
||||||
|
}
|
||||||
|
|
||||||
|
const offerContent = collection?.offer && collection.offer()?.content;
|
||||||
|
|
||||||
|
if (offerContent?.offerAutopilotSettings) {
|
||||||
|
return SharedConstants.CollectionCreation.DefaultCollectionRUs400;
|
||||||
|
}
|
||||||
|
|
||||||
|
const collectionThroughputInfo: DataModels.OfferThroughputInfo = offerContent?.collectionThroughputInfo;
|
||||||
|
|
||||||
|
if (collectionThroughputInfo?.minimumRUForCollection > 0) {
|
||||||
|
return collectionThroughputInfo.minimumRUForCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
const numPartitions = collectionThroughputInfo?.numPhysicalPartitions ?? collection.quotaInfo()?.numPartitions;
|
||||||
|
|
||||||
|
if (!numPartitions || numPartitions === 1) {
|
||||||
|
return SharedConstants.CollectionCreation.DefaultCollectionRUs400;
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseRU = SharedConstants.CollectionCreation.DefaultCollectionRUs400;
|
||||||
|
|
||||||
|
const quotaInKb = collection.quotaInfo().collectionSize;
|
||||||
|
const quotaInGb = PricingUtils.usageInGB(quotaInKb);
|
||||||
|
|
||||||
|
const perPartitionGBQuota: number = Math.max(10, quotaInGb / numPartitions);
|
||||||
|
const baseRUbyPartitions: number = ((numPartitions * perPartitionGBQuota) / 10) * 100;
|
||||||
|
|
||||||
|
return Math.max(baseRU, baseRUbyPartitions);
|
||||||
|
};
|
||||||
|
|
||||||
export const parseConflictResolutionMode = (modeFromBackend: string): DataModels.ConflictResolutionMode => {
|
export const parseConflictResolutionMode = (modeFromBackend: string): DataModels.ConflictResolutionMode => {
|
||||||
// Backend can contain different casing as it does case-insensitive comparisson
|
// Backend can contain different casing as it does case-insensitive comparisson
|
||||||
if (!modeFromBackend) {
|
if (!modeFromBackend) {
|
||||||
|
|||||||
@@ -18,14 +18,17 @@ export const collection = ({
|
|||||||
excludedPaths: []
|
excludedPaths: []
|
||||||
}),
|
}),
|
||||||
uniqueKeyPolicy: {} as DataModels.UniqueKeyPolicy,
|
uniqueKeyPolicy: {} as DataModels.UniqueKeyPolicy,
|
||||||
usageSizeInKB: ko.observable(100),
|
quotaInfo: ko.observable<DataModels.CollectionQuotaInfo>({} as DataModels.CollectionQuotaInfo),
|
||||||
offer: ko.observable<DataModels.Offer>({
|
offer: ko.observable<DataModels.Offer>({
|
||||||
autoscaleMaxThroughput: undefined,
|
content: {
|
||||||
manualThroughput: 10000,
|
offerThroughput: 10000,
|
||||||
minimumThroughput: 6000,
|
offerIsRUPerMinuteThroughputEnabled: false,
|
||||||
id: "offer",
|
collectionThroughputInfo: {
|
||||||
offerReplacePending: false
|
minimumRUForCollection: 6000,
|
||||||
}),
|
numPhysicalPartitions: 4
|
||||||
|
} as DataModels.OfferThroughputInfo
|
||||||
|
}
|
||||||
|
} as DataModels.Offer),
|
||||||
conflictResolutionPolicy: ko.observable<DataModels.ConflictResolutionPolicy>(
|
conflictResolutionPolicy: ko.observable<DataModels.ConflictResolutionPolicy>(
|
||||||
{} as DataModels.ConflictResolutionPolicy
|
{} as DataModels.ConflictResolutionPolicy
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKeyVisible": [Function],
|
"partitionKeyVisible": [Function],
|
||||||
"requestUnitsUsageCost": [Function],
|
"requestUnitsUsageCost": [Function],
|
||||||
"ruToolTipText": [Function],
|
"ruToolTipText": [Function],
|
||||||
|
"rupm": [Function],
|
||||||
|
"rupmVisible": [Function],
|
||||||
"sharedAutoPilotThroughput": [Function],
|
"sharedAutoPilotThroughput": [Function],
|
||||||
"sharedThroughputRangeText": [Function],
|
"sharedThroughputRangeText": [Function],
|
||||||
"shouldCreateMongoWildcardIndex": [Function],
|
"shouldCreateMongoWildcardIndex": [Function],
|
||||||
@@ -620,6 +622,8 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKeyVisible": [Function],
|
"partitionKeyVisible": [Function],
|
||||||
"requestUnitsUsageCost": [Function],
|
"requestUnitsUsageCost": [Function],
|
||||||
"ruToolTipText": [Function],
|
"ruToolTipText": [Function],
|
||||||
|
"rupm": [Function],
|
||||||
|
"rupmVisible": [Function],
|
||||||
"sharedAutoPilotThroughput": [Function],
|
"sharedAutoPilotThroughput": [Function],
|
||||||
"sharedThroughputRangeText": [Function],
|
"sharedThroughputRangeText": [Function],
|
||||||
"shouldCreateMongoWildcardIndex": [Function],
|
"shouldCreateMongoWildcardIndex": [Function],
|
||||||
@@ -731,6 +735,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"arcadiaToken": [Function],
|
"arcadiaToken": [Function],
|
||||||
|
"armEndpoint": [Function],
|
||||||
"browseQueriesPane": BrowseQueriesPane {
|
"browseQueriesPane": BrowseQueriesPane {
|
||||||
"canSaveQueries": [Function],
|
"canSaveQueries": [Function],
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@@ -942,6 +947,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"hasWriteAccess": [Function],
|
"hasWriteAccess": [Function],
|
||||||
"isAccountReady": [Function],
|
"isAccountReady": [Function],
|
||||||
"isAuthWithResourceToken": [Function],
|
"isAuthWithResourceToken": [Function],
|
||||||
|
"isCodeOfConductEnabled": [Function],
|
||||||
"isCopyNotebookPaneEnabled": [Function],
|
"isCopyNotebookPaneEnabled": [Function],
|
||||||
"isEnableMongoCapabilityPresent": [Function],
|
"isEnableMongoCapabilityPresent": [Function],
|
||||||
"isFixedCollectionWithSharedThroughputSupported": [Function],
|
"isFixedCollectionWithSharedThroughputSupported": [Function],
|
||||||
@@ -950,6 +956,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isHostedDataExplorerEnabled": [Function],
|
"isHostedDataExplorerEnabled": [Function],
|
||||||
"isLeftPaneExpanded": [Function],
|
"isLeftPaneExpanded": [Function],
|
||||||
"isLinkInjectionEnabled": [Function],
|
"isLinkInjectionEnabled": [Function],
|
||||||
|
"isMongoIndexEditorEnabled": [Function],
|
||||||
"isNotebookEnabled": [Function],
|
"isNotebookEnabled": [Function],
|
||||||
"isNotebooksEnabledForAccount": [Function],
|
"isNotebooksEnabledForAccount": [Function],
|
||||||
"isNotificationConsoleExpanded": [Function],
|
"isNotificationConsoleExpanded": [Function],
|
||||||
@@ -966,6 +973,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isRightPanelV2Enabled": [Function],
|
"isRightPanelV2Enabled": [Function],
|
||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
|
"isSettingsV2Enabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": [Function],
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
@@ -1022,6 +1030,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"onRefreshResourcesClick": [Function],
|
"onRefreshResourcesClick": [Function],
|
||||||
"onSwitchToConnectionString": [Function],
|
"onSwitchToConnectionString": [Function],
|
||||||
"onToggleKeyDown": [Function],
|
"onToggleKeyDown": [Function],
|
||||||
|
"parentFrameDataExplorerVersion": [Function],
|
||||||
"provideFeedbackEmail": [Function],
|
"provideFeedbackEmail": [Function],
|
||||||
"queriesClient": QueriesClient {
|
"queriesClient": QueriesClient {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@@ -1047,6 +1056,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"titleLabel": "Select Columns",
|
"titleLabel": "Select Columns",
|
||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
|
"quotaId": [Function],
|
||||||
"refreshDatabaseAccount": [Function],
|
"refreshDatabaseAccount": [Function],
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
@@ -1292,9 +1302,9 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"version": 2,
|
"version": 2,
|
||||||
},
|
},
|
||||||
"partitionKeyProperty": "partitionKey",
|
"partitionKeyProperty": "partitionKey",
|
||||||
|
"quotaInfo": [Function],
|
||||||
"readSettings": [Function],
|
"readSettings": [Function],
|
||||||
"uniqueKeyPolicy": Object {},
|
"uniqueKeyPolicy": Object {},
|
||||||
"usageSizeInKB": [Function],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
container={
|
container={
|
||||||
@@ -1404,6 +1414,8 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKeyVisible": [Function],
|
"partitionKeyVisible": [Function],
|
||||||
"requestUnitsUsageCost": [Function],
|
"requestUnitsUsageCost": [Function],
|
||||||
"ruToolTipText": [Function],
|
"ruToolTipText": [Function],
|
||||||
|
"rupm": [Function],
|
||||||
|
"rupmVisible": [Function],
|
||||||
"sharedAutoPilotThroughput": [Function],
|
"sharedAutoPilotThroughput": [Function],
|
||||||
"sharedThroughputRangeText": [Function],
|
"sharedThroughputRangeText": [Function],
|
||||||
"shouldCreateMongoWildcardIndex": [Function],
|
"shouldCreateMongoWildcardIndex": [Function],
|
||||||
@@ -1891,6 +1903,8 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKeyVisible": [Function],
|
"partitionKeyVisible": [Function],
|
||||||
"requestUnitsUsageCost": [Function],
|
"requestUnitsUsageCost": [Function],
|
||||||
"ruToolTipText": [Function],
|
"ruToolTipText": [Function],
|
||||||
|
"rupm": [Function],
|
||||||
|
"rupmVisible": [Function],
|
||||||
"sharedAutoPilotThroughput": [Function],
|
"sharedAutoPilotThroughput": [Function],
|
||||||
"sharedThroughputRangeText": [Function],
|
"sharedThroughputRangeText": [Function],
|
||||||
"shouldCreateMongoWildcardIndex": [Function],
|
"shouldCreateMongoWildcardIndex": [Function],
|
||||||
@@ -2002,6 +2016,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"arcadiaToken": [Function],
|
"arcadiaToken": [Function],
|
||||||
|
"armEndpoint": [Function],
|
||||||
"browseQueriesPane": BrowseQueriesPane {
|
"browseQueriesPane": BrowseQueriesPane {
|
||||||
"canSaveQueries": [Function],
|
"canSaveQueries": [Function],
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@@ -2213,6 +2228,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"hasWriteAccess": [Function],
|
"hasWriteAccess": [Function],
|
||||||
"isAccountReady": [Function],
|
"isAccountReady": [Function],
|
||||||
"isAuthWithResourceToken": [Function],
|
"isAuthWithResourceToken": [Function],
|
||||||
|
"isCodeOfConductEnabled": [Function],
|
||||||
"isCopyNotebookPaneEnabled": [Function],
|
"isCopyNotebookPaneEnabled": [Function],
|
||||||
"isEnableMongoCapabilityPresent": [Function],
|
"isEnableMongoCapabilityPresent": [Function],
|
||||||
"isFixedCollectionWithSharedThroughputSupported": [Function],
|
"isFixedCollectionWithSharedThroughputSupported": [Function],
|
||||||
@@ -2221,6 +2237,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isHostedDataExplorerEnabled": [Function],
|
"isHostedDataExplorerEnabled": [Function],
|
||||||
"isLeftPaneExpanded": [Function],
|
"isLeftPaneExpanded": [Function],
|
||||||
"isLinkInjectionEnabled": [Function],
|
"isLinkInjectionEnabled": [Function],
|
||||||
|
"isMongoIndexEditorEnabled": [Function],
|
||||||
"isNotebookEnabled": [Function],
|
"isNotebookEnabled": [Function],
|
||||||
"isNotebooksEnabledForAccount": [Function],
|
"isNotebooksEnabledForAccount": [Function],
|
||||||
"isNotificationConsoleExpanded": [Function],
|
"isNotificationConsoleExpanded": [Function],
|
||||||
@@ -2237,6 +2254,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isRightPanelV2Enabled": [Function],
|
"isRightPanelV2Enabled": [Function],
|
||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
|
"isSettingsV2Enabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": [Function],
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
@@ -2293,6 +2311,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"onRefreshResourcesClick": [Function],
|
"onRefreshResourcesClick": [Function],
|
||||||
"onSwitchToConnectionString": [Function],
|
"onSwitchToConnectionString": [Function],
|
||||||
"onToggleKeyDown": [Function],
|
"onToggleKeyDown": [Function],
|
||||||
|
"parentFrameDataExplorerVersion": [Function],
|
||||||
"provideFeedbackEmail": [Function],
|
"provideFeedbackEmail": [Function],
|
||||||
"queriesClient": QueriesClient {
|
"queriesClient": QueriesClient {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@@ -2318,6 +2337,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"titleLabel": "Select Columns",
|
"titleLabel": "Select Columns",
|
||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
|
"quotaId": [Function],
|
||||||
"refreshDatabaseAccount": [Function],
|
"refreshDatabaseAccount": [Function],
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
@@ -2688,6 +2708,8 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKeyVisible": [Function],
|
"partitionKeyVisible": [Function],
|
||||||
"requestUnitsUsageCost": [Function],
|
"requestUnitsUsageCost": [Function],
|
||||||
"ruToolTipText": [Function],
|
"ruToolTipText": [Function],
|
||||||
|
"rupm": [Function],
|
||||||
|
"rupmVisible": [Function],
|
||||||
"sharedAutoPilotThroughput": [Function],
|
"sharedAutoPilotThroughput": [Function],
|
||||||
"sharedThroughputRangeText": [Function],
|
"sharedThroughputRangeText": [Function],
|
||||||
"shouldCreateMongoWildcardIndex": [Function],
|
"shouldCreateMongoWildcardIndex": [Function],
|
||||||
@@ -3175,6 +3197,8 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKeyVisible": [Function],
|
"partitionKeyVisible": [Function],
|
||||||
"requestUnitsUsageCost": [Function],
|
"requestUnitsUsageCost": [Function],
|
||||||
"ruToolTipText": [Function],
|
"ruToolTipText": [Function],
|
||||||
|
"rupm": [Function],
|
||||||
|
"rupmVisible": [Function],
|
||||||
"sharedAutoPilotThroughput": [Function],
|
"sharedAutoPilotThroughput": [Function],
|
||||||
"sharedThroughputRangeText": [Function],
|
"sharedThroughputRangeText": [Function],
|
||||||
"shouldCreateMongoWildcardIndex": [Function],
|
"shouldCreateMongoWildcardIndex": [Function],
|
||||||
@@ -3286,6 +3310,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"arcadiaToken": [Function],
|
"arcadiaToken": [Function],
|
||||||
|
"armEndpoint": [Function],
|
||||||
"browseQueriesPane": BrowseQueriesPane {
|
"browseQueriesPane": BrowseQueriesPane {
|
||||||
"canSaveQueries": [Function],
|
"canSaveQueries": [Function],
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@@ -3497,6 +3522,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"hasWriteAccess": [Function],
|
"hasWriteAccess": [Function],
|
||||||
"isAccountReady": [Function],
|
"isAccountReady": [Function],
|
||||||
"isAuthWithResourceToken": [Function],
|
"isAuthWithResourceToken": [Function],
|
||||||
|
"isCodeOfConductEnabled": [Function],
|
||||||
"isCopyNotebookPaneEnabled": [Function],
|
"isCopyNotebookPaneEnabled": [Function],
|
||||||
"isEnableMongoCapabilityPresent": [Function],
|
"isEnableMongoCapabilityPresent": [Function],
|
||||||
"isFixedCollectionWithSharedThroughputSupported": [Function],
|
"isFixedCollectionWithSharedThroughputSupported": [Function],
|
||||||
@@ -3505,6 +3531,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isHostedDataExplorerEnabled": [Function],
|
"isHostedDataExplorerEnabled": [Function],
|
||||||
"isLeftPaneExpanded": [Function],
|
"isLeftPaneExpanded": [Function],
|
||||||
"isLinkInjectionEnabled": [Function],
|
"isLinkInjectionEnabled": [Function],
|
||||||
|
"isMongoIndexEditorEnabled": [Function],
|
||||||
"isNotebookEnabled": [Function],
|
"isNotebookEnabled": [Function],
|
||||||
"isNotebooksEnabledForAccount": [Function],
|
"isNotebooksEnabledForAccount": [Function],
|
||||||
"isNotificationConsoleExpanded": [Function],
|
"isNotificationConsoleExpanded": [Function],
|
||||||
@@ -3521,6 +3548,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isRightPanelV2Enabled": [Function],
|
"isRightPanelV2Enabled": [Function],
|
||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
|
"isSettingsV2Enabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": [Function],
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
@@ -3577,6 +3605,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"onRefreshResourcesClick": [Function],
|
"onRefreshResourcesClick": [Function],
|
||||||
"onSwitchToConnectionString": [Function],
|
"onSwitchToConnectionString": [Function],
|
||||||
"onToggleKeyDown": [Function],
|
"onToggleKeyDown": [Function],
|
||||||
|
"parentFrameDataExplorerVersion": [Function],
|
||||||
"provideFeedbackEmail": [Function],
|
"provideFeedbackEmail": [Function],
|
||||||
"queriesClient": QueriesClient {
|
"queriesClient": QueriesClient {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@@ -3602,6 +3631,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"titleLabel": "Select Columns",
|
"titleLabel": "Select Columns",
|
||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
|
"quotaId": [Function],
|
||||||
"refreshDatabaseAccount": [Function],
|
"refreshDatabaseAccount": [Function],
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
@@ -3847,9 +3877,9 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"version": 2,
|
"version": 2,
|
||||||
},
|
},
|
||||||
"partitionKeyProperty": "partitionKey",
|
"partitionKeyProperty": "partitionKey",
|
||||||
|
"quotaInfo": [Function],
|
||||||
"readSettings": [Function],
|
"readSettings": [Function],
|
||||||
"uniqueKeyPolicy": Object {},
|
"uniqueKeyPolicy": Object {},
|
||||||
"usageSizeInKB": [Function],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
container={
|
container={
|
||||||
@@ -3959,6 +3989,8 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKeyVisible": [Function],
|
"partitionKeyVisible": [Function],
|
||||||
"requestUnitsUsageCost": [Function],
|
"requestUnitsUsageCost": [Function],
|
||||||
"ruToolTipText": [Function],
|
"ruToolTipText": [Function],
|
||||||
|
"rupm": [Function],
|
||||||
|
"rupmVisible": [Function],
|
||||||
"sharedAutoPilotThroughput": [Function],
|
"sharedAutoPilotThroughput": [Function],
|
||||||
"sharedThroughputRangeText": [Function],
|
"sharedThroughputRangeText": [Function],
|
||||||
"shouldCreateMongoWildcardIndex": [Function],
|
"shouldCreateMongoWildcardIndex": [Function],
|
||||||
@@ -4446,6 +4478,8 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKeyVisible": [Function],
|
"partitionKeyVisible": [Function],
|
||||||
"requestUnitsUsageCost": [Function],
|
"requestUnitsUsageCost": [Function],
|
||||||
"ruToolTipText": [Function],
|
"ruToolTipText": [Function],
|
||||||
|
"rupm": [Function],
|
||||||
|
"rupmVisible": [Function],
|
||||||
"sharedAutoPilotThroughput": [Function],
|
"sharedAutoPilotThroughput": [Function],
|
||||||
"sharedThroughputRangeText": [Function],
|
"sharedThroughputRangeText": [Function],
|
||||||
"shouldCreateMongoWildcardIndex": [Function],
|
"shouldCreateMongoWildcardIndex": [Function],
|
||||||
@@ -4557,6 +4591,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
"arcadiaToken": [Function],
|
"arcadiaToken": [Function],
|
||||||
|
"armEndpoint": [Function],
|
||||||
"browseQueriesPane": BrowseQueriesPane {
|
"browseQueriesPane": BrowseQueriesPane {
|
||||||
"canSaveQueries": [Function],
|
"canSaveQueries": [Function],
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@@ -4768,6 +4803,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"hasWriteAccess": [Function],
|
"hasWriteAccess": [Function],
|
||||||
"isAccountReady": [Function],
|
"isAccountReady": [Function],
|
||||||
"isAuthWithResourceToken": [Function],
|
"isAuthWithResourceToken": [Function],
|
||||||
|
"isCodeOfConductEnabled": [Function],
|
||||||
"isCopyNotebookPaneEnabled": [Function],
|
"isCopyNotebookPaneEnabled": [Function],
|
||||||
"isEnableMongoCapabilityPresent": [Function],
|
"isEnableMongoCapabilityPresent": [Function],
|
||||||
"isFixedCollectionWithSharedThroughputSupported": [Function],
|
"isFixedCollectionWithSharedThroughputSupported": [Function],
|
||||||
@@ -4776,6 +4812,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isHostedDataExplorerEnabled": [Function],
|
"isHostedDataExplorerEnabled": [Function],
|
||||||
"isLeftPaneExpanded": [Function],
|
"isLeftPaneExpanded": [Function],
|
||||||
"isLinkInjectionEnabled": [Function],
|
"isLinkInjectionEnabled": [Function],
|
||||||
|
"isMongoIndexEditorEnabled": [Function],
|
||||||
"isNotebookEnabled": [Function],
|
"isNotebookEnabled": [Function],
|
||||||
"isNotebooksEnabledForAccount": [Function],
|
"isNotebooksEnabledForAccount": [Function],
|
||||||
"isNotificationConsoleExpanded": [Function],
|
"isNotificationConsoleExpanded": [Function],
|
||||||
@@ -4792,6 +4829,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"isRightPanelV2Enabled": [Function],
|
"isRightPanelV2Enabled": [Function],
|
||||||
"isSchemaEnabled": [Function],
|
"isSchemaEnabled": [Function],
|
||||||
"isServerlessEnabled": [Function],
|
"isServerlessEnabled": [Function],
|
||||||
|
"isSettingsV2Enabled": [Function],
|
||||||
"isSparkEnabled": [Function],
|
"isSparkEnabled": [Function],
|
||||||
"isSparkEnabledForAccount": [Function],
|
"isSparkEnabledForAccount": [Function],
|
||||||
"isSynapseLinkUpdating": [Function],
|
"isSynapseLinkUpdating": [Function],
|
||||||
@@ -4848,6 +4886,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"onRefreshResourcesClick": [Function],
|
"onRefreshResourcesClick": [Function],
|
||||||
"onSwitchToConnectionString": [Function],
|
"onSwitchToConnectionString": [Function],
|
||||||
"onToggleKeyDown": [Function],
|
"onToggleKeyDown": [Function],
|
||||||
|
"parentFrameDataExplorerVersion": [Function],
|
||||||
"provideFeedbackEmail": [Function],
|
"provideFeedbackEmail": [Function],
|
||||||
"queriesClient": QueriesClient {
|
"queriesClient": QueriesClient {
|
||||||
"container": [Circular],
|
"container": [Circular],
|
||||||
@@ -4873,6 +4912,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"titleLabel": "Select Columns",
|
"titleLabel": "Select Columns",
|
||||||
"visible": [Function],
|
"visible": [Function],
|
||||||
},
|
},
|
||||||
|
"quotaId": [Function],
|
||||||
"refreshDatabaseAccount": [Function],
|
"refreshDatabaseAccount": [Function],
|
||||||
"refreshNotebookList": [Function],
|
"refreshNotebookList": [Function],
|
||||||
"refreshTreeTitle": [Function],
|
"refreshTreeTitle": [Function],
|
||||||
|
|||||||
@@ -60,100 +60,66 @@ exports[`SettingsUtils functions render 1`] = `
|
|||||||
</StyledLinkBase>
|
</StyledLinkBase>
|
||||||
.
|
.
|
||||||
</Text>
|
</Text>
|
||||||
<Stack
|
<Text
|
||||||
styles={
|
id="throughputSpendElement"
|
||||||
Object {
|
|
||||||
"root": Object {
|
|
||||||
"width": 600,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tokens={
|
|
||||||
Object {
|
|
||||||
"childrenGap": 10,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<StyledWithViewportComponent
|
Estimated cost (
|
||||||
columns={
|
RMB
|
||||||
Array [
|
):
|
||||||
Object {
|
|
||||||
"fieldName": "costType",
|
<b>
|
||||||
"isResizable": true,
|
|
||||||
"key": "costType",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"fieldName": "hourly",
|
|
||||||
"isResizable": true,
|
|
||||||
"key": "hourly",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "Hourly",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"fieldName": "daily",
|
|
||||||
"isResizable": true,
|
|
||||||
"key": "daily",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "Daily",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"fieldName": "monthly",
|
|
||||||
"isResizable": true,
|
|
||||||
"key": "monthly",
|
|
||||||
"maxWidth": 200,
|
|
||||||
"minWidth": 100,
|
|
||||||
"name": "Monthly",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
disableSelectionZone={true}
|
|
||||||
items={
|
|
||||||
Array [
|
|
||||||
Object {
|
|
||||||
"costType": <Text>
|
|
||||||
Current Cost
|
|
||||||
</Text>,
|
|
||||||
"daily": <Text>
|
|
||||||
$ 24.48
|
|
||||||
</Text>,
|
|
||||||
"hourly": <Text>
|
|
||||||
$ 1.02
|
|
||||||
</Text>,
|
|
||||||
"monthly": <Text>
|
|
||||||
$ 744.6
|
|
||||||
</Text>,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
layoutMode={1}
|
|
||||||
onRenderRow={[Function]}
|
|
||||||
selectionMode={0}
|
|
||||||
/>
|
|
||||||
<Text
|
|
||||||
id="throughputSpendElement"
|
|
||||||
>
|
|
||||||
(
|
|
||||||
regions:
|
|
||||||
|
|
||||||
2
|
|
||||||
,
|
|
||||||
1000
|
|
||||||
RU/s,
|
|
||||||
¥
|
¥
|
||||||
0.00051
|
1.29
|
||||||
/RU)
|
hourly
|
||||||
</Text>
|
/
|
||||||
<Text>
|
¥
|
||||||
<em>
|
31.06
|
||||||
*This cost is an estimate and may vary based on the regions where your account is deployed and potential discounts applied to your account
|
daily
|
||||||
</em>
|
/
|
||||||
</Text>
|
¥
|
||||||
</Stack>
|
944.60
|
||||||
|
monthly
|
||||||
|
|
||||||
|
</b>
|
||||||
|
(
|
||||||
|
regions:
|
||||||
|
|
||||||
|
2
|
||||||
|
,
|
||||||
|
1000
|
||||||
|
RU/s,
|
||||||
|
¥
|
||||||
|
0.00051
|
||||||
|
/RU)
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
id="autoscaleSpendElement"
|
||||||
|
>
|
||||||
|
Estimated monthly cost (
|
||||||
|
RMB
|
||||||
|
) is
|
||||||
|
|
||||||
|
<b>
|
||||||
|
¥
|
||||||
|
111.69
|
||||||
|
-
|
||||||
|
¥
|
||||||
|
1116.90
|
||||||
|
|
||||||
|
</b>
|
||||||
|
(
|
||||||
|
regions:
|
||||||
|
|
||||||
|
2
|
||||||
|
,
|
||||||
|
100
|
||||||
|
-
|
||||||
|
1000
|
||||||
|
RU/s,
|
||||||
|
¥
|
||||||
|
0.000765
|
||||||
|
/RU)
|
||||||
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
id="manualToAutoscaleDisclaimerElement"
|
id="manualToAutoscaleDisclaimerElement"
|
||||||
styles={
|
styles={
|
||||||
@@ -261,7 +227,7 @@ exports[`SettingsUtils functions render 1`] = `
|
|||||||
, Container:
|
, Container:
|
||||||
sampleCollection
|
sampleCollection
|
||||||
|
|
||||||
, Current manual throughput: 1000 RU/s
|
, Current manual throughput: 1000 RU/s, Target manual throughput: 2000
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
id="throughputApplyLongDelayMessage"
|
id="throughputApplyLongDelayMessage"
|
||||||
|
|||||||
@@ -126,12 +126,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-bind="visible: !isAutoPilotSelected()">
|
<div data-bind="visible: !isAutoPilotSelected()">
|
||||||
<p>
|
|
||||||
<span
|
|
||||||
>Estimate your required throughput with
|
|
||||||
<a target="_blank" href="https://cosmos.azure.com/capacitycalculator/">capacity calculator</a></span
|
|
||||||
>
|
|
||||||
</p>
|
|
||||||
<div data-bind="setTemplateReady: true">
|
<div data-bind="setTemplateReady: true">
|
||||||
<input
|
<input
|
||||||
data-bind="
|
data-bind="
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
|
jest.mock("../../Common/DocumentClientUtilityBase");
|
||||||
jest.mock("../Graph/GraphExplorerComponent/GremlinClient");
|
jest.mock("../Graph/GraphExplorerComponent/GremlinClient");
|
||||||
jest.mock("../../Common/dataAccess/createCollection");
|
jest.mock("../../Common/dataAccess/createCollection");
|
||||||
jest.mock("../../Common/dataAccess/createDocument");
|
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import Q from "q";
|
import Q from "q";
|
||||||
import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
|
import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
|
||||||
import { createDocument } from "../../Common/dataAccess/createDocument";
|
import { createDocument } from "../../Common/DocumentClientUtilityBase";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
import { updateUserContext } from "../../UserContext";
|
import { updateUserContext } from "../../UserContext";
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import GraphTab from ".././Tabs/GraphTab";
|
|||||||
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
||||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
|
import { createDocument } from "../../Common/DocumentClientUtilityBase";
|
||||||
import { createCollection } from "../../Common/dataAccess/createCollection";
|
import { createCollection } from "../../Common/dataAccess/createCollection";
|
||||||
import { createDocument } from "../../Common/dataAccess/createDocument";
|
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
|
|
||||||
interface SampleDataFile extends DataModels.CreateCollectionParams {
|
interface SampleDataFile extends DataModels.CreateCollectionParams {
|
||||||
@@ -95,15 +95,12 @@ export class ContainerSampleGenerator {
|
|||||||
.reduce((previous, current) => previous.then(current), Promise.resolve());
|
.reduce((previous, current) => previous.then(current), Promise.resolve());
|
||||||
} else {
|
} else {
|
||||||
// For SQL all queries are executed at the same time
|
// For SQL all queries are executed at the same time
|
||||||
await Promise.all(
|
this.sampleDataFile.data.map(doc => {
|
||||||
this.sampleDataFile.data.map(async doc => {
|
const subPromise = createDocument(collection, doc);
|
||||||
try {
|
subPromise.catch(reason => NotificationConsoleUtils.logConsoleError(reason));
|
||||||
await createDocument(collection, doc);
|
promises.push(subPromise);
|
||||||
} catch (error) {
|
});
|
||||||
NotificationConsoleUtils.logConsoleError(error);
|
await Promise.all(promises);
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import DeleteDatabaseConfirmationPane from "./Panes/DeleteDatabaseConfirmationPa
|
|||||||
import { readCollection } from "../Common/dataAccess/readCollection";
|
import { readCollection } from "../Common/dataAccess/readCollection";
|
||||||
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
||||||
import EditTableEntityPane from "./Panes/Tables/EditTableEntityPane";
|
import EditTableEntityPane from "./Panes/Tables/EditTableEntityPane";
|
||||||
import { normalizeArmEndpoint } from "../Common/EnvironmentUtility";
|
import EnvironmentUtility from "../Common/EnvironmentUtility";
|
||||||
import GraphStylingPane from "./Panes/GraphStylingPane";
|
import GraphStylingPane from "./Panes/GraphStylingPane";
|
||||||
import hasher from "hasher";
|
import hasher from "hasher";
|
||||||
import NewVertexPane from "./Panes/NewVertexPane";
|
import NewVertexPane from "./Panes/NewVertexPane";
|
||||||
@@ -121,6 +121,7 @@ export default class Explorer {
|
|||||||
public databaseAccount: ko.Observable<DataModels.DatabaseAccount>;
|
public databaseAccount: ko.Observable<DataModels.DatabaseAccount>;
|
||||||
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
|
public collectionCreationDefaults: ViewModels.CollectionCreationDefaults = SharedConstants.CollectionCreationDefaults;
|
||||||
public subscriptionType: ko.Observable<SubscriptionType>;
|
public subscriptionType: ko.Observable<SubscriptionType>;
|
||||||
|
public quotaId: ko.Observable<string>;
|
||||||
public defaultExperience: ko.Observable<string>;
|
public defaultExperience: ko.Observable<string>;
|
||||||
public isPreferredApiDocumentDB: ko.Computed<boolean>;
|
public isPreferredApiDocumentDB: ko.Computed<boolean>;
|
||||||
public isPreferredApiCassandra: ko.Computed<boolean>;
|
public isPreferredApiCassandra: ko.Computed<boolean>;
|
||||||
@@ -134,10 +135,12 @@ export default class Explorer {
|
|||||||
public canSaveQueries: ko.Computed<boolean>;
|
public canSaveQueries: ko.Computed<boolean>;
|
||||||
public features: ko.Observable<any>;
|
public features: ko.Observable<any>;
|
||||||
public serverId: ko.Observable<string>;
|
public serverId: ko.Observable<string>;
|
||||||
|
public armEndpoint: ko.Observable<string>;
|
||||||
public isTryCosmosDBSubscription: ko.Observable<boolean>;
|
public isTryCosmosDBSubscription: ko.Observable<boolean>;
|
||||||
public queriesClient: QueriesClient;
|
public queriesClient: QueriesClient;
|
||||||
public tableDataClient: TableDataClient;
|
public tableDataClient: TableDataClient;
|
||||||
public splitter: Splitter;
|
public splitter: Splitter;
|
||||||
|
public parentFrameDataExplorerVersion: ko.Observable<string> = ko.observable<string>("");
|
||||||
public mostRecentActivity: MostRecentActivity.MostRecentActivity;
|
public mostRecentActivity: MostRecentActivity.MostRecentActivity;
|
||||||
|
|
||||||
// Notification Console
|
// Notification Console
|
||||||
@@ -201,7 +204,10 @@ export default class Explorer {
|
|||||||
|
|
||||||
// features
|
// features
|
||||||
public isGalleryPublishEnabled: ko.Computed<boolean>;
|
public isGalleryPublishEnabled: ko.Computed<boolean>;
|
||||||
|
public isCodeOfConductEnabled: ko.Computed<boolean>;
|
||||||
public isLinkInjectionEnabled: ko.Computed<boolean>;
|
public isLinkInjectionEnabled: ko.Computed<boolean>;
|
||||||
|
public isSettingsV2Enabled: ko.Observable<boolean>;
|
||||||
|
public isMongoIndexEditorEnabled: ko.Observable<boolean>;
|
||||||
public isGitHubPaneEnabled: ko.Observable<boolean>;
|
public isGitHubPaneEnabled: ko.Observable<boolean>;
|
||||||
public isPublishNotebookPaneEnabled: ko.Observable<boolean>;
|
public isPublishNotebookPaneEnabled: ko.Observable<boolean>;
|
||||||
public isCopyNotebookPaneEnabled: ko.Observable<boolean>;
|
public isCopyNotebookPaneEnabled: ko.Observable<boolean>;
|
||||||
@@ -275,6 +281,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
this.databaseAccount = ko.observable<DataModels.DatabaseAccount>();
|
this.databaseAccount = ko.observable<DataModels.DatabaseAccount>();
|
||||||
this.subscriptionType = ko.observable<SubscriptionType>(SharedConstants.CollectionCreation.DefaultSubscriptionType);
|
this.subscriptionType = ko.observable<SubscriptionType>(SharedConstants.CollectionCreation.DefaultSubscriptionType);
|
||||||
|
this.quotaId = ko.observable<string>("");
|
||||||
let firstInitialization = true;
|
let firstInitialization = true;
|
||||||
this.isRefreshingExplorer = ko.observable<boolean>(true);
|
this.isRefreshingExplorer = ko.observable<boolean>(true);
|
||||||
this.isRefreshingExplorer.subscribe((isRefreshing: boolean) => {
|
this.isRefreshingExplorer.subscribe((isRefreshing: boolean) => {
|
||||||
@@ -314,9 +321,9 @@ export default class Explorer {
|
|||||||
if (isAccountReady) {
|
if (isAccountReady) {
|
||||||
this.isAuthWithResourceToken() ? this.refreshDatabaseForResourceToken() : this.refreshAllDatabases(true);
|
this.isAuthWithResourceToken() ? this.refreshDatabaseForResourceToken() : this.refreshAllDatabases(true);
|
||||||
RouteHandler.getInstance().initHandler();
|
RouteHandler.getInstance().initHandler();
|
||||||
this.notebookWorkspaceManager = new NotebookWorkspaceManager();
|
this.notebookWorkspaceManager = new NotebookWorkspaceManager(this.armEndpoint());
|
||||||
this.arcadiaWorkspaces = ko.observableArray();
|
this.arcadiaWorkspaces = ko.observableArray();
|
||||||
this._arcadiaManager = new ArcadiaResourceManager();
|
this._arcadiaManager = new ArcadiaResourceManager(this.armEndpoint());
|
||||||
this._isAfecFeatureRegistered(Constants.AfecFeatures.StorageAnalytics).then(isRegistered =>
|
this._isAfecFeatureRegistered(Constants.AfecFeatures.StorageAnalytics).then(isRegistered =>
|
||||||
this.hasStorageAnalyticsAfecFeature(isRegistered)
|
this.hasStorageAnalyticsAfecFeature(isRegistered)
|
||||||
);
|
);
|
||||||
@@ -366,6 +373,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
this.features = ko.observable();
|
this.features = ko.observable();
|
||||||
this.serverId = ko.observable<string>();
|
this.serverId = ko.observable<string>();
|
||||||
|
this.armEndpoint = ko.observable<string>(undefined);
|
||||||
this.queriesClient = new QueriesClient(this);
|
this.queriesClient = new QueriesClient(this);
|
||||||
this.isTryCosmosDBSubscription = ko.observable<boolean>(false);
|
this.isTryCosmosDBSubscription = ko.observable<boolean>(false);
|
||||||
|
|
||||||
@@ -398,9 +406,14 @@ export default class Explorer {
|
|||||||
this.isGalleryPublishEnabled = ko.computed<boolean>(() =>
|
this.isGalleryPublishEnabled = ko.computed<boolean>(() =>
|
||||||
this.isFeatureEnabled(Constants.Features.enableGalleryPublish)
|
this.isFeatureEnabled(Constants.Features.enableGalleryPublish)
|
||||||
);
|
);
|
||||||
|
this.isCodeOfConductEnabled = ko.computed<boolean>(() =>
|
||||||
|
this.isFeatureEnabled(Constants.Features.enableCodeOfConduct)
|
||||||
|
);
|
||||||
this.isLinkInjectionEnabled = ko.computed<boolean>(() =>
|
this.isLinkInjectionEnabled = ko.computed<boolean>(() =>
|
||||||
this.isFeatureEnabled(Constants.Features.enableLinkInjection)
|
this.isFeatureEnabled(Constants.Features.enableLinkInjection)
|
||||||
);
|
);
|
||||||
|
this.isSettingsV2Enabled = ko.observable(false);
|
||||||
|
this.isMongoIndexEditorEnabled = ko.observable(false);
|
||||||
this.isGitHubPaneEnabled = ko.observable<boolean>(false);
|
this.isGitHubPaneEnabled = ko.observable<boolean>(false);
|
||||||
this.isPublishNotebookPaneEnabled = ko.observable<boolean>(false);
|
this.isPublishNotebookPaneEnabled = ko.observable<boolean>(false);
|
||||||
this.isCopyNotebookPaneEnabled = ko.observable<boolean>(false);
|
this.isCopyNotebookPaneEnabled = ko.observable<boolean>(false);
|
||||||
@@ -1007,7 +1020,9 @@ export default class Explorer {
|
|||||||
this.isSynapseLinkUpdating(true);
|
this.isSynapseLinkUpdating(true);
|
||||||
this._closeSynapseLinkModalDialog();
|
this._closeSynapseLinkModalDialog();
|
||||||
|
|
||||||
const resourceProviderClient = new ResourceProviderClientFactory().getOrCreate(this.databaseAccount().id);
|
const resourceProviderClient = new ResourceProviderClientFactory(this.armEndpoint()).getOrCreate(
|
||||||
|
this.databaseAccount().id
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const databaseAccount: DataModels.DatabaseAccount = await resourceProviderClient.patchAsync(
|
const databaseAccount: DataModels.DatabaseAccount = await resourceProviderClient.patchAsync(
|
||||||
@@ -1260,6 +1275,16 @@ export default class Explorer {
|
|||||||
$("#contextSwitchPrompt").dialog("open");
|
$("#contextSwitchPrompt").dialog("open");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public displayConnectExplorerForm(): void {
|
||||||
|
$("#divExplorer").hide();
|
||||||
|
$("#connectExplorer").css("display", "flex");
|
||||||
|
}
|
||||||
|
|
||||||
|
public hideConnectExplorerForm(): void {
|
||||||
|
$("#connectExplorer").hide();
|
||||||
|
$("#divExplorer").show();
|
||||||
|
}
|
||||||
|
|
||||||
public isReadWriteToggled: () => boolean = (): boolean => {
|
public isReadWriteToggled: () => boolean = (): boolean => {
|
||||||
return this.shareAccessToggleState() === ShareAccessToggleState.ReadWrite;
|
return this.shareAccessToggleState() === ShareAccessToggleState.ReadWrite;
|
||||||
};
|
};
|
||||||
@@ -1709,7 +1734,6 @@ export default class Explorer {
|
|||||||
case MessageTypes.SendNotification:
|
case MessageTypes.SendNotification:
|
||||||
case MessageTypes.ClearNotification:
|
case MessageTypes.ClearNotification:
|
||||||
case MessageTypes.LoadingStatus:
|
case MessageTypes.LoadingStatus:
|
||||||
case MessageTypes.InitTestExplorer:
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1737,59 +1761,61 @@ export default class Explorer {
|
|||||||
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initDataExplorerWithFrameInputs(inputs);
|
const initPromise: Q.Promise<void> = inputs ? this.initDataExplorerWithFrameInputs(inputs) : Q();
|
||||||
|
|
||||||
const openAction: ActionContracts.DataExplorerAction = message.openAction;
|
initPromise.then(() => {
|
||||||
if (!!openAction) {
|
const openAction: ActionContracts.DataExplorerAction = message.openAction;
|
||||||
if (this.isRefreshingExplorer()) {
|
if (!!openAction) {
|
||||||
const subscription = this.databases.subscribe((databases: ViewModels.Database[]) => {
|
if (this.isRefreshingExplorer()) {
|
||||||
|
const subscription = this.databases.subscribe((databases: ViewModels.Database[]) => {
|
||||||
|
handleOpenAction(openAction, this.nonSystemDatabases(), this);
|
||||||
|
subscription.dispose();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
handleOpenAction(openAction, this.nonSystemDatabases(), this);
|
handleOpenAction(openAction, this.nonSystemDatabases(), this);
|
||||||
subscription.dispose();
|
}
|
||||||
});
|
|
||||||
} else {
|
|
||||||
handleOpenAction(openAction, this.nonSystemDatabases(), this);
|
|
||||||
}
|
}
|
||||||
}
|
if (message.actionType === ActionContracts.ActionType.TransmitCachedData) {
|
||||||
if (message.actionType === ActionContracts.ActionType.TransmitCachedData) {
|
handleCachedDataMessage(message);
|
||||||
handleCachedDataMessage(message);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (message.type) {
|
||||||
if (message.type) {
|
switch (message.type) {
|
||||||
switch (message.type) {
|
case MessageTypes.UpdateLocationHash:
|
||||||
case MessageTypes.UpdateLocationHash:
|
if (!message.locationHash) {
|
||||||
if (!message.locationHash) {
|
break;
|
||||||
break;
|
}
|
||||||
}
|
hasher.replaceHash(message.locationHash);
|
||||||
hasher.replaceHash(message.locationHash);
|
RouteHandler.getInstance().parseHash(message.locationHash);
|
||||||
RouteHandler.getInstance().parseHash(message.locationHash);
|
break;
|
||||||
break;
|
case MessageTypes.SendNotification:
|
||||||
case MessageTypes.SendNotification:
|
if (!message.message) {
|
||||||
if (!message.message) {
|
break;
|
||||||
break;
|
}
|
||||||
}
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
NotificationConsoleUtils.logConsoleMessage(
|
message.consoleDataType || ConsoleDataType.Info,
|
||||||
message.consoleDataType || ConsoleDataType.Info,
|
message.message,
|
||||||
message.message,
|
message.id
|
||||||
message.id
|
);
|
||||||
);
|
break;
|
||||||
break;
|
case MessageTypes.ClearNotification:
|
||||||
case MessageTypes.ClearNotification:
|
if (!message.id) {
|
||||||
if (!message.id) {
|
break;
|
||||||
break;
|
}
|
||||||
}
|
NotificationConsoleUtils.clearInProgressMessageWithId(message.id);
|
||||||
NotificationConsoleUtils.clearInProgressMessageWithId(message.id);
|
break;
|
||||||
break;
|
case MessageTypes.LoadingStatus:
|
||||||
case MessageTypes.LoadingStatus:
|
if (!message.text) {
|
||||||
if (!message.text) {
|
break;
|
||||||
break;
|
}
|
||||||
}
|
this._setLoadingStatusText(message.text, message.title);
|
||||||
this._setLoadingStatusText(message.text, message.title);
|
break;
|
||||||
break;
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.splashScreenAdapter.forceRender();
|
this.splashScreenAdapter.forceRender();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public findSelectedDatabase(): ViewModels.Database {
|
public findSelectedDatabase(): ViewModels.Database {
|
||||||
@@ -1829,14 +1855,8 @@ export default class Explorer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public initDataExplorerWithFrameInputs(inputs: ViewModels.DataExplorerInputsFrame): void {
|
public initDataExplorerWithFrameInputs(inputs: ViewModels.DataExplorerInputsFrame): Q.Promise<void> {
|
||||||
if (inputs != null) {
|
if (inputs != null) {
|
||||||
// In development mode, save the iframe message from the portal in session storage.
|
|
||||||
// This allows webpack hot reload to funciton properly
|
|
||||||
if (process.env.NODE_ENV === "development" && configContext.platform === Platform.Portal) {
|
|
||||||
sessionStorage.setItem("portalDataExplorerInitMessage", JSON.stringify(inputs));
|
|
||||||
}
|
|
||||||
|
|
||||||
const authorizationToken = inputs.authorizationToken || "";
|
const authorizationToken = inputs.authorizationToken || "";
|
||||||
const masterKey = inputs.masterKey || "";
|
const masterKey = inputs.masterKey || "";
|
||||||
const databaseAccount = inputs.databaseAccount || null;
|
const databaseAccount = inputs.databaseAccount || null;
|
||||||
@@ -1845,18 +1865,25 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
this.features(inputs.features);
|
this.features(inputs.features);
|
||||||
this.serverId(inputs.serverId);
|
this.serverId(inputs.serverId);
|
||||||
|
this.armEndpoint(EnvironmentUtility.normalizeArmEndpointUri(inputs.csmEndpoint || configContext.ARM_ENDPOINT));
|
||||||
this.databaseAccount(databaseAccount);
|
this.databaseAccount(databaseAccount);
|
||||||
this.subscriptionType(inputs.subscriptionType);
|
this.subscriptionType(inputs.subscriptionType);
|
||||||
|
this.quotaId(inputs.quotaId);
|
||||||
this.hasWriteAccess(inputs.hasWriteAccess);
|
this.hasWriteAccess(inputs.hasWriteAccess);
|
||||||
this.flight(inputs.addCollectionDefaultFlight);
|
this.flight(inputs.addCollectionDefaultFlight);
|
||||||
this.isTryCosmosDBSubscription(inputs.isTryCosmosDBSubscription);
|
this.isTryCosmosDBSubscription(inputs.isTryCosmosDBSubscription);
|
||||||
this.isAuthWithResourceToken(inputs.isAuthWithresourceToken);
|
this.isAuthWithResourceToken(inputs.isAuthWithresourceToken);
|
||||||
this.setFeatureFlagsFromFlights(inputs.flights);
|
this.setFeatureFlagsFromFlights(inputs.flights);
|
||||||
|
|
||||||
|
if (!!inputs.dataExplorerVersion) {
|
||||||
|
this.parentFrameDataExplorerVersion(inputs.dataExplorerVersion);
|
||||||
|
}
|
||||||
|
|
||||||
this._importExplorerConfigComplete = true;
|
this._importExplorerConfigComplete = true;
|
||||||
|
|
||||||
updateConfigContext({
|
updateConfigContext({
|
||||||
BACKEND_ENDPOINT: inputs.extensionEndpoint || "",
|
BACKEND_ENDPOINT: inputs.extensionEndpoint || "",
|
||||||
ARM_ENDPOINT: normalizeArmEndpoint(inputs.csmEndpoint || configContext.ARM_ENDPOINT)
|
ARM_ENDPOINT: this.armEndpoint()
|
||||||
});
|
});
|
||||||
|
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
@@ -1865,17 +1892,35 @@ export default class Explorer {
|
|||||||
databaseAccount,
|
databaseAccount,
|
||||||
resourceGroup: inputs.resourceGroup,
|
resourceGroup: inputs.resourceGroup,
|
||||||
subscriptionId: inputs.subscriptionId,
|
subscriptionId: inputs.subscriptionId,
|
||||||
subscriptionType: inputs.subscriptionType,
|
subscriptionType: inputs.subscriptionType
|
||||||
quotaId: inputs.quotaId
|
|
||||||
});
|
});
|
||||||
|
TelemetryProcessor.traceSuccess(
|
||||||
|
Action.LoadDatabaseAccount,
|
||||||
|
{
|
||||||
|
resourceId: this.databaseAccount && this.databaseAccount().id,
|
||||||
|
dataExplorerArea: Constants.Areas.ResourceTree,
|
||||||
|
databaseAccount: this.databaseAccount && this.databaseAccount()
|
||||||
|
},
|
||||||
|
inputs.loadDatabaseAccountTimestamp
|
||||||
|
);
|
||||||
|
|
||||||
this.isAccountReady(true);
|
this.isAccountReady(true);
|
||||||
}
|
}
|
||||||
|
return Q();
|
||||||
}
|
}
|
||||||
|
|
||||||
public setFeatureFlagsFromFlights(flights: readonly string[]): void {
|
public setFeatureFlagsFromFlights(flights: readonly string[]): void {
|
||||||
if (!flights) {
|
if (!flights) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flights.indexOf(Constants.Flights.SettingsV2) !== -1) {
|
||||||
|
this.isSettingsV2Enabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flights.indexOf(Constants.Flights.MongoIndexEditor) !== -1) {
|
||||||
|
this.isMongoIndexEditorEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public findSelectedCollection(): ViewModels.Collection {
|
public findSelectedCollection(): ViewModels.Collection {
|
||||||
@@ -2242,6 +2287,7 @@ export default class Explorer {
|
|||||||
name,
|
name,
|
||||||
content,
|
content,
|
||||||
parentDomElement,
|
parentDomElement,
|
||||||
|
this.isCodeOfConductEnabled(),
|
||||||
this.isLinkInjectionEnabled()
|
this.isLinkInjectionEnabled()
|
||||||
);
|
);
|
||||||
this.publishNotebookPaneAdapter = this.notebookManager.publishNotebookPaneAdapter;
|
this.publishNotebookPaneAdapter = this.notebookManager.publishNotebookPaneAdapter;
|
||||||
@@ -2333,13 +2379,11 @@ export default class Explorer {
|
|||||||
this.tabsManager.activateTab(notebookTab);
|
this.tabsManager.activateTab(notebookTab);
|
||||||
} else {
|
} else {
|
||||||
const options: NotebookTabOptions = {
|
const options: NotebookTabOptions = {
|
||||||
account: userContext.databaseAccount,
|
|
||||||
tabKind: ViewModels.CollectionTabKind.NotebookV2,
|
tabKind: ViewModels.CollectionTabKind.NotebookV2,
|
||||||
node: null,
|
node: null,
|
||||||
title: notebookContentItem.name,
|
title: notebookContentItem.name,
|
||||||
tabPath: notebookContentItem.path,
|
tabPath: notebookContentItem.path,
|
||||||
collection: null,
|
collection: null,
|
||||||
masterKey: userContext.masterKey || "",
|
|
||||||
hashLocation: "notebooks",
|
hashLocation: "notebooks",
|
||||||
isActive: ko.observable(false),
|
isActive: ko.observable(false),
|
||||||
isTabsContentExpanded: ko.observable(true),
|
isTabsContentExpanded: ko.observable(true),
|
||||||
@@ -2532,7 +2576,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
public _refreshSparkEnabledStateForAccount = async (): Promise<void> => {
|
public _refreshSparkEnabledStateForAccount = async (): Promise<void> => {
|
||||||
const subscriptionId = userContext.subscriptionId;
|
const subscriptionId = userContext.subscriptionId;
|
||||||
const armEndpoint = configContext.ARM_ENDPOINT;
|
const armEndpoint = this.armEndpoint();
|
||||||
const authType = window.authType as AuthType;
|
const authType = window.authType as AuthType;
|
||||||
if (!subscriptionId || !armEndpoint || authType === AuthType.EncryptedToken) {
|
if (!subscriptionId || !armEndpoint || authType === AuthType.EncryptedToken) {
|
||||||
// explorer is not aware of the database account yet
|
// explorer is not aware of the database account yet
|
||||||
@@ -2541,7 +2585,7 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const featureUri = `subscriptions/${subscriptionId}/providers/Microsoft.Features/providers/Microsoft.DocumentDb/features/${Constants.AfecFeatures.Spark}`;
|
const featureUri = `subscriptions/${subscriptionId}/providers/Microsoft.Features/providers/Microsoft.DocumentDb/features/${Constants.AfecFeatures.Spark}`;
|
||||||
const resourceProviderClient = new ResourceProviderClientFactory().getOrCreate(featureUri);
|
const resourceProviderClient = new ResourceProviderClientFactory(this.armEndpoint()).getOrCreate(featureUri);
|
||||||
try {
|
try {
|
||||||
const sparkNotebooksFeature: DataModels.AfecFeature = await resourceProviderClient.getAsync(
|
const sparkNotebooksFeature: DataModels.AfecFeature = await resourceProviderClient.getAsync(
|
||||||
featureUri,
|
featureUri,
|
||||||
@@ -2561,7 +2605,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
public _isAfecFeatureRegistered = async (featureName: string): Promise<boolean> => {
|
public _isAfecFeatureRegistered = async (featureName: string): Promise<boolean> => {
|
||||||
const subscriptionId = userContext.subscriptionId;
|
const subscriptionId = userContext.subscriptionId;
|
||||||
const armEndpoint = configContext.ARM_ENDPOINT;
|
const armEndpoint = this.armEndpoint();
|
||||||
const authType = window.authType as AuthType;
|
const authType = window.authType as AuthType;
|
||||||
if (!featureName || !subscriptionId || !armEndpoint || authType === AuthType.EncryptedToken) {
|
if (!featureName || !subscriptionId || !armEndpoint || authType === AuthType.EncryptedToken) {
|
||||||
// explorer is not aware of the database account yet
|
// explorer is not aware of the database account yet
|
||||||
@@ -2569,7 +2613,7 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const featureUri = `subscriptions/${subscriptionId}/providers/Microsoft.Features/providers/Microsoft.DocumentDb/features/${featureName}`;
|
const featureUri = `subscriptions/${subscriptionId}/providers/Microsoft.Features/providers/Microsoft.DocumentDb/features/${featureName}`;
|
||||||
const resourceProviderClient = new ResourceProviderClientFactory().getOrCreate(featureUri);
|
const resourceProviderClient = new ResourceProviderClientFactory(this.armEndpoint()).getOrCreate(featureUri);
|
||||||
try {
|
try {
|
||||||
const featureStatus: DataModels.AfecFeature = await resourceProviderClient.getAsync(
|
const featureStatus: DataModels.AfecFeature = await resourceProviderClient.getAsync(
|
||||||
featureUri,
|
featureUri,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
jest.mock("../../../Common/dataAccess/queryDocuments");
|
jest.mock("../../../Common/DocumentClientUtilityBase");
|
||||||
jest.mock("../../../Common/dataAccess/queryDocumentsPage");
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
import { mount, ReactWrapper } from "enzyme";
|
import { mount, ReactWrapper } from "enzyme";
|
||||||
@@ -13,8 +12,7 @@ import * as DataModels from "../../../Contracts/DataModels";
|
|||||||
import * as StorageUtility from "../../../Shared/StorageUtility";
|
import * as StorageUtility from "../../../Shared/StorageUtility";
|
||||||
import GraphTab from "../../Tabs/GraphTab";
|
import GraphTab from "../../Tabs/GraphTab";
|
||||||
import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent";
|
import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
import { queryDocuments } from "../../../Common/dataAccess/queryDocuments";
|
import { queryDocuments, queryDocumentsPage } from "../../../Common/DocumentClientUtilityBase";
|
||||||
import { queryDocumentsPage } from "../../../Common/dataAccess/queryDocumentsPage";
|
|
||||||
|
|
||||||
describe("Check whether query result is vertex array", () => {
|
describe("Check whether query result is vertex array", () => {
|
||||||
it("should reject null as vertex array", () => {
|
it("should reject null as vertex array", () => {
|
||||||
@@ -301,12 +299,12 @@ describe("GraphExplorer", () => {
|
|||||||
ignoreD3Update: boolean
|
ignoreD3Update: boolean
|
||||||
): GraphExplorer => {
|
): GraphExplorer => {
|
||||||
(queryDocuments as jest.Mock).mockImplementation((container: any, query: string, options: any) => {
|
(queryDocuments as jest.Mock).mockImplementation((container: any, query: string, options: any) => {
|
||||||
return {
|
return Q.resolve({
|
||||||
_query: query,
|
_query: query,
|
||||||
nextItem: (callback: (error: any, document: DataModels.DocumentId) => void): void => {},
|
nextItem: (callback: (error: any, document: DataModels.DocumentId) => void): void => {},
|
||||||
hasMoreResults: () => false,
|
hasMoreResults: () => false,
|
||||||
executeNext: (callback: (error: any, documents: DataModels.DocumentId[], headers: any) => void): void => {}
|
executeNext: (callback: (error: any, documents: DataModels.DocumentId[], headers: any) => void): void => {}
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
(queryDocumentsPage as jest.Mock).mockImplementation(
|
(queryDocumentsPage as jest.Mock).mockImplementation(
|
||||||
(rid: string, iterator: any, firstItemIndex: number, options: any) => {
|
(rid: string, iterator: any, firstItemIndex: number, options: any) => {
|
||||||
|
|||||||
@@ -28,10 +28,8 @@ import * as Constants from "../../../Common/Constants";
|
|||||||
import { InputProperty } from "../../../Contracts/ViewModels";
|
import { InputProperty } from "../../../Contracts/ViewModels";
|
||||||
import { QueryIterator, ItemDefinition, Resource } from "@azure/cosmos";
|
import { QueryIterator, ItemDefinition, Resource } from "@azure/cosmos";
|
||||||
import LoadingIndicatorIcon from "../../../../images/LoadingIndicator_3Squares.gif";
|
import LoadingIndicatorIcon from "../../../../images/LoadingIndicator_3Squares.gif";
|
||||||
import { queryDocuments } from "../../../Common/dataAccess/queryDocuments";
|
import { queryDocuments, queryDocumentsPage } from "../../../Common/DocumentClientUtilityBase";
|
||||||
import { queryDocumentsPage } from "../../../Common/dataAccess/queryDocumentsPage";
|
|
||||||
import { getErrorMessage } from "../../../Common/ErrorHandlingUtils";
|
import { getErrorMessage } from "../../../Common/ErrorHandlingUtils";
|
||||||
import { FeedOptions } from "@azure/cosmos";
|
|
||||||
|
|
||||||
export interface GraphAccessor {
|
export interface GraphAccessor {
|
||||||
applyFilter: () => void;
|
applyFilter: () => void;
|
||||||
@@ -727,32 +725,26 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
|||||||
/**
|
/**
|
||||||
* Execute DocDB query and get all results
|
* Execute DocDB query and get all results
|
||||||
*/
|
*/
|
||||||
public async executeNonPagedDocDbQuery(query: string): Promise<DataModels.DocumentId[]> {
|
public executeNonPagedDocDbQuery(query: string): Q.Promise<DataModels.DocumentId[]> {
|
||||||
try {
|
// TODO maxItemCount: this reduces throttling, but won't cap the # of results
|
||||||
// TODO maxItemCount: this reduces throttling, but won't cap the # of results
|
return queryDocuments(this.props.databaseId, this.props.collectionId, query, {
|
||||||
const iterator: QueryIterator<ItemDefinition & Resource> = queryDocuments(
|
maxItemCount: GraphExplorer.PAGE_ALL,
|
||||||
this.props.databaseId,
|
enableCrossPartitionQuery:
|
||||||
this.props.collectionId,
|
StorageUtility.LocalStorageUtility.getEntryString(StorageUtility.StorageKey.IsCrossPartitionQueryEnabled) ===
|
||||||
query,
|
"true"
|
||||||
{
|
}).then(
|
||||||
maxItemCount: GraphExplorer.PAGE_ALL,
|
(iterator: QueryIterator<ItemDefinition & Resource>) => {
|
||||||
enableCrossPartitionQuery:
|
return iterator.fetchNext().then(response => response.resources);
|
||||||
StorageUtility.LocalStorageUtility.getEntryString(
|
},
|
||||||
StorageUtility.StorageKey.IsCrossPartitionQueryEnabled
|
(reason: any) => {
|
||||||
) === "true"
|
GraphExplorer.reportToConsole(
|
||||||
} as FeedOptions
|
ConsoleDataType.Error,
|
||||||
);
|
`Failed to execute non-paged query ${query}. Reason:${reason}`,
|
||||||
const response = await iterator.fetchNext();
|
reason
|
||||||
|
);
|
||||||
return response?.resources;
|
return null;
|
||||||
} catch (error) {
|
}
|
||||||
GraphExplorer.reportToConsole(
|
);
|
||||||
ConsoleDataType.Error,
|
|
||||||
`Failed to execute non-paged query ${query}. Reason:${error}`,
|
|
||||||
error
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -872,7 +864,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
|||||||
/**
|
/**
|
||||||
* User executes query
|
* User executes query
|
||||||
*/
|
*/
|
||||||
public async submitQuery(query: string): Promise<void> {
|
public submitQuery(query: string): void {
|
||||||
// Clear any progress indicator
|
// Clear any progress indicator
|
||||||
this.executeCounter = 0;
|
this.executeCounter = 0;
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -890,22 +882,24 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
|||||||
// Remember query
|
// Remember query
|
||||||
this.pushToLatestQueryFragments(query);
|
this.pushToLatestQueryFragments(query);
|
||||||
|
|
||||||
try {
|
let backendPromise;
|
||||||
let result: UserQueryResult;
|
|
||||||
if (query.toLocaleLowerCase() === "g.V()".toLocaleLowerCase()) {
|
|
||||||
result = await this.executeDocDbGVQuery();
|
|
||||||
} else {
|
|
||||||
result = await this.executeGremlinQuery(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.queryTotalRequestCharge = result.requestCharge;
|
if (query.toLocaleLowerCase() === "g.V()".toLocaleLowerCase()) {
|
||||||
} catch (error) {
|
backendPromise = this.executeDocDbGVQuery();
|
||||||
const errorMsg = `Failure in submitting query: ${query}: ${getErrorMessage(error)}`;
|
} else {
|
||||||
GraphExplorer.reportToConsole(ConsoleDataType.Error, errorMsg);
|
backendPromise = this.executeGremlinQuery(query);
|
||||||
this.setState({
|
|
||||||
filterQueryError: errorMsg
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backendPromise.then(
|
||||||
|
(result: UserQueryResult) => (this.queryTotalRequestCharge = result.requestCharge),
|
||||||
|
(error: any) => {
|
||||||
|
const errorMsg = `Failure in submitting query: ${query}: ${getErrorMessage(error)}`;
|
||||||
|
GraphExplorer.reportToConsole(ConsoleDataType.Error, errorMsg);
|
||||||
|
this.setState({
|
||||||
|
filterQueryError: errorMsg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1396,7 +1390,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
|||||||
/**
|
/**
|
||||||
* Update possible vertices to display in UI
|
* Update possible vertices to display in UI
|
||||||
*/
|
*/
|
||||||
private updatePossibleVertices(): Promise<PossibleVertex[]> {
|
private updatePossibleVertices(): Q.Promise<PossibleVertex[]> {
|
||||||
const highlightedNodeId = this.state.highlightedNode ? this.state.highlightedNode.id : null;
|
const highlightedNodeId = this.state.highlightedNode ? this.state.highlightedNode.id : null;
|
||||||
|
|
||||||
const q = `SELECT c.id, c["${this.props.graphConfigUiData.nodeCaptionChoice() ||
|
const q = `SELECT c.id, c["${this.props.graphConfigUiData.nodeCaptionChoice() ||
|
||||||
@@ -1727,81 +1721,85 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async executeDocDbGVQuery(): Promise<UserQueryResult> {
|
private executeDocDbGVQuery(): Q.Promise<UserQueryResult> {
|
||||||
let query = "select root.id from root where IS_DEFINED(root._isEdge) = false order by root._ts desc";
|
let query = "select root.id from root where IS_DEFINED(root._isEdge) = false order by root._ts desc";
|
||||||
if (this.props.collectionPartitionKeyProperty) {
|
if (this.props.collectionPartitionKeyProperty) {
|
||||||
query = `select root.id, root.${this.props.collectionPartitionKeyProperty} from root where IS_DEFINED(root._isEdge) = false order by root._ts asc`;
|
query = `select root.id, root.${this.props.collectionPartitionKeyProperty} from root where IS_DEFINED(root._isEdge) = false order by root._ts asc`;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return queryDocuments(this.props.databaseId, this.props.collectionId, query, {
|
||||||
const iterator: QueryIterator<ItemDefinition & Resource> = queryDocuments(
|
maxItemCount: GraphExplorer.ROOT_LIST_PAGE_SIZE,
|
||||||
this.props.databaseId,
|
enableCrossPartitionQuery: LocalStorageUtility.getEntryString(StorageKey.IsCrossPartitionQueryEnabled) === "true"
|
||||||
this.props.collectionId,
|
})
|
||||||
query,
|
.then(
|
||||||
{
|
(iterator: QueryIterator<ItemDefinition & Resource>) => {
|
||||||
maxItemCount: GraphExplorer.ROOT_LIST_PAGE_SIZE,
|
this.currentDocDBQueryInfo = {
|
||||||
enableCrossPartitionQuery:
|
iterator: iterator,
|
||||||
LocalStorageUtility.getEntryString(StorageKey.IsCrossPartitionQueryEnabled) === "true"
|
index: 0,
|
||||||
} as FeedOptions
|
query: query
|
||||||
);
|
};
|
||||||
this.currentDocDBQueryInfo = {
|
},
|
||||||
iterator: iterator,
|
(reason: any) => {
|
||||||
index: 0,
|
GraphExplorer.reportToConsole(
|
||||||
query: query
|
ConsoleDataType.Error,
|
||||||
};
|
`Failed to execute CosmosDB query: ${query} reason:${reason}`
|
||||||
return await this.loadMoreRootNodes();
|
);
|
||||||
} catch (error) {
|
}
|
||||||
GraphExplorer.reportToConsole(
|
)
|
||||||
ConsoleDataType.Error,
|
.then(() => this.loadMoreRootNodes());
|
||||||
`Failed to execute CosmosDB query: ${query} reason:${error}`
|
|
||||||
);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async loadMoreRootNodes(): Promise<UserQueryResult> {
|
private loadMoreRootNodes(): Q.Promise<UserQueryResult> {
|
||||||
if (!this.currentDocDBQueryInfo) {
|
if (!this.currentDocDBQueryInfo) {
|
||||||
return undefined;
|
return Q.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
let RU: string = GraphExplorer.REQUEST_CHARGE_UNKNOWN_MSG;
|
let RU: string = GraphExplorer.REQUEST_CHARGE_UNKNOWN_MSG;
|
||||||
|
|
||||||
const queryInfoStr = `${this.currentDocDBQueryInfo.query} (${this.currentDocDBQueryInfo.index + 1}-${this
|
const queryInfoStr = `${this.currentDocDBQueryInfo.query} (${this.currentDocDBQueryInfo.index + 1}-${this
|
||||||
.currentDocDBQueryInfo.index + GraphExplorer.ROOT_LIST_PAGE_SIZE})`;
|
.currentDocDBQueryInfo.index + GraphExplorer.ROOT_LIST_PAGE_SIZE})`;
|
||||||
const id = GraphExplorer.reportToConsole(ConsoleDataType.InProgress, `Executing: ${queryInfoStr}`);
|
const id = GraphExplorer.reportToConsole(ConsoleDataType.InProgress, `Executing: ${queryInfoStr}`);
|
||||||
|
|
||||||
try {
|
return queryDocumentsPage(
|
||||||
const results: ViewModels.QueryResults = await queryDocumentsPage(
|
this.props.collectionId,
|
||||||
this.props.collectionId,
|
this.currentDocDBQueryInfo.iterator,
|
||||||
this.currentDocDBQueryInfo.iterator,
|
this.currentDocDBQueryInfo.index,
|
||||||
this.currentDocDBQueryInfo.index
|
{
|
||||||
);
|
enableCrossPartitionQuery:
|
||||||
|
LocalStorageUtility.getEntryString(StorageKey.IsCrossPartitionQueryEnabled) === "true"
|
||||||
GraphExplorer.clearConsoleProgress(id);
|
}
|
||||||
this.currentDocDBQueryInfo.index = results.lastItemIndex + 1;
|
)
|
||||||
this.setState({ hasMoreRoots: results.hasMoreResults });
|
.then((results: ViewModels.QueryResults) => {
|
||||||
RU = results.requestCharge.toString();
|
GraphExplorer.clearConsoleProgress(id);
|
||||||
GraphExplorer.reportToConsole(
|
this.currentDocDBQueryInfo.index = results.lastItemIndex + 1;
|
||||||
ConsoleDataType.Info,
|
this.setState({ hasMoreRoots: results.hasMoreResults });
|
||||||
`Executed: ${queryInfoStr} ${GremlinClient.GremlinClient.getRequestChargeString(RU)}`
|
RU = results.requestCharge.toString();
|
||||||
);
|
GraphExplorer.reportToConsole(
|
||||||
const pkIds: string[] = (results.documents || []).map((item: DataModels.DocumentId) =>
|
ConsoleDataType.Info,
|
||||||
GraphExplorer.getPkIdFromDocumentId(item, this.props.collectionPartitionKeyProperty)
|
`Executed: ${queryInfoStr} ${GremlinClient.GremlinClient.getRequestChargeString(RU)}`
|
||||||
);
|
);
|
||||||
|
const documents = results.documents || [];
|
||||||
const arg = pkIds.join(",");
|
return documents.map(
|
||||||
await this.executeGremlinQuery(`g.V(${arg})`);
|
(item: DataModels.DocumentId) => {
|
||||||
|
return GraphExplorer.getPkIdFromDocumentId(item, this.props.collectionPartitionKeyProperty);
|
||||||
return { requestCharge: RU };
|
},
|
||||||
} catch (error) {
|
(reason: any) => {
|
||||||
GraphExplorer.clearConsoleProgress(id);
|
// Failure
|
||||||
const errorMsg = `Failed to query: ${this.currentDocDBQueryInfo.query}. Reason:${getErrorMessage(error)}`;
|
GraphExplorer.clearConsoleProgress(id);
|
||||||
GraphExplorer.reportToConsole(ConsoleDataType.Error, errorMsg);
|
const errorMsg = `Failed to query: ${this.currentDocDBQueryInfo.query}. Reason:${reason}`;
|
||||||
this.setState({
|
GraphExplorer.reportToConsole(ConsoleDataType.Error, errorMsg);
|
||||||
filterQueryError: errorMsg
|
this.setState({
|
||||||
});
|
filterQueryError: errorMsg
|
||||||
this.setFilterQueryStatus(FilterQueryStatus.ErrorResult);
|
});
|
||||||
throw error;
|
this.setFilterQueryStatus(FilterQueryStatus.ErrorResult);
|
||||||
}
|
throw reason;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then((pkIds: string[]) => {
|
||||||
|
const arg = pkIds.join(",");
|
||||||
|
return this.executeGremlinQuery(`g.V(${arg})`);
|
||||||
|
})
|
||||||
|
.then(() => ({ requestCharge: RU }));
|
||||||
}
|
}
|
||||||
|
|
||||||
private executeGremlinQuery(query: string): Q.Promise<UserQueryResult> {
|
private executeGremlinQuery(query: string): Q.Promise<UserQueryResult> {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import "./MeControlComponent.less";
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { DefaultButton, BaseButton, IButtonProps } from "office-ui-fabric-react/lib/Button";
|
import { DefaultButton, BaseButton, IButtonProps } from "office-ui-fabric-react/lib/Button";
|
||||||
import { DirectionalHint, IContextualMenuProps } from "office-ui-fabric-react/lib/ContextualMenu";
|
import { DirectionalHint, IContextualMenuProps } from "office-ui-fabric-react/lib/ContextualMenu";
|
||||||
|
|||||||
@@ -99,22 +99,7 @@
|
|||||||
.notificationConsoleControls {
|
.notificationConsoleControls {
|
||||||
padding: @MediumSpace;
|
padding: @MediumSpace;
|
||||||
margin-left:@DefaultSpace;
|
margin-left:@DefaultSpace;
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.ms-Dropdown-container {
|
|
||||||
display: flex;
|
|
||||||
.ms-Dropdown-title {
|
|
||||||
height: 25px;
|
|
||||||
line-height: 25px;
|
|
||||||
}
|
|
||||||
.ms-Dropdown {
|
|
||||||
min-width: 110px;
|
|
||||||
margin-left: 10px;
|
|
||||||
height: 25px;
|
|
||||||
line-height: 25px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#consoleFilterLabel {
|
#consoleFilterLabel {
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
}
|
}
|
||||||
@@ -122,7 +107,6 @@
|
|||||||
.consoleSplitter {
|
.consoleSplitter {
|
||||||
border-left: 1px solid @BaseMedium;
|
border-left: 1px solid @BaseMedium;
|
||||||
margin: @MediumSpace;
|
margin: @MediumSpace;
|
||||||
height: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.clearNotificationsButton {
|
.clearNotificationsButton {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { ClientDefaults, KeyCodes } from "../../../Common/Constants";
|
import { ClientDefaults, KeyCodes } from "../../../Common/Constants";
|
||||||
import AnimateHeight from "react-animate-height";
|
import AnimateHeight from "react-animate-height";
|
||||||
import { Dropdown, IDropdownOption } from "office-ui-fabric-react";
|
|
||||||
import LoadingIcon from "../../../../images/loading.svg";
|
import LoadingIcon from "../../../../images/loading.svg";
|
||||||
import ErrorBlackIcon from "../../../../images/error_black.svg";
|
import ErrorBlackIcon from "../../../../images/error_black.svg";
|
||||||
import infoBubbleIcon from "../../../../images/info-bubble-9x9.svg";
|
import infoBubbleIcon from "../../../../images/info-bubble-9x9.svg";
|
||||||
@@ -53,12 +53,7 @@ export class NotificationConsoleComponent extends React.Component<
|
|||||||
NotificationConsoleComponentState
|
NotificationConsoleComponentState
|
||||||
> {
|
> {
|
||||||
private static readonly transitionDurationMs = 200;
|
private static readonly transitionDurationMs = 200;
|
||||||
private static readonly FilterOptions = [
|
private static readonly FilterOptions = ["All", "In Progress", "Info", "Error"];
|
||||||
{ key: "All", text: "All" },
|
|
||||||
{ key: "In Progress", text: "In progress" },
|
|
||||||
{ key: "Info", text: "Info" },
|
|
||||||
{ key: "Error", text: "Error" }
|
|
||||||
];
|
|
||||||
private headerTimeoutId: number;
|
private headerTimeoutId: number;
|
||||||
private prevHeaderStatus: string;
|
private prevHeaderStatus: string;
|
||||||
private consoleHeaderElement: HTMLElement;
|
private consoleHeaderElement: HTMLElement;
|
||||||
@@ -67,7 +62,7 @@ export class NotificationConsoleComponent extends React.Component<
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
headerStatus: "",
|
headerStatus: "",
|
||||||
selectedFilter: NotificationConsoleComponent.FilterOptions[0].key || "",
|
selectedFilter: NotificationConsoleComponent.FilterOptions[0],
|
||||||
isExpanded: props.isConsoleExpanded
|
isExpanded: props.isConsoleExpanded
|
||||||
};
|
};
|
||||||
this.prevHeaderStatus = null;
|
this.prevHeaderStatus = null;
|
||||||
@@ -155,15 +150,20 @@ export class NotificationConsoleComponent extends React.Component<
|
|||||||
>
|
>
|
||||||
<div className="notificationConsoleContents">
|
<div className="notificationConsoleContents">
|
||||||
<div className="notificationConsoleControls">
|
<div className="notificationConsoleControls">
|
||||||
<Dropdown
|
<label id="consoleFilterLabel">Filter</label>
|
||||||
label="Filter:"
|
<select
|
||||||
role="combobox"
|
|
||||||
selectedKey={this.state.selectedFilter}
|
|
||||||
options={NotificationConsoleComponent.FilterOptions}
|
|
||||||
onChange={this.onFilterSelected.bind(this)}
|
|
||||||
aria-labelledby="consoleFilterLabel"
|
aria-labelledby="consoleFilterLabel"
|
||||||
|
role="combobox"
|
||||||
aria-label={this.state.selectedFilter}
|
aria-label={this.state.selectedFilter}
|
||||||
/>
|
value={this.state.selectedFilter}
|
||||||
|
onChange={this.onFilterSelected.bind(this)}
|
||||||
|
>
|
||||||
|
{NotificationConsoleComponent.FilterOptions.map((value: string) => (
|
||||||
|
<option value={value} key={value}>
|
||||||
|
{value}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
<span className="consoleSplitter" />
|
<span className="consoleSplitter" />
|
||||||
<span
|
<span
|
||||||
className="clearNotificationsButton"
|
className="clearNotificationsButton"
|
||||||
@@ -220,8 +220,8 @@ export class NotificationConsoleComponent extends React.Component<
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private onFilterSelected(event: React.ChangeEvent<HTMLSelectElement>, option: IDropdownOption): void {
|
private onFilterSelected(event: React.ChangeEvent<HTMLSelectElement>): void {
|
||||||
this.setState({ selectedFilter: String(option.key) });
|
this.setState({ selectedFilter: event.target.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
private getFilteredConsoleData(): ConsoleData[] {
|
private getFilteredConsoleData(): ConsoleData[] {
|
||||||
|
|||||||
@@ -110,34 +110,43 @@ exports[`NotificationConsoleComponent renders the console (expanded) 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="notificationConsoleControls"
|
className="notificationConsoleControls"
|
||||||
>
|
>
|
||||||
<StyledWithResponsiveMode
|
<label
|
||||||
|
id="consoleFilterLabel"
|
||||||
|
>
|
||||||
|
Filter
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
aria-label="All"
|
aria-label="All"
|
||||||
aria-labelledby="consoleFilterLabel"
|
aria-labelledby="consoleFilterLabel"
|
||||||
label="Filter:"
|
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
options={
|
|
||||||
Array [
|
|
||||||
Object {
|
|
||||||
"key": "All",
|
|
||||||
"text": "All",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"key": "In Progress",
|
|
||||||
"text": "In progress",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"key": "Info",
|
|
||||||
"text": "Info",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"key": "Error",
|
|
||||||
"text": "Error",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
role="combobox"
|
role="combobox"
|
||||||
selectedKey="All"
|
value="All"
|
||||||
/>
|
>
|
||||||
|
<option
|
||||||
|
key="All"
|
||||||
|
value="All"
|
||||||
|
>
|
||||||
|
All
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
key="In Progress"
|
||||||
|
value="In Progress"
|
||||||
|
>
|
||||||
|
In Progress
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
key="Info"
|
||||||
|
value="Info"
|
||||||
|
>
|
||||||
|
Info
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
key="Error"
|
||||||
|
value="Error"
|
||||||
|
>
|
||||||
|
Error
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
<span
|
<span
|
||||||
className="consoleSplitter"
|
className="consoleSplitter"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
.mongoQueryComponent {
|
||||||
|
margin-left: 10px;
|
||||||
|
|
||||||
|
input {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
padding: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
label:before {
|
||||||
|
top: 2px;
|
||||||
|
left: 2px;
|
||||||
|
height: 16px;
|
||||||
|
width: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.queryInput {
|
||||||
|
border: 1px solid black;
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import { Dispatch } from "redux";
|
||||||
|
import MonacoEditor from "@nteract/monaco-editor";
|
||||||
|
import { PrimaryButton } from "office-ui-fabric-react";
|
||||||
|
import { ChoiceGroup, IChoiceGroupOption } from "office-ui-fabric-react/lib/ChoiceGroup";
|
||||||
|
import Outputs from "@nteract/stateful-components/lib/outputs";
|
||||||
|
import { KernelOutputError, StreamText } from "@nteract/outputs";
|
||||||
|
import TransformMedia from "@nteract/stateful-components/lib/outputs/transform-media";
|
||||||
|
import { actions, selectors, AppState, ContentRef, KernelRef } from "@nteract/core";
|
||||||
|
import loadTransform from "../NotebookComponent/loadTransform";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import Immutable from "immutable";
|
||||||
|
|
||||||
|
import "./MongoQueryComponent.less";
|
||||||
|
interface MongoQueryComponentPureProps {
|
||||||
|
contentRef: ContentRef;
|
||||||
|
kernelRef: KernelRef;
|
||||||
|
databaseId: string;
|
||||||
|
collectionId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MongoQueryComponentDispatchProps {
|
||||||
|
runCell: (contentRef: ContentRef, cellId: string) => void;
|
||||||
|
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) => void;
|
||||||
|
onChange: (text: string, id: string, contentRef: ContentRef) => void;
|
||||||
|
save: (contentRef: ContentRef) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
type OutputType = "rich" | "json";
|
||||||
|
|
||||||
|
interface MongoQueryComponentState {
|
||||||
|
outputType: OutputType;
|
||||||
|
selectedId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options: IChoiceGroupOption[] = [
|
||||||
|
{ key: "rich", text: "Rich Output" },
|
||||||
|
{ key: "json", text: "Json Output" }
|
||||||
|
];
|
||||||
|
|
||||||
|
interface MongoKernelJsonOutput {
|
||||||
|
results: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MongoDocument {
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type MongoQueryComponentProps = MongoQueryComponentPureProps & StateProps & MongoQueryComponentDispatchProps;
|
||||||
|
export class MongoQueryComponent extends React.Component<MongoQueryComponentProps, MongoQueryComponentState> {
|
||||||
|
constructor(props: MongoQueryComponentProps) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
outputType: "json",
|
||||||
|
selectedId: undefined
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount(): void {
|
||||||
|
loadTransform(this.props);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onExecute = () => {
|
||||||
|
this.props.runCell(this.props.contentRef, this.props.firstCellId);
|
||||||
|
this.props.save(this.props.contentRef);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param databaseId
|
||||||
|
* @param collectionId
|
||||||
|
* @param query e.g. { "lastName": { $in: ["Andersen"] } }
|
||||||
|
*/
|
||||||
|
private createFilterQuery(databaseId: string, collectionId: string, query: string): string {
|
||||||
|
const newCommand = `{ "command": "filter", "database": "${databaseId}", "collection": "${collectionId}", "filter": ${JSON.stringify(query)}, "outputType": "${this.state.outputType}" }`;
|
||||||
|
return newCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
private onOutputTypeChange = (e: React.FormEvent<HTMLElement | HTMLInputElement>, option: IChoiceGroupOption): void => {
|
||||||
|
const outputType = option.key as OutputType;
|
||||||
|
this.setState({ outputType }, () => this.onInputChange(this.props.inputValue));
|
||||||
|
};
|
||||||
|
|
||||||
|
private onInputChange = (text: string) => {
|
||||||
|
this.props.onChange(this.createFilterQuery(this.props.databaseId, this.props.collectionId, text),
|
||||||
|
this.props.firstCellId, this.props.contentRef);
|
||||||
|
};
|
||||||
|
|
||||||
|
render(): JSX.Element {
|
||||||
|
const { firstCellId: id, contentRef, outputDocuments } = this.props;
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mongoQueryComponent">
|
||||||
|
<div className="queryInput">
|
||||||
|
<MonacoEditor id={this.props.firstCellId} contentRef={this.props.contentRef} theme={""}
|
||||||
|
language="json" onChange={this.onInputChange}
|
||||||
|
value={this.props.inputValue} />
|
||||||
|
</div>
|
||||||
|
<PrimaryButton text="Apply" onClick={this.onExecute} disabled={!this.props.firstCellId} />
|
||||||
|
<ChoiceGroup
|
||||||
|
selectedKey={this.state.outputType}
|
||||||
|
options={options}
|
||||||
|
onChange={this.onOutputTypeChange}
|
||||||
|
label="Output Type"
|
||||||
|
styles={{ input: { marginTop: 0 }, root: { marginTop: 0 } }}
|
||||||
|
/>
|
||||||
|
<hr />
|
||||||
|
<div style={ { display: "flex" } }>
|
||||||
|
<ul>
|
||||||
|
{outputDocuments && outputDocuments.map(d => (
|
||||||
|
<li key={d.id}>
|
||||||
|
<a onClick={() => this.setState({ selectedId: id })}>{d.id}</a>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
<div style={{ width: "100%" }} >
|
||||||
|
<MonacoEditor id={""} contentRef={""} theme={""} language="json" onChange={() => {}}
|
||||||
|
value={JSON.stringify(outputDocuments.find(doc => doc.id ===this.state.selectedId)) ?? ""} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<Outputs id={id} contentRef={contentRef}>
|
||||||
|
<TransformMedia output_type={"display_data"} id={id} contentRef={contentRef} />
|
||||||
|
<TransformMedia output_type={"execute_result"} id={id} contentRef={contentRef} />
|
||||||
|
<KernelOutputError />
|
||||||
|
<StreamText />
|
||||||
|
</Outputs>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StateProps {
|
||||||
|
firstCellId: string;
|
||||||
|
inputValue: string;
|
||||||
|
outputDocuments: MongoDocument[];
|
||||||
|
}
|
||||||
|
interface InitialProps {
|
||||||
|
contentRef: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redux
|
||||||
|
const makeMapStateToProps = (state: AppState, initialProps: InitialProps) => {
|
||||||
|
const { contentRef } = initialProps;
|
||||||
|
const mapStateToProps = (state: AppState) => {
|
||||||
|
let firstCellId;
|
||||||
|
let inputValue = "";
|
||||||
|
let outputDocuments = [];
|
||||||
|
const content = selectors.content(state, { contentRef });
|
||||||
|
if (content?.type === "notebook") {
|
||||||
|
const cellOrder = selectors.notebook.cellOrder(content.model);
|
||||||
|
if (cellOrder.size > 0) {
|
||||||
|
firstCellId = cellOrder.first() as string;
|
||||||
|
const cell = selectors.notebook.cellById(content.model, { id: firstCellId });
|
||||||
|
|
||||||
|
// Parse to extract filter and output type
|
||||||
|
const cellValue = cell.get("source", "");
|
||||||
|
if (cellValue) {
|
||||||
|
try {
|
||||||
|
const filterValue = JSON.parse(cellValue).filter;
|
||||||
|
if (filterValue) {
|
||||||
|
inputValue = filterValue;
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
console.error("Could not parse", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const outputs = cell.get("outputs", Immutable.List());
|
||||||
|
// Extract "application/json" mime-type
|
||||||
|
let jsonOutput: MongoKernelJsonOutput;
|
||||||
|
for (const output of outputs) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(output.data, "application/json")) {
|
||||||
|
jsonOutput = output.data["application/json"];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outputDocuments = jsonOutput?.results ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
firstCellId,
|
||||||
|
inputValue,
|
||||||
|
outputDocuments
|
||||||
|
};
|
||||||
|
};
|
||||||
|
return mapStateToProps;
|
||||||
|
};
|
||||||
|
|
||||||
|
const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: MongoQueryComponentProps) => {
|
||||||
|
const mapDispatchToProps = (dispatch: Dispatch) => {
|
||||||
|
return {
|
||||||
|
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) => {
|
||||||
|
return dispatch(
|
||||||
|
actions.addTransform({
|
||||||
|
mediaType: transform.MIMETYPE,
|
||||||
|
component: transform
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
runCell: (contentRef: ContentRef, cellId: string) => {
|
||||||
|
return dispatch(
|
||||||
|
actions.executeCell({
|
||||||
|
contentRef,
|
||||||
|
id: cellId
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onChange: (text: string, id: string, contentRef: ContentRef) => {
|
||||||
|
dispatch(actions.updateCellSource({ id, contentRef, value: text }));
|
||||||
|
},
|
||||||
|
save: (contentRef: ContentRef) => {
|
||||||
|
dispatch(actions.save({ contentRef }));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
return mapDispatchToProps;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(makeMapStateToProps, makeMapDispatchToProps)(MongoQueryComponent);
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
import { ReactAdapter } from "../../../Bindings/ReactBindingHandler";
|
||||||
|
import {
|
||||||
|
NotebookComponentBootstrapper,
|
||||||
|
NotebookComponentBootstrapperOptions
|
||||||
|
} from "../NotebookComponent/NotebookComponentBootstrapper";
|
||||||
|
import MongoQueryComponent from "../MongoQueryComponent/MongoQueryComponent";
|
||||||
|
import { actions, createContentRef, createKernelRef, KernelRef } from "@nteract/core";
|
||||||
|
import { Provider } from "react-redux";
|
||||||
|
|
||||||
|
export class MongoQueryComponentAdapter extends NotebookComponentBootstrapper implements ReactAdapter {
|
||||||
|
public parameters: unknown;
|
||||||
|
private kernelRef: KernelRef;
|
||||||
|
|
||||||
|
constructor(options: NotebookComponentBootstrapperOptions, private databaseId: string, private collectionId: string) {
|
||||||
|
super(options);
|
||||||
|
|
||||||
|
if (!this.contentRef) {
|
||||||
|
this.contentRef = createContentRef();
|
||||||
|
this.kernelRef = createKernelRef();
|
||||||
|
|
||||||
|
// Request fetching notebook content
|
||||||
|
this.getStore().dispatch(
|
||||||
|
actions.fetchContent({
|
||||||
|
filepath: "mongo.ipynb",
|
||||||
|
params: {},
|
||||||
|
kernelRef: this.kernelRef,
|
||||||
|
contentRef: this.contentRef
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public renderComponent(): JSX.Element {
|
||||||
|
const props = {
|
||||||
|
contentRef: this.contentRef,
|
||||||
|
kernelRef: this.kernelRef,
|
||||||
|
databaseId: this.databaseId,
|
||||||
|
collectionId: this.collectionId
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Provider store={this.getStore()}>
|
||||||
|
<MongoQueryComponent {...props} />;
|
||||||
|
</Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,9 +128,17 @@ export default class NotebookManager {
|
|||||||
name: string,
|
name: string,
|
||||||
content: string | ImmutableNotebook,
|
content: string | ImmutableNotebook,
|
||||||
parentDomElement: HTMLElement,
|
parentDomElement: HTMLElement,
|
||||||
|
isCodeOfConductEnabled: boolean,
|
||||||
isLinkInjectionEnabled: boolean
|
isLinkInjectionEnabled: boolean
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await this.publishNotebookPaneAdapter.open(name, getFullName(), content, parentDomElement, isLinkInjectionEnabled);
|
await this.publishNotebookPaneAdapter.open(
|
||||||
|
name,
|
||||||
|
getFullName(),
|
||||||
|
content,
|
||||||
|
parentDomElement,
|
||||||
|
isCodeOfConductEnabled,
|
||||||
|
isLinkInjectionEnabled
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public openCopyNotebookPane(name: string, content: string): void {
|
public openCopyNotebookPane(name: string, content: string): void {
|
||||||
|
|||||||
@@ -243,6 +243,38 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- Unlimited Button Content - Start -->
|
<!-- Unlimited Button Content - Start -->
|
||||||
<div class="tabcontent" data-bind="visible: isUnlimitedStorageSelected() || databaseHasSharedOffer()">
|
<div class="tabcontent" data-bind="visible: isUnlimitedStorageSelected() || databaseHasSharedOffer()">
|
||||||
|
<div data-bind="visible: rupmVisible">
|
||||||
|
<div class="tabs">
|
||||||
|
<p>
|
||||||
|
<span class="mandatoryStar">*</span>
|
||||||
|
<span class="addCollectionLabel">RU/m</span>
|
||||||
|
<span class="infoTooltip" role="tooltip" tabindex="0">
|
||||||
|
<img class="infoImg" src="/info-bubble.svg" alt="More information">
|
||||||
|
<span class="tooltiptext throughputRuInfo">
|
||||||
|
For each 100 Request Units per second (RU/s) provisioned, 1,000 Request Units
|
||||||
|
per
|
||||||
|
minute
|
||||||
|
(RU/m) can be provisioned. E.g.: for a container with 5,000 RU/s provisioned
|
||||||
|
with
|
||||||
|
RU/m
|
||||||
|
enabled, the RU/m budget will be 50,000 RU/m.
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<div tabindex="0" data-bind="event: { keydown: onRupmOptionsKeyDown }" aria-label="RU/m">
|
||||||
|
<div class="tab">
|
||||||
|
<input type="radio" id="rupmOn2" name="rupmcoll2" value="on" class="radio"
|
||||||
|
data-bind="checked: rupm">
|
||||||
|
<label for="rupmOn2">ON</label>
|
||||||
|
</div>
|
||||||
|
<div class="tab">
|
||||||
|
<input type="radio" id="rupmOff2" name="rupmcoll2" value="off" class="radio"
|
||||||
|
data-bind="checked: rupm">
|
||||||
|
<label for="rupmOff2">OFF</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div data-bind="visible: partitionKeyVisible">
|
<div data-bind="visible: partitionKeyVisible">
|
||||||
<p>
|
<p>
|
||||||
<span class="mandatoryStar">*</span>
|
<span class="mandatoryStar">*</span>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import { ContextualPaneBase } from "./ContextualPaneBase";
|
|||||||
import { DynamicListItem } from "../Controls/DynamicList/DynamicListComponent";
|
import { DynamicListItem } from "../Controls/DynamicList/DynamicListComponent";
|
||||||
import { createCollection } from "../../Common/dataAccess/createCollection";
|
import { createCollection } from "../../Common/dataAccess/createCollection";
|
||||||
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
||||||
import { userContext } from "../../UserContext";
|
|
||||||
|
|
||||||
export interface AddCollectionPaneOptions extends ViewModels.PaneOptions {
|
export interface AddCollectionPaneOptions extends ViewModels.PaneOptions {
|
||||||
isPreferredApiTable: ko.Computed<boolean>;
|
isPreferredApiTable: ko.Computed<boolean>;
|
||||||
@@ -43,6 +42,8 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
public partitionKeyVisible: ko.Computed<boolean>;
|
public partitionKeyVisible: ko.Computed<boolean>;
|
||||||
public partitionKeyPattern: ko.Computed<string>;
|
public partitionKeyPattern: ko.Computed<string>;
|
||||||
public partitionKeyTitle: ko.Computed<string>;
|
public partitionKeyTitle: ko.Computed<string>;
|
||||||
|
public rupm: ko.Observable<string>;
|
||||||
|
public rupmVisible: ko.Observable<boolean>;
|
||||||
public storage: ko.Observable<string>;
|
public storage: ko.Observable<string>;
|
||||||
public throughputSinglePartition: ViewModels.Editable<number>;
|
public throughputSinglePartition: ViewModels.Editable<number>;
|
||||||
public throughputMultiPartition: ViewModels.Editable<number>;
|
public throughputMultiPartition: ViewModels.Editable<number>;
|
||||||
@@ -142,6 +143,12 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
|
this.rupm = ko.observable<string>(Constants.RUPMStates.off);
|
||||||
|
this.rupmVisible = ko.observable<boolean>(false);
|
||||||
|
const featureSubcription = this.container.features.subscribe(() => {
|
||||||
|
this.rupmVisible(this.container.isFeatureEnabled(Constants.Features.enableRupm));
|
||||||
|
featureSubcription.dispose();
|
||||||
|
});
|
||||||
|
|
||||||
this.canExceedMaximumValue = ko.pureComputed(() => this.container.canExceedMaximumValue());
|
this.canExceedMaximumValue = ko.pureComputed(() => this.container.canExceedMaximumValue());
|
||||||
|
|
||||||
@@ -194,6 +201,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
account.properties.readLocations.length) ||
|
account.properties.readLocations.length) ||
|
||||||
1;
|
1;
|
||||||
const multimaster = (account && account.properties && account.properties.enableMultipleWriteLocations) || false;
|
const multimaster = (account && account.properties && account.properties.enableMultipleWriteLocations) || false;
|
||||||
|
const rupmEnabled: boolean = this.rupm() === Constants.RUPMStates.on;
|
||||||
|
|
||||||
let throughputSpendAckText: string;
|
let throughputSpendAckText: string;
|
||||||
let estimatedSpend: string;
|
let estimatedSpend: string;
|
||||||
@@ -203,15 +211,23 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
rupmEnabled,
|
||||||
this.isSharedAutoPilotSelected()
|
this.isSharedAutoPilotSelected()
|
||||||
);
|
);
|
||||||
estimatedSpend = PricingUtils.getEstimatedSpendHtml(offerThroughput, serverId, regions, multimaster);
|
estimatedSpend = PricingUtils.getEstimatedSpendHtml(
|
||||||
|
offerThroughput,
|
||||||
|
serverId,
|
||||||
|
regions,
|
||||||
|
multimaster,
|
||||||
|
rupmEnabled
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
throughputSpendAckText = PricingUtils.getEstimatedSpendAcknowledgeString(
|
throughputSpendAckText = PricingUtils.getEstimatedSpendAcknowledgeString(
|
||||||
this.sharedAutoPilotThroughput(),
|
this.sharedAutoPilotThroughput(),
|
||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
rupmEnabled,
|
||||||
this.isSharedAutoPilotSelected()
|
this.isSharedAutoPilotSelected()
|
||||||
);
|
);
|
||||||
estimatedSpend = PricingUtils.getEstimatedAutoscaleSpendHtml(
|
estimatedSpend = PricingUtils.getEstimatedAutoscaleSpendHtml(
|
||||||
@@ -248,6 +264,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
account.properties.readLocations.length) ||
|
account.properties.readLocations.length) ||
|
||||||
1;
|
1;
|
||||||
const multimaster = (account && account.properties && account.properties.enableMultipleWriteLocations) || false;
|
const multimaster = (account && account.properties && account.properties.enableMultipleWriteLocations) || false;
|
||||||
|
const rupmEnabled: boolean = this.rupm() === Constants.RUPMStates.on;
|
||||||
|
|
||||||
let throughputSpendAckText: string;
|
let throughputSpendAckText: string;
|
||||||
let estimatedSpend: string;
|
let estimatedSpend: string;
|
||||||
@@ -257,13 +274,15 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
rupmEnabled,
|
||||||
this.isAutoPilotSelected()
|
this.isAutoPilotSelected()
|
||||||
);
|
);
|
||||||
estimatedSpend = PricingUtils.getEstimatedSpendHtml(
|
estimatedSpend = PricingUtils.getEstimatedSpendHtml(
|
||||||
this.throughputMultiPartition(),
|
this.throughputMultiPartition(),
|
||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster
|
multimaster,
|
||||||
|
rupmEnabled
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
throughputSpendAckText = PricingUtils.getEstimatedSpendAcknowledgeString(
|
throughputSpendAckText = PricingUtils.getEstimatedSpendAcknowledgeString(
|
||||||
@@ -271,6 +290,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
rupmEnabled,
|
||||||
this.isAutoPilotSelected()
|
this.isAutoPilotSelected()
|
||||||
);
|
);
|
||||||
estimatedSpend = PricingUtils.getEstimatedAutoscaleSpendHtml(
|
estimatedSpend = PricingUtils.getEstimatedAutoscaleSpendHtml(
|
||||||
@@ -666,10 +686,11 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
storage: this.storage(),
|
storage: this.storage(),
|
||||||
offerThroughput: this._getThroughput(),
|
offerThroughput: this._getThroughput(),
|
||||||
partitionKey: this.partitionKey(),
|
partitionKey: this.partitionKey(),
|
||||||
databaseId: this.databaseId()
|
databaseId: this.databaseId(),
|
||||||
|
rupm: this.rupm()
|
||||||
}),
|
}),
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
|
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
|
||||||
throughput: this._getThroughput(),
|
throughput: this._getThroughput(),
|
||||||
@@ -767,11 +788,12 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
id: this.collectionId(),
|
id: this.collectionId(),
|
||||||
storage: this.storage(),
|
storage: this.storage(),
|
||||||
partitionKey,
|
partitionKey,
|
||||||
|
rupm: this.rupm(),
|
||||||
uniqueKeyPolicy,
|
uniqueKeyPolicy,
|
||||||
collectionWithThroughputInShared: this.collectionWithThroughputInShared()
|
collectionWithThroughputInShared: this.collectionWithThroughputInShared()
|
||||||
}),
|
}),
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
|
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
|
||||||
throughput: offerThroughput,
|
throughput: offerThroughput,
|
||||||
@@ -841,11 +863,12 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
id: this.collectionId(),
|
id: this.collectionId(),
|
||||||
storage: this.storage(),
|
storage: this.storage(),
|
||||||
partitionKey,
|
partitionKey,
|
||||||
|
rupm: this.rupm(),
|
||||||
uniqueKeyPolicy,
|
uniqueKeyPolicy,
|
||||||
collectionWithThroughputInShared: this.collectionWithThroughputInShared()
|
collectionWithThroughputInShared: this.collectionWithThroughputInShared()
|
||||||
}),
|
}),
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
|
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
|
||||||
throughput: offerThroughput,
|
throughput: offerThroughput,
|
||||||
@@ -875,11 +898,12 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
id: this.collectionId(),
|
id: this.collectionId(),
|
||||||
storage: this.storage(),
|
storage: this.storage(),
|
||||||
partitionKey,
|
partitionKey,
|
||||||
|
rupm: this.rupm(),
|
||||||
uniqueKeyPolicy,
|
uniqueKeyPolicy,
|
||||||
collectionWithThroughputInShared: this.collectionWithThroughputInShared()
|
collectionWithThroughputInShared: this.collectionWithThroughputInShared()
|
||||||
},
|
},
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
|
storage: this.storage() === Constants.BackendDefaults.singlePartitionStorageInGb ? "f" : "u",
|
||||||
throughput: offerThroughput,
|
throughput: offerThroughput,
|
||||||
@@ -957,6 +981,20 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onRupmOptionsKeyDown(source: any, event: KeyboardEvent): boolean {
|
||||||
|
if (event.key === "ArrowRight") {
|
||||||
|
this.rupm("off");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key === "ArrowLeft") {
|
||||||
|
this.rupm("on");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public onEnableSynapseLinkButtonClicked() {
|
public onEnableSynapseLinkButtonClicked() {
|
||||||
this.container.openEnableSynapseLinkDialog();
|
this.container.openEnableSynapseLinkDialog();
|
||||||
}
|
}
|
||||||
@@ -980,6 +1018,16 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const throughput = this._getThroughput();
|
const throughput = this._getThroughput();
|
||||||
|
const maxThroughputWithRUPM =
|
||||||
|
SharedConstants.CollectionCreation.MaxRUPMPerPartition * this._calculateNumberOfPartitions();
|
||||||
|
|
||||||
|
if (this.rupm() === Constants.RUPMStates.on && throughput > maxThroughputWithRUPM) {
|
||||||
|
this.formErrors(
|
||||||
|
`The maximum supported provisioned throughput with RU/m enabled is ${maxThroughputWithRUPM} RU/s. Please turn off RU/m to incease thoughput above ${maxThroughputWithRUPM} RU/s.`
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (throughput > SharedConstants.CollectionCreation.DefaultCollectionRUs100K && !this.throughputSpendAck()) {
|
if (throughput > SharedConstants.CollectionCreation.DefaultCollectionRUs100K && !this.throughputSpendAck()) {
|
||||||
this.formErrors(`Please acknowledge the estimated daily spend.`);
|
this.formErrors(`Please acknowledge the estimated daily spend.`);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { createDatabase } from "../../Common/dataAccess/createDatabase";
|
|||||||
import { configContext, Platform } from "../../ConfigContext";
|
import { configContext, Platform } from "../../ConfigContext";
|
||||||
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
||||||
import { SubscriptionType } from "../../Contracts/SubscriptionType";
|
import { SubscriptionType } from "../../Contracts/SubscriptionType";
|
||||||
import { userContext } from "../../UserContext";
|
|
||||||
|
|
||||||
export default class AddDatabasePane extends ContextualPaneBase {
|
export default class AddDatabasePane extends ContextualPaneBase {
|
||||||
public defaultExperience: ko.Computed<string>;
|
public defaultExperience: ko.Computed<string>;
|
||||||
@@ -134,12 +133,19 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
|||||||
let estimatedSpendAcknowledge: string;
|
let estimatedSpendAcknowledge: string;
|
||||||
let estimatedSpend: string;
|
let estimatedSpend: string;
|
||||||
if (!this.isAutoPilotSelected()) {
|
if (!this.isAutoPilotSelected()) {
|
||||||
estimatedSpend = PricingUtils.getEstimatedSpendHtml(offerThroughput, serverId, regions, multimaster);
|
estimatedSpend = PricingUtils.getEstimatedSpendHtml(
|
||||||
|
offerThroughput,
|
||||||
|
serverId,
|
||||||
|
regions,
|
||||||
|
multimaster,
|
||||||
|
false /*rupmEnabled*/
|
||||||
|
);
|
||||||
estimatedSpendAcknowledge = PricingUtils.getEstimatedSpendAcknowledgeString(
|
estimatedSpendAcknowledge = PricingUtils.getEstimatedSpendAcknowledgeString(
|
||||||
offerThroughput,
|
offerThroughput,
|
||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
false /*rupmEnabled*/,
|
||||||
this.isAutoPilotSelected()
|
this.isAutoPilotSelected()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -154,6 +160,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
|||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
false /*rupmEnabled*/,
|
||||||
this.isAutoPilotSelected()
|
this.isAutoPilotSelected()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -251,7 +258,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
|||||||
databaseAccountName: this.container.databaseAccount().name,
|
databaseAccountName: this.container.databaseAccount().name,
|
||||||
defaultExperience: this.container.defaultExperience(),
|
defaultExperience: this.container.defaultExperience(),
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
throughput: this.throughput(),
|
throughput: this.throughput(),
|
||||||
flight: this.container.flight()
|
flight: this.container.flight()
|
||||||
@@ -279,7 +286,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
|||||||
}),
|
}),
|
||||||
offerThroughput,
|
offerThroughput,
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
flight: this.container.flight()
|
flight: this.container.flight()
|
||||||
},
|
},
|
||||||
@@ -343,7 +350,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
|||||||
}),
|
}),
|
||||||
offerThroughput: offerThroughput,
|
offerThroughput: offerThroughput,
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
flight: this.container.flight()
|
flight: this.container.flight()
|
||||||
},
|
},
|
||||||
@@ -367,7 +374,7 @@ export default class AddDatabasePane extends ContextualPaneBase {
|
|||||||
}),
|
}),
|
||||||
offerThroughput: offerThroughput,
|
offerThroughput: offerThroughput,
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
flight: this.container.flight()
|
flight: this.container.flight()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { HashMap } from "../../Common/HashMap";
|
|||||||
import { configContext, Platform } from "../../ConfigContext";
|
import { configContext, Platform } from "../../ConfigContext";
|
||||||
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
||||||
import { SubscriptionType } from "../../Contracts/SubscriptionType";
|
import { SubscriptionType } from "../../Contracts/SubscriptionType";
|
||||||
import { userContext } from "../../UserContext";
|
|
||||||
|
|
||||||
export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
||||||
public createTableQuery: ko.Observable<string>;
|
public createTableQuery: ko.Observable<string>;
|
||||||
@@ -139,12 +138,19 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
|||||||
let estimatedSpend: string;
|
let estimatedSpend: string;
|
||||||
let estimatedDedicatedSpendAcknowledge: string;
|
let estimatedDedicatedSpendAcknowledge: string;
|
||||||
if (!this.isAutoPilotSelected()) {
|
if (!this.isAutoPilotSelected()) {
|
||||||
estimatedSpend = PricingUtils.getEstimatedSpendHtml(offerThroughput, serverId, regions, multimaster);
|
estimatedSpend = PricingUtils.getEstimatedSpendHtml(
|
||||||
|
offerThroughput,
|
||||||
|
serverId,
|
||||||
|
regions,
|
||||||
|
multimaster,
|
||||||
|
false /*rupmEnabled*/
|
||||||
|
);
|
||||||
estimatedDedicatedSpendAcknowledge = PricingUtils.getEstimatedSpendAcknowledgeString(
|
estimatedDedicatedSpendAcknowledge = PricingUtils.getEstimatedSpendAcknowledgeString(
|
||||||
offerThroughput,
|
offerThroughput,
|
||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
false /*rupmEnabled*/,
|
||||||
this.isAutoPilotSelected()
|
this.isAutoPilotSelected()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -159,6 +165,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
|||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
false /*rupmEnabled*/,
|
||||||
this.isAutoPilotSelected()
|
this.isAutoPilotSelected()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -183,12 +190,19 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
|||||||
let estimatedSpend: string;
|
let estimatedSpend: string;
|
||||||
let estimatedSharedSpendAcknowledge: string;
|
let estimatedSharedSpendAcknowledge: string;
|
||||||
if (!this.isSharedAutoPilotSelected()) {
|
if (!this.isSharedAutoPilotSelected()) {
|
||||||
estimatedSpend = PricingUtils.getEstimatedSpendHtml(this.keyspaceThroughput(), serverId, regions, multimaster);
|
estimatedSpend = PricingUtils.getEstimatedSpendHtml(
|
||||||
|
this.keyspaceThroughput(),
|
||||||
|
serverId,
|
||||||
|
regions,
|
||||||
|
multimaster,
|
||||||
|
false /*rupmEnabled*/
|
||||||
|
);
|
||||||
estimatedSharedSpendAcknowledge = PricingUtils.getEstimatedSpendAcknowledgeString(
|
estimatedSharedSpendAcknowledge = PricingUtils.getEstimatedSpendAcknowledgeString(
|
||||||
this.keyspaceThroughput(),
|
this.keyspaceThroughput(),
|
||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
false /*rupmEnabled*/,
|
||||||
this.isSharedAutoPilotSelected()
|
this.isSharedAutoPilotSelected()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -203,6 +217,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
|||||||
serverId,
|
serverId,
|
||||||
regions,
|
regions,
|
||||||
multimaster,
|
multimaster,
|
||||||
|
false /*rupmEnabled*/,
|
||||||
this.isSharedAutoPilotSelected()
|
this.isSharedAutoPilotSelected()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -297,10 +312,11 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
|||||||
storage: Constants.BackendDefaults.multiPartitionStorageInGb,
|
storage: Constants.BackendDefaults.multiPartitionStorageInGb,
|
||||||
offerThroughput: this.throughput(),
|
offerThroughput: this.throughput(),
|
||||||
partitionKey: "",
|
partitionKey: "",
|
||||||
databaseId: this.keyspaceId()
|
databaseId: this.keyspaceId(),
|
||||||
|
rupm: false
|
||||||
}),
|
}),
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
storage: "u",
|
storage: "u",
|
||||||
throughput: this.throughput(),
|
throughput: this.throughput(),
|
||||||
@@ -350,11 +366,12 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
|||||||
offerThroughput: this.throughput(),
|
offerThroughput: this.throughput(),
|
||||||
partitionKey: "",
|
partitionKey: "",
|
||||||
databaseId: this.keyspaceId(),
|
databaseId: this.keyspaceId(),
|
||||||
|
rupm: false,
|
||||||
hasDedicatedThroughput: this.dedicateTableThroughput()
|
hasDedicatedThroughput: this.dedicateTableThroughput()
|
||||||
}),
|
}),
|
||||||
keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(),
|
keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(),
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
storage: "u",
|
storage: "u",
|
||||||
throughput: this.throughput(),
|
throughput: this.throughput(),
|
||||||
@@ -396,11 +413,12 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
|||||||
offerThroughput: this.throughput(),
|
offerThroughput: this.throughput(),
|
||||||
partitionKey: "",
|
partitionKey: "",
|
||||||
databaseId: this.keyspaceId(),
|
databaseId: this.keyspaceId(),
|
||||||
|
rupm: false,
|
||||||
hasDedicatedThroughput: this.dedicateTableThroughput()
|
hasDedicatedThroughput: this.dedicateTableThroughput()
|
||||||
}),
|
}),
|
||||||
keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(),
|
keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(),
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
storage: "u",
|
storage: "u",
|
||||||
throughput: this.throughput(),
|
throughput: this.throughput(),
|
||||||
@@ -426,11 +444,12 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
|||||||
offerThroughput: this.throughput(),
|
offerThroughput: this.throughput(),
|
||||||
partitionKey: "",
|
partitionKey: "",
|
||||||
databaseId: this.keyspaceId(),
|
databaseId: this.keyspaceId(),
|
||||||
|
rupm: false,
|
||||||
hasDedicatedThroughput: this.dedicateTableThroughput()
|
hasDedicatedThroughput: this.dedicateTableThroughput()
|
||||||
},
|
},
|
||||||
keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(),
|
keyspaceHasSharedOffer: this.keyspaceHasSharedOffer(),
|
||||||
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
subscriptionType: SubscriptionType[this.container.subscriptionType()],
|
||||||
subscriptionQuotaId: userContext.quotaId,
|
subscriptionQuotaId: this.container.quotaId(),
|
||||||
defaultsCheck: {
|
defaultsCheck: {
|
||||||
storage: "u",
|
storage: "u",
|
||||||
throughput: this.throughput(),
|
throughput: this.throughput(),
|
||||||
|
|||||||
@@ -98,21 +98,26 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
|
|||||||
author: string,
|
author: string,
|
||||||
notebookContent: string | ImmutableNotebook,
|
notebookContent: string | ImmutableNotebook,
|
||||||
parentDomElement: HTMLElement,
|
parentDomElement: HTMLElement,
|
||||||
|
isCodeOfConductEnabled: boolean,
|
||||||
isLinkInjectionEnabled: boolean
|
isLinkInjectionEnabled: boolean
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
if (isCodeOfConductEnabled) {
|
||||||
const response = await this.junoClient.isCodeOfConductAccepted();
|
try {
|
||||||
if (response.status !== HttpStatusCodes.OK && response.status !== HttpStatusCodes.NoContent) {
|
const response = await this.junoClient.isCodeOfConductAccepted();
|
||||||
throw new Error(`Received HTTP ${response.status} when accepting code of conduct`);
|
if (response.status !== HttpStatusCodes.OK && response.status !== HttpStatusCodes.NoContent) {
|
||||||
}
|
throw new Error(`Received HTTP ${response.status} when accepting code of conduct`);
|
||||||
|
}
|
||||||
|
|
||||||
this.isCodeOfConductAccepted = response.data;
|
this.isCodeOfConductAccepted = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(
|
handleError(
|
||||||
error,
|
error,
|
||||||
"PublishNotebookPaneAdapter/isCodeOfConductAccepted",
|
"PublishNotebookPaneAdapter/isCodeOfConductAccepted",
|
||||||
"Failed to check if code of conduct was accepted"
|
"Failed to check if code of conduct was accepted"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.isCodeOfConductAccepted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as ko from "knockout";
|
|||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import { parseConnectionString } from "../../Platform/Hosted/Helpers/ConnectionStringParser";
|
import { ConnectionStringParser } from "../../Platform/Hosted/Helpers/ConnectionStringParser";
|
||||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
||||||
@@ -48,7 +48,9 @@ export class RenewAdHocAccessPane extends ContextualPaneBase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private _shouldShowContextSwitchPrompt(): boolean {
|
private _shouldShowContextSwitchPrompt(): boolean {
|
||||||
const inputMetadata: DataModels.AccessInputMetadata = parseConnectionString(this.accessKey());
|
const inputMetadata: DataModels.AccessInputMetadata = ConnectionStringParser.parseConnectionString(
|
||||||
|
this.accessKey()
|
||||||
|
);
|
||||||
const apiKind: DataModels.ApiKind =
|
const apiKind: DataModels.ApiKind =
|
||||||
this.container && DefaultExperienceUtility.getApiKindFromDefaultExperience(this.container.defaultExperience());
|
this.container && DefaultExperienceUtility.getApiKindFromDefaultExperience(this.container.defaultExperience());
|
||||||
const hasOpenedTabs: boolean =
|
const hasOpenedTabs: boolean =
|
||||||
|
|||||||
@@ -50,24 +50,13 @@
|
|||||||
id="fileImportLinkNotebook"
|
id="fileImportLinkNotebook"
|
||||||
data-bind="event: { click: onImportLinkClick, keypress: onImportLinkKeyPress }"
|
data-bind="event: { click: onImportLinkClick, keypress: onImportLinkKeyPress }"
|
||||||
>
|
>
|
||||||
<img
|
<img class="fileImportImg" src="/folder_16x16.svg" alt="upload files" title="Upload files" />
|
||||||
id="importFileButton"
|
|
||||||
class="fileImportImg"
|
|
||||||
src="/folder_16x16.svg"
|
|
||||||
alt="upload files"
|
|
||||||
title="Upload files"
|
|
||||||
/>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="paneFooter">
|
<div class="paneFooter">
|
||||||
<div class="leftpanel-okbut">
|
<div class="leftpanel-okbut">
|
||||||
<input
|
<input type="submit" data-bind="attr: { value: submitButtonLabel }" class="btncreatecoll1" />
|
||||||
id="uploadFileButton"
|
|
||||||
type="submit"
|
|
||||||
data-bind="attr: { value: submitButtonLabel }"
|
|
||||||
class="btncreatecoll1"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Upload File inputs - End -->
|
<!-- Upload File inputs - End -->
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
padding: 32px 16px;
|
padding: 32px 16px;
|
||||||
display: flex;
|
display: flex;
|
||||||
background-color: @BaseLight;
|
background-color: @BaseLight;
|
||||||
border: 1px solid #949494;
|
border: 1px solid #E5E5E5;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|||||||
@@ -421,47 +421,53 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
|||||||
* Note that this also means that we can get less entities than the requested download size in a successful call.
|
* Note that this also means that we can get less entities than the requested download size in a successful call.
|
||||||
* See Microsoft Azure API Documentation at: https://msdn.microsoft.com/en-us/library/azure/dd135718.aspx
|
* See Microsoft Azure API Documentation at: https://msdn.microsoft.com/en-us/library/azure/dd135718.aspx
|
||||||
*/
|
*/
|
||||||
private async prefetchData(
|
private prefetchData(
|
||||||
tableQuery: Entities.ITableQuery,
|
tableQuery: Entities.ITableQuery,
|
||||||
downloadSize: number,
|
downloadSize: number,
|
||||||
currentRetry: number = 0
|
currentRetry: number = 0
|
||||||
): Promise<IListTableEntitiesSegmentedResult> {
|
): Q.Promise<any> {
|
||||||
if (!this.cache.serverCallInProgress) {
|
if (!this.cache.serverCallInProgress) {
|
||||||
this.cache.serverCallInProgress = true;
|
this.cache.serverCallInProgress = true;
|
||||||
this.allDownloaded = false;
|
this.allDownloaded = false;
|
||||||
this.lastPrefetchTime = new Date().getTime();
|
this.lastPrefetchTime = new Date().getTime();
|
||||||
const time = this.lastPrefetchTime;
|
var time = this.lastPrefetchTime;
|
||||||
|
|
||||||
|
var promise: Q.Promise<IListTableEntitiesSegmentedResult>;
|
||||||
if (this._documentIterator && this.continuationToken) {
|
if (this._documentIterator && this.continuationToken) {
|
||||||
// TODO handle Cassandra case
|
// TODO handle Cassandra case
|
||||||
const response = await this._documentIterator.fetchNext();
|
|
||||||
const entities: Entities.ITableEntity[] = TableEntityProcessor.convertDocumentsToEntities(response?.resources);
|
|
||||||
|
|
||||||
return {
|
promise = Q(this._documentIterator.fetchNext().then(response => response.resources)).then(
|
||||||
Results: entities,
|
(documents: any[]) => {
|
||||||
ContinuationToken: this._documentIterator.hasMoreResults()
|
let entities: Entities.ITableEntity[] = TableEntityProcessor.convertDocumentsToEntities(documents);
|
||||||
};
|
let finalEntities: IListTableEntitiesSegmentedResult = <IListTableEntitiesSegmentedResult>{
|
||||||
|
Results: entities,
|
||||||
|
ContinuationToken: this._documentIterator.hasMoreResults()
|
||||||
|
};
|
||||||
|
return Q.resolve(finalEntities);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else if (this.continuationToken && this.queryTablesTab.container.isPreferredApiCassandra()) {
|
||||||
|
promise = this.queryTablesTab.container.tableDataClient.queryDocuments(
|
||||||
|
this.queryTablesTab.collection,
|
||||||
|
this.cqlQuery(),
|
||||||
|
true,
|
||||||
|
this.continuationToken
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
let query = this.sqlQuery();
|
||||||
|
if (this.queryTablesTab.container.isPreferredApiCassandra()) {
|
||||||
|
query = this.cqlQuery();
|
||||||
|
}
|
||||||
|
promise = this.queryTablesTab.container.tableDataClient.queryDocuments(
|
||||||
|
this.queryTablesTab.collection,
|
||||||
|
query,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
return promise
|
||||||
try {
|
.then((result: IListTableEntitiesSegmentedResult) => {
|
||||||
let documents: IListTableEntitiesSegmentedResult;
|
|
||||||
if (this.continuationToken && this.queryTablesTab.container.isPreferredApiCassandra()) {
|
|
||||||
documents = await this.queryTablesTab.container.tableDataClient.queryDocuments(
|
|
||||||
this.queryTablesTab.collection,
|
|
||||||
this.cqlQuery(),
|
|
||||||
true,
|
|
||||||
this.continuationToken
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
const query = this.queryTablesTab.container.isPreferredApiCassandra() ? this.cqlQuery() : this.sqlQuery();
|
|
||||||
documents = await this.queryTablesTab.container.tableDataClient.queryDocuments(
|
|
||||||
this.queryTablesTab.collection,
|
|
||||||
query,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!this._documentIterator) {
|
if (!this._documentIterator) {
|
||||||
this._documentIterator = documents.iterator;
|
this._documentIterator = result.iterator;
|
||||||
}
|
}
|
||||||
var actualDownloadSize: number = 0;
|
var actualDownloadSize: number = 0;
|
||||||
|
|
||||||
@@ -472,11 +478,11 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
|||||||
return Q.resolve(null);
|
return Q.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var entities = documents.Results;
|
var entities = result.Results;
|
||||||
actualDownloadSize = entities.length;
|
actualDownloadSize = entities.length;
|
||||||
|
|
||||||
// Queries can fetch no results and still return a continuation header. See prefetchAndRender() method.
|
// Queries can fetch no results and still return a continuation header. See prefetchAndRender() method.
|
||||||
this.continuationToken = this.isCancelled ? null : documents.ContinuationToken;
|
this.continuationToken = this.isCancelled ? null : result.ContinuationToken;
|
||||||
|
|
||||||
if (!this.continuationToken) {
|
if (!this.continuationToken) {
|
||||||
this.allDownloaded = true;
|
this.allDownloaded = true;
|
||||||
@@ -508,22 +514,20 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
|||||||
// For #2.1, set prefetch exceeds maximum retry number and end prefetch.
|
// For #2.1, set prefetch exceeds maximum retry number and end prefetch.
|
||||||
// For #2.2, go to next round prefetch.
|
// For #2.2, go to next round prefetch.
|
||||||
if (this.allDownloaded || nextDownloadSize === 0) {
|
if (this.allDownloaded || nextDownloadSize === 0) {
|
||||||
return documents;
|
return Q.resolve(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRetry >= TableEntityListViewModel._maximumNumberOfPrefetchRetries) {
|
if (currentRetry >= TableEntityListViewModel._maximumNumberOfPrefetchRetries) {
|
||||||
documents.ExceedMaximumRetries = true;
|
result.ExceedMaximumRetries = true;
|
||||||
return documents;
|
return Q.resolve(result);
|
||||||
}
|
}
|
||||||
|
return this.prefetchData(tableQuery, nextDownloadSize, currentRetry + 1);
|
||||||
return await this.prefetchData(tableQuery, nextDownloadSize, currentRetry + 1);
|
})
|
||||||
}
|
.catch((error: Error) => {
|
||||||
} catch (error) {
|
this.cache.serverCallInProgress = false;
|
||||||
this.cache.serverCallInProgress = false;
|
return Q.reject(error);
|
||||||
throw error;
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Q from "q";
|
|||||||
import { displayTokenRenewalPromptForStatus, getAuthorizationHeader } from "../../Utils/AuthorizationUtils";
|
import { displayTokenRenewalPromptForStatus, getAuthorizationHeader } from "../../Utils/AuthorizationUtils";
|
||||||
import { AuthType } from "../../AuthType";
|
import { AuthType } from "../../AuthType";
|
||||||
import { ConsoleDataType } from "../../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
import { ConsoleDataType } from "../../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
import { FeedOptions } from "@azure/cosmos";
|
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as Entities from "./Entities";
|
import * as Entities from "./Entities";
|
||||||
import * as HeadersUtility from "../../Common/HeadersUtility";
|
import * as HeadersUtility from "../../Common/HeadersUtility";
|
||||||
@@ -13,12 +12,9 @@ import * as TableConstants from "./Constants";
|
|||||||
import * as TableEntityProcessor from "./TableEntityProcessor";
|
import * as TableEntityProcessor from "./TableEntityProcessor";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
|
import { queryDocuments, deleteDocument, updateDocument, createDocument } from "../../Common/DocumentClientUtilityBase";
|
||||||
import { configContext } from "../../ConfigContext";
|
import { configContext } from "../../ConfigContext";
|
||||||
import { handleError } from "../../Common/ErrorHandlingUtils";
|
import { handleError } from "../../Common/ErrorHandlingUtils";
|
||||||
import { createDocument } from "../../Common/dataAccess/createDocument";
|
|
||||||
import { deleteDocument } from "../../Common/dataAccess/deleteDocument";
|
|
||||||
import { queryDocuments } from "../../Common/dataAccess/queryDocuments";
|
|
||||||
import { updateDocument } from "../../Common/dataAccess/updateDocument";
|
|
||||||
|
|
||||||
export interface CassandraTableKeys {
|
export interface CassandraTableKeys {
|
||||||
partitionKeys: CassandraTableKey[];
|
partitionKeys: CassandraTableKey[];
|
||||||
@@ -42,19 +38,19 @@ export abstract class TableDataClient {
|
|||||||
collection: ViewModels.Collection,
|
collection: ViewModels.Collection,
|
||||||
originalDocument: any,
|
originalDocument: any,
|
||||||
newEntity: Entities.ITableEntity
|
newEntity: Entities.ITableEntity
|
||||||
): Promise<Entities.ITableEntity>;
|
): Q.Promise<Entities.ITableEntity>;
|
||||||
|
|
||||||
public abstract queryDocuments(
|
public abstract queryDocuments(
|
||||||
collection: ViewModels.Collection,
|
collection: ViewModels.Collection,
|
||||||
query: string,
|
query: string,
|
||||||
shouldNotify?: boolean,
|
shouldNotify?: boolean,
|
||||||
paginationToken?: string
|
paginationToken?: string
|
||||||
): Promise<Entities.IListTableEntitiesResult>;
|
): Q.Promise<Entities.IListTableEntitiesResult>;
|
||||||
|
|
||||||
public abstract deleteDocuments(
|
public abstract deleteDocuments(
|
||||||
collection: ViewModels.Collection,
|
collection: ViewModels.Collection,
|
||||||
entitiesToDelete: Entities.ITableEntity[]
|
entitiesToDelete: Entities.ITableEntity[]
|
||||||
): Promise<any>;
|
): Q.Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TablesAPIDataClient extends TableDataClient {
|
export class TablesAPIDataClient extends TableDataClient {
|
||||||
@@ -78,63 +74,77 @@ export class TablesAPIDataClient extends TableDataClient {
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateDocument(
|
public updateDocument(
|
||||||
collection: ViewModels.Collection,
|
collection: ViewModels.Collection,
|
||||||
originalDocument: any,
|
originalDocument: any,
|
||||||
entity: Entities.ITableEntity
|
entity: Entities.ITableEntity
|
||||||
): Promise<Entities.ITableEntity> {
|
): Q.Promise<Entities.ITableEntity> {
|
||||||
try {
|
const deferred = Q.defer<Entities.ITableEntity>();
|
||||||
const newDocument = await updateDocument(
|
|
||||||
collection,
|
updateDocument(
|
||||||
originalDocument,
|
collection,
|
||||||
TableEntityProcessor.convertEntityToNewDocument(<Entities.ITableEntityForTablesAPI>entity)
|
originalDocument,
|
||||||
);
|
TableEntityProcessor.convertEntityToNewDocument(<Entities.ITableEntityForTablesAPI>entity)
|
||||||
return TableEntityProcessor.convertDocumentsToEntities([newDocument])[0];
|
).then(
|
||||||
} catch (error) {
|
(newDocument: any) => {
|
||||||
handleError(error, "TablesAPIDataClient/updateDocument");
|
const newEntity = TableEntityProcessor.convertDocumentsToEntities([newDocument])[0];
|
||||||
throw error;
|
deferred.resolve(newEntity);
|
||||||
}
|
},
|
||||||
|
reason => {
|
||||||
|
deferred.reject(reason);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async queryDocuments(
|
public queryDocuments(
|
||||||
collection: ViewModels.Collection,
|
collection: ViewModels.Collection,
|
||||||
query: string
|
query: string
|
||||||
): Promise<Entities.IListTableEntitiesResult> {
|
): Q.Promise<Entities.IListTableEntitiesResult> {
|
||||||
try {
|
const deferred = Q.defer<Entities.IListTableEntitiesResult>();
|
||||||
const options = {
|
|
||||||
enableCrossPartitionQuery: HeadersUtility.shouldEnableCrossPartitionKey()
|
|
||||||
} as FeedOptions;
|
|
||||||
const iterator = queryDocuments(collection.databaseId, collection.id(), query, options);
|
|
||||||
const response = await iterator.fetchNext();
|
|
||||||
const documents = response?.resources;
|
|
||||||
const entities = TableEntityProcessor.convertDocumentsToEntities(documents);
|
|
||||||
|
|
||||||
return {
|
let options: any = {};
|
||||||
Results: entities,
|
options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey();
|
||||||
ContinuationToken: iterator.hasMoreResults(),
|
queryDocuments(collection.databaseId, collection.id(), query, options).then(
|
||||||
iterator: iterator
|
iterator => {
|
||||||
};
|
iterator
|
||||||
} catch (error) {
|
.fetchNext()
|
||||||
handleError(error, "TablesAPIDataClient/queryDocuments", "Query documents failed");
|
.then(response => response.resources)
|
||||||
throw error;
|
.then(
|
||||||
}
|
(documents: any[] = []) => {
|
||||||
|
let entities: Entities.ITableEntity[] = TableEntityProcessor.convertDocumentsToEntities(documents);
|
||||||
|
let finalEntities: Entities.IListTableEntitiesResult = <Entities.IListTableEntitiesResult>{
|
||||||
|
Results: entities,
|
||||||
|
ContinuationToken: iterator.hasMoreResults(),
|
||||||
|
iterator: iterator
|
||||||
|
};
|
||||||
|
deferred.resolve(finalEntities);
|
||||||
|
},
|
||||||
|
reason => {
|
||||||
|
deferred.reject(reason);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
reason => {
|
||||||
|
deferred.reject(reason);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteDocuments(
|
public deleteDocuments(collection: ViewModels.Collection, entitiesToDelete: Entities.ITableEntity[]): Q.Promise<any> {
|
||||||
collection: ViewModels.Collection,
|
let documentsToDelete: any[] = TableEntityProcessor.convertEntitiesToDocuments(
|
||||||
entitiesToDelete: Entities.ITableEntity[]
|
|
||||||
): Promise<any> {
|
|
||||||
const documentsToDelete: any[] = TableEntityProcessor.convertEntitiesToDocuments(
|
|
||||||
<Entities.ITableEntityForTablesAPI[]>entitiesToDelete,
|
<Entities.ITableEntityForTablesAPI[]>entitiesToDelete,
|
||||||
collection
|
collection
|
||||||
);
|
);
|
||||||
|
let promiseArray: Q.Promise<any>[] = [];
|
||||||
await Promise.all(
|
documentsToDelete &&
|
||||||
documentsToDelete?.map(async document => {
|
documentsToDelete.forEach(document => {
|
||||||
document.id = ko.observable<string>(document.id);
|
document.id = ko.observable<string>(document.id);
|
||||||
await deleteDocument(collection, document);
|
let promise: Q.Promise<any> = deleteDocument(collection, document);
|
||||||
})
|
promiseArray.push(promise);
|
||||||
);
|
});
|
||||||
|
return Q.all(promiseArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +180,10 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
(data: any) => {
|
(data: any) => {
|
||||||
entity[TableConstants.EntityKeyNames.RowKey] = entity[this.getCassandraPartitionKeyProperty(collection)];
|
entity[TableConstants.EntityKeyNames.RowKey] = entity[this.getCassandraPartitionKeyProperty(collection)];
|
||||||
entity[TableConstants.EntityKeyNames.RowKey]._ = entity[TableConstants.EntityKeyNames.RowKey]._.toString();
|
entity[TableConstants.EntityKeyNames.RowKey]._ = entity[TableConstants.EntityKeyNames.RowKey]._.toString();
|
||||||
NotificationConsoleUtils.logConsoleInfo(`Successfully added new row to table ${collection.id()}`);
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Info,
|
||||||
|
`Successfully added new row to table ${collection.id()}`
|
||||||
|
);
|
||||||
deferred.resolve(entity);
|
deferred.resolve(entity);
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
@@ -184,149 +197,181 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateDocument(
|
public updateDocument(
|
||||||
collection: ViewModels.Collection,
|
collection: ViewModels.Collection,
|
||||||
originalDocument: any,
|
originalDocument: any,
|
||||||
newEntity: Entities.ITableEntity
|
newEntity: Entities.ITableEntity
|
||||||
): Promise<Entities.ITableEntity> {
|
): Q.Promise<Entities.ITableEntity> {
|
||||||
const clearMessage = NotificationConsoleUtils.logConsoleProgress(`Updating row ${originalDocument.RowKey._}`);
|
const notificationId = NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.InProgress,
|
||||||
try {
|
`Updating row ${originalDocument.RowKey._}`
|
||||||
let whereSegment = " WHERE";
|
);
|
||||||
let keys: CassandraTableKey[] = collection.cassandraKeys.partitionKeys.concat(
|
const deferred = Q.defer<Entities.ITableEntity>();
|
||||||
collection.cassandraKeys.clusteringKeys
|
let promiseArray: Q.Promise<any>[] = [];
|
||||||
);
|
let query = `UPDATE ${collection.databaseId}.${collection.id()}`;
|
||||||
for (let keyIndex in keys) {
|
let isChange: boolean = false;
|
||||||
const key = keys[keyIndex].property;
|
for (let property in newEntity) {
|
||||||
const keyType = keys[keyIndex].type;
|
if (!originalDocument[property] || newEntity[property]._.toString() !== originalDocument[property]._.toString()) {
|
||||||
whereSegment += this.isStringType(keyType)
|
if (this.isStringType(newEntity[property].$)) {
|
||||||
? ` ${key} = '${newEntity[key]._}' AND`
|
query = `${query} SET ${property} = '${newEntity[property]._}',`;
|
||||||
: ` ${key} = ${newEntity[key]._} AND`;
|
} else {
|
||||||
}
|
query = `${query} SET ${property} = ${newEntity[property]._},`;
|
||||||
whereSegment = whereSegment.slice(0, whereSegment.length - 4);
|
|
||||||
|
|
||||||
let updateQuery = `UPDATE ${collection.databaseId}.${collection.id()}`;
|
|
||||||
let isPropertyUpdated = false;
|
|
||||||
for (let property in newEntity) {
|
|
||||||
if (
|
|
||||||
!originalDocument[property] ||
|
|
||||||
newEntity[property]._.toString() !== originalDocument[property]._.toString()
|
|
||||||
) {
|
|
||||||
updateQuery += this.isStringType(newEntity[property].$)
|
|
||||||
? ` SET ${property} = '${newEntity[property]._}',`
|
|
||||||
: ` SET ${property} = ${newEntity[property]._},`;
|
|
||||||
isPropertyUpdated = true;
|
|
||||||
}
|
}
|
||||||
|
isChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPropertyUpdated) {
|
|
||||||
updateQuery = updateQuery.slice(0, updateQuery.length - 1);
|
|
||||||
updateQuery += whereSegment;
|
|
||||||
await this.queryDocuments(collection, updateQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
let deleteQuery = `DELETE `;
|
|
||||||
let isPropertyDeleted = false;
|
|
||||||
for (let property in originalDocument) {
|
|
||||||
if (property !== TableConstants.EntityKeyNames.RowKey && !newEntity[property] && !!originalDocument[property]) {
|
|
||||||
deleteQuery += ` ${property},`;
|
|
||||||
isPropertyDeleted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPropertyDeleted) {
|
|
||||||
deleteQuery = deleteQuery.slice(0, deleteQuery.length - 1);
|
|
||||||
deleteQuery += ` FROM ${collection.databaseId}.${collection.id()}${whereSegment}`;
|
|
||||||
await this.queryDocuments(collection, deleteQuery);
|
|
||||||
}
|
|
||||||
|
|
||||||
newEntity[TableConstants.EntityKeyNames.RowKey] = originalDocument[TableConstants.EntityKeyNames.RowKey];
|
|
||||||
NotificationConsoleUtils.logConsoleInfo(`Successfully updated row ${newEntity.RowKey._}`);
|
|
||||||
return newEntity;
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, "UpdateRowCassandra", "Failed to update row ${newEntity.RowKey._}");
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
clearMessage();
|
|
||||||
}
|
}
|
||||||
|
query = query.slice(0, query.length - 1);
|
||||||
|
let whereSegment = " WHERE";
|
||||||
|
let keys: CassandraTableKey[] = collection.cassandraKeys.partitionKeys.concat(
|
||||||
|
collection.cassandraKeys.clusteringKeys
|
||||||
|
);
|
||||||
|
for (let keyIndex in keys) {
|
||||||
|
const key = keys[keyIndex].property;
|
||||||
|
const keyType = keys[keyIndex].type;
|
||||||
|
if (this.isStringType(keyType)) {
|
||||||
|
whereSegment = `${whereSegment} ${key} = '${newEntity[key]._}' AND`;
|
||||||
|
} else {
|
||||||
|
whereSegment = `${whereSegment} ${key} = ${newEntity[key]._} AND`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
whereSegment = whereSegment.slice(0, whereSegment.length - 4);
|
||||||
|
query = query + whereSegment;
|
||||||
|
if (isChange) {
|
||||||
|
promiseArray.push(this.queryDocuments(collection, query));
|
||||||
|
}
|
||||||
|
query = `DELETE `;
|
||||||
|
for (let property in originalDocument) {
|
||||||
|
if (property !== TableConstants.EntityKeyNames.RowKey && !newEntity[property] && !!originalDocument[property]) {
|
||||||
|
query = `${query} ${property},`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (query.length > 7) {
|
||||||
|
query = query.slice(0, query.length - 1);
|
||||||
|
query = `${query} FROM ${collection.databaseId}.${collection.id()}${whereSegment}`;
|
||||||
|
promiseArray.push(this.queryDocuments(collection, query));
|
||||||
|
}
|
||||||
|
Q.all(promiseArray)
|
||||||
|
.then(
|
||||||
|
(data: any) => {
|
||||||
|
newEntity[TableConstants.EntityKeyNames.RowKey] = originalDocument[TableConstants.EntityKeyNames.RowKey];
|
||||||
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Info,
|
||||||
|
`Successfully updated row ${newEntity.RowKey._}`
|
||||||
|
);
|
||||||
|
deferred.resolve(newEntity);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
handleError(error, "UpdateRowCassandra", `Failed to update row ${newEntity.RowKey._}`);
|
||||||
|
deferred.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
NotificationConsoleUtils.clearInProgressMessageWithId(notificationId);
|
||||||
|
});
|
||||||
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async queryDocuments(
|
public queryDocuments(
|
||||||
collection: ViewModels.Collection,
|
collection: ViewModels.Collection,
|
||||||
query: string,
|
query: string,
|
||||||
shouldNotify?: boolean,
|
shouldNotify?: boolean,
|
||||||
paginationToken?: string
|
paginationToken?: string
|
||||||
): Promise<Entities.IListTableEntitiesResult> {
|
): Q.Promise<Entities.IListTableEntitiesResult> {
|
||||||
const clearMessage =
|
let notificationId: string;
|
||||||
shouldNotify && NotificationConsoleUtils.logConsoleProgress(`Querying rows for table ${collection.id()}`);
|
if (shouldNotify) {
|
||||||
try {
|
notificationId = NotificationConsoleUtils.logConsoleMessage(
|
||||||
const authType = window.authType;
|
ConsoleDataType.InProgress,
|
||||||
const apiEndpoint: string =
|
`Querying rows for table ${collection.id()}`
|
||||||
authType === AuthType.EncryptedToken
|
);
|
||||||
? Constants.CassandraBackend.guestQueryApi
|
|
||||||
: Constants.CassandraBackend.queryApi;
|
|
||||||
const data: any = await $.ajax(`${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`, {
|
|
||||||
type: "POST",
|
|
||||||
data: {
|
|
||||||
accountName:
|
|
||||||
collection && collection.container.databaseAccount && collection.container.databaseAccount().name,
|
|
||||||
cassandraEndpoint: this.trimCassandraEndpoint(
|
|
||||||
collection.container.databaseAccount().properties.cassandraEndpoint
|
|
||||||
),
|
|
||||||
resourceId: collection.container.databaseAccount().id,
|
|
||||||
keyspaceId: collection.databaseId,
|
|
||||||
tableId: collection.id(),
|
|
||||||
query,
|
|
||||||
paginationToken
|
|
||||||
},
|
|
||||||
beforeSend: this.setAuthorizationHeader,
|
|
||||||
error: this.handleAjaxError,
|
|
||||||
cache: false
|
|
||||||
});
|
|
||||||
shouldNotify &&
|
|
||||||
NotificationConsoleUtils.logConsoleInfo(
|
|
||||||
`Successfully fetched ${data.result.length} rows for table ${collection.id()}`
|
|
||||||
);
|
|
||||||
return {
|
|
||||||
Results: data.result,
|
|
||||||
ContinuationToken: data.paginationToken
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
shouldNotify &&
|
|
||||||
handleError(error, "QueryDocumentsCassandra", `Failed to query rows for table ${collection.id()}`);
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
clearMessage?.();
|
|
||||||
}
|
}
|
||||||
|
const deferred = Q.defer<Entities.IListTableEntitiesResult>();
|
||||||
|
const authType = window.authType;
|
||||||
|
const apiEndpoint: string =
|
||||||
|
authType === AuthType.EncryptedToken
|
||||||
|
? Constants.CassandraBackend.guestQueryApi
|
||||||
|
: Constants.CassandraBackend.queryApi;
|
||||||
|
$.ajax(`${configContext.BACKEND_ENDPOINT}/${apiEndpoint}`, {
|
||||||
|
type: "POST",
|
||||||
|
data: {
|
||||||
|
accountName: collection && collection.container.databaseAccount && collection.container.databaseAccount().name,
|
||||||
|
cassandraEndpoint: this.trimCassandraEndpoint(
|
||||||
|
collection.container.databaseAccount().properties.cassandraEndpoint
|
||||||
|
),
|
||||||
|
resourceId: collection.container.databaseAccount().id,
|
||||||
|
keyspaceId: collection.databaseId,
|
||||||
|
tableId: collection.id(),
|
||||||
|
query: query,
|
||||||
|
paginationToken: paginationToken
|
||||||
|
},
|
||||||
|
beforeSend: this.setAuthorizationHeader,
|
||||||
|
error: this.handleAjaxError,
|
||||||
|
cache: false
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
(data: any) => {
|
||||||
|
if (shouldNotify) {
|
||||||
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
|
ConsoleDataType.Info,
|
||||||
|
`Successfully fetched ${data.result.length} rows for table ${collection.id()}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
deferred.resolve({
|
||||||
|
Results: data.result,
|
||||||
|
ContinuationToken: data.paginationToken
|
||||||
|
});
|
||||||
|
},
|
||||||
|
(error: any) => {
|
||||||
|
if (shouldNotify) {
|
||||||
|
handleError(error, "QueryDocumentsCassandra", `Failed to query rows for table ${collection.id()}`);
|
||||||
|
}
|
||||||
|
deferred.reject(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.done(() => {
|
||||||
|
if (shouldNotify) {
|
||||||
|
NotificationConsoleUtils.clearInProgressMessageWithId(notificationId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteDocuments(
|
public deleteDocuments(collection: ViewModels.Collection, entitiesToDelete: Entities.ITableEntity[]): Q.Promise<any> {
|
||||||
collection: ViewModels.Collection,
|
|
||||||
entitiesToDelete: Entities.ITableEntity[]
|
|
||||||
): Promise<any> {
|
|
||||||
const query = `DELETE FROM ${collection.databaseId}.${collection.id()} WHERE `;
|
const query = `DELETE FROM ${collection.databaseId}.${collection.id()} WHERE `;
|
||||||
const partitionKeyProperty = this.getCassandraPartitionKeyProperty(collection);
|
let promiseArray: Q.Promise<any>[] = [];
|
||||||
|
let partitionKeyProperty = this.getCassandraPartitionKeyProperty(collection);
|
||||||
await Promise.all(
|
for (let i = 0, len = entitiesToDelete.length; i < len; i++) {
|
||||||
entitiesToDelete.map(async (currEntityToDelete: Entities.ITableEntity) => {
|
let currEntityToDelete: Entities.ITableEntity = entitiesToDelete[i];
|
||||||
const clearMessage = NotificationConsoleUtils.logConsoleProgress(`Deleting row ${currEntityToDelete.RowKey._}`);
|
let currQuery = query;
|
||||||
const partitionKeyValue = currEntityToDelete[partitionKeyProperty];
|
let partitionKeyValue = currEntityToDelete[partitionKeyProperty];
|
||||||
const currQuery =
|
if (partitionKeyValue._ != null && this.isStringType(partitionKeyValue.$)) {
|
||||||
query + this.isStringType(partitionKeyValue.$)
|
currQuery = `${currQuery}${partitionKeyProperty} = '${partitionKeyValue._}' AND `;
|
||||||
? `${partitionKeyProperty} = '${partitionKeyValue._}'`
|
} else {
|
||||||
: `${partitionKeyProperty} = ${partitionKeyValue._}`;
|
currQuery = `${currQuery}${partitionKeyProperty} = ${partitionKeyValue._} AND `;
|
||||||
|
}
|
||||||
try {
|
currQuery = currQuery.slice(0, currQuery.length - 5);
|
||||||
await this.queryDocuments(collection, currQuery);
|
const notificationId = NotificationConsoleUtils.logConsoleMessage(
|
||||||
NotificationConsoleUtils.logConsoleInfo(`Successfully deleted row ${currEntityToDelete.RowKey._}`);
|
ConsoleDataType.InProgress,
|
||||||
} catch (error) {
|
`Deleting row ${currEntityToDelete.RowKey._}`
|
||||||
handleError(error, "DeleteRowCassandra", `Error while deleting row ${currEntityToDelete.RowKey._}`);
|
);
|
||||||
throw error;
|
promiseArray.push(
|
||||||
} finally {
|
this.queryDocuments(collection, currQuery)
|
||||||
clearMessage();
|
.then(
|
||||||
}
|
() => {
|
||||||
})
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
);
|
ConsoleDataType.Info,
|
||||||
|
`Successfully deleted row ${currEntityToDelete.RowKey._}`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
handleError(error, "DeleteRowCassandra", `Error while deleting row ${currEntityToDelete.RowKey._}`);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
NotificationConsoleUtils.clearInProgressMessageWithId(notificationId);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Q.all(promiseArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createKeyspace(
|
public createKeyspace(
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user