Skip to content

Commit b99d52f

Browse files
authored
Merge pull request #3897 from hLinx/hotfix_master
Hotfix master
2 parents a6bcfd7 + cf6653d commit b99d52f

File tree

8 files changed

+296
-148
lines changed

8 files changed

+296
-148
lines changed

src/frontend/src/components/app-select/index.vue

Lines changed: 214 additions & 142 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import _ from 'lodash';
2+
import { onBeforeUnmount, watch } from 'vue';
3+
4+
export default (scrollEle, expandScopeGroupMap, list, isShowSelectPanel) => {
5+
const handleScroll = _.throttle(() => {
6+
const groupElList = Array.from(scrollEle.value?.querySelectorAll('.group-item') || []);
7+
const { top: listTop, bottom: listBottom } = scrollEle.value.getBoundingClientRect();
8+
const stickyIndexMap = {};
9+
groupElList.forEach((groupEl, index) => {
10+
const { top } = groupEl.getBoundingClientRect();
11+
if (top - 32 * index < listTop) {
12+
groupEl.style.position = 'sticky';
13+
groupEl.style.top = `${32 * index}px`;
14+
groupEl.style.bottom = '';
15+
stickyIndexMap[index] = true;
16+
}
17+
});
18+
_.reverse(groupElList).forEach((groupEl, index) => {
19+
const { bottom } = groupEl.getBoundingClientRect();
20+
if (bottom + 32 * index > listBottom) {
21+
groupEl.style.position = 'sticky';
22+
groupEl.style.top = '';
23+
groupEl.style.bottom = `${32 * index}px`;
24+
stickyIndexMap[groupElList.length - 1 - index] = true;
25+
}
26+
});
27+
}, 60);
28+
29+
watch(scrollEle, () => {
30+
if (scrollEle.value) {
31+
scrollEle.value?.addEventListener('scroll', handleScroll);
32+
}
33+
});
34+
watch([expandScopeGroupMap, list, isShowSelectPanel], () => {
35+
setTimeout(() => {
36+
handleScroll();
37+
}, 60);
38+
}, {
39+
immediate: true,
40+
});
41+
42+
43+
onBeforeUnmount(() => {
44+
scrollEle.value?.removeEventListener('scroll', handleScroll);
45+
});
46+
};

src/frontend/src/components/app-select/usePagination.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,24 @@ export default (scrollEle, loadingEle, list) => {
3434
});
3535

3636

37-
const renderData = computed(() => list.value.slice(0, pagination.current * pagination.pageSize));
37+
const groupItemMap = computed(() => list.value.reduce((result, item) => {
38+
if (!item.groupId) {
39+
Object.assign(result, { [item.id]: item });
40+
}
41+
return result;
42+
}, {}));
43+
44+
const renderData = computed(() => {
45+
const renderList = list.value.slice(0, pagination.current * pagination.pageSize);
46+
47+
const appendGroupMap = { ...groupItemMap.value };
48+
renderList.forEach((item) => {
49+
if (!item.groupId && appendGroupMap[item.id]) {
50+
delete appendGroupMap[item.id];
51+
}
52+
});
53+
return renderList.concat(Object.values(appendGroupMap));
54+
});
3855

3956
const handleScroll = _.throttle(() => {
4057
if (pagination.current * pagination.pageSize >= pagination.total) {

src/frontend/src/domain/service/app-manage.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,8 @@ export default {
4444
return AppManageSource.updateCancelFavorApp(params)
4545
.then(({ data }) => data);
4646
},
47+
fetchGroupPanel() {
48+
return AppManageSource.getGroupPanel()
49+
.then(({ data }) => data);
50+
},
4751
};

src/frontend/src/domain/source/app-manage.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class AppManage extends ModuleBase {
6060
params,
6161
});
6262
}
63+
getGroupPanel() {
64+
return Request.get(`${this.module}/scopeGroupPanel`, {
65+
cache: 1000,
66+
});
67+
}
6368
}
6469

6570
export default new AppManage();

src/frontend/src/i18n/language/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,5 +571,7 @@
571571
"输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。": "Enter the path of the custom interpreter software on the target machine, such as: D:\\Software\\python3\\python.exe",
572572
"解释器路径有误,需为合法的文件路径、且以 .exe 结尾。": "Interpreter path is invalid; it must be a valid file path ending with .exe.",
573573
"执行目标包含 Linux 服务器,但自定义解释器仅对 Windows 有效,请知悉。": "Please note: The execution targets include Linux hosts, but the interpreter is only supported on Windows.",
574-
"未分配管控区,请到节点管理重装 Agent": "Unassigned control area. Please reinstall the Agent in the Node Management interface."
574+
"未分配管控区,请到节点管理重装 Agent": "Unassigned control area. Please reinstall the Agent in the Node Management interface.",
575+
"去新建": "New",
576+
"请联系业务运维加入业务": "Please contact the business operation and maintenance to join the business."
575577
}

src/frontend/src/i18n/language/zh.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,5 +571,7 @@
571571
"输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。": "输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。",
572572
"解释器路径有误,需为合法的文件路径、且以 .exe 结尾。": "解释器路径有误,需为合法的文件路径、且以 .exe 结尾。",
573573
"执行目标包含 Linux 服务器,但自定义解释器仅对 Windows 有效,请知悉。": "执行目标包含 Linux 服务器,但自定义解释器仅对 Windows 有效,请知悉。",
574-
"未分配管控区,请到节点管理重装 Agent": "未分配管控区,请到节点管理重装 Agent"
574+
"未分配管控区,请到节点管理重装 Agent": "未分配管控区,请到节点管理重装 Agent",
575+
"去新建": "去新建",
576+
"请联系业务运维加入业务": "请联系业务运维加入业务"
575577
}

src/frontend/src/utils/request/middleware/request.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
*/
2525

2626
import Cookie from 'js-cookie';
27+
import _ from 'lodash';
28+
2729

2830
const CRRF_TOKEN_KEY = 'job_csrf_key';
2931

3032
export default (interceptors) => {
3133
interceptors.use((request) => {
3234
const CSRFToken = Cookie.get(CRRF_TOKEN_KEY);
33-
if (CSRFToken !== undefined) {
35+
if (CSRFToken && _.trim(request.baseURL) === _.trim(window.PROJECT_CONFIG.AJAX_URL_PREFIX)) {
3436
Object.assign(request.headers, {
3537
'X-CSRF-Token': CSRFToken || '',
3638
});
37-
} else {
38-
console.warn('Can not find csrftoken in document.cookie');
3939
}
4040

4141
return request;

0 commit comments

Comments
 (0)