Skip to content

Commit

Permalink
Merge pull request #7514 from normal-wls/hb_merge_master_20240625
Browse files Browse the repository at this point in the history
hb merge master 20240625
  • Loading branch information
normal-wls authored Jun 25, 2024
2 parents 307fe6c + d155de9 commit a0f138f
Show file tree
Hide file tree
Showing 32 changed files with 939 additions and 91 deletions.
11 changes: 11 additions & 0 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"blueapps.opentelemetry.instrument_app",
"apigw_manager.apigw",
"bk_notice_sdk",
"bk_audit.contrib.bk_audit",
)

# 这里是默认的中间件,大部分情况下,不需要改动
Expand Down Expand Up @@ -876,3 +877,13 @@ def check_engine_admin_permission(request, *args, **kwargs):

# 报错联系助手链接
MESSAGE_HELPER_URL = env.MESSAGE_HELPER_URL

# bk_audit
ENABLE_BK_AUDIT = True if env.BK_AUDIT_DATA_TOKEN else False
BK_AUDIT_SETTINGS = {
"log_queue_limit": 50000,
"exporters": ["bk_audit.contrib.opentelemetry.exporters.OTLogExporter"],
"service_name_handler": "bk_audit.contrib.opentelemetry.utils.ServiceNameHandler",
"ot_endpoint": env.BK_AUDIT_ENDPOINT,
"bk_data_token": env.BK_AUDIT_DATA_TOKEN,
}
49 changes: 49 additions & 0 deletions docs/apidoc/en/get_task_count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
### Functional description

Get tasks count for a business, support task name keyword searching

#### Interface Parameters

| Field | Type | Required | Description |
|-----------------|-------------|----|------------------|
| bk_biz_id | string | YES | the business ID |
| scope | string | NO | id scope, can be "cmdb_biz" or "project". if scope is "cmdb_biz" then bk_biz_id represent cmdb business ID, otherwise bk_biz_id represent proejct id. default is "cmdb_biz" |
| keyword | string | NO | keyword to filter the task count based on the task name. default is no filter |
| is_started | bool | NO | task status to filter the task count based on the start status. default is no filter |
| is_finished | bool | NO | task status to filter the task count based on the finish status. default is no filter |
| executor | string | NO | task executor to filter the task count. default is no filter |

### Request Parameters Example

```
{
"bk_app_code": "esb_test",
"bk_app_secret": "xxx",
"bk_token": "xxx",
"bk_username": "xxx",
"bk_biz_id": "2",
"keyword": "定时",
"is_started": true,
"is_finished": "false",
"scope":"cmdb_biz"
}
```

### 返回结果示例

```
{
"result": true,
"data": 1,
"trace_id": "xxx"
}
```

### Return Result Description

| Field | Type | Description |
|-----------|----------|-----------|
| result | bool | true or false, indicate success or failure |
| data | dict | data returned when result is true, details are described below |
| message | string | error message returned when result is false |
| trace_id | string | open telemetry trace_id |
1 change: 1 addition & 0 deletions docs/apidoc/en/get_task_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Get tasks list for a business, support task name keyword searching
| expected_timezone | string | NO | expected timezone of time related field in response, e.g. Asia/Shanghai |
| limit | int | NO | pagination, the number of tasks in the task list in each result. default is 100 |
| offset | int | NO | pagination, the start index of task in the task list in each result. default is 0 |
| without_count | bool | NO | without count,default count is returned |

### Request Parameters Example

Expand Down
50 changes: 50 additions & 0 deletions docs/apidoc/zh_hans/get_task_count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
### 功能描述

获取某个业务下的任务列表,支持任务名关键词搜索

#### 接口参数

