-
Notifications
You must be signed in to change notification settings - Fork 1.3k
ui: add new API docs tab #9409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
ui: add new API docs tab #9409
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
687af9f
ui: add new API docs tab
yadvr d8fcee9
Update ui/src/views/plugins/ApiDocsPlugin.vue
yadvr d45bc42
Update ui/src/views/plugins/ApiDocsPlugin.vue
yadvr 485a3df
Update ui/src/views/plugins/ApiDocsPlugin.vue
yadvr c8ad8d1
Update ui/src/views/plugins/ApiDocsPlugin.vue
yadvr edcad51
Update ui/src/views/plugins/ApiDocsPlugin.vue
yadvr b4b0400
fix performance issues
yadvr 4df4afc
Update ui/src/views/plugins/ApiDocsPlugin.vue
yadvr 3a46ca0
Update ui/public/locales/en.json
yadvr 2766597
address Suresh's feedback
yadvr 7eb9e06
filter example/options as we type
yadvr ac1a9a0
Address Joao's comments
yadvr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| <template> | ||
| <div> | ||
| <resource-layout> | ||
| <template #left> | ||
| <a-card :bordered="false"> | ||
| <a-auto-complete | ||
| v-model:value="query" | ||
| :options="options.filter(value => value.value.toLowerCase().includes(query.toLowerCase()))" | ||
| style="width: 100%" | ||
| > | ||
| <a-input-search | ||
| size="default" | ||
| :placeholder="$t('label.search')" | ||
| v-model:value="query" | ||
| allow-clear | ||
| enter-button | ||
| > | ||
| <template #prefix><search-outlined /></template> | ||
| </a-input-search> | ||
| </a-auto-complete> | ||
| <a-list style="margin-top: 12px; height:580px; overflow-y: scroll;" size="small" :data-source="Object.keys($store.getters.apis).sort()"> | ||
| <template #renderItem="{ item }"> | ||
| <a> | ||
| <a-list-item | ||
| v-if="item.toLowerCase().includes(query.toLowerCase())" | ||
| @click="showApi(item)" | ||
| style="padding-left: 12px" | ||
| :class="selectedApi === item ? 'selected-item' : ''"> | ||
| {{ item }} <a-tag v-if="$store.getters.apis[item].isasync" color="blue">async</a-tag> | ||
| </a-list-item> | ||
| </a> | ||
| </template> | ||
| </a-list> | ||
| <a-divider style="margin-bottom: 12px" /> | ||
| <span>{{ Object.keys($store.getters.apis).length }} {{ $t('label.api.docs.count') }}</span> | ||
|
yadvr marked this conversation as resolved.
|
||
| </a-card> | ||
| </template> | ||
| <template #right> | ||
| <a-card | ||
| class="spin-content" | ||
| :bordered="true" | ||
| style="width: 100%; overflow-x: auto"> | ||
| <span v-if="selectedApi && selectedApi in $store.getters.apis"> | ||
| <h2>{{ selectedApi }} | ||
| <a-tag v-if="$store.getters.apis[selectedApi].isasync" color="blue">Asynchronous API</a-tag> | ||
| <a-tag v-if="$store.getters.apis[selectedApi].since">Since {{ $store.getters.apis[selectedApi].since }}</a-tag> | ||
| <tooltip-button | ||
| tooltipPlacement="right" | ||
| :tooltip="$t('label.copy') + ' ' + selectedApi" | ||
| icon="CopyOutlined" | ||
| type="outlined" | ||
| size="small" | ||
| @onClick="$message.success($t('label.copied.clipboard'))" | ||
| :copyResource="selectedApi" /> | ||
| </h2> | ||
| <p>{{ $store.getters.apis[selectedApi].description }}</p> | ||
| <h3>{{ $t('label.request') }} {{ $t('label.params') }}:</h3> | ||
| <a-table | ||
| :columns="[{title: $t('label.name'), dataIndex: 'name'}, {title: $t('label.required'), dataIndex: 'required'}, {title: $t('label.type'), dataIndex: 'type'}, {title: $t('label.description'), dataIndex: 'description'}]" | ||
| :data-source="selectedParams" | ||
| :pagination="false" | ||
| size="small"> | ||
| <template #bodyCell="{text, column, record}"> | ||
| <a-tag v-if="record.since && column.dataIndex === 'description'">Since {{ record.since }}</a-tag> | ||
| <span v-if="record.required === true"><strong>{{ text }}</strong></span> | ||
| <span v-else>{{ text }}</span> | ||
| </template> | ||
| </a-table> | ||
| <br/> | ||
| <h3>{{ $t('label.response') }} {{ $t('label.params') }}:</h3> | ||
| <a-table | ||
| :columns="[{title: $t('label.name'), dataIndex: 'name'}, {title: $t('label.type'), dataIndex: 'type'}, {title: $t('label.description'), dataIndex: 'description'}]" | ||
| :data-source="selectedResponse" | ||
| :pagination="false" | ||
| size="small" /> | ||
| </span> | ||
| <span v-else> | ||
| <a-alert | ||
| :message="$t('label.api.docs')" | ||
| type="info" | ||
| show-icon | ||
| banner> | ||
| <template #description> | ||
| <a href="https://docs.cloudstack.apache.org/en/latest/developersguide/dev.html" target="_blank">{{ $t('label.api.docs.description') }}</a> | ||
| </template> | ||
| </a-alert> | ||
| <a-result | ||
| status="success" | ||
| :title="$t('label.download') + ' CloudStack CloudMonkey CLI'" | ||
| sub-title="For API automation and orchestration" | ||
| > | ||
| <template #extra> | ||
| <a-button type="primary"><a href="https://github.com/apache/cloudstack-cloudmonkey/releases" target="_blank">{{ $t('label.download') }} CLI</a></a-button> | ||
| <a-button><a href="https://github.com/apache/cloudstack-cloudmonkey/wiki/Usage" target="_blank">{{ $t('label.open.documentation') }} (CLI)</a></a-button> | ||
| <br/> | ||
| <br/> | ||
| <div v-if="showKeys"> | ||
| <key-outlined /> | ||
| <strong> | ||
| {{ $t('label.apikey') }} | ||
| <tooltip-button | ||
| tooltipPlacement="right" | ||
| :tooltip="$t('label.copy') + ' ' + $t('label.apikey')" | ||
| icon="CopyOutlined" | ||
| type="dashed" | ||
| size="small" | ||
| @onClick="$message.success($t('label.copied.clipboard'))" | ||
| :copyResource="userkeys.apikey" /> | ||
| </strong> | ||
| <div> | ||
| {{ userkeys.apikey.substring(0, 20) }}... | ||
| </div> | ||
| <br/> | ||
| <lock-outlined /> | ||
| <strong> | ||
| {{ $t('label.secretkey') }} | ||
| <tooltip-button | ||
| tooltipPlacement="right" | ||
| :tooltip="$t('label.copy') + ' ' + $t('label.secretkey')" | ||
| icon="CopyOutlined" | ||
| type="dashed" | ||
| size="small" | ||
| @onClick="$message.success($t('label.copied.clipboard'))" | ||
| :copyResource="userkeys.secretkey" /> | ||
| </strong> | ||
| <div> | ||
| {{ userkeys.secretkey.substring(0, 20) }}... | ||
| </div> | ||
| </div> | ||
| </template> | ||
| </a-result> | ||
| </span> | ||
| </a-card> | ||
| </template> | ||
| </resource-layout> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { api } from '@/api' | ||
|
|
||
| import ResourceLayout from '@/layouts/ResourceLayout' | ||
| import TooltipButton from '@/components/widgets/TooltipButton' | ||
|
|
||
| export default { | ||
| name: 'ApiDocsPlugin', | ||
| components: { | ||
| ResourceLayout, | ||
| TooltipButton | ||
| }, | ||
| data () { | ||
| return { | ||
| query: '', | ||
| selectedApi: '', | ||
| selectedParams: [], | ||
| selectedResponse: [], | ||
| showKeys: false, | ||
| userkeys: {}, | ||
| options: [ | ||
| { value: 'VirtualMachine', label: 'Instance' }, | ||
| { value: 'Kubernetes', label: 'Kubernetes' }, | ||
| { value: 'Volume', label: 'Volume' }, | ||
| { value: 'Snapshot', label: 'Snapshot' }, | ||
| { value: 'Backup', label: 'Backup' }, | ||
| { value: 'Network', label: 'Network' }, | ||
| { value: 'IpAddress', label: 'IP Address' }, | ||
| { value: 'VPN', label: 'VPN' }, | ||
| { value: 'VPC', label: 'VPC' }, | ||
| { value: 'NetworkACL', label: 'Network ACL' }, | ||
| { value: 'SecurityGroup', label: 'Security Group' }, | ||
| { value: 'Template', label: 'Template' }, | ||
| { value: 'ISO', label: 'ISO' }, | ||
| { value: 'SSH', label: 'SSH' }, | ||
| { value: 'Project', label: 'Project' }, | ||
| { value: 'Account', label: 'Account' }, | ||
| { value: 'User', label: 'User' }, | ||
| { value: 'Event', label: 'Event' }, | ||
| { value: 'Offering', label: 'Offering' }, | ||
| { value: 'Zone', label: 'Zone' } | ||
| ] | ||
| } | ||
| }, | ||
| created () { | ||
| if (!('getUserKeys' in this.$store.getters.apis)) { | ||
| return | ||
| } | ||
| api('getUserKeys', { id: this.$store.getters.userInfo.id }).then(json => { | ||
| this.userkeys = json.getuserkeysresponse.userkeys | ||
| if (this.userkeys && this.userkeys.secretkey) { | ||
| this.showKeys = true | ||
| } | ||
| }) | ||
| }, | ||
| methods: { | ||
| showApi (api) { | ||
| this.selectedApi = api | ||
| this.selectedParams = this.$store.getters.apis[api].params | ||
| .sort((a, b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0)) | ||
| .sort((a, b) => (a.required > b.required) ? -1 : ((b.required > a.required) ? 1 : 0)) | ||
| .filter(value => Object.keys(value).length > 0) | ||
| this.selectedResponse = this.$store.getters.apis[api].response.filter(value => Object.keys(value).length > 0) | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.