Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
queryAppData = (projectId = AppState.currentMenuType.id, type, refersh, isReloadApp) => {
// 已经加载过app数据 只更新对应模块的数据, 除非主动刷新 否则不查询app数据,
if (!isReloadApp && this.appData.length !== 0 && type !== 'CodeManagerBranch') {
refersh && refersh();
return;
}
if (Number(this.preProId) !== Number(projectId)) {
DeploymentPipelineStore.setProRole('app', '');
}
this.setAppData([]);
this.setPreProId(projectId);
this.setLoading(true);
axios.get(`/devops/v1/projects/${projectId}/app_service/list_by_active`)
.then((data) => {
this.setLoading(false);
if (handlePromptError(data)) {
this.setAppData(data);
if (data && data.length) {
if (this.selectedApp) {
if (_.filter(data, ['id', this.selectedApp]).length === 0) {
this.setSelectApp(data[0].id);
}
} else {
this.setSelectApp(data[0].id);
}
refersh && refersh();
} else {
this.setSelectApp(null);
}
async function checkCode(value) {
const pa = /^[a-z]([-a-z0-9]*[a-z0-9])?$/;
if (value && pa.test(value)) {
try {
const res = await axios.get(`/devops/v1/projects/${projectId}/app_service/check_code?code=${value}`);
if (res && res.failed) {
return formatMessage({ id: 'checkCodeExist' });
} else {
return true;
}
} catch (err) {
return formatMessage({ id: 'checkCodeFailed' });
}
} else {
return formatMessage({ id: 'checkCodeReg' });
}
}
async loadSingleData(projectId, id) {
try {
const res = await axios.get(`/devops/v1/projects/${projectId}/customize_resource/${id}`);
if (handlePromptError(res)) {
this.setSingleData(res);
}
} catch (e) {
Choerodon.handleResponseError(e);
}
},
page: current,
size: pageSize,
instanceId,
version,
params,
service: serviceName,
};
if (columnKey) {
const sorter = [];
sorter.push(columnKey);
if (order === 'asc') {
sorter.push('asc');
}
queryObj.sort = sorter.join(',');
}
return axios.get(`/manager/v1/instances?${querystring.stringify(queryObj)}`);
}
loadInstanceInfo = instanceId => axios.get(`manager/v1/instances/${instanceId}`)
}
loadSingleData = (projectId, id) => axios.get(`/devops/v1/projects/${projectId}/notification/${id}`)
.then((data) => {
if (handlePromptError(data)) {
this.setSingleData(data);
return data;
} else {
return false;
}
});
async checkHasApp(projectId) {
this.setLoading(true);
try {
const res = await axios.get(`/devops/v1/projects/${projectId}/app_service/count_by_active`);
if ((res && !res.failed) || res === 0) {
this.setHasApp(res);
}
this.setLoading(false);
} catch (e) {
this.setLoading(false);
Choerodon.handleResponseError(e);
}
},
}));
async loadSingleData(projectId, id) {
const res = await axios.get(`/devops/v1/projects/${projectId}/secret/${id}?to_decode=true`);
if (handlePromptError(res)) {
this.setSingleData(res);
}
return res;
},