| 字段 | 类型 | 必选 | 描述 |
|-------------|--|---------|------------------|
| bk_biz_id | string || 项目唯一 ID,项目 ID 或 CMDB 业务 ID |
| scope | string || 唯一 ID 的范围,取值为 cmdb_biz 或 project,为 cmdb_biz 时 bk_biz_id 代表业务 ID,反之代表项目 ID,不传时默认为 cmdb_biz |
| keyword | string || 根据任务名关键词过滤任务列表,默认不过滤 |
| is_started | bool || 根据任务是否已开始过滤任务列表,默认不过滤 |
| is_finished | bool || 根据任务是否已结束过滤任务列表,默认不过滤 |
| executor | string || 根据任务执行人过滤任务列表,默认不过滤 |

### 请求参数示例

```
{
"bk_app_code": "esb_test",
"bk_app_secret": "xxx",
"bk_token": "xxx",
"bk_username": "xxx",
"bk_biz_id": "2",
"keyword": "定时",
"is_started": true,
"is_finished": "false",
"scope":"cmdb_biz"
}
```

### 返回结果示例

```
{
"result": true,
"data": 5
"trace_id": "xxx"
}
```

### 返回结果说明

| 名称 | 类型 | 说明 |
| ------------ | ---------- | ------------------------------ |
| result | bool | true/false 操作是否成功 |
| data | dict | result=true 时成功数据,详细信息请见下面说明 |
| message | string | result=false 时错误信息 |
| trace_id | string | open telemetry trace_id |

1 change: 1 addition & 0 deletions docs/apidoc/zh_hans/get_task_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
| expected_timezone | string || 任务时间相关字段期望返回的时区,形如Asia/Shanghai |
| limit | int || 分页,返回任务列表任务数,默认为100 |
| offset | int || 分页,返回任务列表起始任务下标,默认为0 |
| without_count | bool || 有无count,默认返回count |

### 请求参数示例

Expand Down
4 changes: 4 additions & 0 deletions env.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,7 @@

# 报错联系助手链接
MESSAGE_HELPER_URL = os.getenv("BKAPP_MESSAGE_HELPER_URL", "")

