Compare commits

..

71 Commits

Author SHA1 Message Date
Bryan
56aa3caa83 Merge pull request #4410 from jumpserver/dev
v4.3.0
2024-10-17 14:56:18 +08:00
Bryan
19b1dc0dbc Merge pull request #4367 from jumpserver/dev
merge: from dev to master
2024-09-19 19:36:42 +08:00
Bryan
77ef172a23 Merge pull request #4320 from jumpserver/dev
v4.1.0
2024-08-15 21:42:42 +08:00
Bryan
4596887bf1 Merge pull request #4178 from jumpserver/dev
v4.0.0
2024-07-03 19:06:07 +08:00
Bryan
0a3dc30c85 Merge pull request #4072 from jumpserver/dev
v3.10.11-lts
2024-06-19 16:04:12 +08:00
Bryan
51d24bc8e5 Merge pull request #3941 from jumpserver/dev
v3.10.10-lts
2024-05-16 16:05:04 +08:00
Bryan
1b15a4d043 Merge pull request #3871 from jumpserver/dev
v3.10.9 (dev to master)
2024-04-22 19:44:33 +08:00
Bryan
7d3f818242 Merge pull request #3864 from jumpserver/v3.10
v3.10.8
2024-04-18 17:58:05 +08:00
Bryan
4e26f18d77 Merge pull request #3862 from jumpserver/dev
v3.10.8
2024-04-18 17:17:36 +08:00
Bryan
b22613617a Revert "build(deps): bump follow-redirects from 1.15.3 to 1.15.4"
This reverts commit e971cbf4a8.
2024-03-27 16:16:07 +08:00
dependabot[bot]
e971cbf4a8 build(deps): bump follow-redirects from 1.15.3 to 1.15.4
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-27 16:11:26 +08:00
wangruidong
4672abae35 fix: 刷新页面根据搜索条件过滤出对应的资源 2024-03-04 19:17:05 +08:00
Bryan
ba36d72602 Merge pull request #3761 from jumpserver/master
v3.10.4 (branch-v3.10)
2024-02-29 16:26:13 +08:00
Bryan
4bfbbba4c5 Merge pull request #3760 from jumpserver/dev
v3.10.4
2024-02-29 16:15:33 +08:00
Bryan
ea038ce43a Merge pull request #3697 from jumpserver/master
v3.10.2
2024-01-17 13:34:12 +00:00
Bryan
e16b19666c Merge pull request #3696 from jumpserver/dev
v3.10.2
2024-01-17 13:33:22 +00:00
Bryan
c7f5409eb6 Merge pull request #3694 from jumpserver/master
v3.10.2
2024-01-17 07:35:33 -04:00
Bryan
fdbd7d2222 Merge pull request #3693 from jumpserver/dev
v3.10.2
2024-01-17 07:24:50 -04:00
Bryan
ddbaeeafea Merge pull request #3668 from jumpserver/master
v3.10.1
2023-12-29 11:34:04 +05:00
Bryan
efb0e9dacb Merge pull request #3665 from jumpserver/dev
v3.10.1
2023-12-29 11:14:54 +05:00
huailei
f6f8301ad5 Revert "perf: 账号收集翻译"
This reverts commit 9a63ae63d4.
2023-12-22 15:25:31 +08:00
“huailei000”
9a63ae63d4 perf: 账号收集翻译 2023-12-22 11:31:45 +08:00
Bryan
1e007ccda3 Merge pull request #3642 from jumpserver/dev
v3.10
2023-12-21 15:15:52 +05:00
老广
d1d0b06b53 Merge pull request #3546 from jumpserver/dev
v3.9.0
2023-11-16 18:25:10 +08:00
Bryan
5fb70d2f24 Merge pull request #3450 from jumpserver/dev
v3.8.0
2023-10-19 03:33:53 -05:00
Bryan
b54a95430f Merge pull request #3404 from jumpserver/dev
v3.7.0
2023-09-21 17:04:42 +08:00
Bryan
4d8b4c45af Merge pull request #3355 from jumpserver/dev
v3.6.0
2023-08-17 14:00:33 +05:00
Bryan
a6d642df60 Merge pull request #3283 from jumpserver/dev
v3.5.0
2023-07-20 19:04:29 +08:00
Jiangjie.Bai
2e74f1522f Merge pull request #3222 from jumpserver/dev
v3.4.0
2023-06-15 14:51:36 +08:00
Jiangjie.Bai
fe615e0314 Merge pull request #3219 from jumpserver/dev
v3.4.0
2023-06-15 14:17:46 +08:00
Jiangjie.Bai
09f734e6fc Merge pull request #3135 from jumpserver/dev
v3.3.0
2023-05-18 19:18:11 +08:00
Jiangjie.Bai
3117046342 Merge pull request #3061 from jumpserver/dev
v3.2.0
2023-04-20 18:40:08 +08:00
Bai
b68aecb5cc fix: 批量更新资产平台help-text 2023-04-20 18:39:22 +08:00
Jiangjie.Bai
1c9b155d97 Merge pull request #3057 from jumpserver/dev
v3.2.0
2023-04-20 18:22:46 +08:00
Jiangjie.Bai
75b1be9864 Merge pull request #3019 from jumpserver/dev
v3.2.0 rc2
2023-04-14 19:01:37 +08:00
Jiangjie.Bai
615c3c1cf4 Merge pull request #3014 from jumpserver/dev
v3.2.0 rc1
2023-04-13 20:02:38 +08:00
Jiangjie.Bai
4d82231af4 Merge pull request #3012 from jumpserver/dev
v3.2.0 rc1
2023-04-13 19:22:38 +08:00
“huailei000”
c6cf6571b6 perf: ldap导入用户列表-组织下拉框设置最大宽度 2023-03-16 16:44:36 +08:00
Bai
8ea990d070 fix: 修复创建资产添加账号模版报错问题 2023-03-16 16:44:36 +08:00
“huailei000”
f4a32170d5 perf: message 2023-03-16 16:44:36 +08:00
ibuler
073508675e perf: 添加默认的信息 2023-03-16 16:44:36 +08:00
Jiangjie.Bai
1d6ca0a93a Merge pull request #2924 from jumpserver/dev
v3.1.0 rc4
2023-03-15 19:46:31 +08:00
Jiangjie.Bai
36aea652d6 Merge pull request #2788 from jumpserver/dev
v3.0.0
2023-02-23 20:16:41 +08:00
Jiangjie.Bai
1a42ce90ab Merge pull request #2760 from jumpserver/dev
v3.0.0-rc-latest
2023-02-22 22:21:54 +08:00
Jiangjie.Bai
31a401b55d Merge pull request #2463 from jumpserver/dev
v3.0.0-rc4
2023-01-31 18:55:34 +08:00
Jiangjie.Bai
582a84178d Merge pull request #2187 from jumpserver/dev
v2.28.0
2022-11-17 17:44:19 +08:00
Jiangjie.Bai
9b9f7c936c Merge pull request #2184 from jumpserver/dev
v2.28.0-rc5
2022-11-17 14:18:15 +08:00
Jiangjie.Bai
2a6100957f Merge pull request #2182 from jumpserver/dev
v2.28.0-rc4
2022-11-16 21:08:55 +08:00
Jiangjie.Bai
16606d6a27 Merge pull request #2176 from jumpserver/dev
v2.28.0-rc2
2022-11-14 10:01:05 +08:00
Jiangjie.Bai
0a612f50e6 Merge pull request #2164 from jumpserver/dev
v2.28.0-rc1
2022-11-10 17:45:47 +08:00
Jiangjie.Bai
fe36fa9390 Merge pull request #2117 from jumpserver/dev
v2.27.0-rc4
2022-10-18 21:02:10 +08:00
Jiangjie.Bai
ba109900ec Merge pull request #2113 from jumpserver/dev
v2.27.0-rc3
2022-10-18 11:20:57 +08:00
Jiangjie.Bai
ec7768267f Merge pull request #2105 from jumpserver/dev
v2.27.0-rc2
2022-10-14 11:01:32 +08:00
Jiangjie.Bai
cc58b374ab Merge pull request #2101 from jumpserver/dev
v2.27.0-rc1
2022-10-13 17:44:53 +08:00
Jiangjie.Bai
04ffbb8fd6 Merge pull request #2097 from jumpserver/dev
v2.27.0-rc1
2022-10-13 15:14:40 +08:00
Jiangjie.Bai
49880f6739 Merge pull request #2059 from jumpserver/dev
v2.26.0
2022-09-15 17:49:44 +08:00
Jiangjie.Bai
e6f98d58c4 Merge pull request #2057 from jumpserver/dev
v2.26.0-rc4
2022-09-15 16:18:03 +08:00
Jiangjie.Bai
fd1f16d43c Merge pull request #2050 from jumpserver/dev
v2.26.0-rc2
2022-09-13 17:41:39 +08:00
Jiangjie.Bai
968b2415b1 Merge pull request #2043 from jumpserver/dev
v2.26.0-rc1
2022-09-08 15:46:44 +08:00
Jiangjie.Bai
776090d6ba Merge pull request #2001 from jumpserver/dev
v2.25.0
2022-08-18 16:12:45 +08:00
Jiangjie.Bai
3a37952288 Merge pull request #1996 from jumpserver/dev
v2.25.0-rc4
2022-08-17 16:53:23 +08:00
Jiangjie.Bai
62b8fc0e3b Merge pull request #1994 from jumpserver/dev
v2.25.0-rc3
2022-08-16 19:08:23 +08:00
Jiangjie.Bai
b2028869cb Merge pull request #1986 from jumpserver/dev
v2.25.0-rc2
2022-08-12 18:06:56 +08:00
Jiangjie.Bai
5277a725f8 Merge pull request #1973 from jumpserver/dev
v2.25.0-rc1
2022-08-11 14:11:59 +08:00
Jiangjie.Bai
f137788c1a Merge pull request #1957 from jumpserver/dev
v2.24.0-rc5
2022-07-20 19:06:03 +08:00
Jiangjie.Bai
f7d17c8de7 Merge pull request #1954 from jumpserver/dev
v2.24.0-rc4
2022-07-19 16:18:13 +08:00
Jiangjie.Bai
feea70b0be Merge pull request #1944 from jumpserver/dev
v2.24.0-rc3
2022-07-18 12:05:42 +08:00
Jiangjie.Bai
04696ef3d6 Merge pull request #1940 from jumpserver/dev
v2.24.0-rc2
2022-07-15 18:07:37 +08:00
Jiangjie.Bai
1731f4f788 Merge pull request #1934 from jumpserver/dev
v2.24.0-rc1
2022-07-14 18:27:51 +08:00
Jiangjie.Bai
6f25d93909 Merge pull request #1931 from jumpserver/dev
v2.24.0-rc1
2022-07-14 17:51:58 +08:00
Jiangjie.Bai
46461ec324 Merge pull request #1925 from jumpserver/dev
v2.24.0-rc1
2022-07-14 15:12:15 +08:00
728 changed files with 9839 additions and 30552 deletions

View File

