Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
6d5ff6d7
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
12 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6d5ff6d7
编写于
3月 18, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cache tree expend keys
上级
a003603c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
117 addition
and
53 deletion
+117
-53
internal/comm/helper/zentao/zentao.go
internal/comm/helper/zentao/zentao.go
+33
-25
internal/server/modules/v1/controller/zentao.go
internal/server/modules/v1/controller/zentao.go
+3
-3
internal/server/modules/v1/service/test-filter.go
internal/server/modules/v1/service/test-filter.go
+42
-9
ui/src/config/settings.ts
ui/src/config/settings.ts
+2
-0
ui/src/utils/cache.ts
ui/src/utils/cache.ts
+12
-1
ui/src/views/script/index.vue
ui/src/views/script/index.vue
+25
-15
未找到文件。
internal/comm/helper/zentao/zentao.go
浏览文件 @
6d5ff6d7
...
...
@@ -115,7 +115,6 @@ func ListProduct(workspacePath string) (products []serverDomain.ZentaoProduct, e
config
:=
configUtils
.
LoadByWorkspacePath
(
workspacePath
)
return
loadProduct
(
config
)
}
func
loadProduct
(
config
commDomain
.
WorkspaceConf
)
(
products
[]
serverDomain
.
ZentaoProduct
,
err
error
)
{
if
config
.
Url
==
""
{
err
=
errors
.
New
(
i118Utils
.
Sprintf
(
"pls_config_workspace"
))
...
...
@@ -155,8 +154,11 @@ func loadProduct(config commDomain.WorkspaceConf) (products []serverDomain.Zenta
return
}
func
ListModule
ForCase
(
productId
int
,
workspacePath
string
)
(
modules
[]
serverDomain
.
ZentaoModule
,
err
error
)
{
func
ListModule
(
productId
int
,
workspacePath
string
)
(
modules
[]
serverDomain
.
ZentaoModule
,
err
error
)
{
config
:=
configUtils
.
LoadByWorkspacePath
(
workspacePath
)
return
LoadModule
(
productId
,
config
)
}
func
LoadModule
(
productId
int
,
config
commDomain
.
WorkspaceConf
)
(
modules
[]
serverDomain
.
ZentaoModule
,
err
error
)
{
err
=
Login
(
config
)
if
err
!=
nil
{
return
...
...
@@ -183,34 +185,17 @@ func ListModuleForCase(productId int, workspacePath string) (modules []serverDom
for
_
,
item
:=
range
arr
{
mp
:=
item
.
(
map
[
string
]
interface
{})
mp
[
"level"
]
=
0
G
enModuleData
(
mp
,
&
modules
)
g
enModuleData
(
mp
,
&
modules
)
}
return
}
func
GenModuleData
(
mp
map
[
string
]
interface
{},
modules
*
[]
serverDomain
.
ZentaoModule
)
{
mpLevel
:=
mp
[
"level"
]
.
(
int
)
idStr
:=
mp
[
"id"
]
.
(
string
)
id
,
_
:=
strconv
.
Atoi
(
idStr
)
name
:=
strings
.
Repeat
(
" "
,
mpLevel
*
3
)
+
mp
[
"name"
]
.
(
string
)
*
modules
=
append
(
*
modules
,
serverDomain
.
ZentaoModule
{
Id
:
id
,
Name
:
name
})
if
mp
[
"children"
]
==
nil
{
return
}
children
:=
mp
[
"children"
]
.
([]
interface
{})
for
_
,
child
:=
range
children
{
childMap
:=
child
.
(
map
[
string
]
interface
{})
childMap
[
"level"
]
=
mp
[
"level"
]
.
(
int
)
+
1
GenModuleData
(
childMap
,
modules
)
}
}
func
ListSuiteByProduct
(
productId
int
,
workspacePath
string
)
(
suites
[]
serverDomain
.
ZentaoSuite
,
err
error
)
{
func
ListSuite
(
productId
int
,
workspacePath
string
)
(
products
[]
serverDomain
.
ZentaoSuite
,
err
error
)
{
config
:=
configUtils
.
LoadByWorkspacePath
(
workspacePath
)
return
LoadSuite
(
productId
,
config
)
}
func
LoadSuite
(
productId
int
,
config
commDomain
.
WorkspaceConf
)
(
suites
[]
serverDomain
.
ZentaoSuite
,
err
error
)
{
err
=
Login
(
config
)
if
err
!=
nil
{
return
...
...
@@ -246,8 +231,11 @@ func ListSuiteByProduct(productId int, workspacePath string) (suites []serverDom
return
}
func
ListTask
ByProduct
(
productId
int
,
workspacePath
string
)
(
task
s
[]
serverDomain
.
ZentaoTask
,
err
error
)
{
func
ListTask
(
productId
int
,
workspacePath
string
)
(
product
s
[]
serverDomain
.
ZentaoTask
,
err
error
)
{
config
:=
configUtils
.
LoadByWorkspacePath
(
workspacePath
)
return
LoadTask
(
productId
,
config
)
}
func
LoadTask
(
productId
int
,
config
commDomain
.
WorkspaceConf
)
(
tasks
[]
serverDomain
.
ZentaoTask
,
err
error
)
{
if
config
.
Url
==
""
{
err
=
errors
.
New
(
i118Utils
.
Sprintf
(
"pls_config_workspace"
))
return
...
...
@@ -288,3 +276,23 @@ func ListTaskByProduct(productId int, workspacePath string) (tasks []serverDomai
return
}
func
genModuleData
(
mp
map
[
string
]
interface
{},
modules
*
[]
serverDomain
.
ZentaoModule
)
{
mpLevel
:=
mp
[
"level"
]
.
(
int
)
idStr
:=
mp
[
"id"
]
.
(
string
)
id
,
_
:=
strconv
.
Atoi
(
idStr
)
name
:=
strings
.
Repeat
(
" "
,
mpLevel
*
3
)
+
mp
[
"name"
]
.
(
string
)
*
modules
=
append
(
*
modules
,
serverDomain
.
ZentaoModule
{
Id
:
id
,
Name
:
name
})
if
mp
[
"children"
]
==
nil
{
return
}
children
:=
mp
[
"children"
]
.
([]
interface
{})
for
_
,
child
:=
range
children
{
childMap
:=
child
.
(
map
[
string
]
interface
{})
childMap
[
"level"
]
=
mp
[
"level"
]
.
(
int
)
+
1
genModuleData
(
childMap
,
modules
)
}
}
internal/server/modules/v1/controller/zentao.go
浏览文件 @
6d5ff6d7
...
...
@@ -78,7 +78,7 @@ func (c *ZentaoCtrl) ListModule(ctx iris.Context) {
return
}
data
,
err
:=
zentaoHelper
.
ListModule
ForCase
(
productId
,
workspacePath
)
data
,
err
:=
zentaoHelper
.
ListModule
(
productId
,
workspacePath
)
if
err
!=
nil
{
ctx
.
JSON
(
c
.
ErrResp
(
commConsts
.
CommErr
,
err
.
Error
()))
return
...
...
@@ -95,7 +95,7 @@ func (c *ZentaoCtrl) ListSuite(ctx iris.Context) {
return
}
data
,
err
:=
zentaoHelper
.
ListSuite
ByProduct
(
productId
,
workspacePath
)
data
,
err
:=
zentaoHelper
.
ListSuite
(
productId
,
workspacePath
)
if
err
!=
nil
{
ctx
.
JSON
(
c
.
ErrResp
(
commConsts
.
CommErr
,
err
.
Error
()))
return
...
...
@@ -112,7 +112,7 @@ func (c *ZentaoCtrl) ListTask(ctx iris.Context) {
return
}
data
,
err
:=
zentaoHelper
.
ListTask
ByProduct
(
productId
,
workspacePath
)
data
,
err
:=
zentaoHelper
.
ListTask
(
productId
,
workspacePath
)
if
err
!=
nil
{
ctx
.
JSON
(
c
.
ErrResp
(
commConsts
.
CommErr
,
err
.
Error
()))
return
...
...
internal/server/modules/v1/service/test-filter.go
浏览文件 @
6d5ff6d7
...
...
@@ -2,6 +2,8 @@ package service
import
(
commConsts
"github.com/aaronchen2k/deeptest/internal/comm/consts"
commDomain
"github.com/aaronchen2k/deeptest/internal/comm/domain"
zentaoHelper
"github.com/aaronchen2k/deeptest/internal/comm/helper/zentao"
serverDomain
"github.com/aaronchen2k/deeptest/internal/server/modules/v1/domain"
"github.com/aaronchen2k/deeptest/internal/server/modules/v1/repo"
)
...
...
@@ -23,19 +25,19 @@ func (s *TestFilterService) ListFilterItems(filerType commConsts.ScriptFilterTyp
return
}
//
site, _ := s.SiteService.GetDomainObject(uint(siteId))
//
config := commDomain.WorkspaceConf{
//
Url: site.Url,
//
Username: site.Username,
//
Password: site.Password,
//
}
site
,
_
:=
s
.
SiteService
.
GetDomainObject
(
uint
(
siteId
))
config
:=
commDomain
.
WorkspaceConf
{
Url
:
site
.
Url
,
Username
:
site
.
Username
,
Password
:
site
.
Password
,
}
if
filerType
==
commConsts
.
FilterModule
{
ret
,
err
=
s
.
ListModuleFilter
(
config
,
productId
)
}
else
if
filerType
==
commConsts
.
FilterSuite
{
ret
,
err
=
s
.
ListSuiteFilter
(
config
,
productId
)
}
else
if
filerType
==
commConsts
.
FilterTask
{
ret
,
err
=
s
.
ListTaskFilter
(
config
,
productId
)
}
return
...
...
@@ -51,3 +53,34 @@ func (s *TestFilterService) ListWorkspaceFilter(siteId int, productId int) (ret
return
}
func
(
s
*
TestFilterService
)
ListModuleFilter
(
config
commDomain
.
WorkspaceConf
,
productId
int
)
(
ret
[]
serverDomain
.
FilterItem
,
err
error
)
{
modules
,
_
:=
zentaoHelper
.
LoadModule
(
productId
,
config
)
for
_
,
item
:=
range
modules
{
filterItem
:=
serverDomain
.
FilterItem
{
Label
:
item
.
Name
,
Value
:
item
.
Id
}
ret
=
append
(
ret
,
filterItem
)
}
return
}
func
(
s
*
TestFilterService
)
ListSuiteFilter
(
config
commDomain
.
WorkspaceConf
,
productId
int
)
(
ret
[]
serverDomain
.
FilterItem
,
err
error
)
{
suites
,
_
:=
zentaoHelper
.
LoadSuite
(
productId
,
config
)
for
_
,
item
:=
range
suites
{
filterItem
:=
serverDomain
.
FilterItem
{
Label
:
item
.
Name
,
Value
:
item
.
Id
}
ret
=
append
(
ret
,
filterItem
)
}
return
}
func
(
s
*
TestFilterService
)
ListTaskFilter
(
config
commDomain
.
WorkspaceConf
,
productId
int
)
(
ret
[]
serverDomain
.
FilterItem
,
err
error
)
{
tasks
,
_
:=
zentaoHelper
.
LoadTask
(
productId
,
config
)
for
_
,
item
:=
range
tasks
{
filterItem
:=
serverDomain
.
FilterItem
{
Label
:
item
.
Name
,
Value
:
item
.
Id
}
ret
=
append
(
ret
,
filterItem
)
}
return
}
ui/src/config/settings.ts
浏览文件 @
6d5ff6d7
...
...
@@ -30,6 +30,7 @@ export interface SettingsType {
currProductIdBySite
:
string
;
currWorkspace
:
string
;
scriptFilters
:
string
;
expandedKeys
:
string
;
/**
* Ajax请求头发送Token 的 Key值
...
...
@@ -58,6 +59,7 @@ const settings: SettingsType = {
currProductIdBySite
:
'
currProductIdBySite
'
,
currWorkspace
:
'
currWorkspace
'
,
scriptFilters
:
'
scriptFilters
'
,
expandedKeys
:
'
expandedKeys
'
,
ajaxHeadersTokenKey
:
'
Authorization
'
,
ajaxResponseNoVerifyUrl
:
[
...
...
ui/src/utils/cache.ts
浏览文件 @
6d5ff6d7
...
...
@@ -43,6 +43,17 @@ export const setScriptFilters = async (by, val) => {
if
(
val
)
mp
[
by
]
=
val
console
.
log
(
'
---
'
,
mp
)
await
setCache
(
settings
.
scriptFilters
,
mp
);
}
export
const
cacheExpandedKeys
=
async
(
keys
)
=>
{
console
.
log
(
'
cacheExpandedKeys
'
,
keys
)
const
arr
=
[...
keys
]
await
setCache
(
settings
.
expandedKeys
,
arr
);
}
export
const
retrieveExpandedKeys
=
async
()
=>
{
console
.
log
(
'
retrieveExpandedKeys
'
)
const
keys
=
await
getCache
(
settings
.
expandedKeys
);
return
[...
keys
]
}
ui/src/views/script/index.vue
浏览文件 @
6d5ff6d7
...
...
@@ -21,7 +21,7 @@
ref=
"select"
v-model:value=
"filerValue"
@
change=
"selectFilerValue"
style=
"width:
12
0px"
style=
"width:
20
0px"
:bordered=
"false"
:dropdownMatchSelectWidth=
"false"
>
...
...
@@ -92,8 +92,9 @@ import {Empty, message, notification} from "ant-design-vue";
import
{
MonacoOptions
}
from
"
@/utils/const
"
;
import
MonacoEditor
from
"
@/components/Editor/MonacoEditor.vue
"
;
import
{
ZentaoData
}
from
"
@/store/zentao
"
;
import
{
getScriptFilter
s
,
setScriptFilters
}
from
"
@/utils/cache
"
;
import
{
cacheExpandedKeys
,
getScriptFilters
,
retrieveExpandedKey
s
,
setScriptFilters
}
from
"
@/utils/cache
"
;
import
{
listFilterItems
}
from
"
@/views/script/service
"
;
import
_
from
"
lodash
"
;
interface
ListScriptPageSetupData
{
t
:
(
key
:
string
|
number
)
=>
string
;
...
...
@@ -146,6 +147,19 @@ export default defineComponent({
const
currProduct
=
computed
<
any
>
(()
=>
zentaoStore
.
state
.
zentao
.
currProduct
);
const
treeData
=
computed
<
any
>
(()
=>
zentaoStore
.
state
.
zentao
.
testScripts
);
watch
(
treeData
,
(
currConfig
)
=>
{
console
.
log
(
'
watch treeData
'
,
treeData
.
value
)
retrieveExpandedKeys
().
then
(
async
keys
=>
{
console
.
log
(
'
keys
'
,
keys
,
expandedKeys
.
value
)
if
(
keys
)
expandedKeys
.
value
=
keys
if
(
!
expandedKeys
.
value
||
expandedKeys
.
value
.
length
===
0
)
{
getOpenKeys
(
treeData
.
value
[
0
],
false
)
// expend first level folder
await
cacheExpandedKeys
(
expandedKeys
.
value
)
}
})
},
{
deep
:
true
})
console
.
log
(
`treeData loaded
${
scriptLoaded
.
value
}
`
,
treeData
.
value
.
length
)
if
(
!
scriptLoaded
.
value
)
{
// switch to current page
zentaoStore
.
dispatch
(
'
zentao/fetchSitesAndProducts
'
,
{
needLoadScript
:
true
})
...
...
@@ -160,7 +174,6 @@ export default defineComponent({
filerType
.
value
=
filter
.
by
filerValue
.
value
=
filter
.
val
listFilterItems
(
filerType
.
value
).
then
((
data
)
=>
{
console
.
log
(
'
ksjdhfdsf
'
,
data
)
filerItems
.
value
=
data
.
data
})
}
...
...
@@ -190,10 +203,6 @@ export default defineComponent({
expandedKeys
.
value
=
[]
getOpenKeys
(
treeData
.
value
[
0
],
false
)
watch
(
treeData
,
(
currConfig
)
=>
{
expandedKeys
.
value
=
[]
getOpenKeys
(
treeData
.
value
[
0
],
false
)
})
let
tree
=
ref
(
null
)
...
...
@@ -208,10 +217,6 @@ export default defineComponent({
resizeWidth
(
'
main
'
,
'
left
'
,
'
resize
'
,
'
content
'
,
280
,
800
)
})
const
expandNode
=
(
keys
:
string
[],
e
:
any
)
=>
{
console
.
log
(
'
expandNode
'
,
keys
[
0
],
e
)
}
onUnmounted
(()
=>
{
console
.
log
(
'
onUnmounted
'
,
tree
)
})
...
...
@@ -230,15 +235,20 @@ export default defineComponent({
})
}
const
expandNode
=
(
keys
:
string
[],
e
:
any
)
=>
{
console
.
log
(
'
expandNode
'
,
expandedKeys
.
value
)
cacheExpandedKeys
(
expandedKeys
.
value
)
}
const
expandAll
=
(
e
)
=>
{
console
.
log
(
'
expandAll
'
)
isExpand
.
value
=
!
isExpand
.
value
expandedKeys
.
value
=
[]
if
(
isExpand
.
value
)
{
getOpenKeys
(
treeData
.
value
[
0
],
true
)
}
if
(
isExpand
.
value
)
getOpenKeys
(
treeData
.
value
[
0
],
true
)
console
.
log
(
'
expandAll
'
,
expandedKeys
.
value
)
cacheExpandedKeys
(
expandedKeys
.
value
)
}
const
extract
=
()
=>
{
console
.
log
(
'
extract
'
,
selectedNode
.
props
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录