# bk_audit
BK_AUDIT_ENDPOINT = os.getenv("BK_AUDIT_ENDPOINT", None)
BK_AUDIT_DATA_TOKEN = os.getenv("BK_AUDIT_DATA_TOKEN", None)
6 changes: 5 additions & 1 deletion frontend/desktop/src/components/layout/Navigation.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<bk-navigation
navigation-type="left-right"
:side-title="platformInfo.name"
:side-title="appName"
:need-menu="true"
:class="$route.name === 'taskList' ? 'hide-header-border' : ''"
:default-open="sideNavOpen"
Expand Down Expand Up @@ -143,6 +143,10 @@
return this.$t('拥有流程管理权限的人员,通过设置“执行代理人”功能,将流程任务的执行操作交由第三方人员(如:外包、外聘人员),帮助流程管理人员从繁重的执行工作中解放。')
}
return ''
},
appName () {
const { i18n, name } = this.platformInfo
return i18n.name || name
}
},
watch: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@
this.constantsLoading = true
const variables = Object.keys(this.subflowForms)
.map(key => this.subflowForms[key])
.filter(item => item.show_type === 'show')
.filter(item => item.show_type === 'show' || item.is_meta) // meta变量特殊处理
.sort((a, b) => a.index - b.index)
const inputs = await Promise.all(variables.map(async (variable) => {
Expand Down Expand Up @@ -777,10 +777,13 @@
}
})
}
if (variable.show_type === 'hide') {
return
}
return formItemConfig
}))
this.constantsLoading = false
return inputs
return inputs.filter(item => item)
},
/**
* 获取任务节点基础信息数据
Expand Down
43 changes: 22 additions & 21 deletions frontend/desktop/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ const store = new Vuex.Store({
},
setFooterInfo (state, content) {
state.footerInfo = content

const { bk_tencent_url, env, smart_url, sops_version, tech_support_url, bk_helper_url, bk_desktop_url } = content
// 默认配置
const config = state.platformInfo
config.version = sops_version
if (env) {
config.i18n.footerInfoHTML = `
<a target="_blank" class="link-item" href="${tech_support_url}">${i18n.t('技术支持')}</a>
| <a target="_blank" class="link-item" href="${smart_url}">${i18n.t('社区论坛')}</a>
| <a target="_blank" class="link-item" href="${bk_tencent_url}">${i18n.t('产品官网')}</a>
`
} else {
config.i18n.footerInfoHTML = `
<a target="_blank" class="link-item" href="${bk_helper_url}">${i18n.t('联系bk助手')}</a>
| <a target="_blank" class="link-item" href="${bk_desktop_url}">${i18n.t('蓝鲸桌面')}</a>
`
}
},
setPlatformInfo (state, content) {
state.platformInfo = content
Expand Down Expand Up @@ -251,33 +268,17 @@ const store = new Vuex.Store({
* @returns {Object}
*/
async getGlobalConfig ({ state, commit }) {
const { bk_tencent_url, env, smart_url, sops_version, tech_support_url, bk_helper_url, bk_desktop_url } = state.footerInfo
// 默认配置
const config = {
...state.platformInfo,
version: sops_version
}

if (env) {
config.i18n.footerInfoHTML = `
<a target="_blank" class="link-item" href="${tech_support_url}">${i18n.t('技术支持')}</a>
| <a target="_blank" class="link-item" href="${smart_url}">${i18n.t('社区论坛')}</a>
| <a target="_blank" class="link-item" href="${bk_tencent_url}">${i18n.t('产品官网')}</a>
`
} else {
config.i18n.footerInfoHTML = `
<a target="_blank" class="link-item" href="${bk_helper_url}">${i18n.t('联系bk助手')}</a>
| <a target="_blank" class="link-item" href="${bk_desktop_url}">${i18n.t('蓝鲸桌面')}</a>
`
}
const config = { ...state.platformInfo }
let resp
const bkRepoUrl = `${window.BK_PAAS_SHARED_RES_URL}/bk_sops/base.js`
const bkRepoUrl = window.BK_PAAS_SHARED_RES_URL
if (bkRepoUrl) {
resp = await getPlatformConfig(bkRepoUrl, config)
resp = await getPlatformConfig(`${bkRepoUrl}/bk_sops/base.js`, config)
} else {
resp = await getPlatformConfig(config)
}
document.title = `${resp.name} | ${resp.brandName}`
const { name, brandName, i18n } = config
document.title = `${i18n.name || name} | ${i18n.brandName || brandName}`
setShortcutIcon(resp.favicon)
commit('setPlatformInfo', resp)
return resp
Expand Down
1 change: 1 addition & 0 deletions gcloud/apigw/forms/get_task_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ class GetTaskListForm(forms.Form):
executor = forms.CharField(required=False)
create_method = forms.CharField(required=False)
template_id = forms.CharField(required=False)
without_count = forms.BooleanField(required=False)
67 changes: 48 additions & 19 deletions gcloud/apigw/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,35 @@

from django.conf.urls import url

from gcloud.apigw.views.create_clocked_task import create_clocked_task
from gcloud.apigw.views.get_mini_app_list import get_mini_app_list
from gcloud.apigw.views.register_project import register_project
from gcloud.apigw.views.get_plugin_detail import get_plugin_detail
from gcloud.apigw.views.get_functionalization_task_list import get_functionalization_task_list
from gcloud.apigw.views.claim_functionalization_task import claim_functionalization_task
from gcloud.apigw.views.create_and_start_task import create_and_start_task
from gcloud.apigw.views.create_clocked_task import create_clocked_task
from gcloud.apigw.views.create_periodic_task import create_periodic_task
from gcloud.apigw.views.create_task import create_task
from gcloud.apigw.views.fast_create_task import fast_create_task
from gcloud.apigw.views.get_common_template_info import get_common_template_info
from gcloud.apigw.views.get_common_template_list import get_common_template_list
from gcloud.apigw.views.get_functionalization_task_list import get_functionalization_task_list
from gcloud.apigw.views.get_mini_app_list import get_mini_app_list
from gcloud.apigw.views.get_periodic_task_info import get_periodic_task_info
from gcloud.apigw.views.get_periodic_task_list import get_periodic_task_list
from gcloud.apigw.views.get_plugin_detail import get_plugin_detail
from gcloud.apigw.views.get_plugin_list import get_plugin_list
from gcloud.apigw.views.get_task_list import get_task_list
from gcloud.apigw.views.get_task_count import get_task_count
from gcloud.apigw.views.get_task_detail import get_task_detail
from gcloud.apigw.views.get_task_list import get_task_list
from gcloud.apigw.views.get_task_node_data import get_task_node_data
from gcloud.apigw.views.get_task_node_detail import get_task_node_detail
from gcloud.apigw.views.get_task_status import get_task_status
from gcloud.apigw.views.get_tasks_manual_intervention_state import get_tasks_manual_intervention_state
from gcloud.apigw.views.get_tasks_status import get_tasks_status
from gcloud.apigw.views.get_template_info import get_template_info
from gcloud.apigw.views.get_template_list import get_template_list
from gcloud.apigw.views.get_template_schemes import get_template_schemes
from gcloud.apigw.views.get_user_project_detail import get_user_project_detail
from gcloud.apigw.views.get_user_project_list import get_user_project_list
from gcloud.apigw.views.import_common_template import import_common_template
from gcloud.apigw.views.import_project_template import import_project_template
from gcloud.apigw.views.modify_constants_for_periodic_task import modify_constants_for_periodic_task
from gcloud.apigw.views.modify_constants_for_task import modify_constants_for_task
from gcloud.apigw.views.modify_cron_for_periodic_task import modify_cron_for_periodic_task
Expand All @@ -48,17 +52,17 @@
from gcloud.apigw.views.preview_common_task_tree import preview_common_task_tree
from gcloud.apigw.views.preview_task_tree import preview_task_tree
from gcloud.apigw.views.query_task_count import query_task_count
from gcloud.apigw.views.register_project import register_project
from gcloud.apigw.views.set_periodic_task_enabled import set_periodic_task_enabled
from gcloud.apigw.views.start_task import start_task
from gcloud.apigw.views.get_tasks_status import get_tasks_status
from gcloud.apigw.views.import_project_template import import_project_template
from gcloud.apigw.views.get_tasks_manual_intervention_state import get_tasks_manual_intervention_state
from gcloud.apigw.views.create_and_start_task import create_and_start_task

urlpatterns = [
url(r"^dispatch_plugin_query/$", dispatch_plugin_query),
url(r"^get_template_list/(?P<project_id>\d+)/$", get_template_list),
url(r"^get_template_info/(?P<template_id>\d+)/(?P<project_id>\d+)/$", get_template_info,),
url(
r"^get_template_info/(?P<template_id>\d+)/(?P<project_id>\d+)/$",
get_template_info,
),
url(r"^get_common_template_list/$", get_common_template_list),
url(r"^get_common_template_info/(?P<template_id>\d+)/$", get_common_template_info),
url(r"^create_task/(?P<template_id>\d+)/(?P<project_id>\d+)/$", create_task),
Expand All @@ -68,27 +72,51 @@
url(r"^get_task_status/(?P<task_id>\d+)/(?P<project_id>\d+)/$", get_task_status),
url(r"^query_task_count/(?P<project_id>\d+)/$", query_task_count),
url(r"^get_periodic_task_list/(?P<project_id>\d+)/$", get_periodic_task_list),
url(r"^get_periodic_task_info/(?P<task_id>\d+)/(?P<project_id>\d+)/$", get_periodic_task_info,),
url(r"^create_periodic_task/(?P<template_id>\d+)/(?P<project_id>\d+)/$", create_periodic_task,),
url(r"^set_periodic_task_enabled/(?P<task_id>\d+)/(?P<project_id>\d+)/$", set_periodic_task_enabled,),
url(r"^modify_cron_for_periodic_task/(?P<task_id>\d+)/(?P<project_id>\d+)/$", modify_cron_for_periodic_task,),
url(
r"^get_periodic_task_info/(?P<task_id>\d+)/(?P<project_id>\d+)/$",
get_periodic_task_info,
),
url(
r"^create_periodic_task/(?P<template_id>\d+)/(?P<project_id>\d+)/$",
create_periodic_task,
),
url(
r"^set_periodic_task_enabled/(?P<task_id>\d+)/(?P<project_id>\d+)/$",
set_periodic_task_enabled,
),
url(
r"^modify_cron_for_periodic_task/(?P<task_id>\d+)/(?P<project_id>\d+)/$",
modify_cron_for_periodic_task,
),
url(r"^modify_constants_for_task/(?P<task_id>\d+)/(?P<project_id>\d+)/$", modify_constants_for_task),
url(
r"^modify_constants_for_periodic_task/(?P<task_id>\d+)/(?P<project_id>\d+)/$",
modify_constants_for_periodic_task,
),
url(r"^get_task_list/(?P<project_id>\d+)/$", get_task_list),
url(r"^get_task_detail/(?P<task_id>\d+)/(?P<project_id>\d+)/$", get_task_detail),
url(r"^get_task_node_detail/(?P<task_id>\d+)/(?P<project_id>\d+)/$", get_task_node_detail,),
url(
r"^get_task_node_detail/(?P<task_id>\d+)/(?P<project_id>\d+)/$",
get_task_node_detail,
),
url(r"^node_callback/(?P<task_id>\d+)/(?P<project_id>\d+)/$", node_callback),
url(r"^import_common_template/$", import_common_template),
url(r"^get_plugin_list/(?P<project_id>\d+)/$", get_plugin_list),
url(r"^get_plugin_detail/(?P<project_id>\d+)/$", get_plugin_detail),
url(r"^get_user_project_list/$", get_user_project_list),
url(r"^get_user_project_detail/(?P<project_id>\d+)/$", get_user_project_detail),
url(r"^get_template_schemes/(?P<project_id>\d+)/(?P<template_id>\d+)/$", get_template_schemes,),
url(r"^preview_task_tree/(?P<project_id>\d+)/(?P<template_id>\d+)/$", preview_task_tree,),
url(r"^get_task_node_data/(?P<project_id>\d+)/(?P<task_id>\d+)/$", get_task_node_data,),
url(
r"^get_template_schemes/(?P<project_id>\d+)/(?P<template_id>\d+)/$",
get_template_schemes,
),
url(
r"^preview_task_tree/(?P<project_id>\d+)/(?P<template_id>\d+)/$",
preview_task_tree,
),
url(
r"^get_task_node_data/(?P<project_id>\d+)/(?P<task_id>\d+)/$",
get_task_node_data,
),
url(r"^operate_node/(?P<project_id>\d+)/(?P<task_id>\d+)/$", operate_node),
url(r"^get_tasks_status/(?P<project_id>\d+)/$", get_tasks_status),
url(r"^get_tasks_manual_intervention_state/(?P<project_id>\d+)/$", get_tasks_manual_intervention_state),
Expand All @@ -100,4 +128,5 @@
url(r"^create_and_start_task/(?P<template_id>\d+)/(?P<project_id>\d+)/$", create_and_start_task),
url(r"^create_clocked_task/(?P<template_id>\d+)/(?P<project_id>\d+)/$", create_clocked_task),
url(r"^get_mini_app_list/(?P<project_id>\d+)/$", get_mini_app_list),
url(r"^get_task_count/(?P<project_id>\d+)/$", get_task_count),
]
Loading

0 comments on commit a0f138f

Please sign in to comment.