@@ -14,97 +14,64 @@ module.exports = {
window: true,
_: true
},
plugins: ['vue', 'spellcheck'],
// add your custom rules here
// it is base on https://github.com/vuejs/eslint-config-vue
rules: {
'vue/max-attributes-per-line': [
2,
{
singleline: 10,
multiline: {
max: 1,
allowFirstLine: false
}
'vue/max-attributes-per-line': [2, {
'singleline': 10,
'multiline': {
'max': 1,
'allowFirstLine': false
}
],
}],
'vue/singleline-html-element-content-newline': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/name-property-casing': ['error', 'PascalCase'],
'vue/no-v-html': 'off',
'accessor-pairs': 2,
'arrow-spacing': [
2,
{
before: true,
after: true
}
],
'arrow-spacing': [2, {
'before': true,
'after': true
}],
'block-spacing': [2, 'always'],
'brace-style': [
2,
'1tbs',
{
allowSingleLine: true
}
],
camelcase: [
0,
{
properties: 'always'
}
],
'brace-style': [2, '1tbs', {
'allowSingleLine': true
}],
'camelcase': [0, {
'properties': 'always'
}],
'comma-dangle': [2, 'never'],
'comma-spacing': [
2,
{
before: false,
after: true
}
],
'comma-spacing': [2, {
'before': false,
'after': true
}],
'comma-style': [2, 'last'],
'constructor-super': 2,
curly: [2, 'multi-line'],
'curly': [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
eqeqeq: ['error', 'always', { null: 'ignore' }],
'generator-star-spacing': [
2,
{
before: true,
after: true
}
],
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
'generator-star-spacing': [2, {
'before': true,
'after': true
}],
'handle-callback-err': [2, '^(err|error)$'],
indent: [
2,
2,
{
SwitchCase: 1
}
],
'indent': [2, 2, {
'SwitchCase': 1
}],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [
2,
{
beforeColon: false,
afterColon: true
}
],
'keyword-spacing': [
2,
{
before: true,
after: true
}
],
'new-cap': [
2,
{
newIsCap: true,
capIsNew: false
}
],
'key-spacing': [2, {
'beforeColon': false,
'afterColon': true
}],
'keyword-spacing': [2, {
'before': true,
'after': true
}],
'new-cap': [2, {
'newIsCap': true,
'capIsNew': false
}],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
@@ -135,23 +102,17 @@ module.exports = {
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [
2,
{
allowLoop: false,
allowSwitch: false
}
],
'no-labels': [2, {
'allowLoop': false,
'allowSwitch': false
}],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [
2,
{
max: 1
}
],
'no-multiple-empty-lines': [2, {
'max': 1
}],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
@@ -179,125 +140,62 @@ module.exports = {
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [
2,
{
defaultAssignment: false
}
],
'no-unneeded-ternary': [2, {
'defaultAssignment': false
}],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [
2,
{
vars: 'all',
args: 'none'
}
],
'no-unused-vars': [2, {
'vars': 'all',
'args': 'none'
}],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [
2,
{
initialized: 'never'
'one-var': [2, {
'initialized': 'never'
}],
'operator-linebreak': [2, 'after', {
'overrides': {
'?': 'before',
':': 'before'
}
],
'operator-linebreak': [
2,
'after',
{
overrides: {
'?': 'before',
':': 'before'
}
}
],
}],
'padded-blocks': [2, 'never'],
quotes: [
2,
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
],
semi: [2, 'never'],
'semi-spacing': [
2,
{
before: false,
after: true
}
],
'quotes': [2, 'single', {
'avoidEscape': true,
'allowTemplateLiterals': true
}],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
}],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [
2,
{ anonymous: 'never', named: 'never', asyncArrow: 'always' }
],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [
2,
{
words: true,
nonwords: false
}
],
'object-curly-spacing': [2, 'always'],
'spaced-comment': [
2,
'always',
{
markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}
],
'space-unary-ops': [2, {
'words': true,
'nonwords': false
}],
'spaced-comment': [2, 'always', {
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
yoda: [2, 'never'],
'yoda': [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'array-bracket-spacing': [2, 'never'],
'spellcheck/spell-checker': [
'warn',
{
comments: true,
strings: false,
identifiers: false,
lang: 'en_US',
skipWords: [
'echarts',
'resize',
'vue',
'eslint',
'babel',
'jsx',
'scss',
'v-deep',
'calc',
'vw',
'vh',
'px',
'rgba',
'rgb',
'var',
'lang',
'scoped',
'pdf',
'rbac'
],
skipIfMatch: [
'http://[^s]*',
'^[-\\w]+/[-\\w\\.]+$' // For import paths
],
minLength: 3
}
]
'object-curly-spacing': [2, 'always', {
objectsInObjects: false
}],
'array-bracket-spacing': [2, 'never']
}
}

View File

@@ -1,28 +0,0 @@
name: LLM Code Review
permissions:
contents: read
pull-requests: write
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
llm-code-review:
runs-on: ubuntu-latest
steps:
- uses: fit2cloud/LLM-CodeReview-Action@main
env:
GITHUB_TOKEN: ${{ secrets.FIT2CLOUDRD_LLM_CODE_REVIEW_TOKEN }}
OPENAI_API_KEY: ${{ secrets.ALIYUN_LLM_API_KEY }}
LANGUAGE: English
OPENAI_API_ENDPOINT: https://dashscope.aliyuncs.com/compatible-mode/v1
MODEL: qwen2-1.5b-instruct
PROMPT: "Please check the following code differences for any irregularities, potential issues, or optimization suggestions, and provide your answers in English."
top_p: 1
temperature: 1
# max_tokens: 10000
MAX_PATCH_LENGTH: 10000
IGNORE_PATTERNS: "/node_modules,*.md,/dist,/.github"
FILE_PATTERNS: "*.java,*.go,*.py,*.vue,*.ts,*.js,*.css,*.scss,*.html"

View File

@@ -1,28 +0,0 @@
name: LLM Code Review
permissions:
contents: read
pull-requests: write
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
llm-code-review:
runs-on: ubuntu-latest
steps:
- uses: fit2cloud/LLM-CodeReview-Action@main
env:
GITHUB_TOKEN: ${{ secrets.FIT2CLOUDRD_LLM_CODE_REVIEW_TOKEN }}
OPENAI_API_KEY: ${{ secrets.ALIYUN_LLM_API_KEY }}
LANGUAGE: English
OPENAI_API_ENDPOINT: https://dashscope.aliyuncs.com/compatible-mode/v1
MODEL: qwen2-1.5b-instruct
PROMPT: "Please check the following code differences for any irregularities, potential issues, or optimization suggestions, and provide your answers in English."
top_p: 1
temperature: 1
# max_tokens: 10000
MAX_PATCH_LENGTH: 10000
IGNORE_PATTERNS: "/node_modules,*.md,/dist,/.github"
FILE_PATTERNS: "*.java,*.go,*.py,*.vue,*.ts,*.js,*.css,*.scss,*.html"

2
.gitignore vendored
View File

@@ -17,5 +17,3 @@ tests/**/coverage/
*.sln
.env.development
.python-version
helper.json

View File

@@ -1,57 +0,0 @@
# Dependencies
node_modules/
dist/
build/
lina/
# Logs
*.log
logs/
# Runtime data
pids/
*.pid
*.seed
# Coverage directory used by tools like istanbul
coverage/
# Generated files
*.min.js
*.min.css
# Package files
*.tgz
*.tar.gz
# Lock files
package-lock.json
yarn.lock
# Build outputs
*.map
# Config files that shouldn't be formatted
.eslintrc.js
babel.config.js
jest.config.js
vue.config.js
postcss.config.js
# Theme files
src/styles/fonts/
public/fonts/
lina/fonts/
# Assets
src/assets/
public/
# Mock data
mock/
# Test files
tests/
# Documentation
*.md

View File

@@ -1,11 +0,0 @@
module.exports = {
singleQuote: true,
semi: false,
trailingComma: 'none',
printWidth: 100,
tabWidth: 2,
useTabs: false,
bracketSpacing: true,
arrowParens: 'avoid',
endOfLine: 'auto'
}

View File

@@ -1,4 +1,4 @@
FROM jumpserver/lina-base:20250910_084112 AS stage-build
FROM jumpserver/lina-base:20240723_084702 AS stage-build
ARG VERSION
ENV VERSION=$VERSION

View File

@@ -1,76 +0,0 @@
# Prettier 配置说明
本项目已配置 Prettier 代码格式化工具,**仅在保存时自动格式化**,不进行批量格式化,以保持现有代码风格。
## 配置文件
- `.prettierrc` - Prettier 配置文件
- `.prettierignore` - 忽略格式化的文件列表
- `.vscode/settings.json` - VSCode 编辑器配置(保存时自动格式化)
- `.vscode/extensions.json` - 推荐的 VSCode 扩展
## 使用方法
### 1. 安装依赖
项目已安装以下依赖:
- `prettier@^2.8.8` - Prettier 核心
- `eslint-plugin-prettier@^3.1.4` - ESLint 与 Prettier 集成
- `eslint-config-prettier@^6.15.0` - 禁用与 Prettier 冲突的 ESLint 规则
### 2. 命令行使用
```bash
# ESLint 检查和修复
npm run fix
```
**注意**:本项目配置为仅在保存时自动格式化,不提供批量格式化命令。
### 3. VSCode 编辑器配置
确保安装了推荐的扩展:
- Prettier - Code formatter (esbenp.prettier-vscode)
- ESLint (dbaeumer.vscode-eslint)
- Vetur (octref.vetur)
配置已设置为保存时自动格式化。
### 4. Git 提交钩子
项目使用 `husky``lint-staged` 在提交时进行代码检查:
- 提交时运行 ESLint 检查和修复
- 不进行批量格式化,保持原有代码风格
## Prettier 配置说明
```json
{
"semi": false, // 不使用分号
"singleQuote": true, // 使用单引号
"tabWidth": 0, // 不使用缩进
"useTabs": false, // 使用空格而不是制表符
"trailingComma": "none", // 不使用尾随逗号
"printWidth": 100, // 行宽 100 字符
"bracketSpacing": true, // 对象括号内有空格
"arrowParens": "avoid", // 箭头函数单参数时不使用括号
"endOfLine": "lf", // 使用 LF 换行符
"vueIndentScriptAndStyle": false // Vue 文件中 script 和 style 标签不缩进
}
```
## 常见问题
### Q: 如何临时禁用格式化?
A: 使用注释:
```javascript
// prettier-ignore
const uglyCode = {
a:1,b:2
}
```
### Q: 如何添加文件到忽略列表?
A: 编辑 `.prettierignore` 文件,添加文件或目录路径。
### Q: VSCode 保存时没有自动格式化?
A: 检查是否安装了 Prettier 扩展,并确认 `.vscode/settings.json` 配置正确。

View File

@@ -5,6 +5,5 @@
"@/*": ["src/*"]
}
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}

View File

@@ -1,25 +1,13 @@
import Mock from 'mockjs'
import { param2Obj } from '../src/utils'
import user from './user'
import table from './table'
export function param2Obj(url) {
const search = url.split('?')[1]
if (!search) {
return {}
}
return JSON.parse(
'{"' +
decodeURIComponent(search)
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"')
.replace(/\+/g, ' ') +
'"}'
)
}
const mocks = [...user, ...table]
const mocks = [
...user,
...table
]
// for front mock
// please use it cautiously, it will redefine XMLHttpRequest,

View File

@@ -2,7 +2,7 @@
"name": "lina",
"version": "v4.0.0",
"description": "JumpServer Web UI",
"author": "JumpServer Team <support@lxware.hk>",
"author": "JumpServer Team <support@fit2cloud.com>",
"license": "GPL-3.0-or-later",
"scripts": {
"dev": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
@@ -26,13 +26,10 @@
"dependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
"@fontsource/open-sans": "^5.0.24",
"@kangc/v-md-editor": "^1.7.12",
"@traptitech/markdown-it-katex": "^3.6.0",
"@ztree/ztree_v3": "3.5.44",
"axios": "0.28.0",
"axios-retry": "^3.1.9",
"babel-loader": "^10.0.0",
"cache-loader": "^4.1.0",
"caniuse-lite": "^1.0.30001642",
"cron-parser": "^4.0.0",
"crypto-js": "^4.1.1",
@@ -41,8 +38,7 @@
"deepmerge": "^4.2.2",
"dompurify": "^3.1.6",
"echarts": "4.7.0",
"element-ui": "^2.15.14",
"elementui-lts": "^2.16.0",
"element-ui": "2.15.14",
"eslint-plugin-html": "^6.0.0",
"highlight.js": "^11.9.0",
"install": "^0.13.0",
@@ -71,7 +67,6 @@
"npm": "^7.8.0",
"nprogress": "0.2.0",
"path-to-regexp": "3.3.0",
"sortablejs": "^1.15.6",
"v-sanitize": "^0.0.13",
"vue": "2.6.10",
"vue-codemirror": "4.0.6",
@@ -80,12 +75,12 @@
"vue-i18n": "^8.15.5",
"vue-json-editor": "^1.4.3",
"vue-markdown": "^2.2.4",
"vue-moment": "^4.1.0",
"vue-password-strength-meter": "^1.7.2",
"vue-router": "3.0.6",
"vue-select": "^3.9.5",
"vuejs-logger": "^1.5.4",
"vuex": "3.1.0",
"watermark-js-plus": "^1.5.8",
"xss": "^1.0.14",
"xterm": "^4.5.0",
"xterm-addon-fit": "^0.3.0",
@@ -100,17 +95,15 @@
"@vue/cli-service": "3.6.0",
"@vue/test-utils": "1.0.0-beta.29",
"autoprefixer": "^9.5.1",
"babel-core": "6.26.3",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "23.6.0",
"chalk": "2.4.2",
"compression-webpack-plugin": "^6.1.1",
"connect": "3.6.6",
"deasync": "^0.1.29",
"element-theme-chalk": "^2.13.1",
"eslint": "^5.15.3",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-spellcheck": "^0.0.20",
"eslint-plugin-vue": "5.2.2",
"eslint-plugin-vue-i18n": "^0.3.0",
"github-markdown-css": "^5.1.0",
@@ -119,8 +112,6 @@
"less-loader": "^5.0.0",
"lint-staged": "^10.1.2",
"mockjs": "1.0.1-beta3",
"prettier": "^3.6.2",
"pretty-bytes": "^5.6.0",
"runjs": "^4.3.2",
"sass": "~1.32.6",
"sass-loader": "^7.1.0",
@@ -131,8 +122,7 @@
"svg-sprite-loader": "4.1.3",
"svgo": "1.2.2",
"vue-i18n-extract": "^1.1.1",
"vue-template-compiler": "2.6.10",
"webpack": "^4.28.4"
"vue-template-compiler": "2.6.10"
},
"engines": {
"node": ">=8.9",

View File

@@ -1,90 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="0" http-equiv="Expires">
<meta content="no-cache" http-equiv="Pragma">
<meta content="no-cache" http-equiv="Cache-control">
<meta content="no-cache" http-equiv="Cache">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title><%= webpackConfig.name %></title>
<link href="<%= BASE_URL %>theme/element-ui.css" rel="stylesheet">
<style>
#loading {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(255, 255, 255, 0.98);
z-index: 9999;
}
#loading .spinner {
width: 40px;
height: 40px;
border: 3px solid transparent;
border-top-color: var(--color-primary);
border-radius: 50%;
animation: spin 1s linear infinite;
}
#loading .spinner::after {
content: '';
position: absolute;
top: -3px;
left: -3px;
width: 40px;
height: 40px;
border: 3px solid transparent;
border-top-color: rgba(64, 158, 255, 0.2);
border-radius: 50%;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<noscript>
<strong>
We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled.
Please enable it to continue.
</strong>
</noscript>
<script>
window.onload = function () {
<link rel="stylesheet" href="<%= BASE_URL %>theme/element-ui.css">
</head>
<body>
<noscript>
<strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<script>
window.onload = function() {
if (location.pathname === '/') {
location.pathname = '/ui/'
location.pathname = '/ui/'
}
const pathname = window.location.pathname
if (pathname.startsWith('/core')) {
return
}
if (pathname.indexOf('/ui') === -1) {
window.location.href = window.location.origin + '/ui/#' + pathname
if(pathname.indexOf('/ui') === -1) {
window.location.href = window.location.origin + '/ui/#' + pathname
}
if (pathname.startsWith('/ui/#/chat')) {
window.location.href = window.location.origin + pathname
window.location.href = window.location.origin + pathname
}
}
</script>
<div id="app">
</div>
<div id="loading">
<div class="spinner"></div>
</div>
<!-- built files will be auto injected -->
</body>
}
</script>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@@ -5,90 +5,14 @@
</template>
<script>
import { mapState, mapGetters } from 'vuex'
import { Watermark } from 'watermark-js-plus'
import { mapState } from 'vuex'
export default {
name: 'App',
data() {
return {
watermark: null
}
},
computed: {
...mapState({
isRouterAlive: state => state.common.isRouterAlive
}),
...mapGetters({
currentUser: 'currentUser',
publicSettings: 'publicSettings'
})
},
watch: {
currentUser: {
handler(newVal) {
this.createWatermark()
}
},
'publicSettings.SECURITY_WATERMARK_ENABLED': {
handler(newVal) {
if (!newVal) {
return setTimeout(() => {
this.watermark?.destroy()
this.watermark = null
})
}
this.createWatermark()
}
}
},
methods: {
getWaterMarkFields() {
const user = this.currentUser
const userId = user?.id || ''
const name = user?.name || ''
const userName = user?.username || ''
const currentTime = this.$moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
return { userId, name, userName, currentTime }
},
getWaterMarkContent() {
const fields = this.getWaterMarkFields()
const template = this.publicSettings.SECURITY_WATERMARK_CONSOLE_CONTENT || ''
// 找出模板中所有的变量占位符 ${xxx}
const placeholders = template.match(/\${([^}]+)}/g) || []
const allVariables = {}
// 为模板中的每个变量准备值
placeholders.forEach(placeholder => {
const varName = placeholder.slice(2, -1) // 提取变量名,去掉 ${ 和 }
allVariables[varName] = fields[varName] !== undefined ? fields[varName] : 'N/A'
})
// 合并用户现有的字段和模板中可能缺失的字段
const safeFields = { ...fields, ...allVariables }
// 安全解析模板
return new Function(...Object.keys(safeFields), `return \`${template}\`;`)(...Object.values(safeFields))
},
createWatermark() {
if (this.currentUser?.username && this.publicSettings?.SECURITY_WATERMARK_ENABLED) {
this.watermark = new Watermark({
content: this.getWaterMarkContent(),
width: this.publicSettings?.SECURITY_WATERMARK_WIDTH,
height: this.publicSettings?.SECURITY_WATERMARK_HEIGHT,
rotate: this.publicSettings?.SECURITY_WATERMARK_ROTATE,
fontWeight: 'normal',
fontSize: this.publicSettings?.SECURITY_WATERMARK_FONT_SIZE + 'px',
fontColor: this.publicSettings?.SECURITY_WATERMARK_COLOR,
contentType: 'multi-line-text',
lineHeight: this.publicSettings?.SECURITY_WATERMARK_FONT_SIZE
})
this.watermark.create()
}
}
}
}
</script>

View File

@@ -16,9 +16,9 @@ export function getSystemUserList(data) {
})
}
export function getZoneList(data) {
export function getDomainList(data) {
return request({
url: '/api/v1/assets/zones/',
url: '/api/v1/assets/domains/',
method: 'get',
params: data
})

View File

@@ -53,7 +53,7 @@ export function createJob(form) {
})
}
export function stopJob(form) {
export function StopJob(form) {
return request({
url: '/api/v1/ops/job-executions/stop/',
method: 'post',
@@ -61,21 +61,13 @@ export function stopJob(form) {
})
}
export function JobUploadFile(form, config = {}) {
export function JobUploadFile(form) {
return request({
url: '/api/v1/ops/jobs/upload/',
method: 'post',
headers: { 'Content-Type': 'multipart/form-data' },
timeout: 60 * 60 * 1000,
data: form,
...config
})
}
export function auditUpdateJob(id, form) {
return request({
url: `/api/v1/audits/jobs/${id}/`,
method: 'patch',
data: form
})
}

View File

@@ -8,20 +8,11 @@ export function login(data) {
})
}
export async function getProfile(token) {
let profile = await request({
export function getProfile(token) {
return request({
url: '/api/v1/users/profile/',
method: 'get'
})
const perms = await request({
url: '/api/v1/users/profile/permissions/',
method: 'get'
})
profile = {
...profile,
...perms
}
return profile
}
export function getUserList(data) {
@@ -31,7 +22,6 @@ export function getUserList(data) {
params: data
})
}
export function getUserGroupList(params) {
return request({
url: '/api/v1/users/groups/',
@@ -39,7 +29,6 @@ export function getUserGroupList(params) {
params: params
})
}
export function getUserGroupDetail(id) {
return request({
url: `/api/v1/users/groups/${id}/`,
@@ -61,7 +50,6 @@ export function editUserGroup(data) {
data: data
})
}
export function updateUserGroup(id, data) {
return request({
url: '/api/v1/users/groups/' + id + '/',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 584 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -1 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1752631175762" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4421" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M93.866667 234.666667c-34.133333 12.8-51.2 25.6-51.2 34.133333 0 4.266667 51.2 64 115.2 136.533333 64 68.266667 115.2 128 115.2 128s-51.2 59.733333-115.2 128C93.866667 729.6 42.666667 793.6 42.666667 797.866667c4.266667 17.066667 59.733333 42.666667 98.133333 42.666666 64 0 81.066667-12.8 217.6-162.133333 68.266667-76.8 128-140.8 128-140.8 0-4.266667-55.466667-64-123.733333-140.8-85.333333-102.4-132.266667-145.066667-153.6-157.866667-29.866667-12.8-81.066667-17.066667-115.2-4.266666z m725.333333 4.266666c-21.333333 8.533333-68.266667 59.733333-153.6 153.6-68.266667 76.8-123.733333 140.8-123.733333 140.8 0 4.266667 55.466667 68.266667 128 140.8 136.533333 153.6 153.6 162.133333 217.6 162.133334 42.666667 0 98.133333-21.333333 98.133333-42.666667 0-4.266667-51.2-68.266667-115.2-136.533333-64-68.266667-115.2-128-115.2-128s51.2-59.733333 115.2-128c64-68.266667 115.2-128 115.2-136.533334-4.266667-17.066667-55.466667-38.4-98.133333-38.4-34.133333 0-46.933333 4.266667-68.266667 12.8z" fill="#E57000" p-id="4422"></path><path d="M238.933333 136.533333c-42.666667 21.333333-42.666667 25.6-4.266666 68.266667 221.866667 243.2 273.066667 302.933333 277.333333 302.933333 4.266667 0 311.466667-332.8 315.733333-341.333333 0-4.266667-8.533333-12.8-21.333333-21.333333-17.066667-12.8-34.133333-17.066667-68.266667-17.066667-64-4.266667-85.333333 8.533333-162.133333 93.866667-34.133333 38.4-64 72.533333-64 72.533333s-29.866667-29.866667-64-68.266667c-34.133333-38.4-72.533333-76.8-89.6-85.333333-25.6-17.066667-89.6-21.333333-119.466667-4.266667zM354.133333 725.333333c-85.333333 93.866667-153.6 170.666667-153.6 174.933334 0 4.266667 8.533333 12.8 21.333334 21.333333 17.066667 12.8 34.133333 17.066667 68.266666 17.066667 59.733333 4.266667 85.333333-8.533333 162.133334-98.133334 34.133333-38.4 64-68.266667 64-68.266666s29.866667 29.866667 64 68.266666c81.066667 89.6 98.133333 102.4 162.133333 98.133334 34.133333 0 51.2-4.266667 68.266667-17.066667 12.8-8.533333 21.333333-17.066667 21.333333-21.333333-4.266667-8.533333-311.466667-345.6-315.733333-341.333334-8.533333 0-76.8 76.8-162.133334 166.4z" p-id="4423"></path></svg>

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -1 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1748326203303" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2853" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M10.24 605.184l839.168-481.28L1013.76 220.672v191.488L174.592 895.488 10.24 804.352z" fill="#0096FF" p-id="2854"></path><path d="M10.24 416.768V220.672l168.96-96.768 308.736 178.688-331.776 193.536zM541.184 717.312l331.264-195.072 141.312 88.064v194.048l-165.376 95.744z" fill="#25C764" p-id="2855"></path></svg>

Before

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -3,7 +3,7 @@
</template>
<script>
import DataActions from '@/components/Common/DataActions/index.vue'
import DataActions from '@/components/DataActions'
export default {
name: 'ActionsGroup',

View File

@@ -1,26 +1,23 @@
import { UpdateToken, UploadSecret } from '@/components/Form/FormFields'
import Select2 from '@/components/Form/FormFields/Select2.vue'
import AssetSelect from '@/components/Apps/AssetSelect/index.vue'
import { Required, RequiredChange } from '@/components/Form/DataForm/rules'
import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSetting.vue'
export const accountFieldsMeta = (vm) => {
const defaultPrivilegedAccounts = ['root', 'administrator']
function onPrivilegedUser(value, updateForm) {
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
if (maybePrivileged) {
updateForm({ privileged: true, secret_reset: false, push_now: false })
}
}
return {
assets: {
component: AssetSelect,
label: vm.$t('Asset'),
component: Select2,
label: vm.$t('Assets'),
rules: [Required],
el: {
multiple: false
multiple: true,
ajax: {
url: '/api/v1/assets/assets/',
transformOption: (item) => {
return { label: item.name + '(' + item.address + ')', value: item.id }
}
}
},
hidden: () => {
return vm.platform || vm.asset
@@ -30,9 +27,6 @@ export const accountFieldsMeta = (vm) => {
component: Select2,
rules: [Required],
el: {
get disabled() {
return vm.isDisabled
},
multiple: false,
ajax: {
url: '/api/v1/accounts/account-templates/',
@@ -49,11 +43,6 @@ export const accountFieldsMeta = (vm) => {
rules: [Required],
label: vm.$t('AccountPolicy'),
helpTip: vm.$t('AccountPolicyHelpText'),
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: () => {
return vm.platform || vm.asset
}
@@ -61,19 +50,17 @@ export const accountFieldsMeta = (vm) => {
name: {
label: vm.$t('Name'),
rules: [RequiredChange],
el: {
get disabled() {
return vm.isDisabled
}
},
on: {
input: ([value], updateForm) => {
if (!vm.usernameChanged) {
if (!vm.account?.name) {
updateForm({ username: value })
}
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
if (maybePrivileged) {
updateForm({ privileged: true })
}
}
onPrivilegedUser(value, updateForm)
}
},
hidden: () => {
@@ -82,16 +69,17 @@ export const accountFieldsMeta = (vm) => {
},
username: {
el: {
get disabled() {
return !!vm.account?.name || vm.isDisabled
}
disabled: !!vm.account?.name
},
on: {
input: ([value], updateForm) => {
vm.usernameChanged = true
},
change: ([value], updateForm) => {
onPrivilegedUser(value, updateForm)
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
if (maybePrivileged) {
updateForm({ privileged: true })
}
}
},
hidden: () => {
@@ -100,11 +88,6 @@ export const accountFieldsMeta = (vm) => {
},
privileged: {
label: vm.$t('Privileged'),
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: () => {
return vm.addTemplate
}
@@ -127,11 +110,6 @@ export const accountFieldsMeta = (vm) => {
},
su_from_username: {
label: vm.$t('UserSwitchFrom'),
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => {
return vm.platform || vm.asset || vm.addTemplate
}
@@ -139,11 +117,6 @@ export const accountFieldsMeta = (vm) => {
password: {
label: vm.$t('Password'),
component: UpdateToken,
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => {
return formValue.secret_type !== 'password' || vm.addTemplate
}
@@ -151,63 +124,33 @@ export const accountFieldsMeta = (vm) => {
ssh_key: {
label: vm.$t('PrivateKey'),
component: UploadSecret,
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate
},
passphrase: {
label: vm.$t('Passphrase'),
component: UpdateToken,
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate
},
token: {
label: vm.$t('Token'),
component: UploadSecret,
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'token' || vm.addTemplate
},
access_key: {
id: 'access_key',
label: vm.$t('AccessKey'),
component: UploadSecret,
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'access_key' || vm.addTemplate
},
api_key: {
id: 'api_key',
label: vm.$t('ApiKey'),
component: UploadSecret,
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: (formValue) => formValue.secret_type !== 'api_key' || vm.addTemplate
},
secret_type: {
type: 'radio-group',
options: [],
el: {
get disabled() {
return vm.isDisabled
}
},
hidden: () => {
return vm.addTemplate
}
@@ -220,8 +163,7 @@ export const accountFieldsMeta = (vm) => {
!automation.ansible_enabled ||
!vm.$hasPerm('accounts.push_account') ||
(formValue.secret_type === 'ssh_key' && vm.iPlatform.type.value === 'windows') ||
vm.addTemplate ||
!formValue.secret_reset
vm.addTemplate
}
},
params: {
@@ -230,9 +172,6 @@ export const accountFieldsMeta = (vm) => {
el: {},
hidden: (formValue) => {
const automation = vm.iPlatform.automation || {}
if (!vm.iPlatform.automation) {
return true
}
vm.fieldsMeta.params.el.method = vm.iPlatform.automation.push_account_method
vm.fieldsMeta.params.el.pushAccountParams = vm.iPlatform.automation.push_account_params
return !formValue.push_now ||
@@ -245,27 +184,12 @@ export const accountFieldsMeta = (vm) => {
}
},
is_active: {
label: vm.$t('IsActive'),
el: {
get disabled() {
return vm.isDisabled
}
}
label: vm.$t('IsActive')
},
comment: {
label: vm.$t('Comment'),
el: {
get disabled() {
return vm.isDisabled
}
}
},
secret_reset: {
label: vm.$t('SecretReset'),
el: {
get disabled() {
return vm.isDisabled
}
hidden: () => {
return vm.addTemplate
}
}
}

View File

@@ -11,7 +11,7 @@
<script>
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
import { encryptPassword } from '@/utils/secure'
import { encryptPassword } from '@/utils/crypto'
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
export default {
@@ -45,7 +45,6 @@ export default {
data() {
return {
loading: true,
isDisabled: false,
usernameChanged: false,
submitBtnText: this.$t('Confirm'),
iPlatform: {
@@ -62,12 +61,11 @@ export default {
form: Object.assign({ 'on_invalid': 'error' }, this.account || {}),
encryptedFields: ['secret'],
fields: [
[this.$t('Basic'), ['name', 'username', 'privileged', 'su_from', 'su_from_username', 'template']],
[this.$t('Asset'), ['assets']],
[this.$t('AccountTemplate'), ['template']],
[this.$t('Basic'), ['assets', 'name', 'username', 'privileged', 'su_from', 'su_from_username']],
[this.$t('Secret'), [
'secret_type', 'password', 'ssh_key', 'token',
'access_key', 'passphrase', 'api_key',
'secret_reset'
'access_key', 'passphrase', 'api_key'
]],
[this.$t('Other'), ['push_now', 'params', 'on_invalid', 'is_active', 'comment']]
],
@@ -75,16 +73,6 @@ export default {
hasSaveContinue: false
}
},
watch: {
'$route.query': {
handler(nv, ov) {
if (nv && (nv.flag === 'move' || nv.flag === 'copy')) {
this.isDisabled = true
}
},
immediate: true
}
},
async mounted() {
try {
await this.getPlatform()
@@ -157,11 +145,7 @@ export default {
delete form['secret']
}
if (this.account?.name) {
if (this.account.payload && this.account.payload === 'pam_account_clone') {
this.$emit('add', form)
} else {
this.$emit('edit', form)
}
this.$emit('edit', form)
} else {
this.$emit('add', form)
}
@@ -173,16 +157,16 @@ export default {
<style lang='scss' scoped>
.account-add {
::v-deep .el-form-item {
//margin-bottom: 5px;
margin-bottom: 5px;
.help-block {
//margin-bottom: 5px;
margin-bottom: 5px;
}
}
::v-deep .form-group-header {
.hr-line-dashed {
//margin: 5px 0;
margin: 5px 0;
}
h3 {

View File

@@ -11,7 +11,7 @@
<script>
import { GenericUpdateFormDialog } from '@/layout/components'
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
import { encryptPassword } from '@/utils/secure'
import { encryptPassword } from '@/utils/crypto'
export default {
name: 'AccountBulkUpdateDialog',

View File

@@ -1,38 +1,36 @@
<template v-if="iVisible">
<Drawer
<template>
<Dialog
v-if="iVisible"
:close-on-click-modal="false"
:destroy-on-close="true"
:show-cancel="false"
:show-confirm="false"
:title="title"
:visible="iVisible"
class="drawer"
@close-drawer="handleCloseDrawer"
:visible.sync="iVisible"
v-bind="$attrs"
width="900px"
v-on="$listeners"
>
<Page :title="'null'">
<IBox class="content">
<AccountCreateUpdateForm
v-if="!loading"
ref="form"
:account="account"
:add-template="addTemplate"
:asset="asset"
@add="addAccount"
@edit="editAccount"
/>
</IBox>
</Page>
</Drawer>
<AccountCreateUpdateForm
v-if="!loading"
ref="form"
:account="account"
:add-template="addTemplate"
:asset="asset"
@add="addAccount"
@edit="editAccount"
/>
</Dialog>
</template>
<script>
import Drawer from '@/components/Drawer/index.vue'
import Dialog from '@/components/Dialog/index.vue'
import AccountCreateUpdateForm from '@/components/Apps/AccountCreateUpdateForm/index.vue'
import IBox from '@/components/Common/IBox/index.vue'
import Page from '@/layout/components/Page/index.vue'
export default {
name: 'CreateAccountDialog',
components: {
IBox,
Drawer,
Page,
Dialog,
AccountCreateUpdateForm
},
props: {
@@ -113,22 +111,11 @@ export default {
},
editAccount(form) {
const data = { ...form }
const flag = this.$route.query.flag
switch (flag) {
case 'copy':
this.handleAccountOperation(this.account.id, 'copy-to-assets', data)
break
case 'move':
this.handleAccountOperation(this.account.id, 'move-to-assets', data)
break
default:
this.$axios.patch(`/api/v1/accounts/accounts/${this.account.id}/`, data).then(() => {
this.iVisible = false
this.$emit('add', true)
this.$message.success(this.$tc('UpdateSuccessMsg'))
}).catch(error => this.setFieldError(error))
}
this.$axios.patch(`/api/v1/accounts/accounts/${this.account.id}/`, data).then(() => {
this.iVisible = false
this.$emit('add', true)
this.$message.success(this.$tc('UpdateSuccessMsg'))
}).catch(error => this.setFieldError(error))
},
handleResult(resp, error) {
let bulkCreate = !this.asset
@@ -181,29 +168,7 @@ export default {
refsAutoDataForm.setFieldError(current, err)
}
}
},
handleCloseDrawer() {
this.iVisible = false
// Reflect.deleteProperty(this.$route.query, 'flag')
},
handleAccountOperation(id, path, data) {
this.$axios.post(`/api/v1/accounts/accounts/${id}/${path}/`, data).then((res) => {
this.iVisible = false
this.$emit('add', true)
this.handleResult(res, null)
}).catch(error => this.handleResult(null, error))
}
}
}
</script>
<style lang="scss" scoped>
.drawer {
::v-deep .el-drawer__body {
.el-form {
margin-right: 30px;
}
}
}
</style>

View File

@@ -1,12 +1,6 @@
<template>
<div>
<DrawerListTable
ref="ListTable"
:detail-drawer="detailDrawer"
:header-actions="headerActions"
:quick-filters="quickFilters"
:table-config="tableConfig"
/>
<ListTable ref="ListTable" :header-actions="headerActions" :table-config="tableConfig" />
<ViewSecret
v-if="showViewSecretDialog"
:account="account"
@@ -22,13 +16,22 @@
<AccountCreateUpdate
v-if="showAddDialog"
:account="account"
:add-template="addTemplate"
:asset="iAsset"
:title="accountCreateUpdateTitle"
:visible.sync="showAddDialog"
@add="addAccountSuccess"
@bulk-create-done="showBulkCreateResult($event)"
/>
<AccountCreateUpdate
v-if="showAddTemplateDialog"
:account="account"
:add-template="true"
:asset="iAsset"
:title="accountCreateByTemplateTitle"
:visible.sync="showAddTemplateDialog"
@add="addAccountSuccess"
@bulk-create-done="showBulkCreateResult($event)"
/>
<ResultDialog
v-if="showResultDialog"
:result="createAccountResults"
@@ -41,42 +44,29 @@
v-bind="updateSelectedDialogSetting"
@update="handleAccountBulkUpdate"
/>
<PasswordHistoryDialog
v-if="showPasswordHistoryDialog"
:account="currentAccountColumn"
:visible.sync="showPasswordHistoryDialog"
/>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import { accountOtherActions, accountQuickFilters, connectivityMeta, isDirectoryServiceAccount } from './const'
import { openTaskPage } from '@/utils/jms/index'
import {
AccountConnectFormatter,
ActionsFormatter,
PlatformFormatter,
SecretViewerFormatter
} from '@/components/Table/TableFormatters'
import ListTable from '@/components/Table/ListTable/index.vue'
import { ActionsFormatter } from '@/components/Table/TableFormatters'
import ViewSecret from './ViewSecret.vue'
import UpdateSecretInfo from './UpdateSecretInfo.vue'
import ResultDialog from './BulkCreateResultDialog.vue'
import AccountCreateUpdate from './AccountCreateUpdate.vue'
import PasswordHistoryDialog from './PasswordHistoryDialog.vue'
import DrawerListTable from '@/components/Table/DrawerListTable/index.vue'
import { connectivityMeta } from './const'
import { openTaskPage } from '@/utils/jms'
import ResultDialog from './BulkCreateResultDialog.vue'
import AccountBulkUpdateDialog from '@/components/Apps/AccountListTable/AccountBulkUpdateDialog.vue'
export default {
name: 'AccountListTable',
components: {
ViewSecret,
AccountBulkUpdateDialog,
ResultDialog,
DrawerListTable,
ListTable,
UpdateSecretInfo,
AccountCreateUpdate,
PasswordHistoryDialog,
AccountBulkUpdateDialog
ViewSecret,
AccountCreateUpdate
},
props: {
url: {
@@ -99,7 +89,7 @@ export default {
},
hasClone: {
type: Boolean,
default: true
default: false
},
asset: {
type: Object,
@@ -129,7 +119,7 @@ export default {
columnsDefault: {
type: Array,
default: () => ([
'name', 'username', 'secret', 'asset', 'platform', 'connect'
'name', 'username', 'asset', 'date_updated'
])
},
headerExtraActions: {
@@ -139,34 +129,22 @@ export default {
extraQuery: {
type: Object,
default: () => ({})
},
showQuickFilters: {
type: Boolean,
default: true
},
showActions: {
type: Boolean,
default: true
}
},
data() {
const vm = this
return {
addTemplate: false,
isUpdateAccount: false,
currentAccountColumn: {},
showPasswordHistoryDialog: false,
showViewSecretDialog: false,
showUpdateSecretDialog: false,
showResultDialog: false,
showAddDialog: false,
showAddTemplateDialog: false,
detailDrawer: () => import('@/views/accounts/Account/AccountDetail/index.vue'),
createAccountResults: [],
accountCreateUpdateTitle: this.$t('AddAccount'),
accountCreateByTemplateTitle: this.$t('AddAccountByTemplate'),
iAsset: this.asset,
account: {},
secretUrl: '',
quickFilters: this.showQuickFilters ? accountQuickFilters(this) : [],
tableConfig: {
url: this.url,
permissions: {
@@ -175,86 +153,40 @@ export default {
},
extraQuery: this.extraQuery,
columnsExclude: ['spec_info'],
columnsAdd: ['secret', 'platform', 'connect'],
columnsShow: {
min: ['name', 'username', 'actions'],
default: this.columnsDefault
},
columnsMeta: {
name: {
minWidth: '60px',
formatterArgs: {
can: () => vm.$hasPerm('accounts.view_account'),
getRoute: ({ row }) => ({
name: 'AccountDetail',
width: '120px',
formatter: function(row) {
const to = {
name: 'AssetAccountDetail',
params: { id: row.id }
}),
getTitle: ({ row }) => {
let title = row.name
if (row.ds && this.asset && this.asset.id !== row.asset.id) {
const dsID = row.ds.id.split('-')[0]
title = `${row.name}@${dsID}`
}
return title
},
getDrawerTitle({ row }) {
return `${row.username}@${row.asset.name}`
}
}
},
secret: {
formatter: SecretViewerFormatter,
width: '130px',
formatterArgs: {
secretFrom: 'api',
hasDownload: false,
actionLeft: true
}
},
connect: {
label: this.$t('Connect'),
width: '80px',
formatter: AccountConnectFormatter,
formatterArgs: {
asset: this.asset,
can: ({ row }) => {
return this.currentUserIsSuperAdmin
}
}
},
ds: {
width: '100px',
formatter: (row) => {
if (row.ds && row.ds['domain_name']) {
return row.ds['domain_name']
if (vm.$hasPerm('accounts.view_account')) {
return <router-link to={to}>{row.name}</router-link>
} else {
return ''
return <span>{row.name}</span>
}
}
},
platform: {
label: this.$t('Platform'),
width: '150px',
formatter: PlatformFormatter,
formatterArgs: {
platformAttr: 'asset.platform'
}
},
asset: {
minWidth: '100px',
formatter: function(row) {
return row.asset.name
const to = {
name: 'AssetDetail',
params: { id: row.asset.id }
}
if (vm.$hasPerm('assets.view_asset')) {
return <router-link to={to}>{row.asset.name}</router-link>
} else {
return <span>{row.asset.name}</span>
}
}
},
username: {
minWidth: '60px',
formatter: function(row) {
if (row.ds && row.ds['domain_name']) {
return `${row.username}@${row.ds['domain_name']}`
} else {
return row.username
}
}
width: '120px'
},
secret_type: {
formatter: function(row) {
@@ -282,19 +214,77 @@ export default {
connectivity: connectivityMeta,
actions: {
formatter: ActionsFormatter,
has: this.showActions,
formatterArgs: {
performDelete: ({ row }) => {
const id = row.id
const url = `/api/v1/accounts/accounts/${id}/`
return this.$axios.delete(url)
},
hasUpdate: false, // can set function(row, value)
hasDelete: true, // can set function(row, value)
hasClone: false,
canDelete: ({ row }) => vm.$hasPerm('accounts.delete_account') && !isDirectoryServiceAccount(row, this),
hasDelete: false, // can set function(row, value)
hasClone: this.hasClone,
moreActionsTitle: this.$t('More'),
extraActions: accountOtherActions(this)
extraActions: [
{
name: 'View',
title: this.$t('View'),
can: this.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
callback: ({ row }) => {
// debugger
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
vm.account = row
vm.showViewSecretDialog = false
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'Update',
title: this.$t('Edit'),
can: this.$hasPerm('accounts.change_account') && !this.$store.getters.currentOrgIsRoot,
callback: ({ row }) => {
const data = {
...this.asset,
...row.asset
}
vm.account = row
vm.iAsset = data
vm.showAddDialog = false
vm.accountCreateUpdateTitle = this.$t('UpdateAccount')
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'Test',
title: this.$t('Test'),
can: ({ row }) =>
!this.$store.getters.currentOrgIsRoot &&
this.$hasPerm('accounts.verify_account') &&
row.asset['auto_config'].ansible_enabled &&
row.asset['auto_config'].ping_enabled,
callback: ({ row }) => {
this.$axios.post(
`/api/v1/accounts/accounts/tasks/`,
{ action: 'verify', accounts: [row.id] }
).then(res => {
openTaskPage(res['task'])
})
}
},
{
name: 'ClearSecret',
title: this.$t('ClearSecret'),
can: this.$hasPerm('accounts.change_account'),
type: 'primary',
callback: ({ row }) => {
this.$axios.patch(
`/api/v1/accounts/accounts/clear-secret/`,
{ account_ids: [row.id] }
).then(() => {
this.$message.success(this.$tc('ClearSuccessMsg'))
})
}
}
]
}
},
...this.columnsMeta
@@ -323,15 +313,15 @@ export default {
type: 'primary',
icon: 'plus',
can: () => {
return vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot
return vm.$hasPerm('accounts.add_account') && !this.$store.getters.currentOrgIsRoot
},
callback: () => {
callback: async() => {
await this.getAssetDetail()
setTimeout(() => {
vm.iAsset = this.asset
vm.account = {}
this.addTemplate = false
this.showAddDialog = true
}, 200)
vm.showAddDialog = true
})
}
},
{
@@ -339,15 +329,14 @@ export default {
title: this.$t('TemplateAdd'),
has: !(this.platform || this.asset),
can: () => {
return vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot
return vm.$hasPerm('accounts.add_account') && !this.$store.getters.currentOrgIsRoot
},
callback: async () => {
callback: async() => {
await this.getAssetDetail()
setTimeout(() => {
vm.iAsset = this.asset
vm.account = {}
vm.showAddDialog = true
vm.addTemplate = true
vm.showAddTemplateDialog = true
})
}
},
@@ -358,11 +347,11 @@ export default {
name: 'TestSelected',
title: this.$t('TestSelected'),
type: 'primary',
icon: 'verify',
icon: 'fa-link',
can: ({ selectedRows }) => {
return selectedRows.length > 0 &&
['clickhouse', 'redis', 'website', 'chatgpt'].indexOf(selectedRows[0].asset.type.value) === -1 &&
!this.$store.getters.currentOrgIsRoot && vm.$hasPerm('accounts.verify_account')
['clickhouse', 'redis', 'website', 'chatgpt'].indexOf(selectedRows[0].asset.type.value) === -1 &&
!this.$store.getters.currentOrgIsRoot
},
callback: function({ selectedRows }) {
const ids = selectedRows.map(v => {
@@ -427,18 +416,6 @@ export default {
}
}
},
computed: {
...mapGetters(['currentUserIsSuperAdmin']),
accountCreateUpdateTitle() {
if (this.addTemplate) {
return this.$t('AddAccountByTemplate')
} else if (this.isUpdateAccount) {
return this.$t('UpdateAccount')
} else {
return this.$t('AddAccount')
}
}
},
watch: {
url(iNew) {
this.$set(this.tableConfig, 'url', iNew)
@@ -446,39 +423,56 @@ export default {
}
},
mounted() {
this.setActions()
if (this.columns.length > 0) {
this.tableConfig.columns = this.columns
}
if (this.otherActions) {
const actionColumn = this.tableConfig.columns[this.tableConfig.columns.length - 1]
for (const item of this.otherActions) {
actionColumn.formatterArgs.extraActions.push(item)
}
}
if (this.hasDeleteAction) {
this.tableConfig.columnsMeta.actions.formatterArgs.extraActions.push(
{
name: 'Delete',
title: this.$t('Delete'),
can: this.$hasPerm('accounts.delete_account'),
type: 'primary',
callback: ({ row }) => {
const msg = this.$t('AccountDeleteConfirmMsg')
this.$confirm(msg, this.$tc('Info'), {
type: 'warning',
confirmButtonClass: 'el-button--danger',
beforeClose: async(action, instance, done) => {
if (action !== 'confirm') return done()
this.$axios.delete(`/api/v1/accounts/accounts/${row.id}/`).then(() => {
done()
this.$refs.ListTable.reloadTable()
this.$message.success(this.$tc('DeleteSuccessMsg'))
})
}
})
}
}
)
}
},
activated() {
// 由于组件嵌套较深,有可能导致 Error in activated hook: "TypeError: Cannot read properties of undefined (reading 'getList')" 的问题
if (this.tabDeactivated) {
setTimeout(() => this.refresh(), 300)
}
},
deactivated() {
this.tabDeactivated = true
setTimeout(() => {
this.refresh()
}, 300)
},
methods: {
setActions() {
if (this.columns.length > 0) {
this.tableConfig.columns = this.columns
}
if (this.otherActions) {
const actionColumn = this.tableConfig.columns[this.tableConfig.columns.length - 1]
for (const item of this.otherActions) {
actionColumn.formatterArgs.extraActions.push(item)
}
}
},
onUpdateAuthDone(account) {
Object.assign(this.account, account)
},
addAccountSuccess() {
// Reflect.deleteProperty(this.$route.query, 'flag')
this.isUpdateAccount = false
this.$refs.ListTable.reloadTable()
},
async getAssetDetail() {
const { query: { asset } } = this.$route
const { query: { asset }} = this.$route
if (asset) {
this.iAsset = await this.$axios.get(`/api/v1/assets/assets/${asset}/`)
}
@@ -513,7 +507,7 @@ export default {
}
</script>
<style lang="scss" scoped>
<style lang='scss' scoped>
.cell a {
color: var(--color-info);
}

View File

@@ -4,7 +4,7 @@
<script>
import { GenericListTableDialog } from '@/layout/components'
import { SecretViewerFormatter } from '@/components/Table/TableFormatters'
import { ShowKeyCopyFormatter } from '@/components/Table/TableFormatters'
export default {
components: {
@@ -33,7 +33,7 @@ export default {
columnsMeta: {
secret: {
label: this.$t('Password'),
formatter: SecretViewerFormatter,
formatter: ShowKeyCopyFormatter,
formatterArgs: {
hasDownload: false,
name: this.account.name

View File

@@ -12,7 +12,7 @@
<script>
import Dialog from '@/components/Dialog/index.vue'
import { openTaskPage } from '@/utils/jms/index'
import { openTaskPage } from '@/utils/jms'
export default {
name: 'RemoveAccount',

View File

@@ -1,36 +1,44 @@
<template>
<Dialog
:destroy-on-close="true"
:show-buttons="false"
:title="$tc('UpdateAssetUserToken')"
:visible.sync="iVisible"
width="800px"
:visible.sync="visible"
width="50"
@cancel="handleCancel()"
@confirm="handleConfirm()"
v-on="$listeners"
>
<AutoDataForm
:fields="fields"
:fields-meta="fieldsMeta"
:form="init"
:has-reset="false"
:has-save-continue="false"
:url="''"
method="patch"
@submit="handleConfirm"
/>
<el-form label-position="right" label-width="90px">
<el-form-item :label="$tc('Name')">
<el-input v-model="account['asset_name']" readonly />
</el-form-item>
<el-form-item :label="$tc('Username')">
<el-input v-model="account['username']" readonly />
</el-form-item>
<el-form-item :label="$tc('Password')">
<UpdateToken v-model="authInfo.password" />
</el-form-item>
<el-form-item :label="$tc('SSHSecretKey')">
<UploadKey @input="getFile" />
</el-form-item>
<el-form-item :label="$tc('Passphrase')">
<UpdateToken v-model="authInfo.passphrase" />
</el-form-item>
</el-form>
</Dialog>
</template>
<script>
import Dialog from '@/components/Dialog/index.vue'
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
import { encryptPassword } from '@/utils/secure'
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
import { UpdateToken, UploadKey } from '@/components/Form/FormFields'
import { encryptPassword } from '@/utils/crypto'
export default {
name: 'UpdateSecretInfo',
components: {
AutoDataForm,
Dialog
Dialog,
UploadKey,
UpdateToken
},
props: {
account: {
@@ -43,59 +51,49 @@ export default {
}
},
data() {
const accountMeta = accountFieldsMeta(this)
return {
fields: [
'name', 'secret_type', 'password', 'ssh_key', 'token',
'access_key', 'passphrase', 'api_key'
],
fieldsMeta: {
...accountMeta,
name: {
...accountMeta.name,
readonly: true
},
secret_type: {
hidden: () => true
}
},
init: {
...this.account
}
}
},
computed: {
iVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
secretInfo: {
password: '',
private_key: '',
passphrase: ''
}
}
},
methods: {
handleConfirm(form) {
const secretType = this.account.secret_type.value
const data = {
secret: encryptPassword(form[secretType])
handleConfirm() {
const data = {}
if (this.secretInfo.password !== '') {
data.password = encryptPassword(this.secretInfo.password)
}
if (this.secretInfo.private_key !== '') {
data.private_key = encryptPassword(this.secretInfo.private_key)
if (this.secretInfo.passphrase) data.passphrase = this.secretInfo.passphrase
}
this.$axios.patch(
`/api/v1/accounts/accounts/${this.account.id}/`,
data,
{ disableFlashErrorMsg: true }
).then(res => {
this.authInfo = { password: '', private_key: '' }
this.$message.success(this.$tc('UpdateSuccessMsg'))
this.iVisible = false
this.$emit('updateAuthDone', res)
this.$emit('update:visible', false)
}).catch(err => {
const errMsg = Object.values(err.response.data).join(', ')
this.$message.error(this.$tc('UpdateErrorMsg') + ' ' + errMsg)
this.iVisible = false
this.$emit('update:visible', true)
})
},
handleCancel() {
this.$emit('update:visible', false)
},
getFile(file) {
this.secretInfo.private_key = file
}
}
}
</script>
<style scoped>
</style>

View File

@@ -18,7 +18,7 @@
<span>{{ account['username'] }}</span>
</el-form-item>
<el-form-item :label="secretTypeLabel">
<SecretViewerFormatter
<ShowKeyCopyFormatter
:cell-value="secretInfo.secret"
:col="{ formatterArgs: {
name: account['name'],
@@ -60,15 +60,15 @@
<script>
import Dialog from '@/components/Dialog/index.vue'
import PasswordHistoryDialog from './PasswordHistoryDialog.vue'
import { SecretViewerFormatter } from '@/components/Table/TableFormatters'
import { encryptPassword } from '@/utils/secure'
import { ShowKeyCopyFormatter } from '@/components/Table/TableFormatters'
import { encryptPassword } from '@/utils/crypto'
export default {
name: 'ShowSecretInfo',
components: {
Dialog,
PasswordHistoryDialog,
SecretViewerFormatter
ShowKeyCopyFormatter
},
props: {
account: {

View File

@@ -1,5 +1,4 @@
import { ChoicesFormatter } from '@/components/Table/TableFormatters'
import { openTaskPage } from '@/utils/jms/index'
export const connectivityMeta = {
formatter: ChoicesFormatter,
@@ -7,23 +6,11 @@ export const connectivityMeta = {
faChoices: {
'-': '',
ok: 'fa-check-circle',
err: 'fa-times-circle',
auth_err: 'fa-times-circle',
rdp_err: 'fa-times-circle',
password_err: 'fa-times-circle',
openssh_key_err: 'fa-times-circle',
ntlm_err: 'fa-times-circle',
create_temp_err: 'fa-times-circle'
err: 'fa-times-circle'
},
classChoices: {
ok: 'text-primary',
err: 'text-danger',
auth_err: 'text-danger',
rdp_err: 'text-danger',
password_err: 'text-danger',
openssh_key_err: 'text-danger',
ntlm_err: 'text-danger',
create_temp_err: 'text-danger'
err: 'text-danger'
},
getText({ cellValue }) {
if (cellValue?.value === '-' || cellValue?.value === 'unknown') {
@@ -35,316 +22,3 @@ export const connectivityMeta = {
},
width: '130px'
}
export function isDirectoryServiceAccount(account, vm) {
return vm.asset && vm.asset.id !== account.asset.id
}
export const accountOtherActions = vm => {
return [
{
name: 'View',
title: vm.$t('View'),
can: vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
order: 1,
callback: ({ row }) => {
// debugger
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
vm.account = row
vm.showViewSecretDialog = false
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'Update',
title: vm.$t('Edit'),
can: ({ row }) => {
return (
vm.$hasPerm('accounts.change_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
)
},
callback: ({ row }) => {
vm.isUpdateAccount = true
const data = {
...vm.asset,
...row.asset
}
vm.iAsset = data
vm.account = row
vm.addTemplate = false
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'UpdateSecret',
title: vm.$t('EditSecret'),
can: ({ row }) => {
return (
vm.$hasPerm('accounts.change_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
)
},
callback: ({ row }) => {
const data = {
...vm.asset,
...row.asset
}
vm.account = row
vm.iAsset = data
vm.showUpdateSecretDialog = false
vm.accountCreateUpdateTitle = vm.$t('UpdateAccount')
setTimeout(() => {
vm.showUpdateSecretDialog = true
})
}
},
{
name: 'Clone',
title: vm.$t('Duplicate'),
has: () => {
return !vm.asset
},
can: ({ row }) => {
return (
vm.$hasPerm('accounts.add_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
)
},
callback: ({ row }) => {
vm.account = {
name: `${row.name} - ${vm.$t('Duplicate').toLowerCase()}`,
username: `${row.username} - ${vm.$t('Duplicate').toLowerCase()}`,
payload: 'pam_account_clone'
}
vm.iAsset = vm.asset
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'Test',
title: vm.$t('VerifySecret'),
divided: true,
can: ({ row }) =>
!vm.$store.getters.currentOrgIsRoot &&
vm.$hasPerm('accounts.verify_account') &&
row.asset['auto_config'].ansible_enabled &&
row.asset['auto_config'].ping_enabled,
callback: ({ row }) => {
vm.$axios
.post(`/api/v1/accounts/accounts/tasks/`, { action: 'verify', accounts: [row.id] })
.then(res => {
openTaskPage(res['task'])
})
}
},
{
name: 'ClearSecret',
title: vm.$t('ClearSecret'),
can: ({ row }) => {
return vm.$hasPerm('accounts.change_account') && !isDirectoryServiceAccount(row, vm)
},
type: 'primary',
callback: ({ row }) => {
vm.$axios
.patch(`/api/v1/accounts/accounts/clear-secret/`, { account_ids: [row.id] })
.then(() => {
vm.$message.success(vm.$tc('ClearSuccessMsg'))
})
}
},
{
name: 'SecretHistory',
title: vm.$t('HistoryPassword'),
can: () => vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
callback: ({ row }) => {
vm.account = row
vm.currentAccountColumn = row
vm.showViewSecretDialog = false
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'CopyToOther',
title: vm.$t('CopyToAsset'),
type: 'primary',
divided: true,
can: ({ row }) => {
return (
vm.$hasPerm('accounts.add_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
)
},
has: () => {
return !vm.asset
},
callback: ({ row }) => {
vm.accountCreateUpdateTitle = vm.$t('CopyToOther')
vm.$route.query.flag = 'copy'
vm.iAsset = vm.asset
vm.account = row
vm.showAddDialog = true
}
},
{
name: 'MoveToOther',
title: vm.$t('MoveToAsset'),
type: 'primary',
can: ({ row }) => {
return (
vm.$hasPerm('accounts.delete_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
)
},
has: () => {
return !vm.asset
},
callback: ({ row }) => {
vm.accountCreateUpdateTitle = vm.$t('MoveToOther')
vm.$route.query.flag = 'move'
vm.iAsset = vm.asset
vm.account = row
vm.showAddDialog = true
}
}
]
}
export const accountQuickFilters = vm => [
{
label: vm.$t('Recent (7 days)'),
options: [
{
label: vm.$t('RecentlyDiscovered'),
filter: {
latest_discovery: '1'
}
},
{
label: vm.$t('RecentlyLoggedIn'),
filter: {
latest_accessed: '1'
}
},
{
label: vm.$t('RecentlyModified'),
filter: {
latest_updated: '1'
}
},
{
label: vm.$t('RecentlyChangedPassword'),
filter: {
latest_secret_changed: '1'
}
},
{
label: vm.$t('RecentPasswordChangeFailed'),
filter: {
latest_secret_change_failed: '1'
}
}
]
},
{
label: vm.$t('RiskyAccount'),
options: [
{
label: vm.$t('NoLoginLongTime'),
filter: {
long_time_no_login: 'true'
}
},
{
label: vm.$t('AddAccount'),
filter: {
risk: 'new_found'
}
},
{
label: vm.$t('WeakPassword'),
filter: {
risk: 'weak_password'
}
},
{
label: vm.$t('EmptyPassword'),
filter: {
has_secret: 'false'
}
},
{
label: vm.$t('LongTimePassword'),
filter: {
long_time_no_change_secret: 'true'
}
}
]
},
{
label: vm.$t('AccountType'),
options: [
{
label: vm.$t('All'),
filter: {
category: ''
}
},
{
label: vm.$t('Host'),
filter: {
category: 'host'
}
},
{
label: vm.$t('Database'),
filter: {
category: 'database'
}
},
{
label: vm.$t('Cloud'),
filter: {
category: 'cloud'
}
},
{
label: vm.$t('Device'),
filter: {
category: 'device'
}
},
{
label: 'Web',
filter: {
category: 'web'
}
},
{
label: vm.$t('Other'),
filter: {
category: 'custom'
}
}
]
}
]

View File

@@ -16,7 +16,7 @@
</template>
<script>
import IBox from '@/components/Common/IBox/index.vue'
import IBox from '@/components/IBox/index.vue'
import AssetSelect from '@/components/Apps/AssetSelect/index.vue'
export default {
@@ -48,13 +48,11 @@ export default {
},
performAdd: {
type: Function,
default: (objects, that) => {
}
default: (objects, that) => {}
},
onAddSuccess: {
type: Function,
default: (objects, that) => {
}
default: (objects, that) => {}
},
canSelect: {
type: Function,
@@ -64,7 +62,8 @@ export default {
}
},
data() {
return {}
return {
}
},
methods: {
addObjects() {
@@ -78,18 +77,18 @@ export default {
</script>
<style scoped>
b, strong {
font-weight: 700;
font-size: 13px;
}
b, strong {
font-weight: 700;
font-size: 13px;
}
tr td {
line-height: 1.42857;
padding: 8px;
vertical-align: top;
}
tr td {
line-height: 1.42857;
padding: 8px;
vertical-align: top;
}
tr.item td {
border-top: 1px solid #e7eaec;
}
tr.item td {
border-top: 1px solid #e7eaec;
}
</style>

View File

@@ -2,6 +2,7 @@
<Dialog
:close-on-click-modal="false"
:title="$tc('Assets')"
:disabled-status="!isLoaded"
custom-class="asset-select-dialog"
top="2vh"
v-bind="$attrs"
@@ -22,8 +23,8 @@
:url="baseUrl"
class="tree-table"
v-bind="$attrs"
@loaded="handleTableLoaded"
v-on="$listeners"
@loaded="handleTableLoaded"
/>
</Dialog>
</template>
@@ -82,7 +83,7 @@ export default {
},
{
prop: 'address',
label: this.$t('Address'),
label: this.$t('IpDomain'),
sortable: 'custom'
},
{

View File

@@ -56,10 +56,6 @@ export default {
treeSetting: {
type: Object,
default: () => ({})
},
disabled: {
type: [Boolean, Function],
default: false
}
},
data() {
@@ -75,7 +71,6 @@ export default {
dialogVisible: false,
initialValue: _.cloneDeep(iValue),
select2Config: {
disabled: this.disabled,
value: iValue,
multiple: true,
clearable: true,

View File

@@ -20,7 +20,7 @@
<script>
import TreeTable from '../../Table/TreeTable/index.vue'
import { setRouterQuery, setUrlParam } from '@/utils/common/index'
import { setRouterQuery, setUrlParam } from '@/utils/common'
import $ from '@/utils/jquery-vendor'
export default {
@@ -114,11 +114,6 @@ export default {
treeUrl: `${this.typeUrl}?assets=${showAssets ? '1' : '0'}&count_resource=${this.treeSetting.countResource || 'asset'}`,
callback: {
onSelected: (event, treeNode) => this.getAssetsUrl(treeNode)
},
edit: {
drag: {
isMove: false
}
}
}
}
@@ -147,9 +142,6 @@ export default {
treeSetting.showDelete = this.$hasPerm('assets.delete_node')
},
methods: {
reloadTable() {
this.$refs.TreeList.reloadTable()
},
setTreeUrlQuery() {
let str = ''
for (const key in this.treeUrlQuery) {

View File

@@ -3,7 +3,7 @@
</template>
<script>
import { DrawerListTable as ListTable } from '@/components'
import ListTable from '@/components/Table/ListTable/index.vue'
export default {
name: 'BlockedIPList',

View File

@@ -12,7 +12,7 @@
>
<el-form :model="secretInfo" class="password-form" label-position="right" label-width="100px">
<el-form-item :label="$tc('OldSecret')">
<SecretViewerFormatter
<ShowKeyCopyFormatter
:cell-value="secretInfo.old_secret"
:col="{ formatterArgs: {
name: 'old_secret'
@@ -20,7 +20,7 @@
/>
</el-form-item>
<el-form-item :label="$tc('NewSecret')">
<SecretViewerFormatter
<ShowKeyCopyFormatter
:cell-value="secretInfo.new_secret"
:col="{ formatterArgs: {
name: 'new_secret'
@@ -34,13 +34,13 @@
<script>
import Dialog from '@/components/Dialog/index.vue'
import { SecretViewerFormatter } from '@/components/Table/TableFormatters'
import { ShowKeyCopyFormatter } from '@/components/Table/TableFormatters'
export default {
name: 'RecordViewSecret',
components: {
Dialog,
SecretViewerFormatter
ShowKeyCopyFormatter
},
props: {
visible: {

View File

@@ -1,6 +1,6 @@
<template>
<div class="container">
<div v-if="hasPrompt" class="chat-action">
<div class="chat-action">
<Select2
v-model="select.value"
:disabled="isLoading || isSelectDisabled"
@@ -36,10 +36,6 @@ export default {
expanded: {
type: Boolean,
default: false
},
hasPrompt: {
type: Boolean,
default: true
}
},
data() {
@@ -50,7 +46,7 @@ export default {
url: '/api/v1/settings/chatai-prompts/',
value: '',
multiple: false,
placeholder: this.$t('Role'),
placeholder: this.$t('Prompt'),
ajax: {
transformOption: (item) => {
return { label: item.name, value: item.content }

View File

@@ -1,73 +1,42 @@
<template>
<div :class="{ 'user-role': isUserRole }" class="chat-item">
<div class="chart-item-container">
<div class="avatar">
<el-avatar
:src="isUserRole ? userUrl : chatUrl"
class="header-avatar"
/>
<div :class="{'user-role': isUserRole}" class="chat-item">
<div class="avatar">
<el-avatar :src="isUserRole ? userUrl : chatUrl" class="header-avatar" />
</div>
<div class="content">
<div class="operational">
<span class="date">
{{ $moment(item.message.create_time).format('YYYY-MM-DD HH:mm:ss') }}
</span>
</div>
<div class="content">
<div class="operational">
<div v-if="!item.message.is_reasoning" class="date">
{{
$moment(item.message.create_time).format("YYYY-MM-DD HH:mm:ss")
}}
</div>
<div v-else class="thinking-time">{{ $i18n.t('DeeplyThoughtAbout') }}</div>
<div class="message">
<div class="message-content">
<span v-if="isSystemError" class="error">
{{ item.message.content }}
</span>
<span v-else class="chat-text">
<MessageText :message="item.message" />
</span>
</div>
<div :class="item.reasoning ? 'reasoning' : 'message'">
<div class="message-content">
<div v-if="!item.reasoning">
<span v-if="isSystemError" class="error">
{{ item.message.content }}
</span>
<span v-else class="chat-text">
<MessageText :message="item.message" />
</span>
</div>
<div v-else class="thinking-wrapper">
<div class="thinking-content">
<!-- eslint-disable-next-line -->
<div class="divider"></div>
<p>
<MessageText :message="item.reasoning" @insert-code="handleInsertCode" />
</p>
</div>
<div class="thinking-result">
<span v-if="isServerError" class="error">
{{ isServerError }}
</span>
<MessageText :message="item.result" :is-terminal="isTerminal" @insert-code="handleInsertCode" /></div>
</div>
</div>
<div class="action">
<el-tooltip
v-if="isSystemError && isLoading"
:content="$tc('Reconnect')"
:open-delay="500"
placement="top"
>
<svg-icon icon-class="refresh" @click="onRefresh" />
</el-tooltip>
<el-dropdown v-else size="small" @command="handleCommand">
<span class="el-dropdown-link">
<i class="fa fa-ellipsis-v" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="i in dropdownOptions"
:key="i.action"
:command="i.action"
>
{{ i.label }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div class="action">
<el-tooltip
v-if="isSystemError && isLoading"
:content="$tc('Reconnect')"
:open-delay="500"
placement="top"
>
<svg-icon icon-class="refresh" @click="onRefresh" />
</el-tooltip>
<el-dropdown v-else size="small" @command="handleCommand">
<span class="el-dropdown-link">
<i class="fa fa-ellipsis-v" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="i in dropdownOptions" :key="i.action" :command="i.action">
{{ i.label }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</div>
@@ -76,10 +45,10 @@
<script>
import MessageText from './MessageText.vue'
import { mapGetters, mapState } from 'vuex'
import { copy } from '@/utils/common/index'
import { mapState } from 'vuex'
import { copy } from '@/utils/common'
import { useChat } from '../../useChat.js'
import { reconnect } from '@/utils/request'
import { reconnect } from '@/utils/socket'
const { setLoading, removeLoadingMessageInChat } = useChat()
@@ -92,14 +61,11 @@ export default {
type: Object,
default: () => {
}
},
isTerminal: {
type: Boolean,
default: false
}
},
data() {
return {
chatUrl: require('@/assets/img/chat.png'),
userUrl: '/api/v1/settings/logo/',
dropdownOptions: [
{
@@ -113,26 +79,11 @@ export default {
...mapState({
isLoading: state => state.chat.loading
}),
...mapGetters([
'publicSettings'
]),
isUserRole() {
return this.item.message?.role === 'user'
},
isSystemError() {
return (
this.item.type === 'error' && this.item?.role === 'assistant'
)
},
isServerError() {
return (this.item.type === 'finish' && this.item.result.content === '')
? this.$i18n.t('ServerBusyRetry')
: ''
},
chatUrl() {
return this.publicSettings.CHAT_AI_TYPE === 'gpt'
? require('@/assets/img/chat.png')
: require('@/assets/img/deepSeek.png')
return this.item.type === 'error' && this.item.message?.role === 'assistant'
}
},
methods: {
@@ -143,11 +94,8 @@ export default {
},
handleCommand(value) {
if (value === 'copy') {
copy(this.item.result.content)
copy(this.item.message.content)
}
},
handleInsertCode(code) {
this.$emit('insert-code', code)
}
}
}
@@ -156,160 +104,101 @@ export default {
<style lang="scss" scoped>
.chat-item {
display: flex;
padding: 0.5rem;
.chart-item-container {
display: flex;
gap: 0.5rem;
.avatar {
width: 24px;
height: 24px;
margin-top: 2px;
.header-avatar {
width: 100%;
height: 100%;
border-radius: 50%;
&::v-deep img {
background-color: #fff;
}
}
}
.content {
display: flex;
flex-direction: column;
// gap: 0.5rem;
overflow: hidden;
.operational {
display: flex;
justify-content: space-between;
overflow: hidden;
.date {
padding-top: 5px;
}
.thinking-time {
width: 6rem;
display: flex;
justify-content: center;
padding: 5px 10px;
border-radius: 0.5rem;
background-color: #f5f5f5;
}
.copy {
float: right;
cursor: pointer;
}
}
.reasoning {
display: flex;
gap: 0.5rem;
align-items: flex-end;
.message-content .thinking-wrapper {
display: flex;
flex-direction: column;
gap: 0.5rem;
.thinking-content {
position: relative;
color: #8b8b8b;
.divider {
position: absolute;
top: 0;
left: 0;
height: 100%;
border-left: 2px solid #e5e5e5;
}
p {
margin: unset;
padding-left: 0.5rem;
::v-deep p {
color: #8b8b8b;
}
}
}
}
}
.message {
display: -webkit-box;
.message-content {
flex: 1;
padding: 6px 10px;
border-radius: 2px 12px 12px;
background-color: #f0f1f5;
}
.action {
.svg-icon {
transform: translateY(50%);
margin-left: 3px;
cursor: pointer;
}
.el-dropdown {
height: 32px;
line-height: 37px;
font-size: 13px;
.el-dropdown-link {
i {
padding: 4px 5px;
font-size: 15px;
color: #8d9091;
&:hover {
color: #7b8085;
}
}
}
}
}
.error {
color: red;
}
}
}
}
padding: 16px 14px 0;
&:last-child {
padding-bottom: 16px;
}
&.user-role {
flex-direction: row-reverse;
.avatar {
width: 22px;
height: 22px;
margin-top: 2px;
.chart-item-container {
.header-avatar {
width: 100%;
height: 100%;
&::v-deep img {
background-color: #e5e5e7;
}
}
}
.content {
margin-left: 6px;
overflow: hidden;
.operational {
display: flex;
justify-content: space-between;
overflow: hidden;
.copy {
float: right;
cursor: pointer;
}
}
.message {
display: -webkit-box;
.message-content {
flex: 1;
padding: 6px 10px;
border-radius: 2px 12px 12px;
background-color: #f0f1f5;
}
.action {
.svg-icon {
transform: translateY(50%);
margin-left: 3px;
cursor: pointer;
}
.el-dropdown {
height: 32px;
line-height: 37px;
font-size: 13px;
.el-dropdown-link {
i {
padding: 4px 5px;
font-size: 15px;
color: #8d9091;
&:hover {
color: #7b8085
}
}
}
}
}
.error {
color: red;
}
}
}
}
.user-role {
flex-direction: row-reverse;
.content {
margin-right: 10px;
.operational {
flex-direction: row-reverse;
}
.content {
margin-right: 10px;
.message {
flex-direction: row-reverse;
.operational {
flex-direction: row-reverse;
}
.message {
flex-direction: row-reverse;
.message-content {
background-color: var(--menu-hover);
border-radius: 12px 2px 12px 12px;
}
.message-content {
background-color: var(--menu-hover);
border-radius: 12px 2px 12px 12px;
}
}
}

View File

@@ -17,7 +17,7 @@ import mdKatex from '@traptitech/markdown-it-katex'
import mila from 'markdown-it-link-attributes'
import hljs from 'highlight.js'
import 'highlight.js/styles/atom-one-dark.css'
import { copy } from '@/utils/common/index'
import { copy } from '@/utils/common'
export default {
props: {
@@ -25,10 +25,6 @@ export default {
type: Object,
default: () => {
}
},
isTerminal: {
type: Boolean,
default: false
}
},
data() {
@@ -49,10 +45,10 @@ export default {
this.init()
},
updated() {
this.addEvents()
this.addCopyEvents()
},
destroyed() {
this.removeEvents()
this.removeCopyEvents()
},
methods: {
init() {
@@ -69,68 +65,30 @@ export default {
return vm.highlightBlock(hljs.highlightAuto(code).value, '')
}
})
this.markdown.use(mila, { attrs: { target: '_blank', rel: 'noopener', class: 'link-style' } })
this.markdown.use(mila, { attrs: { target: '_blank', rel: 'noopener', class: 'link-style' }})
this.markdown.use(mdKatex, { blockClass: 'katexmath-block rounded-md', errorColor: ' #cc0000' })
},
highlightBlock(str, lang) {
let insertSpanHtml = `<span class="code-block-header__insert">${this.$t('Insert')}</span>`
if (!this.isTerminal) {
insertSpanHtml = ''
}
return `<pre class="code-block-wrapper">
<div class="code-block-header">
<span class="code-block-header__lang">${lang}</span>
<span class="code-block-header__actions">
${insertSpanHtml}
<span class="code-block-header__copy">${this.$t('Copy')}</span>
</span>
</div>
<code class="hljs code-block-body ${lang}">${str}</code></pre>`
return `<pre class="code-block-wrapper"><div class="code-block-header"><span class="code-block-header__lang">${lang}</span><span class="code-block-header__copy">${'Copy'}</span></div><code class="hljs code-block-body ${lang}">${str}</code></pre>`
},
addEvents() {
this.addBtnClickEvents('.code-block-header__copy', this.handlerClickCopy)
this.addBtnClickEvents('.code-block-header__insert', this.handlerClickInsert)
},
handlerClickCopy(event) {
const wrapper = event.target.closest('.code-block-wrapper')
if (wrapper) {
// 查找里面的 code 元素
const codeElement = wrapper.querySelector('code.code-block-body')
if (codeElement) {
const codeText = codeElement.textContent
copy(codeText)
}
}
},
handlerClickInsert(event) {
const wrapper = event.target.closest('.code-block-wrapper')
if (wrapper) {
// 查找里面的 code 元素
const codeElement = wrapper.querySelector('code.code-block-body')
if (codeElement) {
const codeText = codeElement.textContent
this.$emit('insert-code', codeText)
}
}
},
addBtnClickEvents(selector, callback) {
const buttons = this.$refs.textRef.querySelectorAll(selector)
buttons.forEach((btn) => {
btn.addEventListener('click', callback)
})
},
removeBtnClickEvent(selector) {
const buttons = this.$refs.textRef.querySelectorAll(selector)
buttons.forEach((btn) => {
btn.removeEventListener('click', () => {
addCopyEvents() {
const copyBtn = document.querySelectorAll('.code-block-header__copy')
copyBtn.forEach((btn) => {
btn.addEventListener('click', () => {
const code = btn.parentElement?.nextElementSibling?.textContent
if (code) {
copy(code)
}
})
})
},
removeEvents() {
removeCopyEvents() {
if (this.$refs.textRef) {
this.removeBtnClickEvent('.code-block-header__copy')
this.addBtnClickEvents('.code-block-header__insert')
const copyBtn = this.$refs.textRef.querySelectorAll('.code-block-header__copy')
copyBtn.forEach((btn) => {
btn.removeEventListener('click', () => {
})
})
}
}
}
@@ -140,7 +98,6 @@ export default {
<style lang="scss" scoped>
.markdown-body {
font-size: 13px;
max-width: 300px;;
&::v-deep p {
margin-bottom: 0 !important;
@@ -158,46 +115,26 @@ export default {
&::v-deep .code-block-wrapper {
background: #1F2329;
padding: 0;
padding: 2px 6px;
margin: 5px 0;
display: flex;
flex-direction: column;
overflow: hidden;
.code-block-body {
padding: 5px 10px;
padding: 5px 10px 0;
}
;
.code-block-header {
margin-bottom: 4px;
overflow: hidden;
background: #353946;
color: #c2d1e1;
display: flex;
justify-content: space-between;
align-items: center;
padding: 4px 8px;
width: 100%;
box-sizing: border-box;
.code-block-header__actions {
display: flex;
gap: 8px;
.code-block-header__copy {
float: right;
cursor: pointer;
.code-block-header__copy {
cursor: pointer;
&:hover {
color: #6e747b;
}
}
.code-block-header__insert {
cursor: pointer;
&:hover {
color: #6e747b;
}
&:hover {
color: #6e747b;
}
}
}
@@ -241,7 +178,6 @@ export default {
0% {
opacity: 1;
}
100% {
opacity: 0;
}

View File

@@ -17,7 +17,7 @@
</div>
</div>
</div>
<ChatMessage v-for="(item, index) in activeChat.chats" :key="index" :item="item" :is-terminal="isTerminal" @insert-code="insertCode" />
<ChatMessage v-for="(item, index) in activeChat.chats" :key="index" :item="item" />
</div>
<div class="input-box">
<el-button
@@ -28,7 +28,7 @@
size="small"
@click="onStopHandle"
>{{ $tc('Stop') }}</el-button>
<ChatInput ref="chatInput" :expanded="expanded" :has-prompt="!isTerminal" @send="onSendHandle" @select-prompt="onSelectPromptHandle" />
<ChatInput ref="chatInput" :expanded="expanded" @send="onSendHandle" @select-prompt="onSelectPromptHandle" />
</div>
</div>
</template>
@@ -37,7 +37,7 @@
import ChatInput from './ChatInput.vue'
import ChatMessage from './ChatMessage.vue'
import { mapState } from 'vuex'
import { closeWebSocket, createWebSocket, onSend, ws } from '@/utils/request'
import { closeWebSocket, createWebSocket, onSend, ws } from '@/utils/socket'
import { getInputFocus, useChat } from '../../useChat.js'
const {
@@ -68,10 +68,7 @@ export default {
prompt: '',
conversationId: '',
showIntroduction: false,
introduction: [],
terminalContext: null,
isTerminal: false,
sessionChat: {}
introduction: []
}
},
computed: {
@@ -103,9 +100,6 @@ export default {
this.showIntroduction = true
this.conversationId = ''
this.$refs.chatInput.select.value = ''
if (this.terminalContext) {
this.prompt = this.terminalContext.content || ''
}
const chat = {
message: {
content: this.$t('ChatHello'),
@@ -129,17 +123,7 @@ export default {
setLoading(true)
removeLoadingMessageInChat()
this.conversationId = data.id
const newFragment = {
message: { id: data.message.id, is_reasoning: data.message.is_reasoning },
reasoning: { content: data.message.is_reasoning ? data.message.content : '' },
result: { content: data.message.is_reasoning ? '' : data.message.content },
role: data.message.role,
type: data.message.type,
create_time: data.message.create_time
}
updateChaMessageContentById(data.message.id, newFragment)
updateChaMessageContentById(data.message.id, data)
}
if (data.message?.type === 'finish') {
setLoading(false)
@@ -156,32 +140,6 @@ export default {
addMessageToActiveChat(data)
setLoading(true)
},
onTerminalContext(terminalContext) {
const originSessionId = this.terminalContext?.sessionId
const newSessionId = terminalContext.sessionId || ''
if (originSessionId) {
this.saveSessionChat(originSessionId)
}
this.terminalContext = terminalContext
this.isTerminal = true
this.prompt = terminalContext.content || ''
if (originSessionId !== newSessionId) {
if (this.sessionChat[newSessionId]) {
clearChats()
for (const chat of this.sessionChat[newSessionId]) {
addChatMessageById(chat)
}
} else {
this.onNewChat()
}
}
},
saveSessionChat(sessionId) {
if (this.terminalContext) {
this.sessionChat[sessionId] = JSON.parse(JSON.stringify(this.activeChat.chats))
}
},
onSendHandle(value) {
this.showIntroduction = false
this.socket = ws || {}
@@ -236,15 +194,6 @@ export default {
sendIntroduction(item) {
this.showIntroduction = false
this.onSendHandle(item.content)
},
insertCode(code) {
this.sendPostMessage({
name: 'INSERT_TERMINAL_CODE',
data: code.replace(/^[\s\r\n]+|[\s\r\n]+$/g, '')
})
},
sendPostMessage(data) {
window.parent.postMessage(data)
}
}
}

View File

@@ -9,15 +9,10 @@
<div v-if="expanded" class="close-sidebar">
<i class="fa fa-compress" style="font-weight: 200" @click="$emit('compress')" />
</div>
<div class="close-sidebar">
<i class="fa fa-arrows-alt" style="font-weight: 200" @click="openWebsite()" />
</div>
</div>
</template>
<script>
import { BASE_URL } from '@/utils/common/index'
export default {
props: {
active: {
@@ -46,36 +41,6 @@ export default {
},
handleExpand() {
this.$emit('expand-full')
},
async openWebsite() {
let url = `${BASE_URL}/?_=${Date.now()}`
if (process.env.NODE_ENV !== 'production') {
url = url.replace('9528', '5173')
}
const res = await this.$axios.get('/api/v1/accounts/accounts/chat/')
const data = await this.$axios.post(
'/api/v1/authentication/admin-connection-token/?oid=00000000-0000-0000-0000-000000000004',
{
asset: res?.asset.id,
account: res?.id,
protocol: 'chat',
input_username: res?.username,
input_secret: '',
connect_method: 'web',
connect_options: {
charset: 'default',
disableautohash: false,
reusable: false,
token_reusable: false
}
}
)
const token = data?.id
const newUrl = new URL(url)
newUrl.searchParams.set('token', token)
window.open(newUrl.toString(), '_blank')
return url
}
}
}

View File

@@ -1,6 +1,5 @@
<template>
<DrawerPanel
v-if="visible"
ref="drawer"
:default-show-panel="!!defaultShowPanel"
:expanded="expanded"
@@ -46,12 +45,9 @@
import Sidebar from './components/Sidebar/index.vue'
import Chat from './components/ChitChat/index.vue'
import { getInputFocus } from './useChat.js'
import { ws } from '@/utils/request'
import { ws } from '@/utils/socket'
import DrawerPanel from '@/components/Apps/DrawerPanel/index.vue'
import { ObjectLocalStorage } from '@/utils/common'
import { mapGetters } from 'vuex'
const aiPannelLocalStorage = new ObjectLocalStorage('ai_panel_settings')
export default {
components: {
DrawerPanel,
@@ -76,68 +72,23 @@ export default {
},
data() {
return {
visible: false,
active: 'chat',
robotUrl: require('@/assets/img/robot-assistant.png'),
height: '400px',
expanded: false,
clientOffset: {},
currentTerminalContent: {}
clientOffset: {}
}
},
computed: {
...mapGetters([
'publicSettings'
])
},
watch: {
'publicSettings.CHAT_AI_METHOD': {
handler(newVal) {
this.visible = newVal === 'api'
}
}
},
mounted() {
this.handleStartChat()
this.handlePostMessage()
},
methods: {
handleStartChat() {
if (this.publicSettings.CHAT_AI_METHOD === 'api') {
this.visible = true
const expanded = aiPannelLocalStorage.get('expanded')
this.updateExpandedState(expanded)
this.handlePostMessage()
} else if (this.publicSettings.CHAT_AI_METHOD === 'embed') {
const embedScriptId = 'chat-ai-embed-id'
if (document.getElementById(embedScriptId)) {
return
}
const script = document.createElement('script')
script.id = embedScriptId
script.src = this.publicSettings.CHAT_AI_EMBED_URL
script.async = true
script.onload = () => {
const loadEvent = new Event('load', { bubbles: false, cancelable: false })
window.dispatchEvent(loadEvent)
}
document.body.appendChild(script)
}
},
handlePostMessage() {
window.addEventListener('message', (event) => {
if (event.data === 'show-chat-panel') {
this.$refs.drawer.show = true
this.initWebSocket()
return
}
const msg = event.data
switch (msg.name) {
case 'current_terminal_content':
// {content: '...', terminalId: '',sessionId: '',viewId: '',viewName: ''}
this.$log.debug('current_terminal_content', msg)
this.currentTerminalContent = msg.data
this.$refs.component?.onTerminalContext(msg.data)
break
}
})
},
@@ -145,11 +96,6 @@ export default {
this.$refs.drawer.handleHeaderMoveDown(event)
},
handleMouseMoveUp(event) {
// Prevent the new chat button from triggering the header move up
const newButton = event.target.closest('.new')
if (newButton) {
return
}
this.$refs.drawer.handleHeaderMoveUp(event)
},
initWebSocket() {
@@ -161,20 +107,12 @@ export default {
this.$refs.drawer.show = false
},
expandFull() {
this.updateExpandedState(true)
this.save_pannel_settings()
this.height = '100%'
this.expanded = true
},
compress() {
this.updateExpandedState(false)
this.save_pannel_settings()
},
save_pannel_settings() {
aiPannelLocalStorage.set('expanded', this.expanded)
console.log('AI panel settings saved:', this.expanded)
},
updateExpandedState(expanded) {
this.expanded = expanded
this.height = expanded ? '100%' : '400px'
this.height = '400px'
this.expanded = false
},
onNewChat() {
this.active = 'chat'

View File

@@ -1,5 +1,5 @@
import store from '@/store'
import { pageScroll } from '@/utils/common/index'
import { pageScroll } from '@/utils/common'
export const getInputFocus = () => {
const dom = document.querySelector('.chat-input .el-textarea__inner')
@@ -9,11 +9,11 @@ export const getInputFocus = () => {
export function useChat() {
const chatStore = {}
const setLoading = loading => {
const setLoading = (loading) => {
store.commit('chat/setLoading', loading)
}
const onNewChat = name => {
const onNewChat = (name) => {
const data = {
name: name || `new chat`,
id: 1,
@@ -27,7 +27,7 @@ export function useChat() {
store.commit('chat/clearChats')
}
const addMessageToActiveChat = chat => {
const addMessageToActiveChat = (chat) => {
store.commit('chat/addMessageToActiveChat', chat)
}
@@ -35,7 +35,7 @@ export function useChat() {
store.commit('chat/removeLoadingMessageInChat')
}
const addChatMessageById = chat => {
const addChatMessageById = (chat) => {
store.commit('chat/addMessageToActiveChat', chat)
if (chat?.conversation_id) {
store.commit('chat/setActiveChatConversationId', chat.conversation_id)
@@ -54,7 +54,7 @@ export function useChat() {
addChatMessageById(temporaryChat)
}
const newChatAndAddMessageById = chat => {
const newChatAndAddMessageById = (chat) => {
onNewChat(chat.message.content)
addChatMessageById(chat)
}

View File

@@ -34,7 +34,7 @@
<script>
import Dialog from '@/components/Dialog/index.vue'
import { openTaskPage } from '@/utils/jms/index'
import { openTaskPage } from '@/utils/jms'
export default {
name: 'GatewayDialog',

View File

@@ -7,7 +7,7 @@
/>
</template>
<script>
<script type="text/jsx">
import AssetTreeTable from '@/components/Apps/AssetTreeTable'
import { AccountInfoFormatter, DetailFormatter } from '@/components/Table/TableFormatters'
import { connectivityMeta } from '@/components/Apps/AccountListTable/const'
@@ -85,10 +85,9 @@ export default {
hasTree: true,
columnsExtra: ['view_account'],
columnsExclude: ['spec_info'],
columns: ['id', 'name', 'address', 'comment', 'labels', 'connectivity', 'platform', 'view_account', 'actions'],
columnsShow: {
min: ['name', 'address', 'accounts'],
default: ['name', 'address', 'platform', 'view_account', 'actions']
default: ['name', 'address', 'platform', 'connectivity', 'view_account', 'actions']
},
columnsMeta: {
name: {

View File

@@ -1,59 +0,0 @@
<template>
<ListTable ref="ListTable" :header-actions="headerActions" :table-config="tableConfig" :create-drawer="createDrawer" />
</template>
<script>
import { DrawerListTable as ListTable } from '@/components'
export default {
name: 'LeakPasswordList',
components: {
ListTable
},
props: {
object: {
type: Object,
required: false,
default: () => ({})
}
},
data() {
return {
createDrawer: () => import('@/components/Apps/LeakPasswords/LeakPasswordsCreateUpdate.vue'),
tableConfig: {
url: '/api/v1/settings/leak-passwords/',
columns: [
'password'
],
columnsMeta: {
actions: {
formatterArgs: {
hasClone: false,
canDelete: this.$hasPerm('settings.change_security'),
canUpdate: this.$hasPerm('settings.change_security')
}
}
}
},
headerActions: {
hasExport: false,
hasImport: false,
hasCreate: true,
hasSearch: true,
hasRefresh: true,
hasBulkDelete: true,
hasBulkUpdate: false,
hasLeftActions: true,
hasRightActions: true,
canCreate: this.$hasPerm('settings.change_security'),
canBulkDelete: this.$hasPerm('settings.change_security')
}
}
}
}
</script>
<style lang='less' scoped>
</style>

View File

@@ -1,41 +0,0 @@
<template>
<div v-loading="loading">
<GenericCreateUpdatePage
v-if="!loading"
class="user-create-update"
v-bind="$data"
:title="null"
v-on="$listeners"
/>
</div>
</template>
<script>
import { GenericCreateUpdatePage } from '@/layout/components'
export default {
name: 'LeakPasswordsCreateUpdate',
components: {
GenericCreateUpdatePage
},
data() {
return {
loading: true,
fields: [
[this.$t('Basic'), ['password']]
],
encryptedFields: [],
url: '/api/v1/settings/leak-passwords/'
}
},
async mounted() {
this.loading = false
},
methods: {}
}
</script>
<style lang="scss" scoped>
</style>

View File

@@ -1,76 +0,0 @@
<template>
<div>
<div>
<el-button
size="mini"
type="primary"
@click="onOpenDialog"
>
{{ $tc('View') }}
</el-button>
</div>
<Dialog
:destroy-on-close="true"
:show-cancel="false"
:show-confirm="false"
:title="title"
:visible.sync="visible"
v-bind="$attrs"
width="40%"
v-on="$listeners"
>
<LeakPasswordList />
</Dialog>
</div>
</template>
<script>
import { Dialog } from '@/components'
import LeakPasswordList from '@/components/Apps/LeakPasswords/LeakPasswordList.vue'
export default {
componentName: 'LeakPasswords',
components: {
LeakPasswordList,
Dialog
},
props: {
value: {
type: Object,
default: () => ({})
},
title: {
type: String,
default: function() {
return this.$t('LeakPasswordList')
}
},
url: {
type: String,
default: `/api/v1/settings/leak-passwords/`
}
},
data() {
return {
visible: false,
form: this.value,
config: {
url: this.url,
hasSaveContinue: false,
hasButtons: true,
fields: [],
fieldsMeta: {}
}
}
},
methods: {
onOpenDialog() {
this.visible = true
}
}
}
</script>
<style scoped>
</style>

View File

@@ -1,26 +1,24 @@
<template>
<TwoCol>
<ListTable v-bind="config" />
</TwoCol>
<el-row :gutter="24">
<el-col :md="20" :sm="22">
<ListTable v-bind="config" />
</el-col>
</el-row>
</template>
<script>
import { DrawerListTable as ListTable } from '@/components'
import { toM2MJsonParams } from '@/utils/jms/index'
import { DetailFormatter } from '@/components/Table/TableFormatters'
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
import ListTable from '@/components/Table/ListTable/index.vue'
import { toM2MJsonParams } from '@/utils/jms'
export default {
name: 'AssetJsonTab',
components: {
TwoCol,
ListTable
},
props: {
object: {
type: Object,
default: () => {
}
default: () => {}
}
},
data() {
@@ -34,18 +32,21 @@ export default {
},
tableConfig: {
url: `/api/v1/assets/assets/?${key}=${value}`,
columns: ['name', 'address', 'platform', 'type', 'is_active'],
columnsShow: {
min: ['name', 'address'],
default: ['name', 'address', 'platform']
},
columns: ['name', 'address', 'platform',
'type', 'is_active'
],
columnsMeta: {
name: {
label: this.$t('Asset'),
formatter: DetailFormatter,
formatterArgs: {
getRoute: ({ row }) => {
return { name: 'AssetDetail', params: { id: row.id } }
formatter: (row) => {
const to = {
name: 'AssetDetail',
params: { id: row.id }
}
if (this.$hasPerm('assets.view_asset')) {
return <router-link to={to} class='text-link'>{row.name}</router-link>
} else {
return <span>{row.name}</span>
}
}
},
@@ -64,3 +65,7 @@ export default {
}
}
</script>
<style scoped>
</style>

View File

@@ -1,19 +1,18 @@
<template>
<TwoCol>
<ListTable v-bind="config" />
</TwoCol>
<el-row :gutter="24">
<el-col :md="20" :sm="22">
<ListTable v-bind="config" />
</el-col>
</el-row>
</template>
<script>
import { DrawerListTable as ListTable } from '@/components'
import { toM2MJsonParams } from '@/utils/jms/index'
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
import { DetailFormatter } from '@/components/Table/TableFormatters'
import ListTable from '@/components/Table/ListTable/index.vue'
import { toM2MJsonParams } from '@/utils/jms'
export default {
name: 'User',
components: {
TwoCol,
ListTable
},
props: {
@@ -35,23 +34,22 @@ export default {
tableConfig: {
url: `/api/v1/users/users/?${key}=${value}`,
columns: [
'name', 'username', 'email', 'groups', 'system_roles',
'name', 'username', 'groups', 'system_roles',
'org_roles', 'source', 'is_valid'
],
columnsShow: {
min: ['name', 'username'],
default: ['name', 'username', 'email']
},
columnsMeta: {
name: {
label: this.$t('Name'),
formatter: DetailFormatter,
formatterArgs: {
getRoute: ({ row }) => {
return {
name: 'UserDetail',
params: { id: row.id }
}
width: 85,
formatter: (row) => {
const to = {
name: 'UserDetail',
params: { id: row.id }
}
if (this.$hasPerm('users.view_user')) {
return <router-link to={to} class='text-link'>{row.name}</router-link>
} else {
return <span>{row.name}</span>
}
}
},
@@ -89,3 +87,7 @@ export default {
}
}
</script>
<style scoped>
</style>

View File

@@ -1,43 +1,43 @@
<template>
<div>
<TwoCol>
<IBox :title="title" class="block" v-bind="$attrs">
<el-timeline>
<el-timeline-item
v-for="(activity, index) in activities"
:key="index"
:size="activity.size"
:timestamp="activity.timestamp"
:type="activity.type"
placement="bottom"
>
{{ activity.content }}
<el-link
v-if="activity['detail_url']"
type="primary"
@click.native="onClick(activity)"
<el-row :gutter="20">
<el-col :md="16" :sm="24">
<IBox :title="title" class="block" v-bind="$attrs">
<el-timeline>
<el-timeline-item
v-for="(activity, index) in activities"
:key="index"
:size="activity.size"
:timestamp="activity.timestamp"
:type="activity.type"
placement="bottom"
>
{{ $tc('Detail') }}
</el-link>
</el-timeline-item>
</el-timeline>
</IBox>
</TwoCol>
{{ activity.content }}
<el-link
v-if="activity['detail_url']"
type="primary"
@click.native="onClick(activity)"
>
{{ $tc('Detail') }}
</el-link>
</el-timeline-item>
</el-timeline>
</IBox>
</el-col>
</el-row>
<DiffDetail ref="DetailDialog" :title="$tc('OperateLog')" />
</div>
</template>
<script>
import IBox from '@/components/Common/IBox/index.vue'
import IBox from '@/components/IBox/index.vue'
import DiffDetail from '@/components/Dialog/DiffDetail.vue'
import { openTaskPage } from '@/utils/jms/index'
import { toSafeLocalDateStr } from '@/utils/common/time'
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
import { openTaskPage } from '@/utils/jms'
import { toSafeLocalDateStr } from '@/utils/time'
export default {
name: 'ResourceActivity',
components: {
TwoCol,
IBox,
DiffDetail
},

View File

@@ -49,74 +49,32 @@
</el-select>
</el-col>
</el-row>
<el-row v-if="!noCodeMFA.includes(subTypeSelected)" :gutter="24" style="margin: 0 auto;">
<el-col :md="24" :sm="24" style="display: flex; align-items: center; ">
<el-row :gutter="24" style="margin: 0 auto;">
<el-col :md="24" :sm="24" style="display: flex; align-items: center; margin-bottom: 20px;">
<el-input
v-model="secretValue"
:placeholder="inputPlaceholder"
:show-password="showPassword"
@keyup.enter.native="handleConfirm"
/>
<span v-if="subTypeSelected === 'sms' || subTypeSelected === 'email'" style="margin: -1px 0 0 20px;">
<span v-if="subTypeSelected === 'sms'" style="margin: -1px 0 0 20px;">
<el-button
:disabled="smsBtnDisabled"
size="mini"
style="line-height: 14px; float: right;"
type="primary"
@click="sendCode"
@click="sendSMSCode"
>
{{ smsBtnText }}
</el-button>
</span>
</el-col>
</el-row>
<el-row>
<el-col>
<iframe
v-if="passkeyVisible"
:src="passkeyUrl"
style="display: none"
/>
<iframe
v-if="isFaceCaptureVisible && subTypeSelected ==='face' && faceCaptureUrl"
:src="faceCaptureUrl"
allow="camera"
sandbox="allow-scripts allow-same-origin"
style="width: 100%; height: 600px;border: none;"
/>
</el-col>
</el-row>
<el-row :gutter="24" style="margin: 20px auto 10px;">
<el-row :gutter="24" style="margin: 10px auto;">
<el-col :md="24" :sm="24">
<el-button
v-if="!noCodeMFA.includes(subTypeSelected)"
class="confirm-btn"
size="mini"
type="primary"
@click="handleConfirm"
>
<el-button class="confirm-btn" size="mini" type="primary" @click="handleConfirm">
{{ this.$t('Confirm') }}
</el-button>
<el-button
v-if="subTypeSelected === 'face'"
v-show="!isFaceCaptureVisible"
class="confirm-btn"
size="mini"
type="primary"
@click="handleFaceCapture"
>
{{ this.$tc('VerifyFace') }}
</el-button>
<el-button
v-if="subTypeSelected === 'passkey'"
v-loading="passkeyVisible"
class="confirm-btn"
size="mini"
type="primary"
@click="handlePasskeyVerify"
>
{{ this.$tc('Next') }}
</el-button>
</el-col>
</el-row>
</div>
@@ -124,7 +82,7 @@
</template>
<script>
import Dialog from '@/components/Dialog/index.vue'
import { encryptPassword } from '@/utils/secure'
import { encryptPassword } from '@/utils/crypto'
export default {
name: 'UserConfirmDialog',
@@ -155,14 +113,7 @@ export default {
visible: false,
callback: null,
cancel: null,
processing: false,
isFaceCaptureVisible: false,
faceToken: null,
faceCaptureUrl: null,
noCodeMFA: ['face', 'passkey'],
sendCodeMFA: ['email', 'sms', 'otp'],
passkeyVisible: false,
passkeyUrl: '/api/v1/authentication/passkeys/login/?mfa=1'
processing: false
}
},
computed: {
@@ -178,10 +129,6 @@ export default {
},
methods: {
handleSubTypeChange(val) {
if (val !== 'face') {
this.isFaceCaptureVisible = false
}
this.inputPlaceholder = this.subTypeChoices.filter(item => item.name === val)[0]?.placeholder
this.smsWidth = val === 'sms' ? 6 : 0
},
@@ -195,7 +142,7 @@ export default {
this.$log.debug('perform confirm action')
const confirmType = response.data?.code
const confirmUrl = '/api/v1/authentication/confirm/'
this.$axios.get(confirmUrl, { params: { confirm_type: confirmType } }).then((data) => {
this.$axios.get(confirmUrl, { params: { confirm_type: confirmType }}).then((data) => {
this.confirmTypeRequired = data.confirm_type
if (this.confirmTypeRequired === 'relogin') {
@@ -225,8 +172,8 @@ export default {
logout() {
window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}`
},
sendCode() {
this.$axios.post(`/api/v1/authentication/mfa/select/`, { type: this.subTypeSelected }).then(res => {
sendSMSCode() {
this.$axios.post(`/api/v1/authentication/mfa/select/`, { type: 'sms' }).then(res => {
this.$message.success(this.$tc('VerificationCodeSent'))
let time = 60
this.smsBtnDisabled = true
@@ -245,56 +192,6 @@ export default {
this.$message.error(this.$tc('FailedToSendVerificationCode'))
})
},
handlePasskeyVerify() {
this.passkeyVisible = true
this.checkPasskeyStatus()
},
checkPasskeyStatus() {
const url = '/api/v1/authentication/confirm/check/?confirm_type=mfa'
const t = setInterval(() => {
this.$axios.get(url).then(data => {
this.passkeyVisible = false
this.onSuccess()
})
}, 2000)
setTimeout(() => {
clearInterval(t)
if (this.passkeyVisible) {
this.passkeyVisible = false
this.$message.error(this.$tc('PasskeyTimeout'))
}
}, 20000)
},
startFaceCapture() {
const url = '/api/v1/authentication/face/context/'
this.$axios.post(url).then(data => {
const token = data['token']
this.faceCaptureUrl = '/facelive/capture?token=' + token
this.isFaceCaptureVisible = true
const timer = setInterval(() => {
this.$axios.get(url + `?token=${token}`).then(data => {
if (data['is_finished']) {
clearInterval(timer)
this.isFaceCaptureVisible = false
this.handleConfirm()
}
})
}, 1000)
}).catch(() => {
this.$message.error(this.$tc('FailedToStartFaceCapture'))
})
},
handleFaceCapture() {
this.startFaceCapture()
},
onSuccess() {
this.secretValue = ''
this.visible = false
this.$nextTick(() => {
this.callback()
})
},
handleConfirm() {
if (this.confirmTypeRequired === 'relogin') {
return this.logout()
@@ -310,11 +207,13 @@ export default {
}
this.$axios.post(`/api/v1/authentication/confirm/`, data).then(() => {
this.onSuccess()
this.secretValue = ''
this.visible = false
this.$nextTick(() => {
this.callback()
})
}).catch((err) => {
this.$message.error(err.message || this.$tc('ConfirmFailed'))
this.faceCaptureUrl = null
this.isFaceCaptureVisible = false
})
}
}
@@ -322,21 +221,21 @@ export default {
</script>
<style lang="scss" scoped>
.dialog-content ::v-deep .el-dialog__footer {
padding: 0;
}
.dialog-content ::v-deep .el-dialog {
padding: 8px;
.el-dialog__body {
padding-top: 30px;
padding-bottom: 30px;
.dialog-content ::v-deep .el-dialog__footer {
padding: 0;
}
}
.confirm-btn {
width: 100%;
line-height: 20px;
}
.dialog-content ::v-deep .el-dialog {
padding: 8px;
.el-dialog__body {
padding-top: 30px;
padding-bottom: 30px;
}
}
.confirm-btn {
width: 100%;
line-height: 20px;
}
</style>

View File

@@ -1,136 +0,0 @@
<template>
<AutoDataForm
ref="AutoDataForm"
class="variable-add"
:submit-btn-text="submitBtnText"
v-bind="$data"
@submit="confirm"
/>
</template>
<script>
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
export default {
name: 'VariableCreateForm',
components: {
AutoDataForm
},
props: {
variable: {
type: Object,
default: () => ({})
}
},
data() {
const defaultValidator = (rule, value, callback) => {
if (this.defaultValueRequired && !value) {
callback(new Error(this.$t('FieldRequiredError')))
} else {
callback()
}
}
return {
defaultValueRequired: false,
submitBtnText: this.$t('Confirm'),
url: '/api/v1/ops/variables/',
form: Object.assign({ 'on_invalid': 'error' }, this.variable || {}),
fields: [
['', ['name', 'var_name', 'type', 'text_default_value', 'select_default_value', 'extra_args', 'tips', 'required']]
],
fieldsMeta: {
var_name: {
helpTextAsTip: false
},
text_default_value: {
label: this.$t('DefaultValue'),
hidden: (formValue) => {
return formValue.type !== 'text'
},
rules: [{ validator: defaultValidator }],
helpTip: this.$t('DefaultValueTip'),
el: {
type: 'input'
}
},
select_default_value: {
label: this.$t('DefaultValue'),
helpTip: this.$t('DefaultValueTip'),
hidden: (formValue) => {
return formValue.type !== 'select'
},
rules: [{ validator: defaultValidator }],
el: { type: 'input' }
},
extra_args: {
hidden: (formValue) => {
return formValue.type !== 'select'
},
el: { type: 'textarea', rows: 4, placeholder: this.$t('ExtraArgsPlaceholder') },
rules: [
{
validator: (rule, value, callback) => {
try {
const lines = value.split('\n')
const regex = /^[^:]+:[^:]+$/
for (const line of lines) {
if (!regex.test(line.trim())) {
callback(new Error(this.$t('ExtraArgsFormatError')))
}
}
} catch (e) {
callback(new Error(this.$t('ExtraArgsFormatError')))
}
callback()
}
}
]
},
required: {
on: {
change: ([event], updateForm) => {
this.defaultValueRequired = event
}
}
}
},
hasSaveContinue: false,
method: 'get'
}
},
mounted() {
this.defaultValueRequired = this.variable?.required || false
},
methods: {
confirm(form) {
if (this.variable?.name) {
this.$emit('edit', form)
} else {
this.$emit('add', form)
}
}
}
}
</script>
<style lang='scss' scoped>
.variable-add {
::v-deep .el-form-item {
margin-bottom: 5px;
.help-block {
margin-bottom: 5px;
}
}
::v-deep .form-group-header {
.hr-line-dashed {
margin: 5px 0;
}
h3 {
margin-bottom: 10px;
}
}
}
</style>

View File

@@ -1,74 +0,0 @@
<template>
<AutoDataForm
ref="AutoDataForm"
class="variable-set"
:submit-btn-text="submitBtnText"
v-bind="$data"
:fields="fields"
@submit="confirm"
/>
</template>
<script>
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
export default {
name: 'VariableSetForm',
components: {
AutoDataForm
},
props: {
formData: {
type: Array,
default: () => ([])
},
queryParam: {
type: String,
default: ''
}
},
data() {
return {
submitBtnText: this.$t('Confirm'),
// 防止缓存form remoteMeta
url: `/api/v1/ops/variables/form-data/?t=${new Date().getTime()}&` + this.queryParam,
form: {},
hasSaveContinue: false,
method: 'get',
hasReset: false
}
},
computed: {
fields() {
return [['', this.formData.map(item => item.var_name)]]
}
},
methods: {
confirm(form) {
this.$emit('confirm', form)
}
}
}
</script>
<style lang='scss' scoped>
.variable-set {
::v-deep .el-form-item {
margin-bottom: 5px;
.help-block {
margin-bottom: 5px;
}
}
::v-deep .form-group-header {
.hr-line-dashed {
margin: 5px 0;
}
h3 {
margin-bottom: 10px;
}
}
}
</style>

View File

@@ -1,100 +0,0 @@
<template>
<Dialog
:show-cancel="false"
:show-confirm="false"
:title="title"
:visible.sync="iVisible"
class="help-dialog"
top="1vh"
width="50%"
>
<p>{{ variablesHelpText }}</p>
<table border="1" class="help-table">
<tr>
<th>{{ $tc('Variable') }}</th>
<th>{{ $tc('Description') }}</th>
<th>{{ $tc('Example') }}</th>
</tr>
<tr v-for="(item, index) in variables" :key="index">
<td :title="$tc('ClickCopy')" class="item-td text-link" @click="onCopy(item.name)">
<label class="item-label">{{ item.name }}</label>
</td>
<td><span>{{ item.label }}</span></td>
<td><span>{{ item.default }}</span></td>
</tr>
</table>
</Dialog>
</template>
<script>
import Dialog from '@/components/Dialog/index.vue'
import { copy } from '@/utils/common/index'
export default {
components: {
Dialog
},
props: {
visible: {
type: Boolean,
default: false
},
variables: {
type: Array,
default: () => []
},
variablesHelpText: {
type: String,
default() {
return this.$t('WatermarkVariableHelpText')
}
}
},
data() {
return {
title: this.$t('BuiltinVariable')
}
},
computed: {
iVisible: {
set(val) {
this.$emit('update:visible', val)
},
get() {
return this.visible
}
}
},
methods: {
onCopy(key) {
copy(key)
}
}
}
</script>
<style>
.help-dialog.dialog .el-dialog__footer {
border-top: none;
padding: 8px;
}
</style>
<style lang="scss" scoped>
.help-table {
width: 100%;
border-collapse: collapse;
border: 1px solid #dee2e6;
&::v-deep th, td {
height: 40px;
padding: 0 8px;
text-align: left;
}
&::v-deep .item-td, .item-label {
cursor: pointer;
color: var(--color-primary);
}
}
</style>

View File

@@ -1,5 +1,5 @@
<script type="text/jsx">
import { toSafeLocalDateStr } from '@/utils/common/time'
import { toSafeLocalDateStr } from '@/utils/time'
export default {
name: 'ItemValue',
@@ -78,7 +78,7 @@ export default {
formatterData = data
}
return (
<span style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word', lineHeight: '1.2' }}>{formatterData}</span>
<span style={{ whiteSpace: 'pre-wrap', lineHeight: '1.2' }}>{formatterData}</span>
)
}
if (this.value instanceof Array) {
@@ -92,7 +92,7 @@ export default {
)
}
return (
<span style='white-space: pre-wrap;' title={this.displayValue}>{this.displayValue}</span>
<span title={this.displayValue}>{this.displayValue}</span>
)
}
}

View File

@@ -1,20 +1,15 @@
<template>
<IBox v-if="loading" style="width: 100%; height: 200px" />
<div v-else>
<DetailCard
v-if="hasObject && items.length > 0"
:items="validItems"
:loading="loading"
v-bind="$attrs"
/>
<DetailCard v-if="hasObject && items.length > 0" :items="validItems" :loading="loading" v-bind="$attrs" />
</div>
</template>
<script>
import DetailCard from './index.vue'
import { copy } from '@/utils/common/index'
import { toSafeLocalDateStr } from '@/utils/common/time'
import IBox from '@/components/Common/IBox/index.vue'
import { copy } from '@/utils/common'
import { toSafeLocalDateStr } from '@/utils/time'
import IBox from '@/components/IBox/index.vue'
import LabelsDetailFormatter from '../Formatters/LabelsDetailFormatter.vue'
export default {
@@ -37,7 +32,7 @@ export default {
type: Array,
default: null
},
showUndefined: {
showUndefine: {
type: Boolean,
default: true
},
@@ -129,18 +124,8 @@ export default {
parseArrayValue(value, excludes, label) {
if (Array.isArray(value)) {
const tp = typeof value[0]
let object = {}
if (value.length === 0) {
object = {
key: label,
value: '-'
}
return this.items.push(object)
}
// 如果是空数组,那么循环体将不会执行
for (const [index, item] of value.entries()) {
let object = {}
if (tp === 'object') {
const firstValue = value[0]
if (firstValue.hasOwnProperty('name')) {
@@ -183,7 +168,7 @@ export default {
const data = await this.$store.dispatch('common/getUrlMeta', { url: this.url })
let remoteMeta = data.actions['GET'] || {}
if (this.nested) {
remoteMeta = remoteMeta[this.nested]?.children || remoteMeta || {}
remoteMeta = remoteMeta[this.nested]?.children || {}
}
let fields = this.fields
fields = fields || Object.keys(remoteMeta)
@@ -235,7 +220,7 @@ export default {
value = this.parseValue(value, fieldMeta.type)
if (value === undefined) {
if (this.showUndefined) {
if (this.showUndefine) {
value = '-'
} else {
continue

View File

@@ -1,25 +1,24 @@
<template>
<IBox :fa="fa" :title="title">
<el-form :label-width="labelWidth" class="content detail-card" label-position="left">
<template v-for="item in items">
<div v-if="item.has !== false" :key="item.key" :class="item.class " :label="item.key" class="el-form-item">
<span slot="label" class="el-form-item__label"> {{ formateLabel(item.key) }}</span>
<span class="item-value el-form-item__content">
<template
:is="item.component"
v-if="item.component"
v-bind="{...item}"
/>
<ItemValue v-else :value="item.value" v-bind="item" />
</span>
</div>
</template>
<el-form :label-width="labelWidth" class="content" label-position="left">
<span v-for="item in items" :key="item.key">
<el-form-item v-if="item.has !== false" :class="item.class" :label="item.key">
<span slot="label"> {{ formateLabel(item.key) }}</span>
<span
:is="item.component"
v-if="item.component"
v-bind="{...item}"
/>
<ItemValue v-else :value="item.value" class="item-value" v-bind="item" />
</el-form-item>
</span>
</el-form>
<slot />
</IBox>
</template>
<script>
import IBox from '@/components/Common/IBox/index.vue'
import IBox from '../../IBox/index.vue'
import ItemValue from './ItemValue.vue'
export default {
@@ -46,7 +45,7 @@ export default {
},
labelWidth: {
type: String,
default: '120px'
default: '25%'
}
},
data() {
@@ -72,76 +71,55 @@ export default {
padding: 20px 40px;
}
.content {
font-size: 13px;
line-height: 2;
.el-form-item {
border-bottom: 1px dashed #EBEEF5;
padding: 1px 0;
margin-bottom: 0;
::v-deep .el-form-item {
border-bottom: 1px dashed #F4F4F4;
padding: 1px 0;
margin-bottom: 0;
display: flex;
align-items: center;
//text-align: end;
line-height: 32px;
min-height: 32px;
&:last-child {
border-bottom: none;
}
&:last-child {
//border-bottom: none;
&.array-item {
border-bottom: none;
::v-deep .el-form-item__content {
border-bottom: 1px dashed #EBEEF5
}
&.array-item {
border-bottom: none;
::v-deep .el-form-item__content {
border-bottom: 1px dashed #EBEEF5
}
::v-deep .el-form-item__label:last-child {
border: 1px dashed #EBEEF5;
}
}
.el-form-item__label {
//padding-right: 8%;
overflow: hidden;
color: var(--color-icon-primary);
font-size: 12px;
line-height: 1.5;
font-weight: 400;
width: 33%;
min-width: 120px;
padding: 5px 0;
span {
display: inline-block;
//line-height: 1.1;
}
}
.el-form-item__content {
color: var(--color-text-primary);
font-size: 13px;
line-height: 1.5;
width: calc(100% - 120px);
padding: 5px 0;
}
::v-deep .el-tag--mini {
margin-right: 3px;
::v-deep .el-form-item__label:last-child {
border: 1px dashed #EBEEF5;
}
}
.item-value {
::v-deep span {
//display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-word;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
vertical-align: middle;
::v-deep .el-form-item__label {
padding-right: 8%;
overflow: hidden;
color: var(--color-icon-primary);
span {
display: inline-block;
line-height: 1.5;
}
}
::v-deep .el-form-item__content {
color: var(--color-text-primary);
font-size: 13px;
line-height: 40px;
}
::v-deep .el-tag--mini {
margin-right: 3px;
}
}
.item-value span {
word-break: break-word;
}
.content {
font-size: 13px;
line-height: 2.5;
}
</style>

View File

@@ -49,7 +49,7 @@
<script>
import { createSourceIdCache } from '@/api/common'
import { Select2 } from '@/components/Form/FormFields'
import IBox from '@/components/Common/IBox/index.vue'
import IBox from '@/components/IBox/index.vue'
import { mapGetters } from 'vuex'
export default {
@@ -340,13 +340,13 @@ b, strong {
}
tr td {
line-height: 1.4;
padding: 8px 0;
line-height: 1.42857;
padding: 8px;
vertical-align: top;
}
tr.item td {
border-top: 1px dashed #EBEEF5;
border-top: 1px solid #e7eaec;
}
.box-margin {

View File

@@ -1,23 +1,18 @@
<template>
<div>
<div class="summary-header">
<el-tooltip :content="title" :open-delay="500" placement="top">
<span class="title">{{ title }}</span>
</el-tooltip>
<el-card shadow="never">
<div slot="header" class="summary-header">
<span class="header-title">{{ title }}</span>
</div>
<slot>
<h3 class="no-margins ">
<span
:class="{ 'can-direct': canDirect }"
class="num"
@click="handleClick"
>
<span v-if="count === null"> - </span>
<span v-else>{{ count }}</span>
</span>
</h3>
<h1 class="no-margins">
<span v-if="body.disabled" class="disabled-link">{{ body.count }}</span>
<router-link v-else :to="body.route">
<span>{{ body.count }}</span>
</router-link>
</h1>
<small>{{ body.comment }}</small>
</slot>
</div>
</el-card>
</template>
<script>
@@ -28,78 +23,56 @@ export default {
type: String,
default: ''
},
count: {
type: [Number, String, Promise],
default: null
rightSideLabel: {
type: Object,
default: () => ({})
},
route: {
type: [String, Object],
default: ''
},
canDirect: {
type: Boolean,
default: false
},
callback: {
type: Function,
default: () => {
}
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {}
},
methods: {
handleClick() {
if (this.disabled) {
return
}
if (this.route) {
this.$router.push(this.route)
return
}
this.callback.bind(this)()
this.$emit('click')
body: {
type: Object,
default: () => ({})
}
}
}
</script>
<style lang="scss" scoped>
.summary-header {
//color: var(--color-icon-primary);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
.pull-right {
float: right !important;
}
.title {
font-style: normal;
.header-title {
font-size: 14px;
margin: 0 0 7px;
font-weight: 600;
font-size: 12px;
text-transform: uppercase;
line-height: 1.2;
}
}
.no-margins {
margin: 0 !important;
.num {
font-style: normal;
font-weight: 500;
font-size: 24px;
line-height: 40px;
color: var(--color-text-primary);
cursor: pointer;
&.can-direct:hover {
color: var(--color-primary);
}
.right-side ::v-deep .el-tag {
font-weight: 600;
padding: 3px 8px;
text-shadow: none;
line-height: 1;
}
h1 {
font-size: 30px;
font-weight: 100;
}
.el-card__body {
background-color: #ffffff;
color: inherit;
padding: 15px 20px 20px 20px !important;
border-color: #e7eaec;
border-image: none;
border-style: solid solid none;
border-width: 1px 0;
}
.no-margins {
margin: 0 !important;
}
.disabled-link {
color: #428bca;
}
}
</style>

View File

@@ -1,71 +0,0 @@
<template>
<echarts
:options="iOptions"
v-bind="$attrs"
@finished="onFinished"
v-on="$listeners"
/>
</template>
<script>
import 'echarts'
export default {
components: {},
props: {
options: {
type: Object,
required: true
}
},
data() {
const urlParams = new URLSearchParams(window.location.search)
const isExport = urlParams.get('export') === 'true'
return {
isExport: isExport
}
},
computed: {
iOptions() {
return {
...this.options,
animation: !this.isExport
}
}
},
created() {
if (!window._echarts) {
window._echarts = {
total: new Set(),
finished: new Set()
}
}
// 唯一 id避免重复计数
this._chartId = `chart_${Date.now()}_${Math.random().toString(36).slice(2)}`
window._echarts.total.add(this._chartId)
},
beforeDestroy() {
if (window._echarts) {
window._echarts.total.delete(this._chartId)
window._echarts.finished.delete(this._chartId)
// 可选:当没有图表时清理全局对象
if (window._echarts.total.size === 0) {
delete window._echarts
delete window.echartsFinished
}
}
},
methods: {
onFinished() {
if (!window._echarts) return
window._echarts.finished.add(this._chartId)
if (window._echarts.finished.size === window._echarts.total.size) {
window.echartsFinished = true
}
}
}
}
</script>
<style scoped lang="scss">
</style>

View File

@@ -5,59 +5,41 @@
v-if="action.dropdown"
v-show="action.dropdown.length > 0"
:key="action.name"
:class="[action.name, { grouped: action.grouped }]"
:size="action.size"
:split-button="!!action.split"
:type="action.type"
class="action-item"
placement="bottom-start"
trigger="click"
@click="handleClick(action)"
@command="handleDropdownCallback"
>
<span v-if="action.split" :style="{ cursor: action.disabled ? 'not-allowed' : 'pointer' }">
{{ action.title }}
</span>
<el-button
v-else
:class="action.name"
:size="size"
class="more-action"
v-bind="{ ...cleanButtonAction(action), icon: '' }"
>
<span class="pre-icon">
<Icon v-if="action.icon" :icon="action.icon" />
<el-button :size="size" class="more-action" v-bind="cleanButtonAction(action)">
<span v-if="action.icon && !action.icon.startsWith('el-')" class="pre-icon">
<i v-if="action.icon.startsWith('fa')" :class="'fa fa-fw ' + action.icon" />
<svg-icon v-else :icon-class="action.icon" />
</span>
<span v-if="action.title">
{{ action.title }}<i class="el-icon-arrow-down el-icon--right" />
</span>
</el-button>
<el-dropdown-menu slot="dropdown" style="overflow: auto; max-height: 60vh">
<el-dropdown-menu slot="dropdown" style="overflow: auto;max-height: 60vh">
<template v-for="option in action.dropdown">
<div
v-if="option.group"
:key="'group:' + option.name"
:key="'group:'+option.name"
class="dropdown-menu-title"
style="width: 130px"
style="width:130px"
>
{{ option.group }}
</div>
<el-tooltip
:key="option.name"
:content="option.tip"
:disabled="!option.tip"
:open-delay="500"
placement="top"
>
<el-tooltip :key="option.name" :content="option.tip" :disabled="!option.tip" :open-delay="500" placement="top">
<el-dropdown-item
:key="option.name"
:command="[option, action]"
:title="option.tip"
class="dropdown-item"
v-bind="{ ...option, icon: '' }"
v-bind="{...option, icon: ''}"
>
<span v-if="actionsHasIcon(action.dropdown)" class="pre-icon">
<Icon v-if="option.icon" :icon="option.icon" />
<span v-if="option.icon" class="pre-icon">
<i v-if="option.icon.startsWith('fa')" :class="'fa fa-fw ' + option.icon" />
<svg-icon v-else :icon-class="option.icon" />
</span>
{{ option.title }}
</el-dropdown-item>
@@ -69,16 +51,16 @@
<el-button
v-else
:key="action.name"
:class="[action.name, { grouped: action.grouped }]"
:size="size"
class="action-item"
v-bind="{ ...cleanButtonAction(action), icon: '' }"
v-bind="{...cleanButtonAction(action), icon: action.icon && action.icon.startsWith('el-') ? action.icon : ''}"
@click="handleClick(action)"
>
<el-tooltip :content="action.tip" :disabled="!action.tip" placement="top">
<el-tooltip :content="action.tip" :disabled="!action.tip" :open-delay="500" placement="top">
<span>
<span v-if="action.icon" style="vertical-align: initial">
<Icon :icon="action.icon" />
<span v-if="action.icon && !action.icon.startsWith('el-')" style="vertical-align: initial">
<i v-if="action.icon.startsWith('fa')" :class="'fa ' + action.icon" />
<svg-icon v-else :icon-class="action.icon" />
</span>
{{ action.title }}
</span>
@@ -89,14 +71,10 @@
</template>
<script>
import { toSentenceCase } from '@/utils/common/index'
import Icon from '@/components/Widgets/Icon/index.vue'
import { toSentenceCase } from '@/utils/common'
export default {
name: 'DataActions',
components: {
Icon
},
props: {
grouped: {
type: Boolean,
@@ -121,9 +99,6 @@ export default {
}
},
methods: {
actionsHasIcon(actions) {
return actions.some(action => action.icon)
},
hasIcon(action, type = '') {
const icon = action.icon
if (!icon) {
@@ -181,7 +156,6 @@ export default {
delete action['callback']
delete action['name']
delete action['can']
delete action['split']
return action
},
cleanActions(actions) {
@@ -211,10 +185,6 @@ export default {
}
delete action['can']
if (!action.size) {
action.size = 'small'
}
if (action.dropdown) {
action.dropdown = this.cleanActions(action.dropdown)
}
@@ -228,9 +198,9 @@ export default {
<style lang="scss" scoped>
$btn-text-color: #ffffff;
$color-btn-background: #e8f7f4;
$color-btn-focus-background: #83cbba;
$color-divided: #e4e7ed;
$color-btn-background: #E8F7F4;
$color-btn-focus-background: #83CBBA;
$color-divided: #E4E7ED;
$color-drop-menu-title: #909399;
$color-drop-menu-border: #e4e7ed;
@@ -239,10 +209,6 @@ $color-drop-menu-border: #e4e7ed;
.action-item {
margin-left: 5px;
&.grouped {
margin-left: 0;
}
&:first-child {
margin-left: 0;
}
@@ -283,17 +249,10 @@ $color-drop-menu-border: #e4e7ed;
align-items: flex-end;
.el-button {
padding: 2px 5px;
line-height: 1.3;
font-size: 13px;
&:not(.is-plain) {
color: $btn-text-color;
}
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: flex;
align-items: center;
padding: 2px 6px;
color: $btn-text-color;
* {
vertical-align: baseline !important;
@@ -321,6 +280,8 @@ $color-drop-menu-border: #e4e7ed;
// options
.el-dropdown-menu {
::v-deep .more-batch-processing {
text-align: center;
&:hover {
background-color: transparent !important;
}
@@ -342,7 +303,6 @@ $color-drop-menu-border: #e4e7ed;
.dropdown-item {
color: var(--color-text-primary);
line-height: 34px;
.pre-icon {
width: 17px;
@@ -364,8 +324,6 @@ $color-drop-menu-border: #e4e7ed;
}
.el-dropdown-menu__item {
padding: 0 20px;
&.is-disabled {
color: var(--color-disabled);
cursor: not-allowed;

View File

@@ -1,7 +1,6 @@
<template>
<Dialog
v-if="detailVisible"
:modal="false"
:show-cancel="false"
:show-confirm="false"
:title="title"

View File

@@ -1,71 +0,0 @@
<template>
<Dialog
:show-cancel="false"
:visible="iVisible"
class="processing-dialog"
height="300"
:title="$tc('Processing')"
width="300"
@confirm="iVisible=false"
>
<div id="load">
<div class="spinner" />
</div>
</Dialog>
</template>
<script>
import Dialog from './index.vue'
export default {
name: 'ProcessingDialog',
components: { Dialog },
props: {
visible: {
type: Boolean,
default: false
}
},
data() {
return {}
},
computed: {
iVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
}
}
}
</script>
<style lang="scss" scoped>
.processing-dialog {
::v-deep .el-dialog__body {
overflow: hidden;
}
}
.spinner {
width: 100px;
height: 100px;
border: 5px solid rgba(0, 0, 0, 0.1);
border-radius: 50%;
border-top-color: var(--color-primary);
animation: spin 1s infinite linear;
}
#load {
display: flex;
justify-content: center;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
</style>

View File

@@ -1,69 +0,0 @@
<template>
<Dialog
:visible="iVisible"
height="300"
title="Processing"
width="300"
class="processing-dialog"
>
<div id="load">
<div class="spinner" />
</div>
</Dialog>
</template>
<script>
import Dialog from './index.vue'
export default {
name: 'RemoteProcessingDialog',
components: { Dialog },
props: {
visible: {
type: Boolean,
default: false
}
},
data() {
return {}
},
computed: {
iVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
}
}
}
</script>
<style lang="scss" scoped>
.processing-dialog {
::v-deep .el-dialog__body {
overflow: hidden;
}
}
.spinner {
width: 100px;
height: 100px;
border: 5px solid rgba(0, 0, 0, 0.1);
border-radius: 50%;
border-top-color: var(--color-primary);
animation: spin 1s infinite linear;
}
#load {
display: flex;
justify-content: center;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
</style>

View File

@@ -1,75 +0,0 @@
<template>
<div>
<Dialog
v-if="iVisible"
:destroy-on-close="true"
:show-cancel="false"
:show-confirm="false"
:title="$tc('Report')"
:visible.sync="iVisible"
top="35vh"
width="80%"
@close="loading=true"
>
<span v-if="loading" v-loading="loading" class="loading" />
<iframe title="dialog" :src="url" style="border: none;" @load="onIframeLoad" />
</Dialog>
</div>
</template>
<script>
import Dialog from '@/components/Dialog/index.vue'
export default {
name: 'ReportDialog',
components: {
Dialog
},
props: {
visible: {
type: Boolean,
default: false
},
url: {
type: String,
default: ''
}
},
data() {
return {
loading: true
}
},
computed: {
iVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
}
},
mounted() {
},
beforeMount() {
},
methods: {
onIframeLoad() {
this.loading = false
}
}
}
</script>
<style lang="scss" scoped>
iframe {
width: 100%;
height: 500px;
}
.loading {
margin-top: 20px;
display: block;
}
</style>

View File

@@ -1,96 +0,0 @@
<template>
<Dialog
:show-cancel="false"
:title="title"
:visible.sync="visible"
:close-on-click-modal="false"
width="700px"
@close="onClose"
@confirm="visible = false"
>
<el-alert type="warning" :closable="false">
{{ warningText }}
<div class="secret">
<div class="row">
<span class="col">ID:</span>
<span class="value">{{ keyInfo.id }}</span>
<i class="el-icon-copy-document copy-icon" @click="handleCopy(keyInfo.id)" />
</div>
<div class="row">
<span class="col">Secret:</span>
<span class="value">{{ keyInfo.secret }}</span>
<i class="el-icon-copy-document copy-icon" @click="handleCopy(keyInfo.secret)" />
</div>
</div>
</el-alert>
</Dialog>
</template>
<script>
import i18n from '@/i18n/i18n'
import { copy } from '@/utils/common/index'
import Dialog from '@/components/Dialog/index'
export default {
name: 'Secret',
components: {
Dialog
},
props: {
title: {
type: String,
default: () => i18n.t('CreateAccessKey')
},
warningText: {
type: String,
default: () => i18n.t('ApiKeyWarning')
}
},
data() {
return {
keyInfo: { id: '', secret: '' },
visible: false
}
},
methods: {
show(data) {
this.keyInfo = data
this.visible = true
},
onClose() {
this.$emit('close')
},
handleCopy(value) {
copy(value)
}
}
}
</script>
<style lang='scss' scoped>
.secret {
color: #2b2f3a;
margin-top: 20px;
}
.row {
margin-bottom: 10px;
}
.col {
width: 100px;
text-align: left;
display: inline-block;
}
.copy-icon {
margin-left: 5px;
cursor: pointer;
transition: color 0.2s;
}
.value {
font-weight: 600;
}
</style>

View File

@@ -2,7 +2,6 @@
<transition name="dialog-fade">
<el-dialog
:append-to-body="true"
:class="{ shadow: shadow }"
:modal-append-to-body="true"
:title="title"
:top="top"
@@ -47,7 +46,7 @@ export default {
},
width: {
type: String,
default: '800px'
default: '60%'
},
showConfirm: {
type: Boolean,
@@ -80,14 +79,11 @@ export default {
maxWidth: {
type: String,
default: '1200px'
},
shadow: {
type: Boolean,
default: true
}
},
data() {
return {}
return {
}
},
computed: {
iWidth() {
@@ -106,69 +102,59 @@ export default {
</script>
<style lang="scss" scoped>
.dialog.shadow ::v-deep .el-dialog {
box-shadow: 1px 2px 12px 0 rgba(0, 0, 0, 0.6);
}
.dialog ::v-deep .el-dialog {
border-radius: 0.3em;
max-width: min(100vw, 1500px);
.form-group-header {
margin-left: 20px;
}
.el-form--label-top {
.form-group-header {
margin-left: 0;
}
}
.el-icon-circle-check {
display: none;
}
&__header {
box-sizing: border-box;
padding: 15px 22px;
border-bottom: 1px solid #dee2e6;
font-weight: 400;
}
&__body {
padding: 20px 30px;
font-size: 13px;
&:has(.el-table) {
background: #f3f3f4;
}
}
&__footer {
border-top: 1px solid #dee2e6;
padding: 16px 25px;
justify-content: flex-end;
}
}
@media (max-width: 900px) {
.dialog ::v-deep .el-dialog {
max-width: calc(100% - 30px);
border-radius: 0.3em;
max-width: min(100vw, 1500px);
.form-group-header {
margin-left: 20px;
}
.el-icon-circle-check {
display: none;
}
&__header {
box-sizing: border-box;
padding: 15px 22px;
border-bottom: 1px solid #dee2e6;
font-weight: 400;
}
&__body {
padding: 20px 30px;
font-size: 13px;
&:has(.el-table) {
background: #f3f3f4;
}
}
&__footer {
border-top: 1px solid #dee2e6;
padding: 16px 25px;
justify-content: flex-end;
}
}
}
.dialog-footer ::v-deep button.el-button {
font-size: 13px;
padding: 8px 12px;
}
@media (max-width: 900px) {
.dialog ::v-deep .el-dialog {
max-width: calc(100% - 30px);
}
}
.dialog-fade-enter-active, .dialog-fade-leave-active {
transition: opacity 1s ease;
}
.dialog-footer ::v-deep button.el-button {
font-size: 13px;
padding: 8px 12px;
}
.dialog-fade-enter, .dialog-fade-leave-to /* .dialog-fade-leave-active 在 <2.1.8 中以及被重复声明 */
{
opacity: 0;
}
.dialog-fade-enter-active, .dialog-fade-leave-active {
transition: opacity 1s ease;
}
.dialog-fade-enter, .dialog-fade-leave-to /* .dialog-fade-leave-active 在 <2.1.8 中以及被重复声明 */
{
opacity: 0;
}
</style>

View File

@@ -1,305 +0,0 @@
<template>
<el-drawer
ref="drawer"
v-el-drawer-drag-width
:append-to-body="true"
:before-close="handleClose"
:class="['drawer', { 'drawer__no-footer': !hasFooter }]"
:modal="modal"
:size="size"
:title="title"
:visible.sync="iVisible"
custom-class="drawer"
destroy-on-close
direction="rtl"
v-on="$listeners"
>
<div class="drawer__content">
<slot name="default">
<component
:is="component"
v-if="component"
ref="dynamicComponent"
v-bind="componentProps"
v-on="componentListeners"
/>
</slot>
</div>
<div v-if="hasFooter" ref="drawerFooter" class="drawer__footer" />
</el-drawer>
</template>
<script>
import { getDrawerWidth } from '@/utils/common/index'
export default {
props: {
title: {
type: String,
default: ''
},
size: {
type: String,
default: () => {
return getDrawerWidth()
}
},
component: {
type: [String, Function, Object],
default: ''
},
componentProps: {
type: Object,
default: () => ({})
},
componentListeners: {
type: Object,
default: () => ({})
},
visible: {
type: Boolean,
default: false
},
modal: {
type: Boolean,
default: true
},
hasFooter: {
type: Boolean,
default: false
}
},
data() {
return {
loading: false,
formLabelWidth: '80px'
}
},
computed: {
iVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
}
},
mounted() {
},
methods: {
handleClose(done) {
this.$emit('close-drawer')
done()
}
}
}
</script>
<style lang='scss' scoped>
.drawer__no-footer {
::v-deep {
.drawer {
.page {
height: calc(100vh - 55px);
}
}
}
}
@media (max-width: 992px) {
.drawer ::v-deep {
.el-form-item {
display: flex;
flex-direction: column;
gap: 0.3rem;
}
}
}
.drawer {
::v-deep {
min-width: 565px;
.el-card__body {
padding-top: 10px;
padding-bottom: 20px;
}
.page-submenu {
.el-tabs__header {
padding: 0 15px;
}
.el-tabs__item.is-top {
padding: 0 10px;
}
}
.form-buttons {
margin-left: 13px;
}
.el-form {
margin-right: 1px;
padding-right: 15px;
height: 100%;
&.detail-card {
padding-right: 0;
margin-top: unset;
}
// Detail 中
&.content {
margin-right: 0;
}
.form-buttons {
//position: absolute;
// bottom: 13px;
// margin-left: 20%;
// margin-top: 0;
}
// Form 中的子 form
.el-form {
margin-left: 0;
margin-top: 0;
margin-bottom: 0;
}
.el-form-item {
.el-form-item__label {
padding-right: 20px;
}
.el-radio {
line-height: 25px;
margin-right: 13px;
.el-radio__label {
padding-left: 5px;
}
}
}
&.el-form--label-top {
.el-radio-group {
.el-radio {
display: block;
padding-bottom: 3px;
}
}
.el-form-item {
padding-left: 12px;
.el-form-item__label {
padding: 0 20px 0 0;
line-height: 30px;
}
.sub-form {
margin-left: -1px;
.form-fields {
max-height: unset;
}
}
}
&.form-fields {
//overflow: auto;
//max-height: calc(100vh - 180px);
}
.el-checkbox-group {
.el-checkbox {
display: block;
padding-bottom: 3px;
}
}
.el-form-item__content:has(.el-checkbox):not(:has(.el-checkbox-group)) {
display: inline-block; /* 更改为 inline-block */
//width: unset; /* 这个设置上去后,平台详情中, Automations 会有问题 */
vertical-align: bottom;
}
.el-form-item__content {
form {
.el-form-item {
padding-left: 0;
}
}
}
}
.form-group-header {
margin-left: 20px;
}
}
.el-drawer__header {
border-bottom: 1px solid #EBEEF5;
margin-bottom: 0;
padding: 15px 20px;
font-size: 16px;
font-weight: 500;
color: var(--color-text-primary);
}
.sql.container {
display: none;
}
.page {
overflow-y: auto;
height: calc(100vh - 110px);
&.tab-page {
.page-content {
padding-right: 0;
padding-left: 0;
}
}
.page-content {
height: unset;
padding-right: 10px;
padding-left: 20px;
& > div {
margin-bottom: 1px;
}
}
.ibox {
margin-bottom: 10px;
border: none;
}
}
.drawer__content, .tab-page-content {
height: 100%;
background: #f3f3f3;
}
.drawer__footer {
border-top: solid 1px #f3f3f3;
}
//.el-drawer__header {
// margin-bottom: 20px;
//
// span {
// font-size: 16px;
// font-weight: 800;
// color: var(--color-text-primary);
// }
//}
}
}
</style>

View File

@@ -1,28 +1,25 @@
<template>
<div>
<DataForm
v-if="!loading"
ref="dataForm"
:fields="totalFields"
:form="iForm"
:server-errors="serverErrors"
v-bind="$attrs"
v-on="$listeners"
<DataForm
v-if="!loading"
ref="dataForm"
:fields="totalFields"
:form="iForm"
v-bind="$attrs"
v-on="$listeners"
>
<div
v-for="(group, i) in groups"
:key="'group-'+group.name"
:slot="'id:'+group.name"
>
<template
v-for="(group, i) in groups"
:slot="'id:'+group.name"
>
<FormGroupHeader
v-if="!groupHidden(group, i)"
:key="'group-' + group.name"
:group="group"
:index="i"
:line="i !== 0 && !groupHidden(groups[i - 1], i - 1)"
/>
</template>
</DataForm>
</div>
<FormGroupHeader
v-if="!groupHidden(group, i)"
:group="group"
:index="i"
:line="i !== 0 && !groupHidden(groups[i - 1], i - 1)"
/>
</div>
</DataForm>
</template>
<script>
@@ -66,8 +63,7 @@ export default {
totalFields: [],
loading: true,
groups: [],
errors: {},
serverErrors: {}
errors: {}
}
},
computed: {
@@ -91,12 +87,11 @@ export default {
}
},
mounted() {
// this.$log.debug('>>> Method: ', this.method)
this.optionUrlMetaAndGenerateColumns()
},
methods: {
async optionUrlMetaAndGenerateColumns() {
let data = { actions: {} }
let data = { actions: {}}
if (this.url) {
data = await this.$store.dispatch('common/getUrlMeta', { url: this.url })
}
@@ -105,8 +100,6 @@ export default {
this.generateColumns()
this.$emit('afterGenerateColumns', this.totalFields)
this.cleanFormValue()
// 初始化时清空错误
this.serverErrors = {}
this.loading = false
},
generateColumns() {
@@ -143,56 +136,18 @@ export default {
cleanFormValue() {
this._cleanFormValue(this.iForm, this.remoteMeta)
},
_getElFormInstance() {
try {
return this.$refs?.dataForm?.$refs?.form?.$refs?.elForm || null
} catch (e) {
return null
}
},
/**
* @description 仅清理 UI 的错误展示,不触发表单内容重建
*/
clearAllFieldErrors() {
const elForm = this._getElFormInstance()
if (elForm && Array.isArray(elForm.fields)) {
elForm.fields.forEach((item) => {
item.validateMessage = ''
item.validateState = ''
})
}
// 不修改 totalFields/attrs避免触发 content 重建导致输入丢失
this.serverErrors = {}
},
setFieldError(name, error) {
error = (error || '').toString().replace(/[。.]+$/, '')
const elForm = this._getElFormInstance()
if (elForm && Array.isArray(elForm.fields)) {
const item = elForm.fields.find(f => f.prop === name)
if (item) {
item.validateMessage = error
item.validateState = error ? 'error' : ''
}
const field = this.totalFields.find((v) => v.prop === name)
if (!field) {
return
}
// 不写入 totalFields避免触发 innerContent 变化导致表单值被覆盖
this.$set(this.serverErrors, name, error)
},
setErrors(errors) {
const mapped = {}
Object.entries(errors || {}).forEach(([k, v]) => {
let msg = v
if (Array.isArray(v)) msg = v.join('; ')
else if (typeof v === 'object' && v !== null) msg = JSON.stringify(v)
mapped[k] = String(msg || '')
})
this.serverErrors = mapped
const elForm = this._getElFormInstance()
if (elForm && Array.isArray(elForm.fields)) {
elForm.fields.forEach((item) => {
const msg = mapped[item.prop] || ''
item.validateMessage = msg
item.validateState = msg ? 'error' : ''
})
if (field.attrs.error === error) {
error += '.'
}
if (typeof error === 'string') {
field.el.errors = error
field.attrs.error = error
}
},
groupHidden(group, i) {
@@ -208,6 +163,5 @@ export default {
return true
}
}
}
</script>

View File

@@ -1,10 +1,11 @@
import Vue from 'vue'
import ObjectSelect2 from '@/components/Form/FormFields/NestedObjectSelect2.vue'
import NestedField from '@/components/Form/AutoDataForm/components/NestedField.vue'
import Switcher from '@/components/Form/FormFields/Switcher.vue'
import rules from '@/components/Form/DataForm/rules'
import BasicTree from '@/components/Form/FormFields/BasicTree.vue'
import JsonEditor from '@/components/Form/FormFields/JsonEditor.vue'
import { assignIfNot, toSentenceCase } from '@/utils/common/index'
import { assignIfNot, toSentenceCase } from '@/utils/common'
import TagInput from '@/components/Form/FormFields/TagInput.vue'
import i18n from '@/i18n/i18n'
@@ -63,9 +64,8 @@ export class FormFieldGenerator {
}
break
case 'boolean':
type = 'checkbox'
// field.component = Switcher
// field.type = 'checkbox'
type = ''
field.component = Switcher
break
case 'list':
type = 'input'
@@ -112,7 +112,7 @@ export class FormFieldGenerator {
let nestedFields = fieldMeta.fields || []
const nestedFieldsMeta = fieldMeta.fieldsMeta || {}
const nestedFieldsRemoteMeta = fieldRemoteMeta.children || {}
if (nestedFields.toString() === '__all__') {
if (nestedFields === '__all__') {
nestedFields = Object.keys(nestedFieldsRemoteMeta)
}
for (const name of nestedFields) {
@@ -177,10 +177,7 @@ export class FormFieldGenerator {
const systemLang = document.cookie.django_language
if (helpTextAsPlaceholder !== undefined) {
helpTextAsPlaceholder = !!helpTextAsPlaceholder
} else if (
placeholderType.indexOf(field.type) === -1 &&
placeholderComponent.indexOf(field.component) === -1
) {
} else if (placeholderType.indexOf(field.type) === -1 && placeholderComponent.indexOf(field.component) === -1) {
helpTextAsPlaceholder = false
} else if ((helpTextWordLength <= 5 || helpText.length <= 10) && systemLang === 'en') {
helpTextAsPlaceholder = true

View File

@@ -361,10 +361,9 @@ export default {
},
//
submitFill() {
const minMinutes = 60
const crontabDiffMin = this.crontabDiff / 1000 / 60
if (crontabDiffMin > 0 && crontabDiffMin < minMinutes) {
const msg = this.$t('CrontabDiffError', { minutes: minMinutes })
if (crontabDiffMin > 0 && crontabDiffMin < 10) {
const msg = this.$tc('CrontabDiffError')
this.$message.error(msg)
return
}

View File

@@ -10,18 +10,15 @@
<el-form-item>
<el-radio v-model="radioValue" :label="2">
{{ this.$t('From') }}
<el-input-number v-model="cycle01" :max="23" :min="0" size="mini" />
-
<el-input-number v-model="cycle02" :max="23" :min="0" size="mini" />
{{ this.$t('Hour') }}
<el-input-number v-model="cycle01" :max="60" :min="0" size="mini" /> -
<el-input-number v-model="cycle02" :max="60" :min="0" size="mini" /> {{ this.$t('Hour') }}
</el-radio>
</el-form-item>
<el-form-item>
<el-radio v-model="radioValue" :label="3">
{{ this.$t('Every') }}
<el-input-number v-model="average02" :max="23" :min="1" size="mini" />
{{ this.$t('Hour') }} {{ this.$t('ExecuteOnce') }}
<el-input-number v-model="average02" :max="60" :min="1" size="mini" /> {{ this.$t('Hour') }} {{ this.$t('ExecuteOnce') }}
</el-radio>
</el-form-item>
@@ -35,7 +32,7 @@
multiple
style="width:100%"
>
<el-option v-for="item in 24" :key="item" :value="item-1">{{ item - 1 }}</el-option>
<el-option v-for="item in 24" :key="item" :value="item-1">{{ item-1 }}</el-option>
</el-select>
</el-radio>
</el-form-item>

View File

@@ -9,7 +9,7 @@
<el-form-item>
<el-radio v-model="radioValue" :label="3">
{{ this.$t('From') }}
<el-input-number v-model="average02" :max="59" :min="1" size="mini" />
<el-input-number v-model="average02" :max="60" :min="1" size="mini" />
{{ this.$t('Min') }} {{ this.$t('ExecuteOnce') }}
</el-radio>
</el-form-item>

View File

@@ -13,7 +13,7 @@
<script>
import parser from 'cron-parser'
import { toSafeLocalDateStr } from '@/utils/common/time'
import { toSafeLocalDateStr } from '@/utils/time'
export default {
name: 'CrontabResult',

View File

@@ -39,13 +39,6 @@ export default {
showCron: false
}
},
watch: {
value: {
handler(val) {
this.crontabFill(val)
}
}
},
methods: {
crontabFill(value) {
//

View File

@@ -6,24 +6,20 @@
:prop="prop"
:rules="_show && Array.isArray(data.rules) ? data.rules : []"
v-bind="data.attrs"
:error="errorText"
>
<template v-if="data.label" #label>
<span :title="data.label">
<span v-if="data.required">* </span>
{{ data.label }}
<el-tooltip
v-if="data.helpTip"
:open-delay="500"
:tabindex="-1"
effect="dark"
placement="right"
popper-class="help-tips"
>
<div slot="content" v-sanitize="data.helpTip" class="help-tip-content" /> <!-- Noncompliant -->
<i class="fa fa-question-circle-o help-tip-icon" />
</el-tooltip>
</span>
<span>{{ data.label }}</span>
<el-tooltip
v-if="data.helpTip"
:open-delay="500"
:tabindex="-1"
effect="dark"
placement="right"
popper-class="help-tips"
>
<div slot="content" v-sanitize="data.helpTip" class="help-tip-content" /> <!-- Noncompliant -->
<i class="fa fa-question-circle-o help-tip-icon" />
</el-tooltip>
</template>
<template v-if="readonly && hasReadonlyContent">
<div
@@ -75,7 +71,6 @@
<el-tooltip v-if="opt.tip" :content="opt.tip" :open-delay="500" placement="top">
<i class="el-icon-warning-outline" />
</el-tooltip>
<span v-if="data.helpText">{{ data.helpText }}</span>
</el-checkbox>
<!-- WARNING: radio label 属性来表示 value 的含义 -->
<!-- FYI: radio value 属性可以在没有 radio-group 时用来关联到同一个 v-model -->
@@ -92,7 +87,7 @@
</el-radio>
</template>
</custom-component>
<div v-if="data.helpText" :class="data.type" class="help-block">
<div v-if="data.helpText" class="help-block">
<el-alert
v-if="data.helpText.startsWith('!')"
:closable="false"
@@ -104,9 +99,6 @@
</el-alert>
<span v-else v-sanitize="data.helpText" />
</div>
<div v-if="data.helpTextFormatter" class="help-block">
<RenderHelpTextSafe :render-content="data.helpTextFormatter" />
</div>
</el-form-item>
</template>
<script>
@@ -129,18 +121,6 @@ function validator(data) {
export default {
components: {
RenderHelpTextSafe: {
functional: true,
props: {
renderContent: {
type: Function,
required: true
}
},
render(h, { props }) {
return props.renderContent()
}
},
/**
* 🐂🍺只需要有组件选项对象,就可以立刻包装成函数式组件在 template 中使用
* FYI: https://cn.vuejs.org/v2/guide/render-function.html#%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BB%84%E4%BB%B6
@@ -153,10 +133,6 @@ export default {
props: {
// eslint-disable-next-line vue/require-default-prop
data: Object,
serverErrors: {
type: Object,
default: () => ({})
},
prop: {
type: String,
default() {
@@ -184,7 +160,7 @@ export default {
computed: {
// 解构运算符会处理 undefined 的情况
componentProps: ({ data: { el }, propsInner }) => ({ ...el, ...propsInner }),
hasReadonlyContent: ({ data: { type } }) => _includes(['input', 'select'], type),
hasReadonlyContent: ({ data: { type }}) => _includes(['input', 'select'], type),
hiddenStatus: ({ data: { hidden = () => false }, data, value }) => hidden(value, data),
enableWhenStatus: ({ data: { enableWhen }, value }) => getEnableWhenStatus(enableWhen, value),
// 是否显示
@@ -194,11 +170,6 @@ export default {
classes() {
return 'el-form-item-' + this.data.prop + ' ' + (this.data.attrs?.class || '')
},
errorText() {
const fromAttrs = this.data?.attrs?.error
const fromServer = this.serverErrors ? this.serverErrors[this.data.prop] : ''
return fromAttrs || fromServer || ''
},
listeners() {
const {
data: {
@@ -344,10 +315,6 @@ export default {
::v-deep .el-alert__icon {
font-size: 16px
}
&.checkbox {
//display: inline;
}
}
.help-tip-icon {

View File

@@ -1,12 +1,11 @@
<template>
<el-form ref="elForm" :model="value" class="el-form-renderer" v-bind="$attrs" @submit.native.prevent>
<el-form ref="elForm" :model="value" class="el-form-renderer" v-bind="$attrs">
<template v-for="item in innerContent">
<slot v-if="!isHidden(item)" :name="`id:${item.id}`" />
<component
:is="item.type === GROUP ? 'render-form-group' : 'render-form-item'"
:key="item.id"
:data="item"
:server-errors="serverErrors"
:disabled="disabled || item.disabled"
:item-value="value[item.id]"
:options="options[item.id]"
@@ -48,10 +47,6 @@ export default {
type: Array,
required: true
},
serverErrors: {
type: Object,
default: () => ({})
},
disabled: {
type: Boolean,
default: false

View File

@@ -1,91 +1,74 @@
<template>
<div>
<ElFormRender
:id="id"
ref="form"
:class="[mobile ? 'mobile' : 'desktop']"
:content="fields"
:form="basicForm"
:label-position="iLabelPosition"
class="form-fields"
:label-width="labelWidth"
:style="{ '--label-width': labelWidth }"
v-bind="$attrs"
:server-errors="serverErrors"
v-on="$listeners"
>
<!-- slot 透传 -->
<slot
v-for="item in fields"
:slot="`id:${item.id}`"
:name="`id:${item.id}`"
/>
<slot
v-for="item in fields"
:slot="`$id:${item.id}`"
:name="`$id:${item.id}`"
/>
<ElFormRender
:id="id"
ref="form"
:class="mobile ? 'mobile' : 'desktop'"
:content="fields"
:form="basicForm"
:label-position="labelPosition"
label-width="25%"
v-bind="$attrs"
v-on="$listeners"
>
<!-- slot 透传 -->
<slot
v-for="item in fields"
:slot="`id:${item.id}`"
:name="`id:${item.id}`"
/>
<slot
v-for="item in fields"
:slot="`$id:${item.id}`"
:name="`$id:${item.id}`"
/>
<div v-if="hasButtons" class="form-buttons">
<el-button
v-if="defaultButton"
:disabled="!canSubmit"
:loading="isSubmitting"
:size="submitBtnSize"
type="primary"
@click="submitForm('form')"
>
{{ iSubmitBtnText }}
</el-button>
<el-form-item v-if="hasButtons" class="form-buttons">
<el-button
v-if="defaultButton"
:disabled="!canSubmit"
:loading="isSubmitting"
:size="submitBtnSize"
type="primary"
@click="submitForm('form')"
>
{{ iSubmitBtnText }}
</el-button>
<el-button
v-if="defaultButton && hasSaveContinue"
size="small"
@click="submitForm('form', true)"
>
{{ $t("SaveAndAddAnother") }}
</el-button>
<el-button
v-if="defaultButton && hasSaveContinue"
size="small"
@click="submitForm('form', true)"
>
{{ $t("SaveAndAddAnother") }}
</el-button>
<el-button
v-if="defaultButton && hasReset"
size="small"
@click="resetForm('form')"
>
{{ $t("Reset") }}
</el-button>
<el-button
v-if="defaultButton && hasReset"
size="small"
@click="resetForm('form')"
>
{{ $t("Reset") }}
</el-button>
<el-button
v-for="button in moreButtons"
v-show="!iHidden(button)"
:key="button.title"
:loading="button.loading"
size="small"
v-bind="button"
@click="handleClick(button)"
>
{{ button.title }}
</el-button>
</div>
</ElFormRender>
</div>
<el-button
v-for="button in moreButtons"
v-show="!button.hidden"
:key="button.title"
:loading="button.loading"
size="small"
v-bind="button"
@click="handleClick(button)"
>
{{ button.title }}
</el-button>
</el-form-item>
</ElFormRender>
</template>
<script>
import ElFormRender from './components/el-form-renderer'
import { randomString } from '@/utils/common/index'
const scrollToError = (
el,
scrollOption = {
behavior: 'smooth',
block: 'center'
}
) => {
setTimeout(() => {
const isError = el.getElementsByClassName('is-error')
isError[0].scrollIntoView(scrollOption)
}, 0)
}
import { randomString } from '@/utils/string'
import { scrollToError } from '@/utils'
export default {
components: {
@@ -122,10 +105,6 @@ export default {
type: Boolean,
default: true
},
serverErrors: {
type: Object,
default: () => ({})
},
fields: {
type: Array,
default: () => []
@@ -142,14 +121,6 @@ export default {
isSubmitting: {
type: Boolean,
default: false
},
labelPosition: {
type: String,
default: ''
},
labelWidth: {
type: String,
default: '25%'
}
},
data() {
@@ -166,17 +137,7 @@ export default {
mobile() {
return this.$store.state.app.device === 'mobile'
},
drawer() {
return this.$store.state.common.inDrawer
},
iLabelPosition() {
if (this.labelPosition) {
return this.labelPosition
}
// if (this.drawer) {
// return 'left'
// }
// return this.drawer || this.mobile ? 'top' : 'right'
labelPosition() {
return this.mobile ? 'top' : 'right'
}
},
@@ -231,9 +192,6 @@ export default {
},
getFormValue() {
return this.$refs.form.getFormValue()
},
iHidden(item) {
return typeof item.hidden === 'function' ? item.hidden() : item.hidden
}
}
}
@@ -253,42 +211,25 @@ export default {
color: var(--color-text-primary);
}
&.label-top {
::v-deep .el-form-item {
.el-form-item__content {
width: 100%;
}
}
}
::v-deep .el-form-item {
margin-bottom: 10px;
.item-params {
margin-top: 0;
}
.el-form-item__label {
padding: 0 30px 0 0;
line-height: 30px;
color: var(--color-text-primary);
span {
display: unset;
}
i {
color: var(--color-icon-primary);
}
span {
max-width: calc(100% - 25px);
//white-space: nowrap; /* 禁止换行 */
//text-overflow: ellipsis;
overflow: hidden;
display: inline-block;
line-height: 16px;
}
}
.el-form-item__content {
width: calc(100% - var(--label-width));
width: 75%;
line-height: 32px;
// 禁用的输入框
@@ -360,9 +301,8 @@ export default {
}
}
::v-deep .form-buttons {
margin-top: 30px;
margin-left: var(--label-width);
::v-deep .el-form-item.form-buttons {
margin-top: 20px;
}
}

View File

@@ -27,9 +27,7 @@ export default {
},
beforeSubmit: {
type: Function,
default: (val) => {
return true
}
default: (val) => { return true }
}
},
data() {
@@ -52,16 +50,14 @@ export default {
::v-deep .el-select {
width: 100%;
}
::v-deep .el-form-item__content {
width: 100% !important;
}
::v-deep .form-buttons {
margin: 0 !important;
}
.attr-input {
margin-top: -10px;
}
</style>

View File

@@ -47,9 +47,6 @@ export default {
},
computed: {
iValue() {
if (!this.value) {
return []
}
return this.value.map(item => {
if (item.value) {
return item.value
@@ -118,73 +115,6 @@ export default {
color: #999;
}
.el-tree > .el-tree-node:after {
border-top: none;
}
//节点有间隙,隐藏掉展开按钮就好了,如果觉得空隙没事可以删掉
.el-tree-node__expand-icon.is-leaf {
display: none;
}
.el-tree > .el-tree-node:before {
border-left: none;
display: none;
}
.el-tree > .el-tree-node:after {
border-top: none;
display: none;
}
.el-tree-node__children {
padding-left: 13px;
.el-tree-node {
position: relative;
padding-left: 13px;
&:before {
content: "";
left: -4px;
position: absolute;
right: auto;
border-width: 1px;
}
&:first-child::before {
display: none;
}
&:last-child:before {
height: 38px;
}
&:before {
border-left: 1px dashed #dcdcdc;
bottom: 0;
height: 100%;
top: -26px;
width: 1px;
}
&:after {
content: "";
left: -4px;
position: absolute;
right: auto;
border-width: 1px;
}
&:after {
border-top: 1px dashed #dcdcdc;
height: 20px;
top: 12px;
width: 24px;
}
}
}
.el-tree-node__content:hover {
background-color: transparent;
}
@@ -199,7 +129,7 @@ export default {
}
.el-tree-node__children {
//margin-left: -25px;
margin-left: -25px;
}
}
}

Some files were not shown because too many files have changed in this diff Show More