diff --git a/cmdb-api/api/lib/perm/acl/audit.py b/cmdb-api/api/lib/perm/acl/audit.py index dfa44be8d..d16b95b89 100644 --- a/cmdb-api/api/lib/perm/acl/audit.py +++ b/cmdb-api/api/lib/perm/acl/audit.py @@ -389,7 +389,7 @@ def add_login_log(cls, username, is_ok, description, _id=None, logout_at=None, i logout_at=logout_at, ip=(ip or request.headers.get('X-Forwarded-For') or request.headers.get('X-Real-IP') or request.remote_addr or '').split(',')[0], - browser=browser or request.headers.get('User-Agent'), + browser=(browser or request.headers.get('User-Agent') or '')[:255], channel=request.values.get('channel', 'web'), ) diff --git a/cmdb-api/api/views/cmdb/ci.py b/cmdb-api/api/views/cmdb/ci.py index b53f0c6dc..a2f1d95be 100644 --- a/cmdb-api/api/views/cmdb/ci.py +++ b/cmdb-api/api/views/cmdb/ci.py @@ -276,3 +276,55 @@ def post(self, ci_id): return self.jsonify(**CIManager().rollback(ci_id, before_date)) return self.get(ci_id) + + +class CIMobileDetailView(APIView): + url_prefix = "/ci//mobile" + + def get(self, ci_id): + ci = CIManager.get_ci_by_id_from_db(ci_id, ret_key=RetKey.NAME, fields=None, valid=True) + + ci_type = CITypeCache.get(ci.get("_type", 0)) if ci.get("_type") else None + type_info = {"id": ci_type.id, "name": ci_type.name, "alias": ci_type.alias} if ci_type else {} + + attribute_alias_map = {} + if ci_type: + from api.lib.cmdb.ci_type import CITypeAttributeManager + attrs = CITypeAttributeManager.get_attr_names_by_type_id(ci_type.id) + if attrs: + from api.lib.cmdb.cache import AttributeCache + for attr_name in attrs: + attr_obj = AttributeCache.get(attr_name) + if attr_obj: + attribute_alias_map[attr_obj.name] = attr_obj.alias or attr_obj.name + + relations = {"parents": [], "children": []} + try: + from api.lib.cmdb.ci import CIRelationManager + children = CIRelationManager.get_children(ci_id, ret_key=RetKey.NAME) + for type_name, cis in children.items(): + for c in cis: + c["_type_name"] = CITypeCache.get(type_name).alias if type_name else type_name + relations["children"].append(c) + + parent_ids = CIRelationManager.get_parent_ids([ci_id]) + if ci_id in parent_ids: + for p_id, p_type_id in parent_ids[ci_id]: + parent_ci = CIManager.get_cis_by_ids([str(p_id)], ret_key=RetKey.NAME) + if parent_ci: + for p in parent_ci: + p_type = CITypeCache.get(p_type_id) if p_type_id else None + p["_type_name"] = p_type.alias if p_type else "" + relations["parents"].append(p) + except Exception: + pass + + from api.lib.cmdb.history import AttributeHistoryManger + try: + history = AttributeHistoryManger.get_by_ci_id(ci_id) + history = history[:10] + except Exception: + history = [] + + return self.jsonify(ci=ci, type=type_info, relations=relations, history=history, + attribute_alias_map=attribute_alias_map) diff --git a/cmdb-ui/jsconfig.json b/cmdb-ui/jsconfig.json index 5c5d35da6..fa1b7e78c 100644 --- a/cmdb-ui/jsconfig.json +++ b/cmdb-ui/jsconfig.json @@ -7,5 +7,8 @@ } }, "exclude": ["node_modules", "dist"], - "include": ["src/*"] + "include": ["src/*"], + "typeAcquisition": { + "enable": false + } } diff --git a/cmdb-ui/package.json b/cmdb-ui/package.json index 5780a57d0..982969888 100644 --- a/cmdb-ui/package.json +++ b/cmdb-ui/package.json @@ -23,6 +23,7 @@ "axios": "0.18.0", "babel-eslint": "^8.2.2", "butterfly-dag": "^4.3.26", + "codemirror": "^5.65.13", "core-js": "^3.31.0", "echarts": "^5.3.2", "element-ui": "^2.15.10", @@ -37,18 +38,17 @@ "lodash.pick": "^4.4.0", "md5": "^2.2.1", "moment": "^2.24.0", - "monaco-editor": "^0.28.1", - "monaco-editor-webpack-plugin": "^4.2.0", - "monaco-vim": "^0.4.4", "nprogress": "^0.2.0", + "qrcode": "^1.5.4", "relation-graph": "^2.1.42", "snabbdom": "^3.5.1", "sortablejs": "1.9.0", "style-resources-loader": "^1.5.0", "viser-vue": "^2.4.8", "vue": "2.6.11", - "vue-clipboard2": "^0.3.3", "vue-cli-plugin-style-resources-loader": "^0.1.5", + "vue-clipboard2": "^0.3.3", + "vue-codemirror": "^4.0.6", "vue-cropper": "^0.6.2", "vue-grid-layout": "2.3.12", "vue-i18n": "8.28.2", diff --git a/cmdb-ui/src/modules/cmdb/api/ci.js b/cmdb-ui/src/modules/cmdb/api/ci.js index 71b07ef8f..579f1a9ff 100644 --- a/cmdb-ui/src/modules/cmdb/api/ci.js +++ b/cmdb-ui/src/modules/cmdb/api/ci.js @@ -52,6 +52,14 @@ export function getCIById(ciId) { }) } +// 获取移动端CI详情 +export function getCIMobileDetail(ciId) { + return axios({ + url: urlPrefix + `/ci/${ciId}/mobile`, + method: 'GET' + }) +} + // 获取自动发现占比 export function getCIAdcStatistics() { return axios({ diff --git a/cmdb-ui/src/modules/cmdb/components/QRCodeBatchExport.vue b/cmdb-ui/src/modules/cmdb/components/QRCodeBatchExport.vue new file mode 100644 index 000000000..bf228709c --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/components/QRCodeBatchExport.vue @@ -0,0 +1,232 @@ + + + + + diff --git a/cmdb-ui/src/modules/cmdb/components/QRCodeButton.vue b/cmdb-ui/src/modules/cmdb/components/QRCodeButton.vue new file mode 100644 index 000000000..ae096a646 --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/components/QRCodeButton.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue b/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue index 16eaf3f8c..3e7200409 100644 --- a/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue +++ b/cmdb-ui/src/modules/cmdb/components/batchDownload/batchDownload.vue @@ -27,6 +27,11 @@ {{ item.label }} + + + {{ $t('cmdb.ci.qrcodeExport') }} + +
{{ $t('cmdb.menu.citypeManage') }} + + + {{ $t('cmdb.ci.qrcodeExportAll') }} + @@ -76,6 +83,8 @@
{{ $t('update') }} + {{ $t('cmdb.ci.qrcodeExport') }} + {{ $t('download') }} {{ $t('delete') }} @@ -141,6 +150,7 @@ /> +
@@ -151,6 +161,9 @@ + + diff --git a/cmdb-ui/src/router/config.js b/cmdb-ui/src/router/config.js index 0be7e6020..c8e3a0f5a 100644 --- a/cmdb-ui/src/router/config.js +++ b/cmdb-ui/src/router/config.js @@ -103,6 +103,13 @@ export const constantRouterMap = [ redirect: appConfig.redirectTo, // redirect: () => { return store.getters.appRoutes[0] }, }, + { + path: '/cmdb/mobile/:typeId/:ciId', + name: 'cmdb_mobile_detail', + hidden: true, + meta: { title: 'cmdb.ci.mobileDetail' }, + component: () => import(/* webpackChunkName: "mobile" */ '@/modules/cmdb/views/mobile/CIMobileDetail.vue') + }, { path: '/user/login', name: 'login', diff --git a/cmdb-ui/src/views/user/Login.vue b/cmdb-ui/src/views/user/Login.vue index 76b2f674b..9f7f4676b 100644 --- a/cmdb-ui/src/views/user/Login.vue +++ b/cmdb-ui/src/views/user/Login.vue @@ -254,4 +254,39 @@ export default { } } } + +@media screen and (max-width: 768px) { + .ops-login { + min-width: auto; + flex-direction: column; + + .ops-login-left { + width: 100%; + height: 30vh; + min-height: 180px; + + > img { + width: 60%; + max-width: 300px; + } + + > span { + font-size: 18px; + bottom: 12%; + } + } + + .ops-login-right { + width: 100%; + padding: 24px 32px; + + > img { + width: 50%; + max-width: 200px; + margin-left: 25%; + margin-bottom: 16px; + } + } + } +}