Skip to content

Commit a541344

Browse files
committed
fix bug: redeploy and log
1 parent 390f605 commit a541344

13 files changed

Lines changed: 5939 additions & 24241 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

33
ossutil64
4-
node_modules
4+
node_modules/
55
build
66
myapps
77
myapps-*.zip

node_modules/.yarn-integrity

Lines changed: 1746 additions & 1687 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 0 additions & 18626 deletions
This file was deleted.

src/components/TagsInput.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const DeleteDomainConform = (props) => {
4848
try {
4949
// 检查被删除的域名是否正在被监控,如果是则禁用监控
5050
await checkAndDisableMonitoringForDeletedDomains(appId, domains);
51-
console.log(`Checked monitoring for deleted domains: ${domains.join(', ')}`);
5251
} catch (error) {
5352
// 监控检查失败不应该阻止域名删除
5453
console.warn(`Failed to check/disable monitoring for deleted domains:`, error.message || error);

src/helpers/api_apphub/apiCore.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ const getApiKey = async () => {
9090
const clearConfigCache = () => {
9191
configCache.clear();
9292
fetchPromise.clear();
93-
console.log('[ApiCore] Configuration cache cleared');
9493
};
9594

9695
// 检查是否为配置错误并清除相应缓存
@@ -135,7 +134,6 @@ class APICore {
135134
try {
136135
// 优先使用 configManager 的缓存配置(避免重复初始化)
137136
const config = await configManager.getConfigAsync();
138-
console.log('[APICore] Using cached config for axios initialization');
139137

140138
this.axiosInstance = axios.create({
141139
baseURL: config.apiURL,
@@ -220,8 +218,8 @@ class APICore {
220218

221219
// HTTP方法的简化封装
222220
get = (url, params) => this.request('get', url, null, params);
223-
post = (url, data, params) => this.request('post', url, data, params);
224-
put = (url, data, params) => this.request('put', url, data, params);
221+
post = (url, params, data) => this.request('post', url, data, params);
222+
put = (url, params, data) => this.request('put', url, data, params);
225223
delete = (url, params) => this.request('delete', url, null, params);
226224
}
227225

src/helpers/api_apphub/appHub.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ let apiInstance = null;
66

77
const getApiInstance = () => {
88
if (!apiInstance) {
9-
console.log('[AppHub] Creating new APICore instance');
109
apiInstance = new APICore();
1110
}
1211
return apiInstance;
@@ -34,7 +33,7 @@ function RemoveErrorApp(app_id, params) {
3433
//重建App(状态为:Inactive)
3534
function RedeployApp(app_id, params) {
3635
const baseUrl = `/apps/${app_id}/redeploy`;
37-
return getApiInstance().put(`${baseUrl}`, params);
36+
return getApiInstance().put(`${baseUrl}`, params, {});
3837
}
3938

4039
//App 卸载
@@ -76,13 +75,13 @@ function AppDomainDeleteByProxyID(proxy_id, params) {
7675
//根据ProxyID更新域名
7776
function AppDomainUpdateByProxyID(proxy_id, params, body) {
7877
const baseUrl = `/proxys/${proxy_id}`;
79-
return getApiInstance().put(`${baseUrl}`, body, params);
78+
return getApiInstance().put(`${baseUrl}`, params, body);
8079
}
8180

8281
//根据app_id创建域名
8382
function AppDomainCreateByAppID(app_id, params, body) {
8483
const baseUrl = `/proxys/${app_id}`;
85-
return getApiInstance().post(`${baseUrl}`, body, params);
84+
return getApiInstance().post(`${baseUrl}`, params, body);
8685
}
8786

8887
//创建App备份
@@ -106,13 +105,12 @@ function DeleteAppBackup(snapshot_id, params) {
106105
//恢复App备份
107106
function RestoreAppBackup(snapshot_id, app_id, params) {
108107
const baseUrl = `/backup/restore/${app_id}/${snapshot_id}`;
109-
return getApiInstance().post(`${baseUrl}`, {}, params);
108+
return getApiInstance().post(`${baseUrl}`, params, {});
110109
}
111110

112111
// 重置API实例 - 用于错误恢复
113112
function resetApiInstance() {
114113
if (apiInstance) {
115-
console.log('[AppHub] Resetting APICore instance');
116114
apiInstance = null;
117115
}
118116
}

src/pages/appdetail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ const AppDetailModal = (props) => {
442442
icon: 'mdi dripicons-stack',
443443
text: (
444444
<Suspense fallback={<div className="text-center"><i className="fa fa-spinner fa-spin"></i></div>}>
445-
<AppCompose data={currentApp} />
445+
<AppCompose data={currentApp} disabledButton={setAppdetailButtonDisable} enableButton={setAppdetailButtonEnable} />
446446
</Suspense>
447447
),
448448
},

src/pages/appdetailtabs/appcompose.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import React, { useState, useEffect, useRef } from 'react';
1212
import { Button, Card, Col, Form, Modal, Row } from 'react-bootstrap';
1313
import ReactDOM from 'react-dom';
1414
import Spinner from '../../components/Spinner';
15-
import { RedeployApp } from '../../helpers';
1615
import configManager from '../../helpers/api_apphub/configManager';
1716

1817
const _ = cockpit.gettext;
@@ -388,7 +387,7 @@ const AppCompose = (props): React$Element<React$FragmentType> => {
388387
</Row>
389388
{
390389
showRedeployConform &&
391-
<RedeployAppConform showConform={showRedeployConform} onClose={cancelredeployApp} app={props.data} handleBackToLastStep={handleBackToLastStep} />
390+
<RedeployAppConform showConform={showRedeployConform} onClose={cancelredeployApp} app={props.data} handleBackToLastStep={handleBackToLastStep} enableButton={props.enableButton} disableButton={props.disabledButton} />
392391
}
393392
</>
394393
);

src/pages/appdetailtabs/appmonitor.js

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ const AppMonitor = (props) => {
145145
};
146146

147147
const enableMonitoring = async () => {
148+
// 检查是否有可用域名
149+
if (domain_names.length === 0) {
150+
setShowAlert(true);
151+
setAlertMessage(_("Please bind a domain name to the application before enabling monitoring."));
152+
setAlertType("warning");
153+
return;
154+
}
155+
148156
if (!monitorUrl || !notificationEmail || !isEmailValid) return;
149157

150158
setLoading(true);
@@ -183,6 +191,14 @@ const AppMonitor = (props) => {
183191
};
184192

185193
const updateMonitoring = async () => {
194+
// 检查是否有可用域名
195+
if (domain_names.length === 0) {
196+
setShowAlert(true);
197+
setAlertMessage(_("Please bind a domain name to the application before updating monitoring."));
198+
setAlertType("warning");
199+
return;
200+
}
201+
186202
if (!monitorUrl || !notificationEmail || !isEmailValid) return;
187203

188204
setLoading(true);
@@ -252,7 +268,18 @@ const AppMonitor = (props) => {
252268
// 组件挂载时查询监控状态
253269
useEffect(() => {
254270
if (app_id) {
255-
// 使用统一的配置管理器并查询监控状态
271+
// 检查是否有可用的域名,没有域名时不需要调用监控API
272+
if (domain_names.length === 0) {
273+
// 没有域名绑定时,直接设置为禁用状态,不调用API
274+
setMonitorStatus('disabled');
275+
setMonitorUrl('');
276+
setNotificationEmail('');
277+
setDashboardUrl('');
278+
setLoading(false);
279+
return;
280+
}
281+
282+
// 有域名时才调用监控相关API
256283
const initializeAndQuery = async () => {
257284
try {
258285
await configManager.initialize();
@@ -267,7 +294,7 @@ const AppMonitor = (props) => {
267294

268295
initializeAndQuery();
269296
}
270-
}, [app_id, props.dataRefreshKey]); // 添加 dataRefreshKey 作为依赖
297+
}, [app_id, props.dataRefreshKey, domain_names.length]); // 添加 domain_names.length 作为依赖
271298

272299
const handleEnableMonitoring = () => {
273300
if (monitorUrl && notificationEmail && isEmailValid) {
@@ -287,8 +314,16 @@ const AppMonitor = (props) => {
287314

288315
const handleCancelEdit = () => {
289316
setIsEditing(false);
290-
// 恢复原来的值
291-
queryMonitorStatus();
317+
// 只有在有域名的情况下才恢复原来的值(调用API)
318+
if (domain_names.length > 0) {
319+
queryMonitorStatus();
320+
} else {
321+
// 没有域名时直接重置状态
322+
setMonitorUrl('');
323+
setNotificationEmail('');
324+
setMonitorStatus('disabled');
325+
setDashboardUrl('');
326+
}
292327
};
293328

294329
return (
@@ -339,7 +374,7 @@ const AppMonitor = (props) => {
339374
onChange={handleEmailChange}
340375
isInvalid={!isEmailValid}
341376
size="sm"
342-
disabled={(monitorStatus === 'enabled' && !isEditing) || loading}
377+
disabled={domain_names.length === 0 || (monitorStatus === 'enabled' && !isEditing) || loading}
343378
className="me-2"
344379
/>
345380
{!isEmailValid && (

src/pages/appdetailtabs/appuninstall.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ const UninstallConform = (props) => {
8080
try {
8181
// 首先检查并禁用监控(如果启用了的话)
8282
if (props.isMonitorApp) {
83-
await checkAndDisableMonitoring(props.app.app_id);
83+
try {
84+
await checkAndDisableMonitoring(props.app.app_id);
85+
} catch (monitorError) {
86+
// 监控禁用失败不应该阻断卸载流程,只记录警告
87+
console.warn('Failed to disable monitoring, but continuing with uninstall');
88+
}
8489
}
8590

8691
// 然后执行应用卸载

0 commit comments

Comments
 (0)