mirror of
https://github.com/jumpserver/lina.git
synced 2025-11-08 19:02:40 +00:00
Compare commits
815 Commits
v3.4.2
...
pr@v3@fix_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1dd874562 | ||
|
|
81b3c79ac1 | ||
|
|
710fa9c109 | ||
|
|
b3a3ca13a7 | ||
|
|
e04abd8b79 | ||
|
|
e3a207f7b6 | ||
|
|
40379ac761 | ||
|
|
33862c716e | ||
|
|
4162bdb74d | ||
|
|
d231bd503c | ||
|
|
b42c5f9170 | ||
|
|
f823257515 | ||
|
|
d3f4b2b2e8 | ||
|
|
5eba19946c | ||
|
|
b4e889316e | ||
|
|
4a72e5aa2b | ||
|
|
6ea86c7efe | ||
|
|
dc0a0ae868 | ||
|
|
5b3b8f72cd | ||
|
|
df26679166 | ||
|
|
9efccb8ada | ||
|
|
d784530539 | ||
|
|
afcc60f29c | ||
|
|
f8d581e455 | ||
|
|
dba1540953 | ||
|
|
456227abcf | ||
|
|
66532f4d4b | ||
|
|
42f27eb30f | ||
|
|
57920bf771 | ||
|
|
290772f44e | ||
|
|
f140f2f59e | ||
|
|
7b1883e012 | ||
|
|
352ac7e828 | ||
|
|
1cbd58664c | ||
|
|
e48da6be9b | ||
|
|
fa31b36550 | ||
|
|
6b93a6563d | ||
|
|
d561701049 | ||
|
|
edbf477c1e | ||
|
|
6a2578b339 | ||
|
|
2cb7569cb0 | ||
|
|
9e0c623b9a | ||
|
|
40bf040501 | ||
|
|
efee7c7bbf | ||
|
|
5daecb84ae | ||
|
|
3be325214d | ||
|
|
581509f42f | ||
|
|
654b36b064 | ||
|
|
dcec73ae67 | ||
|
|
00bafa8164 | ||
|
|
da09af79a7 | ||
|
|
b596815ea5 | ||
|
|
cb37273e80 | ||
|
|
c5bf7d0ad2 | ||
|
|
c31195a67a | ||
|
|
1eb59b379a | ||
|
|
b7cee17156 | ||
|
|
f1c8874010 | ||
|
|
5ccaa3b77d | ||
|
|
27d3637330 | ||
|
|
9c8ceb04f0 | ||
|
|
ccd7b319c8 | ||
|
|
55637c7fa1 | ||
|
|
4e95c88318 | ||
|
|
1ff49ca16d | ||
|
|
91c44d0500 | ||
|
|
0b3a9844f7 | ||
|
|
95b58f3c96 | ||
|
|
128b9c79ba | ||
|
|
4eda83f83d | ||
|
|
4cd0071054 | ||
|
|
67a2a9be6a | ||
|
|
f927a2a3cc | ||
|
|
ca40cb34da | ||
|
|
d725e5497d | ||
|
|
56f6c17275 | ||
|
|
e1bde89b29 | ||
|
|
e9da168c9f | ||
|
|
c19ef24ec9 | ||
|
|
fb7c4a8b2a | ||
|
|
428ba49f9c | ||
|
|
7602d6e270 | ||
|
|
7b62ce2d33 | ||
|
|
6ed40c45b0 | ||
|
|
31238e0398 | ||
|
|
676ac2bbf6 | ||
|
|
d5415b84c9 | ||
|
|
5e91917ba4 | ||
|
|
c4361b4c17 | ||
|
|
70b5ec3683 | ||
|
|
c93a061852 | ||
|
|
4351d20a1e | ||
|
|
ce23d53e3c | ||
|
|
32fc16126f | ||
|
|
b9a99148e3 | ||
|
|
2a4b99484b | ||
|
|
bd26894135 | ||
|
|
01e55d7f6e | ||
|
|
d0a7201683 | ||
|
|
e2dcc98ab3 | ||
|
|
8dd4f89395 | ||
|
|
33a997f3bb | ||
|
|
1adee78456 | ||
|
|
baf2b6cd9b | ||
|
|
28e756e163 | ||
|
|
251873a7e9 | ||
|
|
ff9bd42322 | ||
|
|
2c245020cd | ||
|
|
429d2fec40 | ||
|
|
c2f8fe45a1 | ||
|
|
caa5e7df75 | ||
|
|
8a439dec8d | ||
|
|
eabf5a117d | ||
|
|
c30672a014 | ||
|
|
5c5df32181 | ||
|
|
ce831df717 | ||
|
|
04688930ad | ||
|
|
ae5787ae52 | ||
|
|
1dfdfe3932 | ||
|
|
f409abbf79 | ||
|
|
a6232da3d0 | ||
|
|
2690538db6 | ||
|
|
6d0af7a149 | ||
|
|
babc048eb0 | ||
|
|
d49be903e8 | ||
|
|
332058b0ea | ||
|
|
e355abc1af | ||
|
|
99200d58bb | ||
|
|
61bb97efa9 | ||
|
|
c5e030e2fe | ||
|
|
8a60ad774f | ||
|
|
b08e6de527 | ||
|
|
a96851686f | ||
|
|
1b0adbfe71 | ||
|
|
c28419438b | ||
|
|
8807f24bcd | ||
|
|
b8a914eb02 | ||
|
|
8bbc66a281 | ||
|
|
19bab778ca | ||
|
|
134bcda895 | ||
|
|
8b725fa4f6 | ||
|
|
205f8bc280 | ||
|
|
4963446b74 | ||
|
|
98be3903db | ||
|
|
2cb7a859a8 | ||
|
|
d51571c530 | ||
|
|
bf0d19ac0b | ||
|
|
28062f5d60 | ||
|
|
720dee578a | ||
|
|
cc0d78a4e7 | ||
|
|
9f0b904043 | ||
|
|
90cbb25d47 | ||
|
|
450d9562c3 | ||
|
|
a69eec5ef6 | ||
|
|
5f6fc7e3b4 | ||
|
|
62b6ca026e | ||
|
|
006f258938 | ||
|
|
756b7db6b6 | ||
|
|
a8d7c01f94 | ||
|
|
0c7e7ecc99 | ||
|
|
342a70c441 | ||
|
|
815247f5b5 | ||
|
|
e6721a9905 | ||
|
|
d6305fddfd | ||
|
|
6db2d5ae31 | ||
|
|
9b43bba6f8 | ||
|
|
f9d89b30e2 | ||
|
|
be29794b4c | ||
|
|
97bf4f1b97 | ||
|
|
76e7684e26 | ||
|
|
2bfd764da7 | ||
|
|
daf3defe14 | ||
|
|
d8c165ca78 | ||
|
|
42115b2c30 | ||
|
|
447013abf5 | ||
|
|
44216326f9 | ||
|
|
fd64e71a3b | ||
|
|
7b990a264f | ||
|
|
7687917aae | ||
|
|
02b71619de | ||
|
|
da90b23f99 | ||
|
|
b8090abcdc | ||
|
|
45b07dd628 | ||
|
|
ad7a6a5579 | ||
|
|
67c8521d5c | ||
|
|
18fc63b8c0 | ||
|
|
64d2854e49 | ||
|
|
99f83a6bc4 | ||
|
|
ca9f90624e | ||
|
|
05edf98514 | ||
|
|
45b8c622bc | ||
|
|
faf1fb60b7 | ||
|
|
f28825ba74 | ||
|
|
3626fd024d | ||
|
|
79ec0610a8 | ||
|
|
eee5889d51 | ||
|
|
038ec49d5e | ||
|
|
669ffc73fd | ||
|
|
278562e855 | ||
|
|
fafa088a5e | ||
|
|
1ff65a2293 | ||
|
|
1c69c61432 | ||
|
|
046870e366 | ||
|
|
b44af12f3b | ||
|
|
d9a9c7e229 | ||
|
|
55dfa5889b | ||
|
|
b35b5bd774 | ||
|
|
1ee9e5df78 | ||
|
|
2fe6cb37e6 | ||
|
|
da570e21ee | ||
|
|
16adcd299a | ||
|
|
df8a464c36 | ||
|
|
52e121cfdb | ||
|
|
f014fc6426 | ||
|
|
88a6c2bb2b | ||
|
|
8fa31fe0c2 | ||
|
|
8f246c18e1 | ||
|
|
9d999a7119 | ||
|
|
dc8f237fec | ||
|
|
41d0615ab5 | ||
|
|
fadc3e7dd0 | ||
|
|
152f56b496 | ||
|
|
ed4f8dea90 | ||
|
|
dced020a20 | ||
|
|
bf3c87575c | ||
|
|
dadb54090c | ||
|
|
3f683b012c | ||
|
|
ecb1e91136 | ||
|
|
454947f08b | ||
|
|
3ff6c6fe2f | ||
|
|
527cc4d727 | ||
|
|
3b4201d2bf | ||
|
|
ba109da324 | ||
|
|
2a92c7657c | ||
|
|
beb8ace5bd | ||
|
|
5e1225524c | ||
|
|
931042eb2f | ||
|
|
383577bb18 | ||
|
|
f9e94386de | ||
|
|
5879eed926 | ||
|
|
e1e54bf7a3 | ||
|
|
9e0c43589d | ||
|
|
ca3b0cfce5 | ||
|
|
245b3f4ad2 | ||
|
|
ea575e0515 | ||
|
|
ff63d2ca39 | ||
|
|
045af27999 | ||
|
|
257365932c | ||
|
|
aca4e4077f | ||
|
|
ce80d36b8b | ||
|
|
7dd5256303 | ||
|
|
fcf1093b4c | ||
|
|
5f9e9afffb | ||
|
|
1bba9980c2 | ||
|
|
6cbcee7656 | ||
|
|
2084c50f95 | ||
|
|
20d98bf09e | ||
|
|
05c2f1f859 | ||
|
|
1e9107ec4a | ||
|
|
96a3f0a334 | ||
|
|
6938299940 | ||
|
|
0d1eb82fca | ||
|
|
ddf268e8ec | ||
|
|
ae6fb878da | ||
|
|
d7099c118b | ||
|
|
1b73591366 | ||
|
|
6f3f66df73 | ||
|
|
598020a89b | ||
|
|
88486e2b00 | ||
|
|
faf8521c91 | ||
|
|
ccd74fb76f | ||
|
|
d76c6fdbd8 | ||
|
|
af6a55d3f4 | ||
|
|
c052961efe | ||
|
|
57d339f513 | ||
|
|
097771175d | ||
|
|
0922557abc | ||
|
|
6842da1960 | ||
|
|
eb839b4113 | ||
|
|
7e3e8fbf2f | ||
|
|
3800151763 | ||
|
|
0121505f28 | ||
|
|
b9a6f5d3ac | ||
|
|
179b568b16 | ||
|
|
c563697efd | ||
|
|
fa9281aa92 | ||
|
|
cc8d94f666 | ||
|
|
1416405644 | ||
|
|
d29b3effbc | ||
|
|
bd9456ba2d | ||
|
|
0c9d5d9b6b | ||
|
|
b19ddd6799 | ||
|
|
ea48b6ebf3 | ||
|
|
fba2f77874 | ||
|
|
3c900ce387 | ||
|
|
7df11b907f | ||
|
|
cdd51a9c16 | ||
|
|
51a4c013d3 | ||
|
|
111aafb4bb | ||
|
|
81f0b13730 | ||
|
|
a36a9e7645 | ||
|
|
cfe6db6ec5 | ||
|
|
ccb221559a | ||
|
|
ace8501648 | ||
|
|
ff627bb0db | ||
|
|
dba8d84f2d | ||
|
|
e24bfff6ab | ||
|
|
cdcc4226db | ||
|
|
09b52738ca | ||
|
|
e324b16e1b | ||
|
|
1b52e4cb93 | ||
|
|
6ac31b05e5 | ||
|
|
6c24c9a2d9 | ||
|
|
b79ef4f7a8 | ||
|
|
d584f83f59 | ||
|
|
22ed0ec0ca | ||
|
|
436e9e59f1 | ||
|
|
ba63d52275 | ||
|
|
aa48e24881 | ||
|
|
f59b33a27f | ||
|
|
9f87708b96 | ||
|
|
78819e9a04 | ||
|
|
8e981d52eb | ||
|
|
9f4c798ddb | ||
|
|
7eac62635b | ||
|
|
3739d710f8 | ||
|
|
aae5aa9d7f | ||
|
|
88be5d5fe8 | ||
|
|
6ac54c9865 | ||
|
|
5cefbbfb51 | ||
|
|
f10e31bd60 | ||
|
|
e8e8b5bfca | ||
|
|
19adbca7b3 | ||
|
|
ba28d5619a | ||
|
|
68363a4c52 | ||
|
|
f947fa8d36 | ||
|
|
c1d0994781 | ||
|
|
fde576fe8b | ||
|
|
27864be41d | ||
|
|
9d461be4a0 | ||
|
|
bcbfe114d8 | ||
|
|
af8448adeb | ||
|
|
9b7a360ea1 | ||
|
|
3bf7eed52e | ||
|
|
c1d80469db | ||
|
|
e6a1039387 | ||
|
|
ad7b2c4e8f | ||
|
|
d51a787598 | ||
|
|
2ac9183047 | ||
|
|
3b9f0b56fb | ||
|
|
d900a8d5a3 | ||
|
|
6daa16b3ca | ||
|
|
28891234db | ||
|
|
1d7bdcb512 | ||
|
|
0964031922 | ||
|
|
6568f47760 | ||
|
|
448e89c733 | ||
|
|
68dccaa93c | ||
|
|
b0cefb05e0 | ||
|
|
d6bf4c86df | ||
|
|
993ded5ca8 | ||
|
|
951df9e63a | ||
|
|
4b98806b3e | ||
|
|
536520c78c | ||
|
|
63650912b8 | ||
|
|
b65069adeb | ||
|
|
7bd3179488 | ||
|
|
bf6ecca1fa | ||
|
|
69449740df | ||
|
|
591f3ae39a | ||
|
|
463d2b16bf | ||
|
|
cc47d93988 | ||
|
|
19e42c48e4 | ||
|
|
6b37c71b6d | ||
|
|
3af6b1d1fe | ||
|
|
2445ecb6e5 | ||
|
|
a5ae4110da | ||
|
|
dc4378b637 | ||
|
|
91f2de7797 | ||
|
|
29b2829199 | ||
|
|
4e23a34af9 | ||
|
|
2bd1aaa03e | ||
|
|
96e23ddb52 | ||
|
|
351e250688 | ||
|
|
e8ebd1aa64 | ||
|
|
6adca44180 | ||
|
|
f3699069c5 | ||
|
|
2f298a32c3 | ||
|
|
3ba81a43cb | ||
|
|
813f17b52f | ||
|
|
0fc292b1ad | ||
|
|
f3f5bbe114 | ||
|
|
8c732f00e1 | ||
|
|
f91b8c75df | ||
|
|
e86b88bf05 | ||
|
|
bf3a2d748d | ||
|
|
8a4b81e2e5 | ||
|
|
34406ec32d | ||
|
|
3269a2a3ff | ||
|
|
5d50844753 | ||
|
|
97cc73a4fa | ||
|
|
574dae6236 | ||
|
|
84c413f51a | ||
|
|
87a1cce4ca | ||
|
|
be89b5d6f2 | ||
|
|
200c727426 | ||
|
|
d563f66ba1 | ||
|
|
4592eeddd3 | ||
|
|
d73a07dff2 | ||
|
|
e8857bf150 | ||
|
|
0abe33053f | ||
|
|
dc9161c6a7 | ||
|
|
d588be696b | ||
|
|
4b2c806f28 | ||
|
|
e28b026ead | ||
|
|
c7414e0199 | ||
|
|
5a478ebaba | ||
|
|
08577f0ae5 | ||
|
|
38527c6a41 | ||
|
|
01c5b7c4a8 | ||
|
|
b0b3e0d1c9 | ||
|
|
5bc273d057 | ||
|
|
e128576763 | ||
|
|
58f4dca599 | ||
|
|
a6dd7f23c7 | ||
|
|
a267d46464 | ||
|
|
8c829ee498 | ||
|
|
bcfa95de06 | ||
|
|
56745ae944 | ||
|
|
5a664f8c2c | ||
|
|
1fd29e13f8 | ||
|
|
af863dae75 | ||
|
|
b1254d2b87 | ||
|
|
d350cadd4c | ||
|
|
cfe9ebd747 | ||
|
|
03177d4ce9 | ||
|
|
a55b0da22b | ||
|
|
1b0bdf25ae | ||
|
|
c746cdc639 | ||
|
|
3cf6b6f639 | ||
|
|
a1bf8f9ab7 | ||
|
|
5449d74d53 | ||
|
|
dc401f80b9 | ||
|
|
379cd2386a | ||
|
|
4e7bdb9c69 | ||
|
|
41449fb538 | ||
|
|
a75488217c | ||
|
|
8e32792696 | ||
|
|
b47caf0287 | ||
|
|
715ae856f0 | ||
|
|
19ae27e6c2 | ||
|
|
2132bacff5 | ||
|
|
e57c5a20d0 | ||
|
|
3d35f0aafe | ||
|
|
68ac03db9e | ||
|
|
7b5471a451 | ||
|
|
7f052ac85e | ||
|
|
64e75eb9ff | ||
|
|
8e75e5d5e3 | ||
|
|
1810e6833c | ||
|
|
8c7c012785 | ||
|
|
378d82518a | ||
|
|
728b04c8e3 | ||
|
|
b8611f095a | ||
|
|
f49a1184e2 | ||
|
|
77a4441018 | ||
|
|
18f1f0de79 | ||
|
|
d252c7dd08 | ||
|
|
e5547f8a4c | ||
|
|
63d6578991 | ||
|
|
da00ae84a8 | ||
|
|
74a905ee85 | ||
|
|
a03e985df3 | ||
|
|
2d6005a4e0 | ||
|
|
c4ca28d2d9 | ||
|
|
3934c17f52 | ||
|
|
51717f8583 | ||
|
|
67e99702c1 | ||
|
|
27ce5a3785 | ||
|
|
49122bb213 | ||
|
|
263c4d3f89 | ||
|
|
2ed203dc32 | ||
|
|
742a06ea2d | ||
|
|
1ad4e2c62e | ||
|
|
7e29a3e836 | ||
|
|
3a66e8323c | ||
|
|
4852e3d26a | ||
|
|
80509dc15f | ||
|
|
601bd4740c | ||
|
|
62be5885db | ||
|
|
62e49567cc | ||
|
|
f2eff11d66 | ||
|
|
ae61586f95 | ||
|
|
a08fbc3b77 | ||
|
|
53d130f1cf | ||
|
|
c05992ce50 | ||
|
|
52522b7095 | ||
|
|
af3f6c5900 | ||
|
|
7b15ca4955 | ||
|
|
031016330a | ||
|
|
e274640d2e | ||
|
|
bd3352424c | ||
|
|
f8ec2bce0c | ||
|
|
81f34f0154 | ||
|
|
759e205bfb | ||
|
|
fc5029e88a | ||
|
|
6fa8052878 | ||
|
|
0dc62712d4 | ||
|
|
23b08590cf | ||
|
|
8d8ab483e1 | ||
|
|
fb757686e3 | ||
|
|
6a8161dcaf | ||
|
|
ae2391f07f | ||
|
|
50a9ce35ad | ||
|
|
2d2a4be3a2 | ||
|
|
e055429ff2 | ||
|
|
8727bac560 | ||
|
|
fd018dc5ac | ||
|
|
4c3673aef2 | ||
|
|
4eb61373e0 | ||
|
|
8e8dd38e2e | ||
|
|
f8b7720e2c | ||
|
|
50af6fe017 | ||
|
|
8bc617c4a7 | ||
|
|
f75d69601b | ||
|
|
f54d819ec8 | ||
|
|
c50db4089c | ||
|
|
a6d7cc1215 | ||
|
|
f6a2fcbbea | ||
|
|
071822e665 | ||
|
|
063dc9f8e1 | ||
|
|
66e90f189c | ||
|
|
bdd1a86568 | ||
|
|
01d0c9a0c2 | ||
|
|
d42bd25371 | ||
|
|
2d07b10961 | ||
|
|
77fb9ef528 | ||
|
|
b5950b795b | ||
|
|
097817e02c | ||
|
|
cf7a77ce2e | ||
|
|
e72850bff8 | ||
|
|
4669cbfc83 | ||
|
|
cf8ad2a581 | ||
|
|
b776d0157b | ||
|
|
9aaee957af | ||
|
|
0bc681ea08 | ||
|
|
ea89ce1796 | ||
|
|
e8a37a9c5b | ||
|
|
1350573ee2 | ||
|
|
ba83bb14f3 | ||
|
|
7ae5adf49c | ||
|
|
85a1385b4b | ||
|
|
4da8eb12dc | ||
|
|
bf1be51c39 | ||
|
|
3bbe9eccc1 | ||
|
|
65e84b9b41 | ||
|
|
0619900fd7 | ||
|
|
9ecc759dac | ||
|
|
946787e876 | ||
|
|
54c30fcc0d | ||
|
|
83d730cf0f | ||
|
|
7f7173432d | ||
|
|
c1e5f1c1ce | ||
|
|
ca3a99a5cf | ||
|
|
95831c3ff7 | ||
|
|
b5abf3e6ad | ||
|
|
9e4f519fc5 | ||
|
|
b712ec4183 | ||
|
|
35936ad01e | ||
|
|
de5aed0f58 | ||
|
|
5cb8cec835 | ||
|
|
d66b2a8a87 | ||
|
|
d06637afd4 | ||
|
|
b27d88859f | ||
|
|
61580e096b | ||
|
|
da5d67ccbe | ||
|
|
85a88616b0 | ||
|
|
3d3dfcafd3 | ||
|
|
d51e025f04 | ||
|
|
e78d201bd5 | ||
|
|
e1836eb1c6 | ||
|
|
085447255b | ||
|
|
e3da28221e | ||
|
|
b276bbad34 | ||
|
|
f534b292ce | ||
|
|
a02e5363e0 | ||
|
|
a0dbb3d7b0 | ||
|
|
b6e955f4b7 | ||
|
|
902662681c | ||
|
|
0196d42ffc | ||
|
|
a0a7590769 | ||
|
|
b18c045a1b | ||
|
|
e0411010d1 | ||
|
|
757c48ebc8 | ||
|
|
38ea835df5 | ||
|
|
869b94d365 | ||
|
|
25a8f43345 | ||
|
|
7f2cb97bd7 | ||
|
|
580c005bc6 | ||
|
|
e22d46bb38 | ||
|
|
8d7dd81ebd | ||
|
|
d5aa439fee | ||
|
|
095492e5a3 | ||
|
|
a4e2cadedd | ||
|
|
29b35ff2a9 | ||
|
|
4b137f855e | ||
|
|
d836b46966 | ||
|
|
f9d7d68c77 | ||
|
|
cafc5879a0 | ||
|
|
2ec88c3591 | ||
|
|
c37212a5ce | ||
|
|
f9c334b003 | ||
|
|
d43d4137d7 | ||
|
|
614565ba9c | ||
|
|
575015616f | ||
|
|
26fac22b82 | ||
|
|
40b7c62099 | ||
|
|
017486e961 | ||
|
|
7bb4567345 | ||
|
|
76c78df007 | ||
|
|
ff6ac297b9 | ||
|
|
6b953506e4 | ||
|
|
7ec130f033 | ||
|
|
2f9e00de2e | ||
|
|
e479dbfcb5 | ||
|
|
1e5b6f970d | ||
|
|
e7222fb63c | ||
|
|
f9617a92a8 | ||
|
|
38e1b070cf | ||
|
|
f75d97305f | ||
|
|
7df0cc78b1 | ||
|
|
a8a90930b9 | ||
|
|
69dbf2f5da | ||
|
|
fc8339d659 | ||
|
|
eada8d319d | ||
|
|
11940428a0 | ||
|
|
af2544e24b | ||
|
|
4546952388 | ||
|
|
a0c849f29d | ||
|
|
fb9cd1614a | ||
|
|
c1543183a2 | ||
|
|
03dc3e993c | ||
|
|
8719ffee8e | ||
|
|
cc60f2c1f5 | ||
|
|
f042692dbf | ||
|
|
3d8dc619ad | ||
|
|
b223c73a47 | ||
|
|
53e313517d | ||
|
|
56bea8eaf4 | ||
|
|
992025e618 | ||
|
|
205d301578 | ||
|
|
4daccc9df3 | ||
|
|
ac802fff59 | ||
|
|
a6b0da60a3 | ||
|
|
45c860797a | ||
|
|
e636aa24c8 | ||
|
|
86b37eeeba | ||
|
|
61cf9e7f14 | ||
|
|
344e49e7ec | ||
|
|
3ebdacafd0 | ||
|
|
e1ae467823 | ||
|
|
65c1ab450b | ||
|
|
cbe3efdb18 | ||
|
|
e5eaa5bcfa | ||
|
|
df687c0c06 | ||
|
|
1cc00517f5 | ||
|
|
f3a6d6c02b | ||
|
|
7bf33a9011 | ||
|
|
7948a59b80 | ||
|
|
af9f715357 | ||
|
|
202f8a357c | ||
|
|
3e75c781b3 | ||
|
|
3c3ed27eb2 | ||
|
|
fd0e23e35f | ||
|
|
c09a2df142 | ||
|
|
36737a6f25 | ||
|
|
e4af9ccc1e | ||
|
|
3c256c6fdc | ||
|
|
1e36f59b23 | ||
|
|
aec6ee8376 | ||
|
|
526b049495 | ||
|
|
5bef5a59a9 | ||
|
|
1e371a4e32 | ||
|
|
0f6fd0ed70 | ||
|
|
fc1aefbb54 | ||
|
|
7561f1224d | ||
|
|
0932132add | ||
|
|
8492882633 | ||
|
|
11698255f6 | ||
|
|
53eee6c857 | ||
|
|
f2bc4d6f22 | ||
|
|
e50b16b13b | ||
|
|
232c30cadb | ||
|
|
3142da16ae | ||
|
|
741f8b847e | ||
|
|
b6d00a1784 | ||
|
|
2f122f7fbe | ||
|
|
c3c46b759e | ||
|
|
a1c4013a69 | ||
|
|
8aa9690a61 | ||
|
|
30c0100a0b | ||
|
|
134dd17f3f | ||
|
|
505642baec | ||
|
|
c08964ee34 | ||
|
|
9df443667c | ||
|
|
8fd8e9c1d4 | ||
|
|
aa3ab5e138 | ||
|
|
a7df8706e5 | ||
|
|
c200781322 | ||
|
|
75c7778a10 | ||
|
|
c30e919573 | ||
|
|
ffff648e6d | ||
|
|
981e676fa2 | ||
|
|
664855d4b0 | ||
|
|
c79637095a | ||
|
|
2a96abdd4a | ||
|
|
9541b97b23 | ||
|
|
52518a9ff3 | ||
|
|
24a1c11288 | ||
|
|
313aebaf50 | ||
|
|
5c6373e689 | ||
|
|
09fe3ea107 | ||
|
|
ccf081b608 | ||
|
|
80ce3293a1 | ||
|
|
4ed282ff2b | ||
|
|
dd8957cb69 | ||
|
|
36c687b854 | ||
|
|
e22ecb6fe8 | ||
|
|
b77440284f | ||
|
|
93d866328c | ||
|
|
42c7b278c5 | ||
|
|
14ba501f2b | ||
|
|
f072546083 | ||
|
|
8f9ebcdfa9 | ||
|
|
7b76917768 | ||
|
|
e4d4bc84b6 | ||
|
|
62cf19e70e | ||
|
|
2cb36f89f0 | ||
|
|
9946ad75ad | ||
|
|
abd8919225 | ||
|
|
6e5e760689 | ||
|
|
1235895973 | ||
|
|
59f9025e42 | ||
|
|
d06bda6d40 | ||
|
|
a8099089b2 | ||
|
|
fd0c14e1c0 | ||
|
|
9a04c81238 | ||
|
|
f1b3e5038f | ||
|
|
f6fe08607b | ||
|
|
6f2ca3e26a | ||
|
|
3ed9ac0d9b | ||
|
|
821ed14f40 | ||
|
|
6f0ee734e5 | ||
|
|
9a5b174eb1 | ||
|
|
c27e1c97f2 | ||
|
|
1b4e01d19e | ||
|
|
28c836b1f6 | ||
|
|
fc85eaf6b9 | ||
|
|
678d17a4e7 | ||
|
|
ddf9780f9c | ||
|
|
d47bd4acad | ||
|
|
09dabb5d3f | ||
|
|
9eea051884 | ||
|
|
f6a3eb1349 | ||
|
|
433f3a34cb | ||
|
|
aa790944f6 | ||
|
|
57167fc821 | ||
|
|
fb70719cba | ||
|
|
5988892840 | ||
|
|
af11e1bf0c | ||
|
|
09416b13d3 | ||
|
|
478745f534 | ||
|
|
3de2bf73ea | ||
|
|
3b877739a3 | ||
|
|
06899d6932 | ||
|
|
6f3d21bb77 | ||
|
|
b7da517ad7 | ||
|
|
598b6b12e8 | ||
|
|
400ceac737 | ||
|
|
34de6d8775 | ||
|
|
080542633a | ||
|
|
653f26137b | ||
|
|
c86f0cc08d | ||
|
|
541c6c5fe5 | ||
|
|
c36a210cd4 | ||
|
|
b9f26df5e6 | ||
|
|
dd0baa7b00 | ||
|
|
524105278b | ||
|
|
2656546e3b | ||
|
|
ecaf1ceace | ||
|
|
cf515a18de | ||
|
|
a0ab7d3f32 | ||
|
|
467c3f7288 | ||
|
|
f68eaee8c8 | ||
|
|
163f661386 | ||
|
|
e54bc076d6 | ||
|
|
1fbf04ae51 | ||
|
|
f002c4aa3d | ||
|
|
f67bd39067 | ||
|
|
5c60624b2d | ||
|
|
488684f293 | ||
|
|
5c511345bf | ||
|
|
be85a91ccd | ||
|
|
94a02a2e7e | ||
|
|
e60a33a2b1 | ||
|
|
a787737290 | ||
|
|
fa517c8325 | ||
|
|
0748b6ce0c | ||
|
|
59ee3eff17 | ||
|
|
5cc17de1e0 | ||
|
|
42aacd9df5 | ||
|
|
bb27171b09 | ||
|
|
ccc163ef07 | ||
|
|
e63630fce7 | ||
|
|
17748c56c9 |
@@ -22,4 +22,5 @@ VUE_APP_LOGOUT_PATH = '/core/auth/logout/'
|
||||
# Dev server for core proxy
|
||||
VUE_APP_CORE_HOST = 'http://localhost:8080'
|
||||
VUE_APP_CORE_WS = 'ws://localhost:8080'
|
||||
VUE_APP_KAEL_HOST = 'http://localhost:8083'
|
||||
VUE_APP_ENV = 'development'
|
||||
|
||||
@@ -10,3 +10,4 @@ jobs:
|
||||
- uses: jumpserver/action-generic-handler@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PRIVATE_TOKEN }}
|
||||
I18N_TOKEN: ${{ secrets.I18N_TOKEN }}
|
||||
|
||||
36
.github/workflows/release-drafter.yml
vendored
36
.github/workflows/release-drafter.yml
vendored
@@ -19,9 +19,7 @@ jobs:
|
||||
id: get_version
|
||||
run: |
|
||||
TAG=$(basename ${GITHUB_REF})
|
||||
VERSION=${TAG/v/}
|
||||
echo "::set-output name=TAG::$TAG"
|
||||
echo "::set-output name=VERSION::$VERSION"
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: release-drafter/release-drafter@v5
|
||||
@@ -33,17 +31,27 @@ jobs:
|
||||
tag: ${{ steps.get_version.outputs.TAG }}
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14.16'
|
||||
|
||||
build-and-release:
|
||||
needs: create-realese
|
||||
name: Build and Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build it and upload
|
||||
uses: jumpserver/action-build-upload-assets@node10
|
||||
node-version: '16.20'
|
||||
- name: Install dependencies
|
||||
run: yarn install
|
||||
- name: Build web
|
||||
run: |
|
||||
sed -i "s@version-dev@${{ steps.get_version.outputs.TAG }}@g" src/layout/components/NavHeader/About.vue
|
||||
yarn build
|
||||
- name: Create Upload Assets
|
||||
run: |
|
||||
rm -rf build/*
|
||||
mv lina lina-${{ steps.get_version.outputs.TAG }}
|
||||
tar -czf lina-${{ steps.get_version.outputs.TAG }}.tar.gz lina-${{ steps.get_version.outputs.TAG }}
|
||||
echo $(md5sum lina-${{ steps.get_version.outputs.TAG }}.tar.gz | awk '{print $1}') > build/lina-${{ steps.get_version.outputs.TAG }}.tar.gz.md5
|
||||
mv lina-${{ steps.get_version.outputs.TAG }}.tar.gz build/
|
||||
- name: Release Upload Assets
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
draft: true
|
||||
files: |
|
||||
build/lina-${{ steps.get_version.outputs.TAG }}.tar.gz
|
||||
build/lina-${{ steps.get_version.outputs.TAG }}.tar.gz.md5
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create-realese.outputs.upload_url }}
|
||||
|
||||
25
Dockerfile
25
Dockerfile
@@ -1,13 +1,28 @@
|
||||
FROM node:14.16 as stage-build
|
||||
FROM node:16.20-bullseye-slim as stage-build
|
||||
ARG TARGETARCH
|
||||
|
||||
ARG DEPENDENCIES=" \
|
||||
g++ \
|
||||
make \
|
||||
python3"
|
||||
|
||||
ARG APT_MIRROR=http://mirrors.ustc.edu.cn
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=lina \
|
||||
sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
|
||||
&& rm -f /etc/apt/apt.conf.d/docker-clean \
|
||||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ${DEPENDENCIES} \
|
||||
&& echo "no" | dpkg-reconfigure dash \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ARG NPM_REGISTRY="https://registry.npmmirror.com"
|
||||
|
||||
WORKDIR /data
|
||||
|
||||
RUN set -ex \
|
||||
&& npm config set registry ${NPM_REGISTRY} \
|
||||
&& yarn config set registry ${NPM_REGISTRY}
|
||||
|
||||
WORKDIR /data
|
||||
|
||||
ADD package.json yarn.lock /data
|
||||
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=lina \
|
||||
yarn install
|
||||
@@ -19,6 +34,6 @@ RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=lin
|
||||
sed -i "s@version-dev@${VERSION}@g" src/layout/components/NavHeader/About.vue \
|
||||
&& yarn build
|
||||
|
||||
FROM nginx:1.24
|
||||
FROM nginx:1.24-bullseye
|
||||
COPY --from=stage-build /data/lina /opt/lina
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
20
package.json
20
package.json
@@ -20,26 +20,29 @@
|
||||
"vue-i18n-report": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/i18n/langs/**/*.json'",
|
||||
"vue-i18n-report-json": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/i18n/langs/**/*.json' -o /tmp/abc.json",
|
||||
"vue-i18n-report-add-miss": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/i18n/langs/**/*.json' -a",
|
||||
"diff-i18n": "python ./src/i18n/langs/i18n-util.py diff en ja",
|
||||
"apply-i18n": "python ./src/i18n/langs/i18n-util.py apply en ja"
|
||||
"diff-i18n": "python ./src/i18n/langs/i18n-util.py diff en ja zh_Hant",
|
||||
"apply-i18n": "python ./src/i18n/langs/i18n-util.py apply en ja zh_Hant"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
|
||||
"@traptitech/markdown-it-katex": "^3.6.0",
|
||||
"@ztree/ztree_v3": "3.5.44",
|
||||
"axios": "0.21.1",
|
||||
"axios": "0.28.0",
|
||||
"axios-retry": "^3.1.9",
|
||||
"cron-parser": "^4.0.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
"css-color-function": "^1.3.3",
|
||||
"decimal.js": "^10.4.3",
|
||||
"deepmerge": "^4.2.2",
|
||||
"echarts": "^4.7.0",
|
||||
"dompurify": "^3.1.6",
|
||||
"echarts": "4.7.0",
|
||||
"element-ui": "2.13.2",
|
||||
"eslint-plugin-html": "^6.0.0",
|
||||
"highlight.js": "^11.9.0",
|
||||
"install": "^0.13.0",
|
||||
"jquery": "^3.6.1",
|
||||
"js-cookie": "2.2.0",
|
||||
"jsencrypt": "^3.2.1",
|
||||
"krry-transfer": "^1.7.3",
|
||||
"less": "^3.10.3",
|
||||
"less-loader": "^5.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
@@ -54,6 +57,8 @@
|
||||
"lodash.set": "^4.3.2",
|
||||
"lodash.topairs": "^4.3.0",
|
||||
"lodash.values": "^4.3.0",
|
||||
"markdown-it": "^13.0.2",
|
||||
"markdown-it-link-attributes": "^4.0.1",
|
||||
"moment": "^2.29.4",
|
||||
"moment-parseformat": "^4.0.0",
|
||||
"normalize.css": "7.0.0",
|
||||
@@ -67,7 +72,6 @@
|
||||
"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",
|
||||
@@ -79,7 +83,7 @@
|
||||
"zxcvbn": "^4.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0",
|
||||
"@babel/core": "7.18.6",
|
||||
"@babel/register": "7.0.0",
|
||||
"@vue/cli-plugin-babel": "3.6.0",
|
||||
"@vue/cli-plugin-eslint": "^3.9.1",
|
||||
@@ -93,6 +97,7 @@
|
||||
"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-plugin-vue": "5.2.2",
|
||||
@@ -109,6 +114,7 @@
|
||||
"script-ext-html-webpack-plugin": "2.1.3",
|
||||
"script-loader": "0.7.2",
|
||||
"serve-static": "^1.13.2",
|
||||
"strip-ansi": "^7.1.0",
|
||||
"svg-sprite-loader": "4.1.3",
|
||||
"svgo": "1.2.2",
|
||||
"vue-i18n-extract": "^1.1.1",
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -424,7 +424,7 @@ td .el-button.el-button--mini {
|
||||
}
|
||||
|
||||
.el-dialog .el-dialog__body {
|
||||
max-height: 90vh;
|
||||
max-height: 80vh;
|
||||
overflow: auto;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,10 @@ export function getCommandFilterList(data) {
|
||||
|
||||
export function getCategoryTypes() {
|
||||
return request({
|
||||
url: '/api/v1/assets/categories/',
|
||||
url: '/api/v1/assets/categories/?limit=1000',
|
||||
method: 'get'
|
||||
}).then(res => {
|
||||
return res.results
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -44,3 +44,30 @@ export function renameFile(playbookId, node) {
|
||||
data: node
|
||||
})
|
||||
}
|
||||
|
||||
export function createJob(form) {
|
||||
return request({
|
||||
url: '/api/v1/ops/jobs/',
|
||||
method: 'post',
|
||||
data: form
|
||||
})
|
||||
}
|
||||
|
||||
export function StopJob(form) {
|
||||
return request({
|
||||
url: '/api/v1/ops/job-executions/stop/',
|
||||
method: 'post',
|
||||
data: form
|
||||
})
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -8,24 +8,11 @@ export function terminateSession(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getSessionDetail(id) {
|
||||
export function toggleLockSession(data) {
|
||||
return request({
|
||||
url: `/api/v1/terminal/sessions/${id}/`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getSessionCommands(id) {
|
||||
return request({
|
||||
url: `/api/v1/terminal/commands/?session_id=${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getTerminalDetail(id) {
|
||||
return request({
|
||||
url: `/api/v1/terminal/terminals/${id}/`,
|
||||
method: 'get'
|
||||
url: '/api/v1/terminal/tasks/toggle-lock-session/',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ export function getProfile(token) {
|
||||
return request({
|
||||
url: '/api/v1/users/profile/',
|
||||
method: 'get'
|
||||
// params: { token }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
BIN
src/assets/img/chat.png
Normal file
BIN
src/assets/img/chat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
1
src/assets/img/chatbot.svg
Normal file
1
src/assets/img/chatbot.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="transparent" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bot "><path d="M12 8V4H8"></path><rect width="16" height="12" x="4" y="8" rx="2"></rect><path d="M2 14h2"></path><path d="M20 14h2"></path><path d="M15 13v2"></path><path d="M9 13v2"></path></svg>
|
||||
|
After Width: | Height: | Size: 406 B |
BIN
src/assets/img/robot-assistant.png
Normal file
BIN
src/assets/img/robot-assistant.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
@@ -1,312 +0,0 @@
|
||||
<template>
|
||||
<AutoDataForm
|
||||
v-if="!loading"
|
||||
ref="AutoDataForm"
|
||||
v-bind="$data"
|
||||
@submit="confirm"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AutoDataForm from '@/components/AutoDataForm'
|
||||
import { UpdateToken, UploadSecret } from '@/components/FormFields'
|
||||
import Select2 from '@/components/FormFields/Select2'
|
||||
import AssetSelect from '@/components/AssetSelect'
|
||||
import { encryptPassword } from '@/utils/crypto'
|
||||
import { Required, RequiredChange } from '@/components/DataForm/rules'
|
||||
import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSetting.vue'
|
||||
|
||||
export default {
|
||||
name: 'AccountCreateForm',
|
||||
components: {
|
||||
AutoDataForm
|
||||
},
|
||||
props: {
|
||||
asset: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
platform: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
account: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
// 默认组件密码加密
|
||||
encryptPassword: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
addTemplate: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
usernameChanged: false,
|
||||
defaultPrivilegedAccounts: ['root', 'administrator'],
|
||||
iPlatform: {
|
||||
automation: {},
|
||||
su_enabled: false,
|
||||
protocols: [
|
||||
{
|
||||
name: 'ssh',
|
||||
secret_types: ['password', 'ssh_key', 'token', 'access_key']
|
||||
}
|
||||
]
|
||||
},
|
||||
url: '/api/v1/accounts/accounts/',
|
||||
form: Object.assign({ 'on_invalid': 'error' }, this.account || {}),
|
||||
encryptedFields: ['secret'],
|
||||
fields: [
|
||||
[this.$t('assets.Asset'), ['assets']],
|
||||
[this.$t('accounts.AccountTemplate'), ['template']],
|
||||
[this.$t('common.Basic'), ['name', 'username', 'privileged', 'su_from', 'su_from_username']],
|
||||
[this.$t('assets.Secret'), [
|
||||
'secret_type', 'secret', 'ssh_key',
|
||||
'token', 'access_key', 'passphrase'
|
||||
]],
|
||||
[this.$t('common.Other'), ['push_now', 'params', 'on_invalid', 'is_active', 'comment']]
|
||||
],
|
||||
fieldsMeta: {
|
||||
assets: {
|
||||
rules: [Required],
|
||||
component: AssetSelect,
|
||||
label: this.$t('assets.Asset'),
|
||||
el: {
|
||||
multiple: false
|
||||
},
|
||||
hidden: () => {
|
||||
return this.platform || this.asset
|
||||
}
|
||||
},
|
||||
template: {
|
||||
component: Select2,
|
||||
rules: [Required],
|
||||
el: {
|
||||
multiple: false,
|
||||
ajax: {
|
||||
url: '/api/v1/accounts/account-templates/',
|
||||
transformOption: (item) => {
|
||||
return { label: item.name, value: item.id }
|
||||
}
|
||||
}
|
||||
},
|
||||
hidden: () => {
|
||||
return this.platform || this.asset || !this.addTemplate
|
||||
}
|
||||
},
|
||||
on_invalid: {
|
||||
rules: [Required],
|
||||
label: this.$t('accounts.AccountPolicy'),
|
||||
helpText: this.$t('accounts.BulkCreateStrategy'),
|
||||
hidden: () => {
|
||||
return this.platform || this.asset
|
||||
}
|
||||
},
|
||||
name: {
|
||||
rules: [RequiredChange],
|
||||
on: {
|
||||
input: ([value], updateForm) => {
|
||||
if (!this.usernameChanged) {
|
||||
if (!this.account?.name) {
|
||||
updateForm({ username: value })
|
||||
}
|
||||
const maybePrivileged = this.defaultPrivilegedAccounts.includes(value)
|
||||
if (maybePrivileged) {
|
||||
updateForm({ privileged: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
hidden: () => {
|
||||
return this.addTemplate
|
||||
}
|
||||
},
|
||||
username: {
|
||||
el: {
|
||||
disabled: !!this.account?.name
|
||||
},
|
||||
on: {
|
||||
input: ([value], updateForm) => {
|
||||
this.usernameChanged = true
|
||||
},
|
||||
change: ([value], updateForm) => {
|
||||
const maybePrivileged = this.defaultPrivilegedAccounts.includes(value)
|
||||
if (maybePrivileged) {
|
||||
updateForm({ privileged: true })
|
||||
}
|
||||
}
|
||||
},
|
||||
hidden: () => {
|
||||
return this.addTemplate
|
||||
}
|
||||
},
|
||||
privileged: {
|
||||
hidden: () => {
|
||||
return this.addTemplate
|
||||
}
|
||||
},
|
||||
su_from: {
|
||||
component: Select2,
|
||||
hidden: (formValue) => {
|
||||
return !this.asset?.id || !this.iPlatform.su_enabled
|
||||
},
|
||||
el: {
|
||||
multiple: false,
|
||||
clearable: true,
|
||||
ajax: {
|
||||
url: `/api/v1/accounts/accounts/su-from-accounts/?account=${this.account?.id || ''}&asset=${this.asset?.id || ''}`,
|
||||
transformOption: (item) => {
|
||||
return { label: `${item.name}(${item.username})`, value: item.id }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
su_from_username: {
|
||||
label: this.$t('assets.UserSwitchFrom'),
|
||||
hidden: (formValue) => {
|
||||
return this.platform || this.asset || this.addTemplate
|
||||
}
|
||||
},
|
||||
secret: {
|
||||
label: this.$t('assets.Password'),
|
||||
component: UpdateToken,
|
||||
hidden: (formValue) => formValue.secret_type !== 'password' || this.addTemplate
|
||||
},
|
||||
ssh_key: {
|
||||
label: this.$t('assets.PrivateKey'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || this.addTemplate
|
||||
},
|
||||
passphrase: {
|
||||
label: this.$t('assets.Passphrase'),
|
||||
component: UpdateToken,
|
||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || this.addTemplate
|
||||
},
|
||||
token: {
|
||||
label: this.$t('assets.Token'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'token' || this.addTemplate
|
||||
},
|
||||
access_key: {
|
||||
id: 'access_key',
|
||||
label: this.$t('assets.AccessKey'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'access_key' || this.addTemplate
|
||||
},
|
||||
secret_type: {
|
||||
type: 'radio-group',
|
||||
options: [],
|
||||
hidden: () => {
|
||||
return this.addTemplate
|
||||
}
|
||||
},
|
||||
push_now: {
|
||||
helpText: this.$t('accounts.AccountPush.WindowsPushHelpText'),
|
||||
hidden: () => {
|
||||
const automation = this.iPlatform.automation || {}
|
||||
return !automation.push_account_enabled ||
|
||||
!automation.ansible_enabled ||
|
||||
!this.$hasPerm('accounts.push_account') ||
|
||||
this.addTemplate
|
||||
}
|
||||
},
|
||||
params: {
|
||||
label: this.$t('assets.PushParams'),
|
||||
component: AutomationParamsForm,
|
||||
el: {
|
||||
method: this.asset?.auto_config?.push_account_method
|
||||
},
|
||||
hidden: (formValue) => {
|
||||
const automation = this.iPlatform.automation || {}
|
||||
return !formValue.push_now ||
|
||||
!automation.push_account_enabled ||
|
||||
!automation.ansible_enabled ||
|
||||
!this.$hasPerm('accounts.push_account') ||
|
||||
this.addTemplate
|
||||
}
|
||||
},
|
||||
comment: {
|
||||
hidden: () => {
|
||||
return this.addTemplate
|
||||
}
|
||||
}
|
||||
},
|
||||
hasSaveContinue: false
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
try {
|
||||
await this.getPlatform()
|
||||
this.setSecretTypeOptions()
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getPlatform() {
|
||||
if (this.platform) {
|
||||
this.iPlatform = this.platform
|
||||
}
|
||||
if (!this.asset || !this.asset.platform) {
|
||||
return
|
||||
}
|
||||
const platformId = this.asset.platform.id
|
||||
this.iPlatform = await this.$axios.get(`/api/v1/assets/platforms/${platformId}/`)
|
||||
},
|
||||
setSecretTypeOptions() {
|
||||
const choices = [
|
||||
{
|
||||
label: this.$t('assets.Password'),
|
||||
value: 'password'
|
||||
},
|
||||
{
|
||||
label: this.$t('assets.SSHKey'),
|
||||
value: 'ssh_key'
|
||||
},
|
||||
{
|
||||
label: this.$t('assets.Token'),
|
||||
value: 'token'
|
||||
},
|
||||
{
|
||||
label: this.$t('assets.AccessKey'),
|
||||
value: 'access_key'
|
||||
}
|
||||
]
|
||||
const secretTypes = []
|
||||
this.iPlatform.protocols?.forEach(p => {
|
||||
secretTypes.push(...p['secret_types'])
|
||||
})
|
||||
if (!this.form?.secret_type) {
|
||||
this.form.secret_type = secretTypes[0]
|
||||
}
|
||||
this.fieldsMeta.secret_type.options = choices.filter(item => {
|
||||
return secretTypes.indexOf(item.value) > -1
|
||||
})
|
||||
},
|
||||
confirm(form) {
|
||||
const secretType = form.secret_type || ''
|
||||
if (secretType !== 'password') {
|
||||
form.secret = form[secretType]
|
||||
}
|
||||
form.secret = this.encryptPassword ? encryptPassword(form.secret) : form.secret
|
||||
if (!form.secret) {
|
||||
delete form['secret']
|
||||
}
|
||||
if (this.account?.name) {
|
||||
this.$emit('edit', form)
|
||||
} else {
|
||||
this.$emit('add', form)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
191
src/components/Apps/AccountCreateUpdateForm/const.js
Normal file
191
src/components/Apps/AccountCreateUpdateForm/const.js
Normal file
@@ -0,0 +1,191 @@
|
||||
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']
|
||||
return {
|
||||
assets: {
|
||||
rules: [Required],
|
||||
component: AssetSelect,
|
||||
label: vm.$t('assets.Asset'),
|
||||
el: {
|
||||
multiple: false
|
||||
},
|
||||
hidden: () => {
|
||||
return vm.platform || vm.asset
|
||||
}
|
||||
},
|
||||
template: {
|
||||
component: Select2,
|
||||
rules: [Required],
|
||||
el: {
|
||||
multiple: false,
|
||||
ajax: {
|
||||
url: '/api/v1/accounts/account-templates/',
|
||||
transformOption: (item) => {
|
||||
return { label: item.name, value: item.id }
|
||||
}
|
||||
}
|
||||
},
|
||||
hidden: () => {
|
||||
return vm.platform || vm.asset || !vm.addTemplate
|
||||
}
|
||||
},
|
||||
on_invalid: {
|
||||
rules: [Required],
|
||||
label: vm.$t('accounts.AccountPolicy'),
|
||||
helpText: vm.$t('accounts.BulkCreateStrategy'),
|
||||
hidden: () => {
|
||||
return vm.platform || vm.asset
|
||||
}
|
||||
},
|
||||
name: {
|
||||
label: vm.$t('common.Name'),
|
||||
rules: [RequiredChange],
|
||||
on: {
|
||||
input: ([value], updateForm) => {
|
||||
if (!vm.usernameChanged) {
|
||||
if (!vm.account?.name) {
|
||||
updateForm({ username: value })
|
||||
}
|
||||
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
|
||||
if (maybePrivileged) {
|
||||
updateForm({ privileged: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
hidden: () => {
|
||||
return vm.addTemplate
|
||||
}
|
||||
},
|
||||
username: {
|
||||
el: {
|
||||
disabled: !!vm.account?.name
|
||||
},
|
||||
on: {
|
||||
input: ([value], updateForm) => {
|
||||
vm.usernameChanged = true
|
||||
},
|
||||
change: ([value], updateForm) => {
|
||||
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
|
||||
if (maybePrivileged) {
|
||||
updateForm({ privileged: true })
|
||||
}
|
||||
}
|
||||
},
|
||||
hidden: () => {
|
||||
return vm.addTemplate
|
||||
}
|
||||
},
|
||||
privileged: {
|
||||
label: vm.$t('assets.Privileged'),
|
||||
hidden: () => {
|
||||
return vm.addTemplate
|
||||
}
|
||||
},
|
||||
su_from: {
|
||||
component: Select2,
|
||||
hidden: (formValue) => {
|
||||
return !vm.asset?.id || !vm.iPlatform.su_enabled
|
||||
},
|
||||
el: {
|
||||
multiple: false,
|
||||
clearable: true,
|
||||
ajax: {
|
||||
url: `/api/v1/accounts/accounts/su-from-accounts/?account=${vm.account?.id || ''}&asset=${vm.asset?.id || ''}`,
|
||||
transformOption: (item) => {
|
||||
return { label: `${item.name}(${item.username})`, value: item.id }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
su_from_username: {
|
||||
label: vm.$t('assets.UserSwitchFrom'),
|
||||
hidden: (formValue) => {
|
||||
return vm.platform || vm.asset || vm.addTemplate
|
||||
}
|
||||
},
|
||||
password: {
|
||||
label: vm.$t('assets.Password'),
|
||||
component: UpdateToken,
|
||||
hidden: (formValue) => {
|
||||
return formValue.secret_type !== 'password' || vm.addTemplate
|
||||
}
|
||||
},
|
||||
ssh_key: {
|
||||
label: vm.$t('assets.PrivateKey'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate
|
||||
},
|
||||
passphrase: {
|
||||
label: vm.$t('assets.Passphrase'),
|
||||
component: UpdateToken,
|
||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate
|
||||
},
|
||||
token: {
|
||||
label: vm.$t('assets.Token'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'token' || vm.addTemplate
|
||||
},
|
||||
access_key: {
|
||||
id: 'access_key',
|
||||
label: vm.$t('assets.AccessKey'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'access_key' || vm.addTemplate
|
||||
},
|
||||
api_key: {
|
||||
id: 'api_key',
|
||||
label: vm.$t('assets.ApiKey'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'api_key' || vm.addTemplate
|
||||
},
|
||||
secret_type: {
|
||||
type: 'radio-group',
|
||||
options: [],
|
||||
hidden: () => {
|
||||
return vm.addTemplate
|
||||
}
|
||||
},
|
||||
push_now: {
|
||||
helpText: vm.$t('accounts.AccountPush.WindowsPushHelpText'),
|
||||
hidden: (formValue) => {
|
||||
const automation = vm.iPlatform.automation || {}
|
||||
return !automation.push_account_enabled ||
|
||||
!automation.ansible_enabled ||
|
||||
!vm.$hasPerm('accounts.push_account') ||
|
||||
(formValue.secret_type === 'ssh_key' && vm.iPlatform.type.value === 'windows') ||
|
||||
vm.addTemplate
|
||||
}
|
||||
},
|
||||
params: {
|
||||
label: vm.$t('assets.PushParams'),
|
||||
component: AutomationParamsForm,
|
||||
el: {},
|
||||
hidden: (formValue) => {
|
||||
const automation = vm.iPlatform.automation || {}
|
||||
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 ||
|
||||
!automation.push_account_enabled ||
|
||||
!automation.ansible_enabled ||
|
||||
(formValue.secret_type === 'ssh_key' &&
|
||||
vm.iPlatform.type.value === 'windows') ||
|
||||
!vm.$hasPerm('accounts.push_account') ||
|
||||
vm.addTemplate
|
||||
}
|
||||
},
|
||||
is_active: {
|
||||
label: vm.$t('common.IsActive')
|
||||
},
|
||||
comment: {
|
||||
label: vm.$t('common.Comment'),
|
||||
hidden: () => {
|
||||
return vm.addTemplate
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
153
src/components/Apps/AccountCreateUpdateForm/index.vue
Normal file
153
src/components/Apps/AccountCreateUpdateForm/index.vue
Normal file
@@ -0,0 +1,153 @@
|
||||
<template>
|
||||
<AutoDataForm
|
||||
v-if="!loading"
|
||||
ref="AutoDataForm"
|
||||
v-bind="$data"
|
||||
@submit="confirm"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
|
||||
import { encryptPassword } from '@/utils/crypto'
|
||||
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
|
||||
|
||||
export default {
|
||||
name: 'AccountCreateForm',
|
||||
components: {
|
||||
AutoDataForm
|
||||
},
|
||||
props: {
|
||||
asset: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
platform: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
account: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
// 默认组件密码加密
|
||||
encryptPassword: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
addTemplate: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
usernameChanged: false,
|
||||
iPlatform: {
|
||||
automation: {},
|
||||
su_enabled: false,
|
||||
protocols: [
|
||||
{
|
||||
name: 'ssh',
|
||||
secret_types: ['password', 'ssh_key', 'token', 'access_key', 'api_key']
|
||||
}
|
||||
]
|
||||
},
|
||||
url: '/api/v1/accounts/accounts/',
|
||||
form: Object.assign({ 'on_invalid': 'error' }, this.account || {}),
|
||||
encryptedFields: ['secret'],
|
||||
fields: [
|
||||
[this.$t('assets.Asset'), ['assets']],
|
||||
[this.$t('accounts.AccountTemplate'), ['template']],
|
||||
[this.$t('common.Basic'), ['name', 'username', 'privileged', 'su_from', 'su_from_username']],
|
||||
[this.$t('assets.Secret'), [
|
||||
'secret_type', 'password', 'ssh_key', 'token',
|
||||
'access_key', 'passphrase', 'api_key'
|
||||
]],
|
||||
[this.$t('common.Other'), ['push_now', 'params', 'on_invalid', 'is_active', 'comment']]
|
||||
],
|
||||
fieldsMeta: accountFieldsMeta(this),
|
||||
hasSaveContinue: false
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
try {
|
||||
await this.getPlatform()
|
||||
this.setSecretTypeOptions()
|
||||
this.getDefaultAssets()
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getDefaultAssets() {
|
||||
const assetId = this.$route.query.asset_id
|
||||
if (assetId && !this.form.name) {
|
||||
this.form.assets = [assetId]
|
||||
}
|
||||
},
|
||||
async getPlatform() {
|
||||
if (this.platform) {
|
||||
this.iPlatform = this.platform
|
||||
}
|
||||
if (!this.asset || !this.asset.platform) {
|
||||
return
|
||||
}
|
||||
const platformId = this.asset.platform.id
|
||||
this.iPlatform = await this.$axios.get(`/api/v1/assets/platforms/${platformId}/`)
|
||||
},
|
||||
setSecretTypeOptions() {
|
||||
const choices = [
|
||||
{
|
||||
label: this.$t('assets.Password'),
|
||||
value: 'password'
|
||||
},
|
||||
{
|
||||
label: this.$t('assets.SSHKey'),
|
||||
value: 'ssh_key'
|
||||
},
|
||||
{
|
||||
label: this.$t('assets.Token'),
|
||||
value: 'token'
|
||||
},
|
||||
{
|
||||
label: this.$t('assets.AccessKey'),
|
||||
value: 'access_key'
|
||||
},
|
||||
{
|
||||
label: this.$t('assets.ApiKey'),
|
||||
value: 'api_key'
|
||||
}
|
||||
]
|
||||
const secretTypes = []
|
||||
this.iPlatform.protocols?.forEach(p => {
|
||||
secretTypes.push(...p['secret_types'])
|
||||
})
|
||||
if (!this.form?.secret_type) {
|
||||
this.form.secret_type = secretTypes[0]
|
||||
}
|
||||
this.fieldsMeta.secret_type.options = choices.filter(item => {
|
||||
return secretTypes.indexOf(item.value) > -1
|
||||
})
|
||||
},
|
||||
confirm(form) {
|
||||
const secretType = form.secret_type || 'password'
|
||||
form.secret = form[secretType]
|
||||
form.secret = this.encryptPassword ? encryptPassword(form.secret) : form.secret
|
||||
|
||||
// 如果不删除会明文显示
|
||||
delete form[secretType]
|
||||
|
||||
if (!form.secret) {
|
||||
delete form['secret']
|
||||
}
|
||||
if (this.account?.name) {
|
||||
this.$emit('edit', form)
|
||||
} else {
|
||||
this.$emit('add', form)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<GenericUpdateFormDialog
|
||||
v-if="visible"
|
||||
:form-setting="formSetting"
|
||||
:selected-rows="selectedRows"
|
||||
:visible="visible"
|
||||
v-on="$listeners"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { GenericUpdateFormDialog } from '@/layout/components'
|
||||
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
|
||||
import { encryptPassword } from '@/utils/crypto'
|
||||
|
||||
export default {
|
||||
name: 'AccountBulkUpdateDialog',
|
||||
components: {
|
||||
GenericUpdateFormDialog
|
||||
},
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
selectedRows: {
|
||||
type: Array,
|
||||
default: () => ([])
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formSetting: {
|
||||
url: '/api/v1/accounts/accounts/',
|
||||
hasSaveContinue: false,
|
||||
fields: [],
|
||||
fieldsMeta: accountFieldsMeta(this),
|
||||
cleanOtherFormValue: (formValue) => {
|
||||
for (const value of formValue) {
|
||||
Object.keys(value).forEach((item, index, arr) => {
|
||||
if (['ssh_key', 'token', 'access_key', 'api_key', 'password'].includes(item)) {
|
||||
value['secret'] = encryptPassword(value[item])
|
||||
delete value[item]
|
||||
}
|
||||
})
|
||||
}
|
||||
return formValue
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.filterFieldsMeta()
|
||||
},
|
||||
methods: {
|
||||
filterFieldsMeta() {
|
||||
let fields = ['privileged']
|
||||
const fieldsMeta = {}
|
||||
const secretFields = ['password', 'ssh_key', 'passphrase', 'token', 'access_key', 'api_key']
|
||||
const secret_type = this.selectedRows[0].secret_type?.value || 'password'
|
||||
for (const field of secretFields) {
|
||||
if (secret_type === 'ssh_key' && field === 'passphrase') {
|
||||
fields.push('passphrase')
|
||||
this.formSetting.fieldsMeta['passphrase'].hidden = () => false
|
||||
continue
|
||||
}
|
||||
if (secret_type === field) {
|
||||
fields.push(field)
|
||||
this.formSetting.fieldsMeta[field].hidden = () => false
|
||||
continue
|
||||
}
|
||||
delete this.formSetting.fieldsMeta[field]
|
||||
}
|
||||
fields = fields.concat(['is_active', 'comment'])
|
||||
for (const field of fields) {
|
||||
fieldsMeta[field] = this.formSetting.fieldsMeta[field]
|
||||
}
|
||||
this.formSetting.fields = fields
|
||||
this.formSetting.fieldsMeta = fieldsMeta
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -8,7 +8,6 @@
|
||||
:title="title"
|
||||
:visible.sync="iVisible"
|
||||
v-bind="$attrs"
|
||||
width="70%"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<AccountCreateUpdateForm
|
||||
@@ -24,8 +23,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog'
|
||||
import AccountCreateUpdateForm from '@/components/AccountCreateUpdateForm'
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import AccountCreateUpdateForm from '@/components/Apps/AccountCreateUpdateForm/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'CreateAccountDialog',
|
||||
@@ -37,22 +37,30 @@
|
||||
:result="createAccountResults"
|
||||
:visible.sync="showResultDialog"
|
||||
/>
|
||||
<AccountBulkUpdateDialog
|
||||
v-if="updateSelectedDialogSetting.visible"
|
||||
:visible.sync="updateSelectedDialogSetting.visible"
|
||||
v-bind="updateSelectedDialogSetting"
|
||||
@update="handleAccountBulkUpdate"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ListTable from '@/components/ListTable/index'
|
||||
import { ActionsFormatter } from '@/components/TableFormatters'
|
||||
import ViewSecret from './ViewSecret'
|
||||
import UpdateSecretInfo from './UpdateSecretInfo'
|
||||
import AccountCreateUpdate from './AccountCreateUpdate'
|
||||
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 AccountCreateUpdate from './AccountCreateUpdate.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: {
|
||||
AccountBulkUpdateDialog,
|
||||
ResultDialog,
|
||||
ListTable,
|
||||
UpdateSecretInfo,
|
||||
@@ -111,12 +119,16 @@ export default {
|
||||
type: Array,
|
||||
default: () => ([
|
||||
'name', 'username', 'asset', 'privileged',
|
||||
'secret_type', 'date_updated'
|
||||
'secret_type', 'is_active', 'date_updated'
|
||||
])
|
||||
},
|
||||
headerExtraActions: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
extraQuery: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -138,14 +150,8 @@ export default {
|
||||
app: 'assets',
|
||||
resource: 'account'
|
||||
},
|
||||
extraQuery: {
|
||||
order: '-date_updated'
|
||||
},
|
||||
extraQuery: this.extraQuery,
|
||||
columnsExclude: ['spec_info'],
|
||||
columns: [
|
||||
'name', 'username', 'asset', 'privileged',
|
||||
'secret_type', 'source', 'actions'
|
||||
],
|
||||
columnsShow: {
|
||||
min: ['name', 'username', 'actions'],
|
||||
default: this.columnsDefault
|
||||
@@ -243,7 +249,7 @@ export default {
|
||||
},
|
||||
{
|
||||
name: 'Test',
|
||||
title: this.$t('common.Test'),
|
||||
title: this.$t('accounts.Test'),
|
||||
can: ({ row }) =>
|
||||
!this.$store.getters.currentOrgIsRoot &&
|
||||
this.$hasPerm('accounts.change_account') &&
|
||||
@@ -283,6 +289,7 @@ export default {
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasLabelSearch: true,
|
||||
hasLeftActions: this.hasLeftActions,
|
||||
hasMoreActions: true,
|
||||
hasCreate: false,
|
||||
@@ -342,6 +349,29 @@ export default {
|
||||
...this.headerExtraActions
|
||||
],
|
||||
extraMoreActions: [
|
||||
{
|
||||
name: 'BulkVerify',
|
||||
title: this.$t('accounts.BulkVerify'),
|
||||
type: 'primary',
|
||||
fa: 'fa-link',
|
||||
can: ({ selectedRows }) => {
|
||||
return selectedRows.length > 0 &&
|
||||
['clickhouse', 'redis', 'website', 'chatgpt'].indexOf(selectedRows[0].asset.type.value) === -1 &&
|
||||
!this.$store.getters.currentOrgIsRoot
|
||||
},
|
||||
callback: function({ selectedRows }) {
|
||||
const ids = selectedRows.map(v => {
|
||||
return v.id
|
||||
})
|
||||
this.$axios.post(
|
||||
'/api/v1/accounts/accounts/tasks/',
|
||||
{ action: 'verify', accounts: ids }).then(res => {
|
||||
openTaskPage(res['task'])
|
||||
}).catch(err => {
|
||||
this.$message.error(this.$tc('common.bulkVerifyErrorMsg' + ' ' + err))
|
||||
})
|
||||
}.bind(this)
|
||||
},
|
||||
{
|
||||
name: 'ClearSecrets',
|
||||
title: this.$t('common.ClearSecret'),
|
||||
@@ -351,7 +381,9 @@ export default {
|
||||
return selectedRows.length > 0 && vm.$hasPerm('accounts.change_account')
|
||||
},
|
||||
callback: function({ selectedRows }) {
|
||||
const ids = selectedRows.map(v => { return v.id })
|
||||
const ids = selectedRows.map(v => {
|
||||
return v.id
|
||||
})
|
||||
this.$axios.patch(
|
||||
'/api/v1/accounts/accounts/clear-secret/',
|
||||
{ account_ids: ids }).then(() => {
|
||||
@@ -360,6 +392,21 @@ export default {
|
||||
this.$message.error(this.$tc('common.bulkClearErrorMsg' + ' ' + err))
|
||||
})
|
||||
}.bind(this)
|
||||
},
|
||||
{
|
||||
name: 'actionUpdateSelected',
|
||||
title: this.$t('accounts.AccountBatchUpdate'),
|
||||
fa: 'batch-update',
|
||||
can: ({ selectedRows }) => {
|
||||
return selectedRows.length > 0 &&
|
||||
!this.$store.getters.currentOrgIsRoot &&
|
||||
vm.$hasPerm('accounts.change_account') &&
|
||||
selectedRows.every(i => i.secret_type.value === selectedRows[0].secret_type.value)
|
||||
},
|
||||
callback: ({ selectedRows }) => {
|
||||
vm.updateSelectedDialogSetting.selectedRows = selectedRows
|
||||
vm.updateSelectedDialogSetting.visible = true
|
||||
}
|
||||
}
|
||||
],
|
||||
canBulkDelete: vm.$hasPerm('accounts.delete_account'),
|
||||
@@ -368,6 +415,10 @@ export default {
|
||||
exclude: ['asset']
|
||||
},
|
||||
hasSearch: true
|
||||
},
|
||||
updateSelectedDialogSetting: {
|
||||
visible: false,
|
||||
selectedRows: []
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -395,9 +446,18 @@ export default {
|
||||
can: this.$hasPerm('accounts.delete_account'),
|
||||
type: 'primary',
|
||||
callback: ({ row }) => {
|
||||
this.$axios.delete(`/api/v1/accounts/accounts/${row.id}/`).then(() => {
|
||||
this.$message.success(this.$tc('common.deleteSuccessMsg'))
|
||||
this.$refs.ListTable.reloadTable()
|
||||
const msg = this.$t('accounts.AccountDeleteConfirmMsg')
|
||||
this.$confirm(msg, this.$tc('common.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('common.deleteSuccessMsg'))
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -426,6 +486,10 @@ export default {
|
||||
setTimeout(() => {
|
||||
this.showResultDialog = true
|
||||
}, 100)
|
||||
},
|
||||
handleAccountBulkUpdate() {
|
||||
this.updateSelectedDialogSetting.visible = false
|
||||
this.$refs.ListTable.reloadTable()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import DataTable from '@/components/DataTable/index.vue'
|
||||
import DataTable from '@/components/Table/DataTable/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'ResultDialog',
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<script>
|
||||
import { GenericListTableDialog } from '@/layout/components'
|
||||
import { ShowKeyCopyFormatter } from '@/components/TableFormatters'
|
||||
import { ShowKeyCopyFormatter } from '@/components/Table/TableFormatters'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -29,7 +29,7 @@ export default {
|
||||
tableConfig: {
|
||||
id: 'history_date',
|
||||
url: `/api/v1/accounts/account-secrets/${this.account.id}/histories/`,
|
||||
columns: ['secret', 'secret_type', 'version', 'history_date'],
|
||||
columns: ['secret', 'version', 'history_date'],
|
||||
columnsMeta: {
|
||||
secret: {
|
||||
label: this.$t('assets.Password'),
|
||||
112
src/components/Apps/AccountListTable/RemoveAccount.vue
Normal file
112
src/components/Apps/AccountListTable/RemoveAccount.vue
Normal file
@@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<Dialog
|
||||
:destroy-on-close="true"
|
||||
:show-cancel="false"
|
||||
:visible.sync="show"
|
||||
:width="'50'"
|
||||
v-bind="$attrs"
|
||||
@confirm="accountConfirmHandle"
|
||||
v-on="$listeners"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import { openTaskPage } from '@/utils/jms'
|
||||
|
||||
export default {
|
||||
name: 'RemoveAccount',
|
||||
components: {
|
||||
Dialog
|
||||
},
|
||||
props: {
|
||||
accounts: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
mfaDialogVisible: true
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
mounted() {
|
||||
const url = `/api/v1/accounts/accounts/tasks/`
|
||||
this.$axios.post(
|
||||
url, { disableFlashErrorMsg: true, action: 'remove' }
|
||||
).then(resp => {
|
||||
this.$axios.post(
|
||||
`/api/v1/accounts/accounts/tasks/`,
|
||||
{
|
||||
action: 'remove',
|
||||
gather_accounts: this.accounts.map(account => account.id)
|
||||
}
|
||||
).then(res => {
|
||||
openTaskPage(res['task'])
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
accountConfirmHandle() {
|
||||
this.show = false
|
||||
this.mfaDialogVisible = false
|
||||
},
|
||||
exit() {
|
||||
this.$emit('update:visible', false)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item-textarea > > > .el-textarea__inner {
|
||||
height: 110px;
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
border-bottom: 1px solid #EBEEF5;
|
||||
padding: 5px 0;
|
||||
margin-bottom: 0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
> > > .el-form-item__label {
|
||||
padding-right: 20px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
> > > .el-form-item__content {
|
||||
line-height: 30px;
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
margin-bottom: 8px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
.title {
|
||||
color: #303133;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -29,8 +29,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog'
|
||||
import { UpdateToken, UploadKey } from '@/components/FormFields'
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import { UpdateToken, UploadKey } from '@/components/Form/FormFields'
|
||||
import { encryptPassword } from '@/utils/crypto'
|
||||
|
||||
export default {
|
||||
@@ -1,12 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="mfaDialogVisible">
|
||||
<UserConfirmDialog
|
||||
:url="url"
|
||||
@UserConfirmCancel="exit"
|
||||
@UserConfirmDone="getAuthInfo"
|
||||
/>
|
||||
</div>
|
||||
<Dialog
|
||||
:destroy-on-close="true"
|
||||
:show-cancel="false"
|
||||
@@ -65,10 +58,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog'
|
||||
import PasswordHistoryDialog from './PasswordHistoryDialog'
|
||||
import UserConfirmDialog from '@/components/UserConfirmDialog'
|
||||
import { ShowKeyCopyFormatter } from '@/components/TableFormatters'
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import PasswordHistoryDialog from './PasswordHistoryDialog.vue'
|
||||
import { ShowKeyCopyFormatter } from '@/components/Table/TableFormatters'
|
||||
import { encryptPassword } from '@/utils/crypto'
|
||||
|
||||
export default {
|
||||
@@ -76,7 +68,6 @@ export default {
|
||||
components: {
|
||||
Dialog,
|
||||
PasswordHistoryDialog,
|
||||
UserConfirmDialog,
|
||||
ShowKeyCopyFormatter
|
||||
},
|
||||
props: {
|
||||
@@ -92,6 +83,10 @@ export default {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'account'
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: function() {
|
||||
@@ -128,7 +123,10 @@ export default {
|
||||
const url = `/api/v1/accounts/account-secrets/${this.account.id}/histories/?limit=1`
|
||||
this.$axios.get(url, { disableFlashErrorMsg: true }).then(resp => {
|
||||
this.versions = resp.count
|
||||
this.showSecretDialog()
|
||||
})
|
||||
} else {
|
||||
this.showSecretDialog()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -142,14 +140,15 @@ export default {
|
||||
name: this.secretInfo.name,
|
||||
secret: encryptPassword(this.modifiedSecret)
|
||||
}
|
||||
this.$axios.patch(`/api/v1/accounts/accounts/${this.account.id}/`, params).then(() => {
|
||||
const url = this.type === 'account' ? `/api/v1/accounts/accounts` : `/api/v1/accounts/account-templates`
|
||||
this.$axios.patch(`${url}/${this.account.id}/`, params).then(() => {
|
||||
this.$message.success(this.$tc('common.updateSuccessMsg'))
|
||||
})
|
||||
},
|
||||
getAuthInfo() {
|
||||
this.$axios.get(this.url, { disableFlashErrorMsg: true }).then(resp => {
|
||||
this.secretInfo = resp
|
||||
this.sshKeyFingerprint = resp?.spec_info?.ssh_key_fingerprint || '-'
|
||||
showSecretDialog() {
|
||||
return this.$axios.get(this.url, { disableFlashErrorMsg: true }).then((res) => {
|
||||
this.secretInfo = res
|
||||
this.sshKeyFingerprint = res?.spec_info?.ssh_key_fingerprint || '-'
|
||||
this.showSecret = true
|
||||
})
|
||||
},
|
||||
@@ -1,5 +1,5 @@
|
||||
import i18n from '@/i18n/i18n'
|
||||
import { ChoicesFormatter } from '@/components/TableFormatters'
|
||||
import { ChoicesFormatter } from '@/components/Table/TableFormatters'
|
||||
|
||||
export const connectivityMeta = {
|
||||
label: i18n.t('assets.Connectivity'),
|
||||
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<IBox :fa="icon" :type="type" :title="title" v-bind="$attrs">
|
||||
<IBox :fa="icon" :title="title" :type="type" v-bind="$attrs">
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<AssetSelect ref="assetSelect" :disabled="disabled" :can-select="canSelect" />
|
||||
<AssetSelect ref="assetSelect" :can-select="canSelect" :disabled="disabled" :tree-setting="treeSetting" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<el-button :type="type" size="small" :disabled="disabled" @click="addObjects">{{ $t('common.Add') }}</el-button>
|
||||
<el-button :disabled="disabled" :type="type" size="small" @click="addObjects">{{ $t('common.Add') }}</el-button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -16,8 +16,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import IBox from '@/components/IBox'
|
||||
import AssetSelect from '@/components/AssetSelect'
|
||||
import IBox from '@/components/IBox/index.vue'
|
||||
import AssetSelect from '@/components/Apps/AssetSelect/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'AssetRelationCard',
|
||||
@@ -59,6 +59,10 @@ export default {
|
||||
default(row, index) {
|
||||
return true
|
||||
}
|
||||
},
|
||||
treeSetting: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -1,10 +1,12 @@
|
||||
<template>
|
||||
<Dialog
|
||||
:close-on-click-modal="false"
|
||||
:loading-status="!isLoaded"
|
||||
:title="$tc('assets.Assets')"
|
||||
custom-class="asset-select-dialog"
|
||||
top="1vh"
|
||||
top="2vh"
|
||||
v-bind="$attrs"
|
||||
width="80vw"
|
||||
width="1000px"
|
||||
@cancel="handleCancel"
|
||||
@close="handleClose"
|
||||
@confirm="handleConfirm"
|
||||
@@ -17,15 +19,17 @@
|
||||
:table-config="tableConfig"
|
||||
:tree-url="`${baseNodeUrl}children/tree/`"
|
||||
:url="baseUrl"
|
||||
:tree-setting="treeSetting"
|
||||
class="tree-table"
|
||||
v-bind="$attrs"
|
||||
@loaded="handleTableLoaded"
|
||||
/>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AssetTreeTable from '@/components/AssetTreeTable'
|
||||
import Dialog from '@/components/Dialog'
|
||||
import AssetTreeTable from '@/components/Apps/AssetTreeTable/index.vue'
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
|
||||
export default {
|
||||
componentName: 'AssetSelectDialog',
|
||||
@@ -52,11 +56,16 @@ export default {
|
||||
disabled: {
|
||||
type: [Boolean, Function],
|
||||
default: false
|
||||
},
|
||||
treeSetting: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
isLoaded: false,
|
||||
dialogVisible: false,
|
||||
rowSelected: _.cloneDeep(this.value) || [],
|
||||
rowsAdd: [],
|
||||
@@ -83,16 +92,6 @@ export default {
|
||||
return row.platform.name
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'protocols',
|
||||
formatter: function(row) {
|
||||
const data = row.protocols.map(p => {
|
||||
return <el-tag size='mini'>{p.name}/{p.port} </el-tag>
|
||||
})
|
||||
return <span> {data} </span>
|
||||
},
|
||||
label: this.$t('assets.Protocols')
|
||||
},
|
||||
{
|
||||
prop: 'actions',
|
||||
has: false
|
||||
@@ -114,6 +113,7 @@ export default {
|
||||
headerActions: {
|
||||
hasLeftActions: false,
|
||||
hasRightActions: false,
|
||||
hasLabelSearch: true,
|
||||
searchConfig: {
|
||||
getUrlQuery: false
|
||||
}
|
||||
@@ -146,6 +146,9 @@ export default {
|
||||
if (selectValueIndex > -1) {
|
||||
this.rowSelected.splice(selectValueIndex, 1)
|
||||
}
|
||||
},
|
||||
handleTableLoaded() {
|
||||
this.isLoaded = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +171,7 @@ export default {
|
||||
}
|
||||
|
||||
.right {
|
||||
height: calc(100vh - 200px);
|
||||
min-height: 500px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
ref="dialog"
|
||||
:base-node-url="baseNodeUrl"
|
||||
:base-url="baseUrl"
|
||||
:tree-setting="treeSetting"
|
||||
:tree-url-query="treeUrlQuery"
|
||||
:value="value"
|
||||
:visible.sync="dialogVisible"
|
||||
@@ -25,9 +26,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Select2 from '@/components/FormFields/Select2'
|
||||
import Select2 from '@/components/Form/FormFields/Select2.vue'
|
||||
import AssetSelectDialog from './dialog.vue'
|
||||
import { b } from 'css-color-function/lib/adjusters'
|
||||
|
||||
export default {
|
||||
componentName: 'AssetSelect',
|
||||
@@ -48,6 +48,10 @@ export default {
|
||||
value: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
treeSetting: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -76,7 +80,6 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
b,
|
||||
handleFocus() {
|
||||
this.$refs.select2.selectRef.blur()
|
||||
this.dialogVisible = true
|
||||
@@ -134,7 +137,8 @@ export default {
|
||||
padding: 5px;
|
||||
|
||||
.ztree {
|
||||
height: calc(100vh - 250px) !important;
|
||||
min-height: 500px;
|
||||
height: inherit !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<TreeTable
|
||||
ref="TreeList"
|
||||
component="TabTree"
|
||||
:table-config="tableConfig"
|
||||
:active-menu.sync="treeTableConfig.activeMenu"
|
||||
:table-config="tableConfig"
|
||||
:tree-tab-config="treeTableConfig"
|
||||
component="TabTree"
|
||||
v-bind="$attrs"
|
||||
v-on="$listeners"
|
||||
>
|
||||
@@ -12,13 +12,13 @@
|
||||
<slot name="table" />
|
||||
</template>
|
||||
<div slot="rMenu" slot-scope="{data}">
|
||||
<slot name="rMenu" :data="data" />
|
||||
<slot :data="data" name="rMenu" />
|
||||
</div>
|
||||
</TreeTable>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TreeTable from '../TreeTable'
|
||||
import TreeTable from '../../Table/TreeTable/index.vue'
|
||||
import { setRouterQuery, setUrlParam } from '@/utils/common'
|
||||
import $ from '@/utils/jquery-vendor'
|
||||
|
||||
@@ -31,6 +31,10 @@ export default {
|
||||
type: String,
|
||||
default: '/api/v1/assets/assets/'
|
||||
},
|
||||
typeUrl: {
|
||||
type: String,
|
||||
default: '/api/v1/assets/nodes/category/tree/'
|
||||
},
|
||||
nodeUrl: {
|
||||
type: String,
|
||||
default: '/api/v1/assets/nodes/'
|
||||
@@ -60,6 +64,7 @@ export default {
|
||||
const showAssets = this.treeSetting?.showAssets || this.showAssets
|
||||
const treeUrlQuery = this.setTreeUrlQuery()
|
||||
const assetTreeUrl = `${this.treeUrl}?assets=${showAssets ? '1' : '0'}&${treeUrlQuery}`
|
||||
const vm = this
|
||||
|
||||
return {
|
||||
treeTabConfig: {
|
||||
@@ -81,7 +86,13 @@ export default {
|
||||
nodeUrl: this.nodeUrl,
|
||||
treeUrl: assetTreeUrl,
|
||||
callback: {
|
||||
onSelected: (event, treeNode) => this.getAssetsUrl(treeNode)
|
||||
onSelected: (event, treeNode) => this.getAssetsUrl(treeNode),
|
||||
beforeRefresh: () => {
|
||||
const query = { ...this.$route.query, node_id: '', asset_id: '' }
|
||||
setTimeout(() => {
|
||||
vm.$router.replace({ query: query })
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
...this.treeSetting
|
||||
}
|
||||
@@ -94,9 +105,14 @@ export default {
|
||||
showAssets: false,
|
||||
showSearch: false,
|
||||
customTreeHeaderName: this.$t('assets.BuiltinTree'),
|
||||
url: '/api/v1/assets/nodes/category/tree/',
|
||||
url: this.typeUrl,
|
||||
nodeUrl: this.treeSetting?.nodeUrl || this.nodeUrl,
|
||||
treeUrl: `/api/v1/assets/nodes/category/tree/?assets=${showAssets ? '1' : '0'}&count_resource=${this.treeSetting.countResource || 'asset'}`,
|
||||
treeUrl: `${this.typeUrl}?assets=${showAssets ? '1' : '0'}&count_resource=${this.treeSetting.countResource || 'asset'}`,
|
||||
edit: {
|
||||
drag: {
|
||||
isMove: false
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onSelected: (event, treeNode) => this.getAssetsUrl(treeNode)
|
||||
}
|
||||
@@ -2,21 +2,23 @@
|
||||
<div>
|
||||
<div>
|
||||
<el-button
|
||||
:disabled="isDisabled"
|
||||
size="mini"
|
||||
type="primary"
|
||||
:disabled="isDisabled"
|
||||
@click="onOpenDialog"
|
||||
>{{ $tc('common.Setting') }}</el-button>
|
||||
>
|
||||
{{ $tc('common.Setting') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<Dialog
|
||||
v-if="visible"
|
||||
width="60%"
|
||||
:visible.sync="visible"
|
||||
:title="title"
|
||||
:destroy-on-close="true"
|
||||
:show-cancel="false"
|
||||
:show-confirm="false"
|
||||
:destroy-on-close="true"
|
||||
:title="title"
|
||||
:visible.sync="visible"
|
||||
v-bind="$attrs"
|
||||
width="60%"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<AutoDataForm
|
||||
@@ -31,9 +33,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Dialog, AutoDataForm } from '@/components'
|
||||
import Dialog from '../../Dialog'
|
||||
import AutoDataForm from '../../Form/AutoDataForm'
|
||||
|
||||
export default {
|
||||
componentName: 'AutomationParams',
|
||||
components: {
|
||||
Dialog,
|
||||
AutoDataForm
|
||||
@@ -57,19 +61,26 @@ export default {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
platforms: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
method: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: `/api/v1/assets/platform-automation-methods/`
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
remoteMeta: {},
|
||||
visible: false,
|
||||
isDisabled: true,
|
||||
form: this.value,
|
||||
node_ids: this.nodes,
|
||||
asset_ids: this.assets,
|
||||
config: {
|
||||
url: this.url,
|
||||
hasSaveContinue: false,
|
||||
@@ -77,7 +88,8 @@ export default {
|
||||
method: 'get',
|
||||
fields: [],
|
||||
fieldsMeta: {}
|
||||
}
|
||||
},
|
||||
onFieldChangeHandler: _.debounce(vm.handleFieldChange, 1000)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -87,22 +99,27 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
nodes: {
|
||||
handler(val) {
|
||||
this.node_ids = val
|
||||
this.onFieldChangeHandle()
|
||||
handler() {
|
||||
this.onFieldChangeHandler()
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
assets: {
|
||||
handler(val) {
|
||||
this.asset_ids = val
|
||||
this.onFieldChangeHandle()
|
||||
handler() {
|
||||
this.onFieldChangeHandler()
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
platforms: {
|
||||
handler(newVal) {
|
||||
this.onFieldChangeHandler()
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getUrlMeta()
|
||||
async mounted() {
|
||||
await this.getUrlMeta()
|
||||
},
|
||||
methods: {
|
||||
async getUrlMeta() {
|
||||
@@ -110,35 +127,34 @@ export default {
|
||||
this.remoteMeta = data.actions[this.config.method.toUpperCase()] || {}
|
||||
},
|
||||
async getFilterPlatforms() {
|
||||
const res = await this.$axios.post(
|
||||
return await this.$axios.post(
|
||||
'/api/v1/assets/platforms/filter-nodes-assets/',
|
||||
{
|
||||
'node_ids': this.node_ids,
|
||||
'asset_ids': this.asset_ids
|
||||
'node_ids': this.nodes,
|
||||
'asset_ids': this.assets,
|
||||
'platform_ids': this.platforms.map(i => i.id || i.pk || i)
|
||||
}
|
||||
)
|
||||
return res
|
||||
},
|
||||
async onFieldChangeHandle() {
|
||||
async handleFieldChange() {
|
||||
const platforms = await this.getFilterPlatforms()
|
||||
let pushAccountMethods = platforms.map(i => i.automation?.push_account_method)
|
||||
let pushAccountMethods = platforms.map(i => i.automation[this.method])
|
||||
pushAccountMethods = _.uniq(pushAccountMethods)
|
||||
// 检测是否有可设置的推送方式
|
||||
const hasCanSettingPushMethods = _.intersection(pushAccountMethods, Object.keys(this.remoteMeta))
|
||||
this.setFormConfig(hasCanSettingPushMethods)
|
||||
if (hasCanSettingPushMethods.length > 0) {
|
||||
this.isDisabled = false
|
||||
this.$emit('input', this.form)
|
||||
} else {
|
||||
this.isDisabled = true
|
||||
this.$emit('input', {})
|
||||
}
|
||||
this.isDisabled = hasCanSettingPushMethods.length <= 0
|
||||
},
|
||||
setFormConfig(methods) {
|
||||
const newForm = {}
|
||||
const fields = []
|
||||
const fieldsMeta = {}
|
||||
this.config.fields = []
|
||||
// Todo: 未来改成后端处理,生成 serializer, 这里就不用判断类型了
|
||||
const typeMapper = {
|
||||
'string': 'input',
|
||||
'boolean': 'switch'
|
||||
}
|
||||
|
||||
for (const method of methods) {
|
||||
const filterField = this.remoteMeta[method] || {}
|
||||
@@ -155,7 +171,7 @@ export default {
|
||||
for (const [k, v] of Object.entries(filterField.children)) {
|
||||
const item = {
|
||||
...v,
|
||||
type: 'input'
|
||||
type: typeMapper[v.type] || 'input'
|
||||
}
|
||||
delete item.default
|
||||
fieldsMeta[method].fields.push(k)
|
||||
@@ -172,8 +188,11 @@ export default {
|
||||
this.visible = true
|
||||
},
|
||||
onSubmit(form) {
|
||||
this.visible = false
|
||||
this.form = form
|
||||
this.$emit('input', form)
|
||||
setTimeout(() => {
|
||||
this.visible = false
|
||||
}, 100)
|
||||
this.$log.debug('Auto push form:', form)
|
||||
}
|
||||
}
|
||||
97
src/components/Apps/BlockedIPs/BlockedIPList.vue
Normal file
97
src/components/Apps/BlockedIPs/BlockedIPList.vue
Normal file
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ListTable from '@/components/Table/ListTable/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'BlockedIPList',
|
||||
components: {
|
||||
ListTable
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
tableConfig: {
|
||||
url: '/api/v1/settings/security/block-ip/',
|
||||
columns: [
|
||||
'ip', 'actions'
|
||||
],
|
||||
columnsMeta: {
|
||||
ip: {
|
||||
label: this.$t('assets.ip')
|
||||
},
|
||||
actions: {
|
||||
formatterArgs: {
|
||||
hasDelete: false,
|
||||
hasUpdate: false,
|
||||
hasClone: false,
|
||||
extraActions: [
|
||||
{
|
||||
name: 'UnlockIP',
|
||||
title: this.$t('setting.Unblock'),
|
||||
can: this.$hasPerm('settings.change_security'),
|
||||
type: 'primary',
|
||||
callback: ({ row }) => {
|
||||
this.$axios.post(
|
||||
'/api/v1/settings/security/unlock-ip/',
|
||||
{ ips: [row.ip] }
|
||||
).then(() => {
|
||||
vm.$message.success(this.$tc('common.UnlockSuccessMsg'))
|
||||
vm.$refs.ListTable.reloadTable()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasExport: false,
|
||||
hasImport: false,
|
||||
hasCreate: false,
|
||||
hasSearch: false,
|
||||
hasRefresh: true,
|
||||
hasBulkDelete: false,
|
||||
hasBulkUpdate: false,
|
||||
hasLeftActions: true,
|
||||
hasRightActions: true,
|
||||
extraMoreActions: [
|
||||
{
|
||||
name: 'UnlockSelected',
|
||||
title: this.$t('setting.BulkUnblock'),
|
||||
type: 'primary',
|
||||
can: ({ selectedRows }) => {
|
||||
return selectedRows.length > 0
|
||||
},
|
||||
callback: function({ selectedRows }) {
|
||||
vm.$axios.post(
|
||||
'/api/v1/settings/security/unlock-ip/',
|
||||
{
|
||||
ips: selectedRows.map(v => { return v.ip })
|
||||
}
|
||||
).then(res => {
|
||||
vm.$message.success(vm.$tc('common.UnlockSuccessMsg'))
|
||||
vm.$refs.ListTable.reloadTable()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
86
src/components/Apps/BlockedIPs/index.vue
Normal file
86
src/components/Apps/BlockedIPs/index.vue
Normal file
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div>
|
||||
<div>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
@click="onOpenDialog"
|
||||
>
|
||||
{{ $tc('common.View') }}
|
||||
<span>({{ $tc('setting.LockedIP', ipCounts ) }})</span>
|
||||
</el-button>
|
||||
</div>
|
||||
<Dialog
|
||||
:visible.sync="visible"
|
||||
:title="title"
|
||||
width="40%"
|
||||
:show-cancel="false"
|
||||
:show-confirm="false"
|
||||
:destroy-on-close="true"
|
||||
v-bind="$attrs"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<BlockedIPList />
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Dialog } from '@/components'
|
||||
import BlockedIPList from '@/components/Apps/BlockedIPs/BlockedIPList'
|
||||
|
||||
export default {
|
||||
componentName: 'BlockedIPs',
|
||||
components: {
|
||||
BlockedIPList,
|
||||
Dialog
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: function() {
|
||||
return this.$t('setting.BlockedIPS')
|
||||
}
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: `/api/v1/assets/platform-automation-methods/`
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
remoteMeta: {},
|
||||
visible: false,
|
||||
form: this.value,
|
||||
ipCounts: 0,
|
||||
config: {
|
||||
url: this.url,
|
||||
hasSaveContinue: false,
|
||||
hasButtons: true,
|
||||
fields: [],
|
||||
fieldsMeta: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getLockedIp()
|
||||
},
|
||||
methods: {
|
||||
getLockedIp() {
|
||||
this.$axios.get('/api/v1/settings/security/block-ip/').then(res => {
|
||||
this.ipCounts = res.count
|
||||
})
|
||||
},
|
||||
onOpenDialog() {
|
||||
this.visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
136
src/components/Apps/ChangeSecret/RecordViewSecret.vue
Normal file
136
src/components/Apps/ChangeSecret/RecordViewSecret.vue
Normal file
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<div>
|
||||
<Dialog
|
||||
:destroy-on-close="true"
|
||||
:show-cancel="false"
|
||||
:title="title"
|
||||
:visible.sync="showSecret"
|
||||
:width="'50'"
|
||||
v-bind="$attrs"
|
||||
@confirm="accountConfirmHandle"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<el-form :model="secretInfo" class="password-form" label-position="right" label-width="100px">
|
||||
<el-form-item :label="$tc('accounts.AccountChangeSecret.OldSecret')">
|
||||
<ShowKeyCopyFormatter
|
||||
:cell-value="secretInfo.old_secret"
|
||||
:col="{ formatterArgs: {
|
||||
name: 'old_secret'
|
||||
}}"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$tc('accounts.AccountChangeSecret.NewSecret')">
|
||||
<ShowKeyCopyFormatter
|
||||
:cell-value="secretInfo.new_secret"
|
||||
:col="{ formatterArgs: {
|
||||
name: 'new_secret'
|
||||
}}"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import { ShowKeyCopyFormatter } from '@/components/Table/TableFormatters'
|
||||
|
||||
export default {
|
||||
name: 'RecordViewSecret',
|
||||
components: {
|
||||
Dialog,
|
||||
ShowKeyCopyFormatter
|
||||
},
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: function() {
|
||||
return this.$tc('common.ViewSecret')
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
secretInfo: {},
|
||||
showSecret: false,
|
||||
mfaDialogVisible: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
mounted() {
|
||||
this.showSecretDialog()
|
||||
},
|
||||
methods: {
|
||||
accountConfirmHandle() {
|
||||
this.showSecret = false
|
||||
this.mfaDialogVisible = false
|
||||
},
|
||||
showSecretDialog() {
|
||||
return this.$axios.get(this.url, { disableFlashErrorMsg: true }).then((res) => {
|
||||
this.secretInfo = res
|
||||
this.showSecret = true
|
||||
})
|
||||
},
|
||||
exit() {
|
||||
this.$emit('update:visible', false)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item-textarea >>> .el-textarea__inner {
|
||||
height: 110px;
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
border-bottom: 1px solid #EBEEF5;
|
||||
padding: 5px 0;
|
||||
margin-bottom: 0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
>>> .el-form-item__label {
|
||||
padding-right: 20px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
>>> .el-form-item__content {
|
||||
line-height: 30px;
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
margin-bottom: 8px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
.title {
|
||||
color: #303133;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
163
src/components/Apps/ChatAi/components/ChitChat/ChatInput.vue
Normal file
163
src/components/Apps/ChatAi/components/ChitChat/ChatInput.vue
Normal file
@@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<div class="chat-action">
|
||||
<Select2
|
||||
v-model="select.value"
|
||||
:disabled="isLoading || isSelectDisabled"
|
||||
v-bind="select"
|
||||
@change="onSelectChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="chat-input">
|
||||
<el-input
|
||||
v-model="inputValue"
|
||||
:disabled="isLoading"
|
||||
:placeholder="$tc('common.InputMessage')"
|
||||
type="textarea"
|
||||
@compositionend="isIM = false"
|
||||
@compositionstart="isIM = true"
|
||||
@keypress.native="onKeyEnter"
|
||||
/>
|
||||
<div class="input-action">
|
||||
<span class="right">
|
||||
<i :class="{'active': inputValue }" class="fa fa-send" @click="onSendHandle" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import Select2 from '../../../../Form/FormFields/Select2.vue'
|
||||
import { useChat } from '../../useChat.js'
|
||||
|
||||
const { setLoading } = useChat()
|
||||
|
||||
export default {
|
||||
components: { Select2 },
|
||||
props: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isIM: false,
|
||||
inputValue: '',
|
||||
select: {
|
||||
url: '/api/v1/settings/chatai-prompts/',
|
||||
value: '',
|
||||
multiple: false,
|
||||
placeholder: this.$t('common.Prompt'),
|
||||
ajax: {
|
||||
transformOption: (item) => {
|
||||
return { label: item.name, value: item.content }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
isLoading: state => state.chat.loading
|
||||
}),
|
||||
isSelectDisabled() {
|
||||
return !!this.select.value
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onKeyEnter(event) {
|
||||
if (event.key === 'Enter') {
|
||||
if ((!this.isIM && !event.shiftKey) || (this.isIM && event.ctrlKey)) {
|
||||
event.preventDefault()
|
||||
this.onSendHandle()
|
||||
}
|
||||
}
|
||||
},
|
||||
onSendHandle() {
|
||||
if (!this.inputValue) return
|
||||
|
||||
setLoading(true)
|
||||
this.$emit('send', this.inputValue)
|
||||
this.inputValue = ''
|
||||
},
|
||||
onSelectChange(value) {
|
||||
this.$emit('select-prompt', value)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
.chat-action {
|
||||
width: 100%;
|
||||
margin: 6px 0;
|
||||
&>>> .el-select {
|
||||
width: 50%;
|
||||
.el-input__inner {
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
border-radius: 14px;
|
||||
border-color: transparent;
|
||||
background-color: #f7f7f8;
|
||||
font-size: 13px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
&:hover {
|
||||
background-color: #ededed;
|
||||
}
|
||||
}
|
||||
.el-input__icon {
|
||||
line-height: 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.chat-input {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid #DCDFE6;
|
||||
border-radius: 12px;
|
||||
&:has(.el-textarea__inner:focus) {
|
||||
border: 1px solid var(--color-primary);
|
||||
}
|
||||
&>>> .el-textarea {
|
||||
height: 100%;
|
||||
.el-textarea__inner {
|
||||
height: 100%;
|
||||
padding: 8px 10px;
|
||||
border: none;
|
||||
border-top-left-radius: 12px;
|
||||
border-top-right-radius: 12px;
|
||||
resize: none;
|
||||
&::-webkit-scrollbar {
|
||||
width: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.el-textarea.is-disabled + .input-action {
|
||||
background-color: #F5F7FA;
|
||||
cursor: no-drop;
|
||||
i {
|
||||
cursor: no-drop;
|
||||
}
|
||||
}
|
||||
.input-action {
|
||||
overflow: hidden;
|
||||
padding: 0 16px 15px;
|
||||
border-bottom-left-radius: 12px;
|
||||
border-bottom-right-radius: 12px;
|
||||
.right {
|
||||
float: right;
|
||||
.active {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
i {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
186
src/components/Apps/ChatAi/components/ChitChat/ChatMessage.vue
Normal file
186
src/components/Apps/ChatAi/components/ChitChat/ChatMessage.vue
Normal file
@@ -0,0 +1,186 @@
|
||||
<template>
|
||||
<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="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="action">
|
||||
<el-tooltip
|
||||
v-if="isSystemError && isLoading"
|
||||
:content="$tc('common.Reconnect')"
|
||||
effect="dark"
|
||||
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>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MessageText from './MessageText.vue'
|
||||
import { mapState } from 'vuex'
|
||||
import { copy } from '@/utils/common'
|
||||
import { useChat } from '../../useChat.js'
|
||||
import { reconnect } from '@/utils/socket'
|
||||
|
||||
const { setLoading, removeLoadingMessageInChat } = useChat()
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MessageText
|
||||
},
|
||||
props: {
|
||||
item: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
chatUrl: require('@/assets/img/chat.png'),
|
||||
userUrl: '/api/v1/settings/logo/',
|
||||
dropdownOptions: [
|
||||
{
|
||||
action: 'copy',
|
||||
label: this.$t('common.Copy')
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
isLoading: state => state.chat.loading
|
||||
}),
|
||||
isUserRole() {
|
||||
return this.item.message?.role === 'user'
|
||||
},
|
||||
isSystemError() {
|
||||
return this.item.type === 'error' && this.item.message?.role === 'assistant'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onRefresh() {
|
||||
reconnect()
|
||||
removeLoadingMessageInChat()
|
||||
setLoading(false)
|
||||
},
|
||||
handleCommand(value) {
|
||||
if (value === 'copy') {
|
||||
copy(this.item.message.content)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.chat-item {
|
||||
display: flex;
|
||||
padding: 16px 14px 0;
|
||||
&:last-child {
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
.avatar {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
margin-top: 2px;
|
||||
.header-avatar {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
&>>> 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;
|
||||
}
|
||||
.message {
|
||||
flex-direction: row-reverse;
|
||||
.message-content {
|
||||
background-color: var(--menu-hover);
|
||||
border-radius: 12px 2px 12px 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
178
src/components/Apps/ChatAi/components/ChitChat/MessageText.vue
Normal file
178
src/components/Apps/ChatAi/components/ChitChat/MessageText.vue
Normal file
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<div>
|
||||
<div ref="textRef" class="leading-relaxed break-words">
|
||||
<span v-if="message.content === 'loading'" class="loading-box">
|
||||
<span />
|
||||
<span />
|
||||
<span />
|
||||
</span>
|
||||
<div v-else class="inline-block markdown-body" v-html="text" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MarkdownIt from 'markdown-it'
|
||||
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'
|
||||
|
||||
/* eslint-disable vue/no-v-html */
|
||||
export default {
|
||||
props: {
|
||||
message: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
markdown: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
text() {
|
||||
const value = this.message?.content || ''
|
||||
if (value && this.markdown) {
|
||||
return this.markdown?.render(value)
|
||||
}
|
||||
return this.$xss.process(value)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
},
|
||||
updated() {
|
||||
this.addCopyEvents()
|
||||
},
|
||||
destroyed() {
|
||||
this.removeCopyEvents()
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
const vm = this
|
||||
this.markdown = new MarkdownIt({
|
||||
html: false,
|
||||
linkify: true,
|
||||
highlight(code, language) {
|
||||
const validLang = !!(language && hljs.getLanguage(language))
|
||||
if (validLang) {
|
||||
const lang = language || ''
|
||||
return vm.highlightBlock(hljs.highlight(lang, code, true).value, lang)
|
||||
}
|
||||
return vm.highlightBlock(hljs.highlightAuto(code).value, '')
|
||||
}
|
||||
})
|
||||
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) {
|
||||
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>`
|
||||
},
|
||||
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)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
removeCopyEvents() {
|
||||
if (this.$refs.textRef) {
|
||||
const copyBtn = this.$refs.textRef.querySelectorAll('.code-block-header__copy')
|
||||
copyBtn.forEach((btn) => {
|
||||
btn.removeEventListener('click', () => {})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.markdown-body {
|
||||
font-size: 13px;
|
||||
&>>> p {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
background: inherit;
|
||||
&>>> pre {
|
||||
padding: 0 0 6px 0;
|
||||
.hljs.code-block-body {
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
&>>> .code-block-wrapper {
|
||||
background: #1F2329;
|
||||
padding: 2px 6px;
|
||||
margin: 5px 0;
|
||||
|
||||
.code-block-body {
|
||||
padding: 5px 10px 0;
|
||||
};
|
||||
.code-block-header {
|
||||
margin-bottom: 4px;
|
||||
overflow: hidden;
|
||||
background: #353946;
|
||||
color: #c2d1e1;
|
||||
|
||||
.code-block-header__copy {
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
color: #6e747b;
|
||||
}
|
||||
}
|
||||
}
|
||||
.hljs.code-block-body.javascript {
|
||||
.hljs-comment {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
>>> .link-style {
|
||||
color: #487bf4;
|
||||
&:hover {
|
||||
color: #275ee3;
|
||||
}
|
||||
}
|
||||
.loading-box{
|
||||
margin-left: 6px;
|
||||
}
|
||||
.loading-box span{
|
||||
display: inline-block;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
margin-right: 5px;
|
||||
border-radius: 50%;
|
||||
vertical-align: middle;
|
||||
background: #676A6c;
|
||||
animation: load 1.2s ease infinite;
|
||||
}
|
||||
.loading-box span:last-child{
|
||||
margin-right: 0;
|
||||
}
|
||||
@keyframes load{
|
||||
0%{
|
||||
opacity: 1;
|
||||
}
|
||||
100%{
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
.loading-box span:nth-child(1){
|
||||
animation-delay: 0.23s;
|
||||
}
|
||||
.loading-box span:nth-child(2){
|
||||
animation-delay: 0.36s;
|
||||
}
|
||||
.loading-box span:nth-child(3){
|
||||
animation-delay: 0.49s;
|
||||
}
|
||||
</style>
|
||||
271
src/components/Apps/ChatAi/components/ChitChat/index.vue
Normal file
271
src/components/Apps/ChatAi/components/ChitChat/index.vue
Normal file
@@ -0,0 +1,271 @@
|
||||
<template>
|
||||
<div class="chat-content">
|
||||
<div id="scrollRef" class="chat-list">
|
||||
<div v-if="showIntroduction" class="introduction">
|
||||
<div v-for="(item, index) in introduction" :key="index" class="introduction-item" @click="sendIntroduction(item)">
|
||||
<div class="head">
|
||||
<i v-if="item.icon" :class="item.icon" />
|
||||
<span class="title">{{ item.title }}</span>
|
||||
</div>
|
||||
<div class="content">
|
||||
{{ item.content }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ChatMessage v-for="(item, index) in activeChat.chats" :key="index" :item="item" />
|
||||
</div>
|
||||
<div class="input-box">
|
||||
<el-button
|
||||
v-if="isLoading && socket && socket.readyState === 1"
|
||||
class="stop"
|
||||
icon="fa fa-stop-circle-o"
|
||||
round
|
||||
size="small"
|
||||
@click="onStopHandle"
|
||||
>{{ $tc('common.Stop') }}</el-button>
|
||||
<ChatInput ref="chatInput" @send="onSendHandle" @select-prompt="onSelectPromptHandle" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ChatInput from './ChatInput.vue'
|
||||
import ChatMessage from './ChatMessage.vue'
|
||||
import { mapState } from 'vuex'
|
||||
import { closeWebSocket, createWebSocket, onSend, ws } from '@/utils/socket'
|
||||
import { getInputFocus, useChat } from '../../useChat.js'
|
||||
|
||||
const {
|
||||
setLoading,
|
||||
clearChats,
|
||||
addChatMessageById,
|
||||
addMessageToActiveChat,
|
||||
newChatAndAddMessageById,
|
||||
removeLoadingMessageInChat,
|
||||
updateChaMessageContentById,
|
||||
addTemporaryLoadingToChat
|
||||
} = useChat()
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ChatInput,
|
||||
ChatMessage
|
||||
},
|
||||
props: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
socket: {},
|
||||
prompt: '',
|
||||
currentConversationId: '',
|
||||
showIntroduction: false,
|
||||
introduction: [
|
||||
{
|
||||
title: this.$t('common.introduction.ConceptTitle'),
|
||||
content: this.$t('common.introduction.ConceptContent')
|
||||
},
|
||||
{
|
||||
title: this.$t('common.introduction.IdeaTitle'),
|
||||
content: this.$t('common.introduction.IdeaContent')
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
isLoading: state => state.chat.loading,
|
||||
activeChat: state => state.chat.activeChat
|
||||
})
|
||||
},
|
||||
destroyed() {
|
||||
closeWebSocket()
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.initWebSocket()
|
||||
this.initChatMessage()
|
||||
},
|
||||
initWebSocket() {
|
||||
const { NODE_ENV, VUE_APP_KAEL_HOST } = process.env || {}
|
||||
const api = '/kael/chat/system/'
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws'
|
||||
const path = `${protocol}://${window.location.host}${api}`
|
||||
const index = VUE_APP_KAEL_HOST?.indexOf('://')
|
||||
const localPath = protocol + VUE_APP_KAEL_HOST?.substring(index, VUE_APP_KAEL_HOST?.length) + api
|
||||
const url = NODE_ENV === 'development' ? localPath : path
|
||||
createWebSocket(url, this.onWebSocketMessage)
|
||||
},
|
||||
initChatMessage() {
|
||||
this.prompt = ''
|
||||
this.showIntroduction = true
|
||||
this.currentConversationId = ''
|
||||
this.$refs.chatInput.select.value = ''
|
||||
const chat = {
|
||||
message: {
|
||||
content: this.$t('common.ChatHello'),
|
||||
role: 'assistant',
|
||||
create_time: new Date()
|
||||
}
|
||||
}
|
||||
newChatAndAddMessageById(chat)
|
||||
setLoading(false)
|
||||
},
|
||||
onWebSocketMessage(data) {
|
||||
if (data.type === 'message') {
|
||||
this.onChatMessage(data)
|
||||
}
|
||||
if (data.type === 'error') {
|
||||
this.onSystemMessage(data)
|
||||
}
|
||||
},
|
||||
onChatMessage(data) {
|
||||
if (data.conversation_id) {
|
||||
setLoading(true)
|
||||
removeLoadingMessageInChat()
|
||||
this.currentConversationId = data.conversation_id
|
||||
updateChaMessageContentById(data.message.id, data)
|
||||
}
|
||||
if (data.message?.type === 'finish') {
|
||||
setLoading(false)
|
||||
getInputFocus()
|
||||
}
|
||||
},
|
||||
onSystemMessage(data) {
|
||||
data.message = {
|
||||
content: data.system_message,
|
||||
role: 'assistant',
|
||||
create_time: new Date()
|
||||
}
|
||||
removeLoadingMessageInChat()
|
||||
addMessageToActiveChat(data)
|
||||
this.socketReadyStateSuccess = false
|
||||
setLoading(true)
|
||||
},
|
||||
onSendHandle(value) {
|
||||
this.showIntroduction = false
|
||||
this.socket = ws || {}
|
||||
if (ws?.readyState === 1) {
|
||||
this.socketReadyStateSuccess = true
|
||||
const chat = {
|
||||
message: {
|
||||
content: value,
|
||||
role: 'user',
|
||||
create_time: new Date()
|
||||
}
|
||||
}
|
||||
const message = {
|
||||
content: value,
|
||||
prompt: this.prompt,
|
||||
conversation_id: this.currentConversationId || ''
|
||||
}
|
||||
addChatMessageById(chat)
|
||||
onSend(message)
|
||||
addTemporaryLoadingToChat()
|
||||
} else {
|
||||
const chat = {
|
||||
message: {
|
||||
content: this.$t('common.ConnectionDropped'),
|
||||
role: 'assistant',
|
||||
create_time: new Date()
|
||||
},
|
||||
type: 'error'
|
||||
}
|
||||
addChatMessageById(chat)
|
||||
this.socketReadyStateSuccess = false
|
||||
setLoading(true)
|
||||
}
|
||||
},
|
||||
onSelectPromptHandle(value) {
|
||||
this.prompt = value
|
||||
this.currentConversationId = ''
|
||||
this.showIntroduction = false
|
||||
this.onSendHandle(value)
|
||||
},
|
||||
onNewChat() {
|
||||
clearChats()
|
||||
this.initChatMessage()
|
||||
},
|
||||
onStopHandle() {
|
||||
this.$axios.post(
|
||||
'/kael/interrupt_current_ask/',
|
||||
{ id: this.currentConversationId || '' }
|
||||
).finally(() => {
|
||||
removeLoadingMessageInChat()
|
||||
setLoading(false)
|
||||
})
|
||||
},
|
||||
sendIntroduction(item) {
|
||||
this.showIntroduction = false
|
||||
this.onSendHandle(item.content)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.chat-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
|
||||
.introduction {
|
||||
padding: 16px 14px 0;
|
||||
|
||||
.introduction-item {
|
||||
padding: 12px 14px;
|
||||
border-radius: 8px;
|
||||
margin-top: 16px;
|
||||
background-color: var(--menu-hover);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 0 2px 2px #00000014;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.head {
|
||||
margin-bottom: 2px;
|
||||
.title {
|
||||
font-weight: 500;
|
||||
color: #373739;
|
||||
}
|
||||
}
|
||||
.content {
|
||||
display: inline-block;
|
||||
color: #a7a7ab;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
}
|
||||
}
|
||||
.chat-list {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
padding: 0 15px 25px;
|
||||
overflow-y: auto;
|
||||
user-select: text;
|
||||
&::-webkit-scrollbar {
|
||||
width: 12px;
|
||||
}
|
||||
}
|
||||
.input-box {
|
||||
position: relative;
|
||||
height: 160px;
|
||||
padding: 0 15px;
|
||||
margin-bottom: 15px;
|
||||
border-top: 1px solid #ececec;
|
||||
}
|
||||
.stop {
|
||||
position: absolute;
|
||||
top: -37px;
|
||||
left: 50%;
|
||||
z-index: 11;
|
||||
transform: translateX(-50%);
|
||||
>>> i {
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
81
src/components/Apps/ChatAi/components/Sidebar/index.vue
Normal file
81
src/components/Apps/ChatAi/components/Sidebar/index.vue
Normal file
@@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<div class="close-sidebar">
|
||||
<i v-if="hasClose" class="el-icon-close" @click="onClose" />
|
||||
</div>
|
||||
<el-tabs v-model="active" :tab-position="'right'" @tab-click="handleClick">
|
||||
<el-tab-pane v-for="(item) in submenu" :key="item.name" :name="item.name">
|
||||
<span slot="label">
|
||||
<el-tooltip effect="dark" placement="left" :content="item.label">
|
||||
<svg-icon :icon-class="item.icon" />
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
active: {
|
||||
type: String,
|
||||
default: 'chat'
|
||||
},
|
||||
hasClose: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
submenu: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick(tab, event) {
|
||||
this.$emit('tab-click', tab)
|
||||
},
|
||||
onClose() {
|
||||
this.$parent.onClose()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #f0f1f5;
|
||||
.close-sidebar {
|
||||
height: 48px;
|
||||
padding: 12px 0;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
i {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
padding: 4px;
|
||||
border-radius: 2px;
|
||||
&:hover {
|
||||
color: var(--color-primary);
|
||||
background: var(--menu-hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
>>> .el-tabs {
|
||||
.el-tabs__item {
|
||||
padding: 0 13px;
|
||||
font-size: 15px;
|
||||
:hover {
|
||||
color: #7b8085;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
145
src/components/Apps/ChatAi/index.vue
Normal file
145
src/components/Apps/ChatAi/index.vue
Normal file
@@ -0,0 +1,145 @@
|
||||
<template>
|
||||
<div class="chat">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="left">
|
||||
<img :src="robotUrl" alt="">
|
||||
<span class="title">{{ title }}</span>
|
||||
</div>
|
||||
<span class="new" @click="onNewChat">
|
||||
<i class="el-icon-plus" />
|
||||
<span>{{ $tc('common.NewChat') }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="content">
|
||||
<keep-alive>
|
||||
<component :is="active" ref="component" />
|
||||
</keep-alive>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidebar">
|
||||
<Sidebar v-bind="$attrs" :active.sync="active" :submenu="submenu" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Sidebar from './components/Sidebar/index.vue'
|
||||
import Chat from './components/ChitChat/index.vue'
|
||||
import { getInputFocus } from './useChat.js'
|
||||
import { ws } from '@/utils/socket'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Chat,
|
||||
Sidebar
|
||||
},
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: function() {
|
||||
return this.$t('setting.ChatAI')
|
||||
}
|
||||
},
|
||||
drawerPanelVisible: {
|
||||
type: Boolean,
|
||||
default: () => false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
active: 'chat',
|
||||
robotUrl: require('../../../assets/img/robot-assistant.png'),
|
||||
submenu: [
|
||||
{
|
||||
name: 'chat',
|
||||
label: this.$t('common.Chat'),
|
||||
icon: 'chat'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
drawerPanelVisible(value) {
|
||||
if (value && !ws) {
|
||||
this.initWebSocket()
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initWebSocket() {
|
||||
this.$refs.component?.init()
|
||||
},
|
||||
onClose() {
|
||||
this.$parent.show = false
|
||||
},
|
||||
onNewChat() {
|
||||
this.active = 'chat'
|
||||
this.$nextTick(() => {
|
||||
this.$refs.component?.onNewChat()
|
||||
getInputFocus()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.chat {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
height: 48px;
|
||||
line-height: 48px;
|
||||
padding: 0 16px;
|
||||
overflow: hidden;
|
||||
border-bottom: 1px solid #ececec;
|
||||
.left {
|
||||
img {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
vertical-align: sub;
|
||||
}
|
||||
.title {
|
||||
display: inline-block;
|
||||
font-size: 18px;
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
.new {
|
||||
display: inline-block;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
border-radius: 16px;
|
||||
padding: 0 10px;
|
||||
transform: translateY(32%);
|
||||
color: var(--color-primary);
|
||||
background-color: #f7f7f8;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
&:hover {
|
||||
background-color: #ededed;
|
||||
}
|
||||
}
|
||||
}
|
||||
.content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
.sidebar {
|
||||
height: 100%;
|
||||
width: 42px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
80
src/components/Apps/ChatAi/useChat.js
Normal file
80
src/components/Apps/ChatAi/useChat.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import store from '@/store'
|
||||
import { pageScroll } from '@/utils/common'
|
||||
|
||||
export const getInputFocus = () => {
|
||||
const dom = document.querySelector('.chat-input .el-textarea__inner')
|
||||
setTimeout(() => dom?.focus(), 200)
|
||||
}
|
||||
|
||||
export function useChat() {
|
||||
const chatStore = {}
|
||||
|
||||
const setLoading = (loading) => {
|
||||
store.commit('chat/setLoading', loading)
|
||||
}
|
||||
|
||||
const onNewChat = (name) => {
|
||||
const data = {
|
||||
name: name || `new chat`,
|
||||
id: 1,
|
||||
conversation_id: '',
|
||||
chats: []
|
||||
}
|
||||
store.commit('chat/addChatToStore', data)
|
||||
}
|
||||
|
||||
const clearChats = () => {
|
||||
store.commit('chat/clearChats')
|
||||
}
|
||||
|
||||
const addMessageToActiveChat = (chat) => {
|
||||
store.commit('chat/addMessageToActiveChat', chat)
|
||||
}
|
||||
|
||||
const removeLoadingMessageInChat = () => {
|
||||
store.commit('chat/removeLoadingMessageInChat')
|
||||
}
|
||||
|
||||
const addChatMessageById = (chat) => {
|
||||
store.commit('chat/addMessageToActiveChat', chat)
|
||||
if (chat?.conversation_id) {
|
||||
store.commit('chat/setActiveChatConversationId', chat.conversation_id)
|
||||
}
|
||||
pageScroll('scrollRef')
|
||||
}
|
||||
|
||||
const addTemporaryLoadingToChat = () => {
|
||||
const temporaryChat = {
|
||||
message: {
|
||||
content: 'loading',
|
||||
role: 'assistant',
|
||||
create_time: new Date()
|
||||
}
|
||||
}
|
||||
addChatMessageById(temporaryChat)
|
||||
}
|
||||
|
||||
const newChatAndAddMessageById = (chat) => {
|
||||
onNewChat(chat.message.content)
|
||||
addChatMessageById(chat)
|
||||
}
|
||||
|
||||
const updateChaMessageContentById = (id, data) => {
|
||||
store.commit('chat/updateChaMessageContentById', { id, data })
|
||||
pageScroll('scrollRef')
|
||||
}
|
||||
|
||||
return {
|
||||
chatStore,
|
||||
setLoading,
|
||||
onNewChat,
|
||||
clearChats,
|
||||
getInputFocus,
|
||||
addMessageToActiveChat,
|
||||
newChatAndAddMessageById,
|
||||
removeLoadingMessageInChat,
|
||||
addChatMessageById,
|
||||
addTemporaryLoadingToChat,
|
||||
updateChaMessageContentById
|
||||
}
|
||||
}
|
||||
209
src/components/Apps/DrawerPanel/index.vue
Normal file
209
src/components/Apps/DrawerPanel/index.vue
Normal file
@@ -0,0 +1,209 @@
|
||||
<template>
|
||||
<div ref="drawer" :class="{show: show}" class="drawer">
|
||||
<div :style="{'background-color': modal ? 'rgba(0, 0, 0, .3)' : 'transparent'}" class="modal" />
|
||||
<div :style="{'width': width}" class="drawer-panel">
|
||||
<div v-show="!show" ref="dragBox" class="handle-button">
|
||||
<i v-if="icon.startsWith('fa') || icon.startsWith('el')" :class="show ? 'el-icon-close': icon" />
|
||||
<img v-else :src="icon" alt="">
|
||||
</div>
|
||||
<div class="drawer-panel-item">
|
||||
<slot :drawer-panel-visible="show" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'DrawerPanel',
|
||||
props: {
|
||||
icon: {
|
||||
type: String,
|
||||
default: 'el-icon-setting'
|
||||
},
|
||||
width: {
|
||||
type: String,
|
||||
default: '440px'
|
||||
},
|
||||
modal: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
clickNotClose: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show(value) {
|
||||
if (value && !this.clickNotClose) {
|
||||
this.addEventClick()
|
||||
}
|
||||
this.$emit('toggle', this.show)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
this.insertToBody()
|
||||
},
|
||||
beforeDestroy() {
|
||||
const element = this.$refs.drawer
|
||||
element.remove()
|
||||
window.removeEventListener('click', this.closeSidebar)
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.$nextTick(() => {
|
||||
const dragBox = this.$refs.dragBox
|
||||
const clientOffset = {}
|
||||
dragBox.addEventListener('mousedown', (event) => {
|
||||
const offsetX = dragBox.getBoundingClientRect().left
|
||||
const offsetY = dragBox.getBoundingClientRect().top
|
||||
const innerX = event.clientX - offsetX
|
||||
const innerY = event.clientY - offsetY
|
||||
|
||||
clientOffset.clientX = event.clientX
|
||||
clientOffset.clientY = event.clientY
|
||||
document.onmousemove = function(event) {
|
||||
dragBox.style.left = event.clientX - innerX + 'px'
|
||||
dragBox.style.top = event.clientY - innerY + 'px'
|
||||
const dragDivTop = window.innerHeight - dragBox.getBoundingClientRect().height
|
||||
const dragDivLeft = window.innerWidth - dragBox.getBoundingClientRect().width
|
||||
dragBox.style.left = dragDivLeft + 'px'
|
||||
dragBox.style.left = '-48px'
|
||||
if (dragBox.getBoundingClientRect().top <= 0) {
|
||||
dragBox.style.top = '0px'
|
||||
}
|
||||
if (dragBox.getBoundingClientRect().top >= dragDivTop) {
|
||||
dragBox.style.top = dragDivTop + 'px'
|
||||
}
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
}
|
||||
document.onmouseup = function() {
|
||||
document.onmousemove = null
|
||||
document.onmouseup = null
|
||||
}
|
||||
}, false)
|
||||
dragBox.addEventListener('mouseup', (event) => {
|
||||
const clientX = event.clientX
|
||||
const clientY = event.clientY
|
||||
if (this.isDifferenceWithinThreshold(clientX, clientOffset.clientX) && this.isDifferenceWithinThreshold(clientY, clientOffset.clientY)) {
|
||||
this.show = !this.show
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
isDifferenceWithinThreshold(num1, num2, threshold = 5) {
|
||||
const difference = Math.abs(num1 - num2)
|
||||
return difference <= threshold
|
||||
},
|
||||
addEventClick() {
|
||||
window.addEventListener('click', this.closeSidebar)
|
||||
},
|
||||
closeSidebar(evt) {
|
||||
const parent = evt.target.closest('.drawer-panel')
|
||||
if (!parent && evt.target.className === 'modal') {
|
||||
this.show = false
|
||||
}
|
||||
},
|
||||
insertToBody() {
|
||||
const element = this.$refs.drawer
|
||||
const body = document.querySelector('body')
|
||||
body.insertBefore(element, body.firstChild)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
opacity: 0;
|
||||
transition: opacity .3s cubic-bezier(.7, .3, .1, 1);
|
||||
background: rgba(0, 0, 0, .3);
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.drawer-panel {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
min-width: 260px;
|
||||
height: 100vh;
|
||||
user-select: none;
|
||||
transition: transform .25s cubic-bezier(.7, .3, .1, 1);
|
||||
box-shadow: 0 0 8px 4px #00000014;
|
||||
transform: translate(100%);
|
||||
background: #FFFFFF;
|
||||
z-index: 1200;
|
||||
}
|
||||
|
||||
.drawer-panel-item {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.drawer-panel-item::-webkit-scrollbar-track {
|
||||
box-shadow: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.show {
|
||||
transition: all .3s cubic-bezier(.7, .3, .1, 1);
|
||||
}
|
||||
|
||||
.show .modal {
|
||||
z-index: 1003;
|
||||
opacity: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.show .drawer-panel {
|
||||
transform: translate(0);
|
||||
}
|
||||
|
||||
.handle-button {
|
||||
position: absolute;
|
||||
bottom: 20%;
|
||||
left: -48px;
|
||||
width: 48px;
|
||||
height: 45px;
|
||||
line-height: 45px;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
border-radius: 20px 0 0 20px;
|
||||
z-index: 0;
|
||||
pointer-events: auto;
|
||||
color: #fff;
|
||||
background-color: #FFFFFF;
|
||||
box-shadow: 0 0 8px 4px #00000014;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
left: -50px !important;
|
||||
width: 50px !important;
|
||||
transform: scale(1.06);
|
||||
}
|
||||
i {
|
||||
font-size: 20px;
|
||||
line-height: 45px;
|
||||
}
|
||||
img {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
transform: translateY(10%);
|
||||
margin-left: 3px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -33,7 +33,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog'
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import { openTaskPage } from '@/utils/jms'
|
||||
|
||||
export default {
|
||||
@@ -3,8 +3,10 @@
|
||||
</template>
|
||||
|
||||
<script type="text/jsx">
|
||||
import TreeTable from '../TreeTable'
|
||||
import { DetailFormatter } from '@/components/TableFormatters'
|
||||
import TreeTable from '../../Table/TreeTable/index.vue'
|
||||
import { DetailFormatter } from '@/components/Table/TableFormatters'
|
||||
import { AccountInfoFormatter } from '@/components/Table/TableFormatters'
|
||||
import { connectivityMeta } from '@/components/Apps/AccountListTable/const'
|
||||
|
||||
export default {
|
||||
name: 'GrantedAssets',
|
||||
@@ -49,6 +51,11 @@ export default {
|
||||
url: this.tableUrl,
|
||||
// ?assets=0不显示资产. =1显示资产
|
||||
treeUrl: this.treeUrl,
|
||||
edit: {
|
||||
drag: {
|
||||
isMove: false
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onSelected: (event, node) => vm.onSelected(node, vm),
|
||||
refresh: vm.refreshObjectAssetPermission
|
||||
@@ -57,10 +64,11 @@ export default {
|
||||
tableConfig: {
|
||||
url: this.tableUrl,
|
||||
hasTree: true,
|
||||
columnsExtra: ['view_account'],
|
||||
columnsExclude: ['spec_info'],
|
||||
columnShow: {
|
||||
columnsShow: {
|
||||
min: ['name', 'address', 'accounts'],
|
||||
default: ['name', 'address', 'accounts', 'actions']
|
||||
default: ['name', 'address', 'platform', 'view_account', 'connectivity']
|
||||
},
|
||||
columnsMeta: {
|
||||
name: {
|
||||
@@ -71,7 +79,13 @@ export default {
|
||||
},
|
||||
actions: {
|
||||
has: false
|
||||
}
|
||||
},
|
||||
view_account: {
|
||||
label: this.$t('assets.Account'),
|
||||
formatter: AccountInfoFormatter,
|
||||
width: '100px'
|
||||
},
|
||||
connectivity: connectivityMeta
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
@@ -7,7 +7,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ListTable from '@/components/ListTable/index.vue'
|
||||
import ListTable from '@/components/Table/ListTable/index.vue'
|
||||
import { toM2MJsonParams } from '@/utils/jms'
|
||||
|
||||
export default {
|
||||
@@ -7,7 +7,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ListTable from '@/components/ListTable/index.vue'
|
||||
import ListTable from '@/components/Table/ListTable/index.vue'
|
||||
import { toM2MJsonParams } from '@/utils/jms'
|
||||
|
||||
export default {
|
||||
@@ -30,8 +30,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import IBox from '@/components/IBox'
|
||||
import DiffDetail from '@/components/Dialog/DiffDetail'
|
||||
import IBox from '@/components/IBox/index.vue'
|
||||
import DiffDetail from '@/components/Dialog/DiffDetail.vue'
|
||||
import { openTaskPage } from '@/utils/jms'
|
||||
|
||||
export default {
|
||||
234
src/components/Apps/UserConfirmDialog/index.vue
Normal file
234
src/components/Apps/UserConfirmDialog/index.vue
Normal file
@@ -0,0 +1,234 @@
|
||||
<template>
|
||||
<Dialog
|
||||
:close-on-click-modal="false"
|
||||
:destroy-on-close="true"
|
||||
:show-cancel="false"
|
||||
:show-confirm="false"
|
||||
:title="title"
|
||||
:visible.sync="visible"
|
||||
class="dialog-content"
|
||||
v-bind="$attrs"
|
||||
width="600px"
|
||||
@confirm="visible = false"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<div v-if="confirmTypeRequired === 'relogin'">
|
||||
<el-row :gutter="24" style="margin: 0 auto;">
|
||||
<el-col :md="24" :sm="24">
|
||||
<el-alert
|
||||
:title="$tc('auth.ReLoginTitle')"
|
||||
center
|
||||
style="margin-bottom: 20px;"
|
||||
type="error"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24" style="margin: 0 auto;">
|
||||
<el-col :md="24" :sm="24">
|
||||
<el-button class="confirm-btn" size="mini" type="primary" @click="logout">
|
||||
{{ this.$t('auth.ReLogin') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-row :gutter="24" style="margin: 0 auto;">
|
||||
<el-col :md="24" :sm="24" :span="24" class="add">
|
||||
<el-select
|
||||
v-model="subTypeSelected"
|
||||
style="width: 100%; margin-bottom: 20px;"
|
||||
@change="handleSubTypeChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item of subTypeChoices"
|
||||
:key="item.name"
|
||||
:disabled="item.disabled"
|
||||
:label="item.display_name"
|
||||
:value="item.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24" style="margin: 0 auto;">
|
||||
<el-col :md="24" :sm="24" style="display: flex; margin-bottom: 20px;">
|
||||
<el-input
|
||||
v-model="secretValue"
|
||||
:placeholder="inputPlaceholder"
|
||||
:show-password="showPassword"
|
||||
@keyup.enter.native="handleConfirm"
|
||||
/>
|
||||
<span v-if="subTypeSelected === 'sms'" style="margin: -1px 0 0 20px;">
|
||||
<el-button
|
||||
:disabled="smsBtnDisabled"
|
||||
size="mini"
|
||||
style="line-height:20px; float: right;"
|
||||
type="primary"
|
||||
@click="sendSMSCode"
|
||||
>
|
||||
{{ smsBtnText }}
|
||||
</el-button>
|
||||
</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24" style="margin: 10px auto;">
|
||||
<el-col :md="24" :sm="24">
|
||||
<el-button class="confirm-btn" size="mini" type="primary" @click="handleConfirm">
|
||||
{{ this.$t('common.Confirm') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import { encryptPassword } from '@/utils/crypto'
|
||||
|
||||
export default {
|
||||
name: 'UserConfirmDialog',
|
||||
components: {
|
||||
Dialog
|
||||
},
|
||||
props: {
|
||||
url: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
handler: {
|
||||
type: Function,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: this.$t('common.CurrentUserVerify'),
|
||||
smsWidth: 0,
|
||||
subTypeSelected: '',
|
||||
inputPlaceholder: '',
|
||||
smsBtnText: this.$t('common.SendVerificationCode'),
|
||||
smsBtnDisabled: false,
|
||||
confirmTypeRequired: '',
|
||||
subTypeChoices: [],
|
||||
secretValue: '',
|
||||
visible: false,
|
||||
callback: null,
|
||||
cancel: null,
|
||||
processing: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
showPassword() {
|
||||
return this.confirmTypeRequired === 'password'
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$eventBus.$on('showConfirmDialog', this.performConfirm)
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$eventBus.$off('showConfirmDialog', this.performConfirm)
|
||||
},
|
||||
methods: {
|
||||
handleSubTypeChange(val) {
|
||||
this.inputPlaceholder = this.subTypeChoices.filter(item => item.name === val)[0]?.placeholder
|
||||
this.smsWidth = val === 'sms' ? 6 : 0
|
||||
},
|
||||
performConfirm: _.throttle(function({ response, callback, cancel }) {
|
||||
if (this.processing || this.visible) {
|
||||
return
|
||||
}
|
||||
this.processing = true
|
||||
this.callback = callback
|
||||
this.cancel = cancel
|
||||
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.confirmTypeRequired = data.confirm_type
|
||||
|
||||
if (this.confirmTypeRequired === 'relogin') {
|
||||
this.$axios.post(confirmUrl, { 'confirm_type': 'relogin', 'secret_key': 'x' }).then(() => {
|
||||
this.callback()
|
||||
this.visible = false
|
||||
}).catch(() => {
|
||||
this.title = this.$t('auth.NeedReLogin')
|
||||
this.visible = true
|
||||
})
|
||||
return
|
||||
}
|
||||
this.subTypeChoices = data.content
|
||||
const defaultSubType = this.subTypeChoices.filter(item => !item.disabled)[0]
|
||||
this.subTypeSelected = defaultSubType.name
|
||||
this.inputPlaceholder = defaultSubType.placeholder
|
||||
this.visible = true
|
||||
}).catch((err) => {
|
||||
const data = err.response?.data
|
||||
const msg = data?.error || data?.detail || data?.msg || this.$t('common.GetConfirmTypeFailed')
|
||||
this.$message.error(msg)
|
||||
this.cancel(err)
|
||||
}).finally(() => {
|
||||
this.processing = false
|
||||
})
|
||||
}, 300),
|
||||
logout() {
|
||||
window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}`
|
||||
},
|
||||
sendSMSCode() {
|
||||
this.$axios.post(`/api/v1/authentication/mfa/select/`, { type: 'sms' }).then(res => {
|
||||
this.$message.success(this.$tc('common.VerificationCodeSent'))
|
||||
let time = 60
|
||||
const interval = setInterval(() => {
|
||||
const originText = this.smsBtnText
|
||||
this.smsBtnText = this.$t('common.Pending') + `: ${time}`
|
||||
this.smsBtnDisabled = true
|
||||
time -= 1
|
||||
|
||||
if (time === 0) {
|
||||
this.smsBtnText = originText
|
||||
this.smsBtnDisabled = false
|
||||
clearInterval(interval)
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
},
|
||||
handleConfirm() {
|
||||
if (this.confirmTypeRequired === 'relogin') {
|
||||
return this.logout()
|
||||
}
|
||||
if (this.subTypeSelected === 'otp' && this.secretValue.length !== 6) {
|
||||
return this.$message.error(this.$tc('common.MFAErrorMsg'))
|
||||
}
|
||||
const data = {
|
||||
confirm_type: this.confirmTypeRequired,
|
||||
mfa_type: this.confirmTypeRequired === 'mfa' ? this.subTypeSelected : '',
|
||||
secret_key: this.confirmTypeRequired === 'password' ? encryptPassword(this.secretValue) : this.secretValue
|
||||
}
|
||||
this.$axios.post(`/api/v1/authentication/confirm/`, data).then(res => {
|
||||
this.callback()
|
||||
this.secretValue = ''
|
||||
this.visible = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.dialog-content >>> .el-dialog__footer {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.dialog-content >>> .el-dialog {
|
||||
padding: 8px;
|
||||
|
||||
.el-dialog__body {
|
||||
padding-top: 30px;
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
width: 100%;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -17,6 +17,9 @@ export default {
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
displayValue() {
|
||||
if ([null, undefined, ''].includes(this.value)) {
|
||||
@@ -64,8 +67,19 @@ export default {
|
||||
}
|
||||
},
|
||||
render(h) {
|
||||
let formatterData = ''
|
||||
if (typeof this.formatter === 'function') {
|
||||
return this.formatter(this.item, this.value)
|
||||
const data = this.formatter(this.item, this.value)
|
||||
if (data instanceof Promise) {
|
||||
data.then(res => {
|
||||
formatterData = res
|
||||
})
|
||||
} else {
|
||||
formatterData = data
|
||||
}
|
||||
return (
|
||||
<span style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word', lineHeight: '1.2' }}>{formatterData}</span>
|
||||
)
|
||||
}
|
||||
if (this.value instanceof Array) {
|
||||
const newArr = this.value || []
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<DetailCard v-if="!loading && hasObject" :items="items" v-bind="$attrs" />
|
||||
<DetailCard v-if="!loading && hasObject && items.length > 0" :items="items" v-bind="$attrs" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DetailCard from './index'
|
||||
import DetailCard from './index.vue'
|
||||
import { copy, toSafeLocalDateStr } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
@@ -106,16 +106,28 @@ export default {
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
if (typeof value[0] === 'object') {
|
||||
value.forEach(item => {
|
||||
const fieldName = `${name}.${item.name}`
|
||||
if (excludes.includes(fieldName)) {
|
||||
return
|
||||
}
|
||||
this.items.push({
|
||||
key: item.label,
|
||||
value: item.value
|
||||
const firstValue = value[0]
|
||||
if (firstValue.hasOwnProperty('name')) {
|
||||
value.forEach(item => {
|
||||
const fieldName = `${name}.${item.name}`
|
||||
if (excludes.includes(fieldName)) {
|
||||
return
|
||||
}
|
||||
this.items.push({
|
||||
key: item.label,
|
||||
value: item.value
|
||||
})
|
||||
})
|
||||
})
|
||||
} else {
|
||||
value.forEach((item, index) => {
|
||||
const v = Object.entries(item).map(([key, value]) => `${key}:${value}`).join(', ')
|
||||
const data = { value: v }
|
||||
if (index === 0) {
|
||||
data['key'] = label
|
||||
}
|
||||
this.items.push(data)
|
||||
})
|
||||
}
|
||||
} else if (typeof value[0] === 'string') {
|
||||
value.forEach((item, index) => {
|
||||
let data = {}
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<IBox :title="title" :fa="fa">
|
||||
<IBox :fa="fa" :title="title">
|
||||
<el-form class="content" label-position="left" label-width="25%">
|
||||
<el-form-item v-for="item in items" :key="item.key" :label="item.key">
|
||||
<ItemValue class="item-value" :value="item.value" v-bind="item" />
|
||||
<el-form-item v-for="item in iItems" :key="item.key" :label="item.key">
|
||||
<ItemValue :value="item.value" class="item-value" v-bind="item" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<slot />
|
||||
@@ -10,8 +10,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import IBox from '../IBox'
|
||||
import ItemValue from './ItemValue'
|
||||
import IBox from '../../IBox/index.vue'
|
||||
import ItemValue from './ItemValue.vue'
|
||||
|
||||
export default {
|
||||
name: 'DetailCard',
|
||||
@@ -35,6 +35,13 @@ export default {
|
||||
type: String,
|
||||
default: 'left'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
iItems: this.items.filter(item => {
|
||||
return !item.hasOwnProperty('has') || item.has === true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<IBox :type="type" :title="title" v-bind="$attrs">
|
||||
<table style="width: 100%;table-layout:fixed;" class="CardTable">
|
||||
<IBox :title="title" :type="type" v-bind="$attrs">
|
||||
<table class="CardTable" style="width: 100%;table-layout:fixed;">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<Select2 ref="select2" v-model="select2.value" :disabled="iDisabled" v-bind="select2" />
|
||||
@@ -9,7 +9,7 @@
|
||||
<slot />
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<el-button :type="type" size="small" :loading="submitLoading" :disabled="iDisabled" @click="addObjects">
|
||||
<el-button :disabled="iDisabled" :loading="submitLoading" :type="type" size="small" @click="addObjects">
|
||||
{{ $t('common.Add') }}
|
||||
</el-button>
|
||||
</td>
|
||||
@@ -17,12 +17,12 @@
|
||||
<template v-if="showHasObjects">
|
||||
<tr v-for="obj of iHasObjects" :key="obj.value" class="item">
|
||||
<td style="width: 100%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
|
||||
<el-tooltip style="margin: 4px;" effect="dark" :content="obj.label" placement="left">
|
||||
<el-tooltip :content="obj.label" effect="dark" placement="left" style="margin: 4px;">
|
||||
<b>{{ obj.label }}</b>
|
||||
</el-tooltip>
|
||||
</td>
|
||||
<td>
|
||||
<el-button size="mini" :disabled="iDisabled" type="danger" style="float: right" @click="removeObject(obj)">
|
||||
<el-button :disabled="iDisabled" size="mini" style="float: right" type="danger" @click="removeObject(obj)">
|
||||
<i class="fa fa-minus" />
|
||||
</el-button>
|
||||
</td>
|
||||
@@ -30,7 +30,7 @@
|
||||
</template>
|
||||
<tr v-if="params.hasMore && showHasMore" class="item">
|
||||
<td colspan="2">
|
||||
<el-button :type="type" :disabled="iDisabled" size="small" style="width: 100%" @click="loadMore">
|
||||
<el-button :disabled="iDisabled" :type="type" size="small" style="width: 100%" @click="loadMore">
|
||||
<i class="fa fa-arrow-down" />
|
||||
{{ $t('common.More') }}
|
||||
</el-button>
|
||||
@@ -41,10 +41,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Select2 from '../FormFields/Select2'
|
||||
import IBox from '../IBox'
|
||||
import Select2 from '@/components/Form/FormFields/Select2.vue'
|
||||
import IBox from '../../IBox/index.vue'
|
||||
import { createSourceIdCache } from '@/api/common'
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'RelationCard',
|
||||
components: {
|
||||
@@ -102,6 +103,10 @@ export default {
|
||||
type: Function,
|
||||
default: (obj, that) => {}
|
||||
},
|
||||
allowCreate: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
onDeleteSuccess: {
|
||||
type: Function,
|
||||
default(obj, that) {
|
||||
@@ -145,6 +150,10 @@ export default {
|
||||
that.$refs.select2.clearSelected()
|
||||
that.$message.success(that.$t('common.AddSuccessMsg'))
|
||||
}
|
||||
},
|
||||
getHasObjects: {
|
||||
type: Function,
|
||||
default: null // (objectIds) => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -162,7 +171,8 @@ export default {
|
||||
options: this.objects,
|
||||
value: this.value,
|
||||
disabled: this.disabled,
|
||||
disabledValues: []
|
||||
disabledValues: [],
|
||||
allowCreate: this.allowCreate
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -257,9 +267,15 @@ export default {
|
||||
return
|
||||
}
|
||||
this.select2.disabledValues = this.hasObjectsId
|
||||
const resp = await createSourceIdCache(this.hasObjectsId)
|
||||
this.params.spm = resp.spm
|
||||
await this.loadHasObjects()
|
||||
if (this.getHasObjects) {
|
||||
this.getHasObjects(this.hasObjectsId).then((data) => {
|
||||
this.iHasObjects = data
|
||||
})
|
||||
} else {
|
||||
const resp = await createSourceIdCache(this.hasObjectsId)
|
||||
this.params.spm = resp.spm
|
||||
await this.loadHasObjects()
|
||||
}
|
||||
},
|
||||
removeObject(obj) {
|
||||
this.performDelete(obj, this).then(
|
||||
@@ -9,11 +9,13 @@
|
||||
v-bind="$attrs"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<slot />
|
||||
<div v-loading="loadingStatus">
|
||||
<slot />
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<slot name="footer">
|
||||
<el-button v-if="showCancel && showButtons" @click="onCancel">{{ cancelTitle }}</el-button>
|
||||
<el-button v-if="showConfirm && showButtons" :loading="loadingStatus" type="primary" @click="onConfirm">
|
||||
<el-button v-if="showConfirm && showButtons" :disabled="loadingStatus" type="primary" @click="onConfirm">
|
||||
{{ confirmTitle }}
|
||||
</el-button>
|
||||
</slot>
|
||||
@@ -71,13 +73,16 @@ export default {
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
return {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
iWidth() {
|
||||
return this.$store.getters.isMobile ? '80%' : this.width
|
||||
return this.$store.getters.isMobile ? '1000px' : this.width
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
onCancel() {
|
||||
this.$emit('cancel')
|
||||
@@ -92,7 +97,7 @@ export default {
|
||||
<style lang="scss" scoped>
|
||||
.dialog >>> .el-dialog {
|
||||
border-radius: 0.3em;
|
||||
max-width: 1500px;
|
||||
max-width: min(100vw, 1500px);
|
||||
|
||||
.el-icon-circle-check {
|
||||
display: none;
|
||||
@@ -119,9 +124,14 @@ export default {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.dialog >>> .el-dialog {
|
||||
max-width: calc(100% - 30px);
|
||||
}
|
||||
}
|
||||
.dialog-footer >>> button.el-button {
|
||||
font-size: 13px;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<template>
|
||||
<DataForm
|
||||
v-if="!loading"
|
||||
:disabled="disabled"
|
||||
:fields="iFields"
|
||||
:form="value"
|
||||
style="margin-left: -26%;margin-right: -6%"
|
||||
v-bind="kwargs"
|
||||
@change="updateValue($event)"
|
||||
@input="updateValue($event)"
|
||||
v-on="$listeners"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DataForm from '@/components/DataForm'
|
||||
import DataForm from '@/components/Form/DataForm/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'NestedField',
|
||||
@@ -37,6 +40,8 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
formJson: JSON.stringify(this.value),
|
||||
kwargs: {
|
||||
hasReset: false,
|
||||
hasSaveContinue: false,
|
||||
@@ -65,7 +70,26 @@ export default {
|
||||
return fields
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler(val) {
|
||||
const valJson = JSON.stringify(val)
|
||||
// 如果不想等,证明是 value 自己变化导致的, 需要重新渲染
|
||||
if (valJson !== this.formJson) {
|
||||
this.loading = true
|
||||
setTimeout(() => {
|
||||
this.loading = false
|
||||
}, 10)
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateValue(val) {
|
||||
this.formJson = JSON.stringify(val)
|
||||
this.$emit('input', val)
|
||||
},
|
||||
objectToString(obj) {
|
||||
let data = ''
|
||||
// eslint-disable-next-line prefer-const
|
||||
@@ -23,9 +23,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DataForm from '../DataForm'
|
||||
import FormGroupHeader from '@/components/FormGroupHeader'
|
||||
import { FormFieldGenerator } from '@/components/AutoDataForm/utils'
|
||||
import DataForm from '../DataForm/index.vue'
|
||||
import FormGroupHeader from '@/components/Form/FormGroupHeader/index.vue'
|
||||
import { FormFieldGenerator } from '@/components/Form/AutoDataForm/utils'
|
||||
|
||||
export default {
|
||||
name: 'AutoDataForm',
|
||||
@@ -67,6 +67,9 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dataForm() {
|
||||
return this.$refs.dataForm
|
||||
},
|
||||
iForm() {
|
||||
const iForm = {}
|
||||
Object.entries(this.form).forEach(([key, value]) => {
|
||||
@@ -1,13 +1,12 @@
|
||||
import Vue from 'vue'
|
||||
import Select2 from '@/components/FormFields/Select2'
|
||||
import ObjectSelect2 from '@/components/FormFields/NestedObjectSelect2'
|
||||
import NestedField from '@/components/AutoDataForm/components/NestedField'
|
||||
import Switcher from '@/components/FormFields/Switcher'
|
||||
import rules from '@/components/DataForm/rules'
|
||||
import BasicTree from '@/components/FormFields/BasicTree'
|
||||
import JsonEditor from '@/components/FormFields/JsonEditor'
|
||||
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 } from '@/utils/common'
|
||||
import TagInput from '@/components/FormFields/TagInput.vue'
|
||||
import TagInput from '@/components/Form/FormFields/TagInput.vue'
|
||||
|
||||
export class FormFieldGenerator {
|
||||
constructor(emit) {
|
||||
@@ -45,13 +44,14 @@ export class FormFieldGenerator {
|
||||
break
|
||||
case 'field':
|
||||
type = ''
|
||||
field.component = Select2
|
||||
field.component = ObjectSelect2
|
||||
if (fieldRemoteMeta.required) {
|
||||
field.el.clearable = false
|
||||
}
|
||||
if (fieldRemoteMeta.child && fieldRemoteMeta.child.type === 'nested object') {
|
||||
field.component = ObjectSelect2
|
||||
}
|
||||
field.el.label = field.label
|
||||
// if (fieldRemoteMeta.child && fieldRemoteMeta.child.type === 'nested object') {
|
||||
// field.component = ObjectSelect2
|
||||
// }
|
||||
break
|
||||
case 'string':
|
||||
type = 'input'
|
||||
@@ -76,6 +76,7 @@ export class FormFieldGenerator {
|
||||
break
|
||||
case 'm2m_related_field':
|
||||
field.component = ObjectSelect2
|
||||
field.el.label = field.label
|
||||
break
|
||||
case 'nested object':
|
||||
type = 'nestedField'
|
||||
@@ -2,7 +2,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-tabs type="border-card">
|
||||
<el-tab-pane v-if="shouldHide('min')" :label="$tc('common.CronTab.min')">
|
||||
<el-tab-pane v-if="shouldHide('min')" :label="$tc('common.CronTab.min')" class="crontab-panel">
|
||||
<CrontabMin
|
||||
ref="cronmin"
|
||||
:check="checkNumber"
|
||||
@@ -59,38 +59,38 @@
|
||||
<td>
|
||||
<el-input
|
||||
v-model.trim="contabValueObj.min"
|
||||
min="0"
|
||||
max="5"
|
||||
size="small"
|
||||
min="0"
|
||||
onkeyup="value=value.replace(/[^\0-9\-\*\,]/g,'')"
|
||||
size="mini"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<el-input
|
||||
v-model.trim="contabValueObj.hour"
|
||||
size="small"
|
||||
onkeyup="value=value.replace(/[^\0-9\-\*\,]/g,'')"
|
||||
size="mini"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<el-input
|
||||
v-model.trim="contabValueObj.day"
|
||||
size="small"
|
||||
onkeyup="value=value.replace(/[^\0-9\\-\*\,]/g,'')"
|
||||
size="mini"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<el-input
|
||||
v-model.trim="contabValueObj.month"
|
||||
size="small"
|
||||
onkeyup="value=value.replace(/[^\0-9\-\*\,]/g,'')"
|
||||
size="mini"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<el-input
|
||||
v-model.trim="contabValueObj.week"
|
||||
size="small"
|
||||
onkeyup="value=value.replace(/[^\0-9\-\*\,]/g,'')"
|
||||
size="mini"
|
||||
/>
|
||||
</td>
|
||||
</tbody>
|
||||
@@ -100,7 +100,7 @@
|
||||
<div style="font-size: 13px;">{{ contabValueString }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<CrontabResult :ex="contabValueString" />
|
||||
<CrontabResult :ex="contabValueString" @crontabDiffChange="crontabDiffChangeHandle" />
|
||||
|
||||
<div class="pop_btn">
|
||||
<el-button
|
||||
@@ -130,7 +130,7 @@ import CrontabWeek from './components/Crontab-Week.vue'
|
||||
import CrontabResult from './components/Crontab-Result.vue'
|
||||
|
||||
export default {
|
||||
name: 'Vcrontab',
|
||||
name: 'VCrontab',
|
||||
components: {
|
||||
CrontabMin,
|
||||
CrontabHour,
|
||||
@@ -167,7 +167,8 @@ export default {
|
||||
week: '*'
|
||||
// year: "",
|
||||
},
|
||||
newContabValueString: ''
|
||||
newContabValueString: '',
|
||||
crontabDiff: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -364,6 +365,12 @@ export default {
|
||||
},
|
||||
// 填充表达式
|
||||
submitFill() {
|
||||
const crontabDiffMin = this.crontabDiff / 1000 / 60
|
||||
if (crontabDiffMin > 0 && crontabDiffMin < 10) {
|
||||
const msg = this.$tc('common.crontabDiffError')
|
||||
this.$message.error(msg)
|
||||
return
|
||||
}
|
||||
this.$emit('fill', this.contabValueString)
|
||||
this.hidePopup()
|
||||
},
|
||||
@@ -381,13 +388,16 @@ export default {
|
||||
for (const j in this.contabValueObj) {
|
||||
this.changeRadio(j, this.contabValueObj[j])
|
||||
}
|
||||
},
|
||||
crontabDiffChangeHandle(diff) {
|
||||
this.crontabDiff = diff
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
<style lang='scss' scoped>
|
||||
.pop_btn {
|
||||
text-align: center;
|
||||
float: right;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
@@ -453,6 +463,12 @@ export default {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.crontab-panel {
|
||||
> > > .el-input-number {
|
||||
margin: 0 5px
|
||||
}
|
||||
}
|
||||
|
||||
.el-form-item--mini.el-form-item,
|
||||
.el-form-item--small.el-form-item {
|
||||
margin-bottom: 10px;
|
||||
@@ -10,15 +10,15 @@
|
||||
<el-form-item>
|
||||
<el-radio v-model="radioValue" :label="3">
|
||||
{{ this.$t('common.CronTab.from') }}
|
||||
<el-input-number v-model="cycle01" :min="0" :max="31" /> -
|
||||
<el-input-number v-model="cycle02" :min="0" :max="31" /> {{ this.$t('common.CronTab.day') }}
|
||||
<el-input-number v-model="cycle01" :max="31" :min="0" size="mini" /> -
|
||||
<el-input-number v-model="cycle02" :max="31" :min="0" size="mini" /> {{ this.$t('common.CronTab.day') }}
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-radio v-model="radioValue" :label="4">
|
||||
{{ this.$t('common.CronTab.every') }}
|
||||
<el-input-number v-model="average02" :min="1" :max="31" /> {{ this.$t('common.CronTab.day') }}{{ this.$t('common.CronTab.executeOnce') }}
|
||||
<el-input-number v-model="average02" :max="31" :min="1" size="mini" /> {{ this.$t('common.CronTab.day') }}{{ this.$t('common.CronTab.executeOnce') }}
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
{{ this.$t('common.CronTab.appoint') }}
|
||||
<el-select
|
||||
v-model="checkboxList"
|
||||
clearable
|
||||
:placeholder="$tc('common.CronTab.manyChoose')"
|
||||
clearable
|
||||
multiple
|
||||
style="width:100%"
|
||||
>
|
||||
@@ -10,15 +10,15 @@
|
||||
<el-form-item>
|
||||
<el-radio v-model="radioValue" :label="2">
|
||||
{{ this.$t('common.CronTab.from') }}
|
||||
<el-input-number v-model="cycle01" :min="0" :max="60" /> -
|
||||
<el-input-number v-model="cycle02" :min="0" :max="60" /> {{ this.$t('common.CronTab.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('common.CronTab.hour') }}
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-radio v-model="radioValue" :label="3">
|
||||
{{ this.$t('common.CronTab.every') }}
|
||||
<el-input-number v-model="average02" :min="1" :max="60" /> {{ this.$t('common.CronTab.hour') }}{{ this.$t('common.CronTab.executeOnce') }}
|
||||
<el-input-number v-model="average02" :max="60" :min="1" size="mini" /> {{ this.$t('common.CronTab.hour') }}{{ this.$t('common.CronTab.executeOnce') }}
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
{{ this.$t('common.CronTab.appoint') }}
|
||||
<el-select
|
||||
v-model="checkboxList"
|
||||
clearable
|
||||
:placeholder="$tc('common.CronTab.manyChoose')"
|
||||
clearable
|
||||
multiple
|
||||
style="width:100%"
|
||||
>
|
||||
@@ -7,18 +7,11 @@
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-radio v-model="radioValue" :label="2">
|
||||
{{ this.$t('common.CronTab.from') }}
|
||||
<el-input-number v-model="cycle01" :min="0" :max="60" /> -
|
||||
<el-input-number v-model="cycle02" :min="0" :max="60" /> {{ this.$t('common.CronTab.min') }}
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-radio v-model="radioValue" :label="3">
|
||||
{{ this.$t('common.CronTab.from') }}
|
||||
<el-input-number v-model="average02" :min="1" :max="60" /> {{ this.$t('common.CronTab.min') }}{{ this.$t('common.CronTab.executeOnce') }}
|
||||
<el-input-number v-model="average02" :max="60" :min="1" size="mini" />
|
||||
{{ this.$t('common.CronTab.min') }}{{ this.$t('common.CronTab.executeOnce') }}
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
@@ -27,13 +20,13 @@
|
||||
{{ this.$t('common.CronTab.appoint') }}
|
||||
<el-select
|
||||
v-model="checkboxList"
|
||||
clearable
|
||||
:placeholder="$tc('common.CronTab.manyChoose')"
|
||||
clearable
|
||||
multiple
|
||||
style="width:100%"
|
||||
size="small"
|
||||
style="width:100%"
|
||||
>
|
||||
<el-option v-for="item in 60" :key="item" :value="item-1">{{ item-1 }}</el-option>
|
||||
<el-option v-for="item in 60" :key="item" :value="item-1">{{ item - 1 }}</el-option>
|
||||
</el-select>
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
@@ -158,7 +151,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-form-item--small.el-form-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.el-form-item--small.el-form-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -10,15 +10,15 @@
|
||||
<el-form-item>
|
||||
<el-radio v-model="radioValue" :label="2">
|
||||
{{ this.$t('common.CronTab.from') }}
|
||||
<el-input-number v-model="cycle01" :min="1" :max="12" /> -
|
||||
<el-input-number v-model="cycle02" :min="1" :max="12" /> {{ this.$t('common.CronTab.month') }}
|
||||
<el-input-number v-model="cycle01" :max="12" :min="1" size="mini" /> -
|
||||
<el-input-number v-model="cycle02" :max="12" :min="1" size="mini" /> {{ this.$t('common.CronTab.month') }}
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-radio v-model="radioValue" :label="3">
|
||||
{{ this.$t('common.CronTab.every') }}
|
||||
<el-input-number v-model="average02" :min="1" :max="12" /> {{ this.$t('common.CronTab.month') }}{{ this.$t('common.CronTab.executeOnce') }}
|
||||
<el-input-number v-model="average02" :max="12" :min="1" size="mini" /> {{ this.$t('common.CronTab.month') }}{{ this.$t('common.CronTab.executeOnce') }}
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
{{ this.$t('common.CronTab.appoint') }}
|
||||
<el-select
|
||||
v-model="checkboxList"
|
||||
clearable
|
||||
:placeholder="$tc('common.CronTab.manyChoose')"
|
||||
clearable
|
||||
multiple
|
||||
style="width:100%"
|
||||
>
|
||||
@@ -14,6 +14,7 @@
|
||||
<script>
|
||||
import parser from 'cron-parser'
|
||||
import { toSafeLocalDateStr } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
name: 'CrontabResult',
|
||||
props: {
|
||||
@@ -51,6 +52,10 @@ export default {
|
||||
const cur = interval.next().toString()
|
||||
this.resultList.push(toSafeLocalDateStr(cur))
|
||||
}
|
||||
const first = new Date(this.resultList[0])
|
||||
const second = new Date(this.resultList[1])
|
||||
const diff = Math.abs(second - first)
|
||||
this.$emit('crontabDiffChange', diff)
|
||||
} catch (error) {
|
||||
this.isShow = false
|
||||
// debug(error, 'error')
|
||||
@@ -10,8 +10,8 @@
|
||||
<el-form-item>
|
||||
<el-radio v-model="radioValue" :label="3">
|
||||
{{ this.$t('common.CronTab.cycleFromWeek') }}
|
||||
<el-input-number v-model="cycle01" :min="1" :max="7" /> -
|
||||
<el-input-number v-model="cycle02" :min="1" :max="7" />
|
||||
<el-input-number v-model="cycle01" :max="7" :min="1" size="mini" /> -
|
||||
<el-input-number v-model="cycle02" :max="7" :min="1" size="mini" />
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
@@ -20,12 +20,14 @@
|
||||
{{ this.$t('common.CronTab.appoint') }}
|
||||
<el-select
|
||||
v-model="checkboxList"
|
||||
clearable
|
||||
:placeholder="$tc('common.CronTab.manyChoose')"
|
||||
clearable
|
||||
multiple
|
||||
style="width:100%"
|
||||
>
|
||||
<el-option v-for="(item,index) of weekList" :key="index" :value="index+1">{{ item }}</el-option>
|
||||
<el-option v-for="(item,index) of weekList" :key="index" :value="index === 6 ? 0 : (index + 1)">
|
||||
{{ item }}
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-radio>
|
||||
</el-form-item>
|
||||
@@ -1,13 +1,19 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="box">
|
||||
<el-input v-model="input" clearable @focus="showDialog" @clear="onClear" />
|
||||
<el-input v-model="input" clearable @clear="onClear" @focus="showDialog" />
|
||||
</div>
|
||||
<el-dialog :title="$tc('common.CronTab.newCron')" :visible.sync="showCron" top="8vh" width="580px" append-to-body>
|
||||
<el-dialog
|
||||
:title="$tc('common.CronTab.newCron')"
|
||||
:visible.sync="showCron"
|
||||
append-to-body
|
||||
top="8vh"
|
||||
width="650px"
|
||||
>
|
||||
<Crontab
|
||||
:expression="expression"
|
||||
@hide="showCron = false"
|
||||
@fill="crontabFill"
|
||||
@hide="showCron = false"
|
||||
/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@@ -7,13 +7,11 @@
|
||||
v-bind="data.attrs"
|
||||
>
|
||||
<template v-if="data.helpTips" #label>
|
||||
<el-tooltip placement="bottom" effect="light" popper-class="help-tips">
|
||||
<div slot="content" v-html="data.helpTips" />
|
||||
<el-button style="padding: 0">
|
||||
<i class="fa fa-info-circle" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
{{ data.label }}
|
||||
<el-tooltip placement="top" effect="light" popper-class="help-tips">
|
||||
<div slot="content" v-html="data.helpTips" />
|
||||
<i class="fa fa-question-circle-o" />
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<template v-if="readonly && hasReadonlyContent">
|
||||
<div
|
||||
@@ -70,7 +68,8 @@
|
||||
:key="opt.label"
|
||||
v-bind="opt"
|
||||
:label="'value' in opt ? opt.value : opt.label"
|
||||
>{{ opt.label }}</el-radio>
|
||||
>{{ opt.label }}
|
||||
</el-radio>
|
||||
</template>
|
||||
</custom-component>
|
||||
<div v-if="data.helpText" class="help-block" v-html="data.helpText" />
|
||||
@@ -38,11 +38,11 @@
|
||||
v-if="defaultButton"
|
||||
:disabled="!canSubmit"
|
||||
:loading="isSubmitting"
|
||||
size="small"
|
||||
:size="submitBtnSize"
|
||||
type="primary"
|
||||
@click="submitForm('form')"
|
||||
>
|
||||
{{ $t('common.Submit') }}
|
||||
{{ submitBtnText }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</ElFormRender>
|
||||
@@ -73,6 +73,16 @@ export default {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
submitBtnSize: {
|
||||
type: String,
|
||||
default: 'small'
|
||||
},
|
||||
submitBtnText: {
|
||||
type: String,
|
||||
default() {
|
||||
return this.$t('common.Submit')
|
||||
}
|
||||
},
|
||||
hasSaveContinue: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
@@ -126,8 +136,8 @@ export default {
|
||||
})
|
||||
},
|
||||
// 重置表单
|
||||
resetForm(formName) {
|
||||
this.$refs[formName].resetFields()
|
||||
resetForm() {
|
||||
this.$refs['form'].resetFields()
|
||||
},
|
||||
handleClick(button) {
|
||||
const callback = button.callback || function(values, form) {
|
||||
@@ -138,6 +148,7 @@ export default {
|
||||
callback(values, form, button)
|
||||
},
|
||||
getFormValue() {
|
||||
return this.$refs.form.getFormValue()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,13 +53,27 @@ export const matchAlphanumericUnderscore = {
|
||||
trigger: ['blur', 'change']
|
||||
}
|
||||
|
||||
// 不能包含()
|
||||
export const MatchExcludeParenthesis = {
|
||||
validator: (rule, value, callback) => {
|
||||
value = value?.trim()
|
||||
if (!/^[^()]*$/.test(value)) {
|
||||
callback(new Error(i18n.t('common.notParenthesis')))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: ['blur', 'change']
|
||||
}
|
||||
|
||||
export default {
|
||||
IpCheck,
|
||||
Required,
|
||||
RequiredChange,
|
||||
EmailCheck,
|
||||
specialEmojiCheck,
|
||||
matchAlphanumericUnderscore
|
||||
matchAlphanumericUnderscore,
|
||||
MatchExcludeParenthesis
|
||||
}
|
||||
|
||||
export const JsonRequired = {
|
||||
76
src/components/Form/FormFields/AllOrSpec.vue
Normal file
76
src/components/Form/FormFields/AllOrSpec.vue
Normal file
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-radio-group v-model="type" @input="handleTypeChange">
|
||||
<el-radio v-for="tp of types" :key="tp.name" :label="tp.name">
|
||||
{{ tp.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
<Select2 v-if="type === 'spec'" v-model="selected" v-bind="select2" @change="onChangeEmit" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Select2 from '@/components/Form/FormFields/Select2.vue'
|
||||
|
||||
export default {
|
||||
name: 'AllOrSpec',
|
||||
components: { Select2 },
|
||||
props: {
|
||||
value: {
|
||||
type: [Array],
|
||||
default: () => ([])
|
||||
},
|
||||
select2: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
resource: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
type: 'all', // all, selected
|
||||
types: [
|
||||
{ name: 'all', label: this.$t('common.All') },
|
||||
{ name: 'spec', label: this.$t('common.Spec') + this.$t('common.WordSep') + this.resource }
|
||||
],
|
||||
selected: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
iValue() {
|
||||
if (this.type === 'all') {
|
||||
return ['all']
|
||||
} else {
|
||||
return this.selected
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value || this.value.length === 0) {
|
||||
return
|
||||
}
|
||||
if (this.value.indexOf('all') > -1) {
|
||||
this.type = 'all'
|
||||
} else {
|
||||
this.type = 'spec'
|
||||
this.selected = this.value
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onChangeEmit() {
|
||||
this.$emit('input', this.iValue)
|
||||
},
|
||||
handleTypeChange() {
|
||||
this.$emit('input', this.iValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
62
src/components/Form/FormFields/AttrInput.vue
Normal file
62
src/components/Form/FormFields/AttrInput.vue
Normal file
@@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<div>
|
||||
<GenericCreateUpdateForm
|
||||
class="attr-form"
|
||||
v-bind="formConfig"
|
||||
@submit="onSubmit"
|
||||
/>
|
||||
<DataTable :config="tableConfig" class="attr-list" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import GenericCreateUpdateForm from '@/layout/components/GenericCreateUpdateForm'
|
||||
import DataTable from '@/components/Table/DataTable/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'AttrInput',
|
||||
components: { DataTable, GenericCreateUpdateForm },
|
||||
props: {
|
||||
formConfig: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
tableConfig: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
beforeSubmit: {
|
||||
type: Function,
|
||||
default: (val) => { return true }
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
onSubmit(value) {
|
||||
if (this.beforeSubmit(value)) {
|
||||
const clonedValue = JSON.parse(JSON.stringify(value))
|
||||
this.tableConfig.totalData.push(clonedValue)
|
||||
this.$emit('submit', this.tableConfig.totalData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.attr-form {
|
||||
>>> .el-select {
|
||||
width: 100%;
|
||||
}
|
||||
>>> .el-form-item__content {
|
||||
width: 100%;
|
||||
}
|
||||
>>> .form-buttons {
|
||||
margin: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -85,7 +85,7 @@ export default {
|
||||
<span>{label} </span>
|
||||
{helpText
|
||||
? (<el-tooltip content={helpText} placement='top'>
|
||||
<i class='fa fa-info-circle'></i>
|
||||
<i class='fa fa-question-circle-o'></i>
|
||||
</el-tooltip>) : ''}
|
||||
</span>)
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="code-editor" style="font-size: 12px">
|
||||
<div class="toolbar">
|
||||
<div
|
||||
v-for="(item,index) in toolbar.left"
|
||||
v-for="(item,index) in iActions"
|
||||
:key="index"
|
||||
style="display: inline-block; margin: 0 2px"
|
||||
>
|
||||
@@ -16,9 +16,8 @@
|
||||
>
|
||||
<i :class="item.icon" style="margin-right: 4px;" />{{ item.name }}
|
||||
</el-button>
|
||||
|
||||
<el-autocomplete
|
||||
v-if="item.type === 'input' && item.el.autoComplete"
|
||||
v-if="item.type === 'input' &&item.el && item.el.autoComplete"
|
||||
v-model="item.value"
|
||||
:placeholder="item.placeholder"
|
||||
:fetch-suggestions="item.el.query"
|
||||
@@ -27,7 +26,14 @@
|
||||
@select="item.callback(item.value)"
|
||||
@change="item.callback(item.value)"
|
||||
/>
|
||||
|
||||
<el-input
|
||||
v-else-if="item.type==='input'"
|
||||
v-model="item.value"
|
||||
:placeholder="item.placeholder"
|
||||
class="inline-input"
|
||||
size="mini"
|
||||
@change="item.callback(item.value)"
|
||||
/>
|
||||
<div v-if="item.type==='select' && item.el && item.el.create" class="select-content">
|
||||
<span class="filter-label">
|
||||
{{ item.name }}:
|
||||
@@ -87,6 +93,16 @@
|
||||
</el-tooltip>
|
||||
</div>
|
||||
|
||||
<div v-if="toolbar.hasOwnProperty('fold')" class="fold">
|
||||
<el-tooltip :content="$tc('common.MoreActions')" placement="top">
|
||||
<i
|
||||
class="fa"
|
||||
:class="[isFold ? 'fa-angle-double-right': 'fa-angle-double-down']"
|
||||
@click="onChangeFold"
|
||||
/>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
|
||||
<div class="right-side" style="float: right">
|
||||
<div
|
||||
v-for="(item,index) in toolbar.right"
|
||||
@@ -148,9 +164,19 @@ export default {
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
return {
|
||||
isFold: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
iActions() {
|
||||
let actions = this.toolbar.left || {}
|
||||
const fold = this.toolbar.fold || {}
|
||||
if (!this.isFold) {
|
||||
actions = { ...actions, ...fold }
|
||||
}
|
||||
return actions
|
||||
},
|
||||
iValue: {
|
||||
get() {
|
||||
return this.value
|
||||
@@ -173,6 +199,9 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onChangeFold() {
|
||||
this.isFold = !this.isFold
|
||||
},
|
||||
getLabel(value, items) {
|
||||
for (const item of items) {
|
||||
if (item.value === value) {
|
||||
@@ -199,6 +228,16 @@ export default {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.fold {
|
||||
display: inline-block;
|
||||
padding-left: 4px;
|
||||
i {
|
||||
font-weight: bold;
|
||||
font-size: 15px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
> > > .CodeMirror pre.CodeMirror-line,
|
||||
> > > .CodeMirror-linenumber.CodeMirror-gutter-elt {
|
||||
line-height: 18px !important;
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-for="(command, index) in value" :key="index" :prop="'value.' + index + '.value'" class="command-item">
|
||||
<el-input v-model="value[index]" size="mini">
|
||||
<div v-for="(command, index) in iValue" :key="index" :prop="'iValue.' + index + '.value'" class="command-item">
|
||||
<el-input v-model="iValue[index]" size="mini">
|
||||
<template slot="prepend"> {{ inputTitle + ' ' + (index + 1) }}</template>
|
||||
</el-input>
|
||||
<div class="input-button">
|
||||
@@ -14,7 +14,7 @@
|
||||
@click="handleDelete(command)"
|
||||
/>
|
||||
<el-button
|
||||
v-if="index === value.length - 1"
|
||||
v-if="index === iValue.length - 1"
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
style="flex-shrink: 0;"
|
||||
@@ -27,6 +27,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
@@ -39,20 +40,32 @@ export default {
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
return {
|
||||
iValue: ['']
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
iValue: {
|
||||
handler(v) {
|
||||
this.$emit('input', Array.from(v))
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.iValue = Array.from(this.value)
|
||||
},
|
||||
methods: {
|
||||
handleDelete(command) {
|
||||
const index = this.value.indexOf(command)
|
||||
const index = this.iValue.indexOf(command)
|
||||
if (index !== -1) {
|
||||
this.value.splice(index, 1)
|
||||
this.iValue.splice(index, 1)
|
||||
}
|
||||
},
|
||||
handleAdd() {
|
||||
this.value.push('')
|
||||
this.iValue.push('')
|
||||
},
|
||||
deleteDisabled() {
|
||||
return this.value.length <= 1
|
||||
return this.iValue.length <= 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DataForm from '@/components/DataForm/index.vue'
|
||||
import DataForm from '@/components/Form/DataForm/index.vue'
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import ValueField from '@/components/FormFields/JSONManyToManySelect/ValueField.vue'
|
||||
import { attrMatchOptions, typeMatchMapper } from './const'
|
||||
import ValueField from '@/components/Form/FormFields/JSONManyToManySelect/ValueField.vue'
|
||||
import { attrMatchOptions, typeMatchMapper } from '@/components/const'
|
||||
|
||||
export default {
|
||||
name: 'AttrFormDialog',
|
||||
@@ -65,8 +65,7 @@ export default {
|
||||
// 变化会影响 match 的选项
|
||||
const attr = this.attrs.find(attr => attr.name === val)
|
||||
if (!attr) return
|
||||
const matchSupports = vm.updateMatchOptions(attr)
|
||||
const matchOption = matchSupports.find(item => item.value === vm.form.match) || matchSupports[0]
|
||||
const matchOption = vm.updateMatchOptions(attr)
|
||||
setTimeout(() => {
|
||||
updateForm({ match: matchOption.value })
|
||||
}, 10)
|
||||
@@ -143,8 +142,9 @@ export default {
|
||||
})
|
||||
this.formConfig.fields[2].el.attr = attr
|
||||
const supports = attrMatchOptions.filter(option => !option.hidden)
|
||||
this.formConfig.fields[2].el.match = supports[0].value
|
||||
return supports
|
||||
const matchOption = supports.find(item => item.value === this.form.match) || supports[0]
|
||||
this.formConfig.fields[2].el.match = matchOption.value
|
||||
return matchOption
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import ListTable from '@/components/ListTable/index.vue'
|
||||
import ListTable from '@/components/Table/ListTable/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'AttrMatchResultDialog',
|
||||
@@ -8,9 +8,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TagInput from '@/components/FormFields/TagInput.vue'
|
||||
import Select2 from '@/components/FormFields/Select2.vue'
|
||||
import Switcher from '@/components/FormFields/Switcher.vue'
|
||||
import TagInput from '@/components/Form/FormFields/TagInput.vue'
|
||||
import Select2 from '@/components/Form/FormFields/Select2.vue'
|
||||
import Switcher from '@/components/Form/FormFields/Switcher.vue'
|
||||
|
||||
export default {
|
||||
name: 'ValueField',
|
||||
@@ -88,15 +88,15 @@ export default {
|
||||
getType() {
|
||||
const attrType = this.attr.type || 'str'
|
||||
this.$log.debug('Value field attr type: ', attrType, this.attr, this.match)
|
||||
if (attrType === 'm2m') {
|
||||
if (['m2m', 'fk', 'select'].includes(attrType)) {
|
||||
return 'select'
|
||||
} else if (attrType === 'bool') {
|
||||
return 'bool'
|
||||
} else if (attrType === 'select') {
|
||||
return 'select'
|
||||
}
|
||||
if (['in', 'ip_in'].includes(this.match)) {
|
||||
return 'array'
|
||||
} else if (this.match.startsWith('m2m')) {
|
||||
return 'select'
|
||||
} else {
|
||||
return 'string'
|
||||
}
|
||||
@@ -3,11 +3,13 @@
|
||||
<i v-if="value" class="fa fa-check text-primary" />
|
||||
<i v-else class="fa fa-times text-danger" />
|
||||
</span>
|
||||
<span v-else :title="value">{{ value }}</span>
|
||||
<span v-else :title="value">
|
||||
{{ value }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BaseFormatter from '@/components/TableFormatters/base.vue'
|
||||
import BaseFormatter from '@/components/Table/TableFormatters/base.vue'
|
||||
import { setUrlParam } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
@@ -32,44 +34,53 @@ export default {
|
||||
value: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
watch: {
|
||||
cellValue: {
|
||||
handler(val) {
|
||||
handler() {
|
||||
this.getValue()
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
formatterArgs: {
|
||||
handler() {
|
||||
this.getValue()
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
row: {
|
||||
handler() {
|
||||
this.getValue()
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getValue()
|
||||
setTimeout(() => {
|
||||
this.getValue()
|
||||
}, 100)
|
||||
},
|
||||
methods: {
|
||||
async getValue() {
|
||||
this.attr = this.formatterArgs.attrs.find(attr => attr.name === this.row.name)
|
||||
this.match = this.row.match
|
||||
const match = this.row.match
|
||||
this.$log.debug('ValueFormatter: ', this.attr, this.row.name)
|
||||
if (this.attr.type === 'm2m') {
|
||||
const url = setUrlParam(this.attr.el.url, 'ids', this.cellValue.join(','))
|
||||
const data = await this.$axios.get(url)
|
||||
const data = await this.$axios.get(url) || []
|
||||
if (data.length > 0) {
|
||||
const displayField = this.attr.el.displayField || 'name'
|
||||
this.value = data.map(item => item[displayField]).join(', ')
|
||||
}
|
||||
} else if (this.attr.type === 'select') {
|
||||
this.value = this.attr.el.options
|
||||
.filter(item => this.cellValue.includes(item.value))
|
||||
.map(item => item.label).join(',')
|
||||
} else if (['in', 'ip_in'].includes(this.match)) {
|
||||
const options = this.attr.el.options || []
|
||||
const items = options.filter(item => this.cellValue.includes(item.value))
|
||||
this.value = items.map(item => item.label).join(', ')
|
||||
} else if (['in', 'ip_in'].includes(match)) {
|
||||
this.value = this.cellValue.join(', ')
|
||||
} else {
|
||||
this.value = this.cellValue
|
||||
}
|
||||
this.loading = false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -38,12 +38,12 @@
|
||||
|
||||
<script>
|
||||
import Select2 from '../Select2.vue'
|
||||
import DataTable from '@/components/DataTable/index.vue'
|
||||
import DataTable from '@/components/Table/DataTable/index.vue'
|
||||
import ValueFormatter from './ValueFormatter.vue'
|
||||
import AttrFormDialog from './AttrFormDialog.vue'
|
||||
import AttrMatchResultDialog from './AttrMatchResultDialog.vue'
|
||||
import { setUrlParam } from '@/utils/common'
|
||||
import { attrMatchOptions } from './const'
|
||||
import { attrMatchOptions } from '@/components/const'
|
||||
import { toM2MJsonParams } from '@/utils/jms'
|
||||
|
||||
export default {
|
||||
@@ -4,6 +4,7 @@
|
||||
v-model="resultInfo"
|
||||
:mode="'code'"
|
||||
:show-btns="false"
|
||||
:class="{resize: resize === 'vertical'}"
|
||||
@json-change="onJsonChange"
|
||||
@json-save="onJsonSave"
|
||||
@has-error="onError"
|
||||
@@ -20,6 +21,13 @@ export default {
|
||||
value: {
|
||||
type: [String, Object, Array],
|
||||
default: () => ({})
|
||||
},
|
||||
resize: {
|
||||
type: String,
|
||||
validator: (value) => {
|
||||
return ['none', 'vertical'].indexOf(value) !== -1
|
||||
},
|
||||
default: 'vertical'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -46,15 +54,21 @@ export default {
|
||||
},
|
||||
onError: _.debounce(function(value) {
|
||||
this.$message.error(this.$tc('common.FormatError'))
|
||||
}, 1100)
|
||||
}, 1500)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "~@/styles/variables.scss";
|
||||
@import "~@/styles/variables";
|
||||
|
||||
.json-editor {
|
||||
.resize {
|
||||
& > > > .jsoneditor {
|
||||
resize: vertical;
|
||||
cursor: s-resize;
|
||||
}
|
||||
}
|
||||
& > > > .jsoneditor {
|
||||
border: 1px solid #e5e6e7;
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Select2 from './Select2'
|
||||
import Select2 from './Select2.vue'
|
||||
|
||||
export default {
|
||||
name: 'NestedObjectSelect2',
|
||||
106
src/components/Form/FormFields/PasswordRule.vue
Normal file
106
src/components/Form/FormFields/PasswordRule.vue
Normal file
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<div style="display: block">
|
||||
<el-button size="mini" type="primary" @click="visible=true">
|
||||
{{ $t('common.Setting') }}
|
||||
</el-button>
|
||||
<Dialog
|
||||
:destroy-on-close="true"
|
||||
:title="$tc('common.PasswordRule')"
|
||||
:visible.sync="visible"
|
||||
width="600px"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
@open="handleOpen"
|
||||
>
|
||||
<AutoDataForm ref="dataform" v-bind="form" />
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Dialog from '@/components/Dialog/index.vue'
|
||||
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'PasswordRule',
|
||||
components: { Dialog, AutoDataForm },
|
||||
props: {
|
||||
value: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
length: 16
|
||||
})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
form: {
|
||||
url: '',
|
||||
hasButtons: false,
|
||||
hasReset: false,
|
||||
hasSaveContinue: false,
|
||||
form: Object.assign({}, this.value),
|
||||
fields: [
|
||||
{
|
||||
id: 'length',
|
||||
label: this.$t('common.Length'),
|
||||
type: 'input-number',
|
||||
el: {
|
||||
min: 8,
|
||||
max: 30
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'uppercase',
|
||||
label: this.$t('common.Uppercase'),
|
||||
type: 'switch'
|
||||
},
|
||||
{
|
||||
id: 'lowercase',
|
||||
label: this.$t('common.Lowercase'),
|
||||
type: 'switch'
|
||||
},
|
||||
{
|
||||
id: 'digit',
|
||||
label: this.$t('common.Digit'),
|
||||
type: 'switch'
|
||||
},
|
||||
{
|
||||
id: 'symbol',
|
||||
label: this.$t('common.SpecialSymbol'),
|
||||
type: 'switch'
|
||||
},
|
||||
{
|
||||
id: 'exclude_symbols',
|
||||
label: this.$t('common.ExcludeSymbol'),
|
||||
type: 'input'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleConfirm() {
|
||||
const formValue = this.$refs.dataform.dataForm.getFormValue()
|
||||
this.form.form = formValue
|
||||
this.$emit('input', formValue)
|
||||
setTimeout(() => {
|
||||
this.visible = false
|
||||
}, 100)
|
||||
},
|
||||
handleCancel() {
|
||||
this.$refs.dataform.dataForm.resetForm()
|
||||
setTimeout(() => {
|
||||
this.visible = false
|
||||
}, 100)
|
||||
},
|
||||
handleOpen() {
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -24,6 +24,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'PhoneInput',
|
||||
@@ -35,21 +36,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
rawValue: {},
|
||||
countries: [
|
||||
{ name: 'China(中国)', value: '+86' },
|
||||
{ name: 'HongKong(中国香港)', value: '+852' },
|
||||
{ name: 'Macao(中国澳门)', value: '+853' },
|
||||
{ name: 'Taiwan(中国台湾)', value: '+886' },
|
||||
{ name: 'America(America)', value: '+1' },
|
||||
{ name: 'Russia(Россия)', value: '+7' },
|
||||
{ name: 'France(français)', value: '+33' },
|
||||
{ name: 'Britain(Britain)', value: '+44' },
|
||||
{ name: 'Germany(Deutschland)', value: '+49' },
|
||||
{ name: 'Japan(日本)', value: '+81' },
|
||||
{ name: 'Korea(한국)', value: '+82' },
|
||||
{ name: 'India(भारत)', value: '+91' }
|
||||
]
|
||||
rawValue: {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -58,7 +45,13 @@ export default {
|
||||
return ''
|
||||
}
|
||||
return `${this.rawValue.code}${this.rawValue.phone}`
|
||||
}
|
||||
},
|
||||
countries: {
|
||||
get() {
|
||||
return this.publicSettings.COUNTRY_CALLING_CODES
|
||||
}
|
||||
},
|
||||
...mapGetters(['publicSettings'])
|
||||
},
|
||||
mounted() {
|
||||
this.rawValue = this.value || { code: '+86', phone: '' }
|
||||
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<Dialog
|
||||
v-if="$attrs.visible"
|
||||
:close-on-click-modal="false"
|
||||
:destroy-on-close="true"
|
||||
:show-cancel="false"
|
||||
:show-confirm="false"
|
||||
:title="$tc('assets.PlatformProtocolConfig') + ':' + protocol.name"
|
||||
class="setting-dialog"
|
||||
v-bind="$attrs"
|
||||
width="800px"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<el-alert v-if="disabled && platformDetail" style="margin-bottom: 10px" type="success">
|
||||
{{ $t('assets.InheritPlatformConfig') }}
|
||||
<el-link :href="platformDetail" class="link-more" target="_blank">
|
||||
{{ $t('common.View') }}
|
||||
</el-link>
|
||||
<i class="fa fa-external-link" />
|
||||
</el-alert>
|
||||
<AutoDataForm
|
||||
:disabled="disabled"
|
||||
:form="form"
|
||||
class="data-form"
|
||||
v-bind="config"
|
||||
@submit="onSubmit"
|
||||
/>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { AutoDataForm, Dialog } from '@/components'
|
||||
import JsonEditor from '@/components/Form/FormFields/JsonEditor.vue'
|
||||
|
||||
export default {
|
||||
name: 'ProtocolSetting',
|
||||
components: {
|
||||
Dialog,
|
||||
AutoDataForm
|
||||
},
|
||||
props: {
|
||||
protocol: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
const platform = this.$route.query.platform
|
||||
return {
|
||||
loading: true,
|
||||
form: this.protocol,
|
||||
platformDetail: platform ? '#/console/assets/platforms/' + platform : '',
|
||||
config: {
|
||||
hasSaveContinue: false,
|
||||
hasButtons: !this.disabled,
|
||||
url: '/api/v1/assets/protocol-settings/?name=' + this.protocol.name,
|
||||
fields: [
|
||||
[vm.$t('common.Basic'), [
|
||||
'primary', 'required', 'default', 'public'
|
||||
]],
|
||||
[vm.$t('common.Advanced'), ['setting']]
|
||||
],
|
||||
fieldsMeta: {
|
||||
setting: {
|
||||
fields: '__all__',
|
||||
fieldsMeta: {
|
||||
username_selector: {
|
||||
hidden: (formValue) => formValue['autofill'] !== 'basic'
|
||||
},
|
||||
password_selector: {
|
||||
hidden: (formValue) => formValue['autofill'] !== 'basic'
|
||||
},
|
||||
submit_selector: {
|
||||
hidden: (formValue) => formValue['autofill'] !== 'basic'
|
||||
},
|
||||
script: {
|
||||
component: JsonEditor,
|
||||
hidden: (formValue) => formValue['autofill'] !== 'script'
|
||||
}
|
||||
}
|
||||
},
|
||||
public: {
|
||||
disabled: this.protocol.name === 'winrm',
|
||||
hidden: (formValue) => {
|
||||
if (this.protocol.name === 'winrm') {
|
||||
formValue['public'] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSubmit(form) {
|
||||
this.protocol = Object.assign(this.protocol, form)
|
||||
this.$emit('update:visible', false)
|
||||
this.$emit('confirm', this.protocol)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.data-form > > > .el-form-item.form-buttons {
|
||||
padding-top: 10px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.setting-dialog > > > .el-dialog__body {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.link-more {
|
||||
font-size: 10px;
|
||||
border-bottom: solid 1px;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
@@ -3,9 +3,10 @@
|
||||
<div v-for="(item, index) in items" :key="item.name" class="protocol-item">
|
||||
<el-input
|
||||
v-model="item.port"
|
||||
:class="readonly ? '' : 'input-with-select'"
|
||||
:class="isPortReadonly(item) ? '' : 'input-with-select'"
|
||||
:placeholder="portPlaceholder"
|
||||
:readonly="readonly"
|
||||
:readonly="isPortReadonly(item)"
|
||||
:title="isPortReadonly(item) ? '端口由 URL 指定' : ''"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<template #prepend>
|
||||
@@ -62,7 +63,7 @@
|
||||
<ProtocolSettingDialog
|
||||
v-if="showDialog"
|
||||
:disabled="settingReadonly || readonly"
|
||||
:item="settingItem"
|
||||
:protocol="currentProtocol"
|
||||
:visible.sync="showDialog"
|
||||
@confirm="handleSettingConfirm"
|
||||
/>
|
||||
@@ -70,7 +71,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ProtocolSettingDialog from './ProtocolSettingDialog'
|
||||
import ProtocolSettingDialog from './ProtocolSettingDialog.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -102,13 +103,17 @@ export default {
|
||||
showSetting: {
|
||||
type: Function,
|
||||
default: (item) => true
|
||||
},
|
||||
instance: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
name: '',
|
||||
items: [],
|
||||
settingItem: {},
|
||||
currentProtocol: {},
|
||||
showDialog: false,
|
||||
loading: false
|
||||
}
|
||||
@@ -138,13 +143,18 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
choices: {
|
||||
handler(value) {
|
||||
handler(value, oldValue) {
|
||||
if (value?.length === oldValue?.length) {
|
||||
return
|
||||
}
|
||||
this.loading = true
|
||||
setTimeout(() => {
|
||||
this.loading = false
|
||||
this.setDefaultItems(value)
|
||||
}, 100)
|
||||
}
|
||||
this.loading = false
|
||||
},)
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
},
|
||||
items: {
|
||||
handler(value) {
|
||||
@@ -157,6 +167,21 @@ export default {
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
},
|
||||
instance: {
|
||||
handler(value) {
|
||||
const port = this.getPortFromInstance(value)
|
||||
if (!port) {
|
||||
return
|
||||
}
|
||||
for (const item of this.items) {
|
||||
if (item['port_from_addr']) {
|
||||
item.port = port
|
||||
}
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@@ -166,21 +191,40 @@ export default {
|
||||
this.$log.debug('Items: ', this.items)
|
||||
},
|
||||
methods: {
|
||||
getPortFromInstance(instance) {
|
||||
if (!instance) {
|
||||
return 0
|
||||
}
|
||||
let address = instance.address || ''
|
||||
if (address.indexOf('://') === -1) {
|
||||
address = `https://${address}`
|
||||
}
|
||||
const parse = require('url-parse')
|
||||
const path = parse(address)
|
||||
let port = path.port
|
||||
if (port < 0 || port > 65535) {
|
||||
port = 0
|
||||
}
|
||||
if (!port) {
|
||||
port = path.protocol === 'https:' ? 443 : 80
|
||||
}
|
||||
return port
|
||||
},
|
||||
handleSettingConfirm() {
|
||||
if (this.settingItem.primary) {
|
||||
if (this.currentProtocol.primary) {
|
||||
const others = this.items
|
||||
.filter(item => item.name !== this.settingItem.name)
|
||||
.filter(item => item.name !== this.currentProtocol.name)
|
||||
.map(item => {
|
||||
item.primary = false
|
||||
return item
|
||||
})
|
||||
this.items = [this.settingItem, ...others]
|
||||
this.items = [this.currentProtocol, ...others]
|
||||
}
|
||||
if (this.settingItem.name === 'winrm') {
|
||||
if (this.settingItem.setting?.use_ssl) {
|
||||
this.settingItem.port = 5986
|
||||
if (this.currentProtocol.name === 'winrm') {
|
||||
if (this.currentProtocol.setting?.use_ssl) {
|
||||
this.currentProtocol.port = 5986
|
||||
} else {
|
||||
this.settingItem.port = 5985
|
||||
this.currentProtocol.port = 5985
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -217,20 +261,25 @@ export default {
|
||||
item.name = selected.name
|
||||
item.port = selected.port
|
||||
},
|
||||
isPortFormAddr(item) {
|
||||
return !!item['port_from_addr']
|
||||
},
|
||||
isPortReadonly(item) {
|
||||
return this.readonly || this.isPortFormAddr(item)
|
||||
},
|
||||
setPrimaryIfNeed(items) {
|
||||
// 如果没有设置主协议,设置第一个为主协议
|
||||
if (!this.settingReadonly) {
|
||||
const primaryProtocols = items.filter(item => item.primary)
|
||||
if (primaryProtocols.length === 0) {
|
||||
items[0].primary = true
|
||||
items[0].default = true
|
||||
items[0].required = true
|
||||
items[0].public = true
|
||||
} else if (primaryProtocols.length > 1) {
|
||||
primaryProtocols.slice(1, primaryProtocols.length).forEach(item => {
|
||||
item.primary = false
|
||||
})
|
||||
}
|
||||
if (this.settingReadonly) {
|
||||
return items
|
||||
}
|
||||
const primaryProtocols = items.filter(item => item.primary)
|
||||
if (primaryProtocols.length === 0) {
|
||||
items[0].default = true
|
||||
items[0].public = true
|
||||
} else if (primaryProtocols.length > 1) {
|
||||
primaryProtocols.slice(1, primaryProtocols.length).forEach(item => {
|
||||
item.primary = false
|
||||
})
|
||||
}
|
||||
return items
|
||||
},
|
||||
@@ -256,7 +305,7 @@ export default {
|
||||
items = protocols.filter(item => allProtocolNames.indexOf(item.name) !== -1)
|
||||
} else {
|
||||
const defaults = choices.filter(item => (item.required || item.primary || item.default))
|
||||
if (defaults.length === 0) {
|
||||
if (defaults.length === 0 && choices.length !== 0) {
|
||||
defaults.push(choices[0])
|
||||
}
|
||||
items = defaults
|
||||
@@ -271,7 +320,7 @@ export default {
|
||||
return protocols
|
||||
},
|
||||
onSettingClick(item) {
|
||||
this.settingItem = item
|
||||
this.currentProtocol = item
|
||||
this.showDialog = true
|
||||
}
|
||||
}
|
||||
5
src/components/Form/FormFields/Secret.vue
Normal file
5
src/components/Form/FormFields/Secret.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
Todo: 抽象 Secret
|
||||
</div>
|
||||
</template>
|
||||
@@ -172,7 +172,11 @@ export default {
|
||||
return params
|
||||
}
|
||||
const defaultTransformOption = (item) => {
|
||||
return { label: item.name, value: item.id }
|
||||
if (typeof item === 'object') {
|
||||
return { label: item.name, value: item.id }
|
||||
} else {
|
||||
return { label: item, value: item }
|
||||
}
|
||||
}
|
||||
const transformOption = this.ajax.transformOption || defaultTransformOption
|
||||
const defaultFilterOption = (item) => {
|
||||
@@ -207,6 +211,12 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
disabled(newValue, oldValue) {
|
||||
this.selectDisabled = newValue
|
||||
},
|
||||
options(newValue, oldValue) {
|
||||
this.iOptions = newValue
|
||||
},
|
||||
iAjax(newValue, oldValue) {
|
||||
this.$log.debug('Select url changed: ', oldValue, ' => ', newValue)
|
||||
this.refresh()
|
||||
@@ -224,6 +234,7 @@ export default {
|
||||
this.$log.debug('Value is : ', this.value)
|
||||
this.iValue = this.value
|
||||
this.initialized = true
|
||||
this.$emit('initialized', true)
|
||||
}, 100)
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
@@ -345,7 +356,7 @@ export default {
|
||||
})
|
||||
},
|
||||
clearSelected() {
|
||||
this.iValue = []
|
||||
this.iValue = this.multiple ? [] : ''
|
||||
},
|
||||
checkDisabled(item) {
|
||||
return item.disabled === undefined ? this.disabledValues.indexOf(item.value) !== -1 : item.disabled
|
||||
@@ -361,6 +372,7 @@ export default {
|
||||
this.refresh()
|
||||
this.$log.debug('Visible change, refresh select2')
|
||||
}
|
||||
this.$emit('visible-change', visible)
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user