Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve] sync some minor improvements from dev-2.1.5 #3766

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ public RestResponse cancel(@Parameter(hidden = true) Application app) throws Exc

/** force stop(stop normal start or in progress) */
@PermissionScope(app = "#app.id")
@PostMapping("forcedStop")
@PostMapping("abort")
@RequiresPermissions("app:cancel")
public RestResponse forcedStop(Application app) {
applicationActionService.forcedStop(app.getId());
public RestResponse abort(Application app) {
applicationActionService.abort(app.getId());
return RestResponse.success();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ public interface ApplicationActionService extends IService<Application> {
*
* @param id the application's id which need to be stopped
*/
void forcedStop(Long id);
void abort(Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void restart(Application appParam) throws Exception {
}

@Override
public void forcedStop(Long id) {
public void abort(Long id) {
CompletableFuture<SubmitResponse> startFuture = startFutureMap.remove(id);
CompletableFuture<CancelResponse> cancelFuture = cancelFutureMap.remove(id);
Application application = this.baseMapper.selectApp(id);
Expand All @@ -225,7 +225,7 @@ public void forcedStop(Long id) {
cancelFuture.cancel(true);
}
if (startFuture == null && cancelFuture == null) {
this.doStopped(id);
this.doAbort(id);
}
}

Expand Down Expand Up @@ -308,7 +308,7 @@ public void cancel(Application appParam) throws Exception {

cancelFutureMap.put(application.getId(), cancelFuture);

cancelFuture.whenComplete(
cancelFuture.whenCompleteAsync(
(cancelResponse, throwable) -> {
cancelFutureMap.remove(application.getId());

Expand All @@ -319,7 +319,7 @@ public void cancel(Application appParam) throws Exception {
applicationLogService.save(applicationLog);

if (throwable instanceof CancellationException) {
doStopped(application.getId());
doAbort(application.getId());
} else {
log.error("stop flink job failed.", throwable);
application.setOptionState(OptionStateEnum.NONE.getValue());
Expand Down Expand Up @@ -465,7 +465,7 @@ public void start(Application appParam, boolean auto) throws Exception {

startFutureMap.put(application.getId(), future);

future.whenComplete(
future.whenCompleteAsync(
(response, throwable) -> {
// 1) remove Future
startFutureMap.remove(application.getId());
Expand Down Expand Up @@ -567,7 +567,7 @@ private void processForException(
applicationLog.setSuccess(false);
applicationLogService.save(applicationLog);
if (throwable instanceof CancellationException) {
doStopped(application.getId());
doAbort(application.getId());
} else {
Application app = getById(appParam.getId());
app.setState(FlinkAppStateEnum.FAILED.getValue());
Expand Down Expand Up @@ -782,7 +782,7 @@ private Map<String, Object> getProperties(Application application) {
return properties;
}

private void doStopped(Long id) {
private void doAbort(Long id) {
Application application = getById(id);
application.setOptionState(OptionStateEnum.NONE.getValue());
application.setState(FlinkAppStateEnum.CANCELED.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ enum APP_API {
NAME = '/flink/app/name',
CHECK_NAME = '/flink/app/checkName',
CANCEL = '/flink/app/cancel',
FORCED_STOP = '/flink/app/forcedStop',
ABORT = '/flink/app/abort',
DELETE = '/flink/app/delete',
DELETE_BAK = '/flink/app/deletebak',
CREATE = '/flink/app/create',
Expand Down Expand Up @@ -167,12 +167,12 @@ export function fetchDeleteOperationLog(id: string) {
}

/**
* forced stop
* abort job
* @returns
* @param data
*/
export function fetchForcedStop(data: { id: string }): Promise<boolean> {
return defHttp.post({ url: APP_API.FORCED_STOP, data });
export function fetchAbort(data: { id: string }): Promise<boolean> {
return defHttp.post({ url: APP_API.ABORT, data });
}

export function fetchStart(data): Promise<AxiosResponse<Result>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@
return slot
? getSlot(slots, slot, unref(getValues))
: render
? render(unref(getValues))
: renderComponent();
? render(unref(getValues))
: renderComponent();
};

const showSuffix = !!suffix;
Expand Down Expand Up @@ -382,8 +382,8 @@
return colSlot
? getSlot(slots, colSlot, values)
: renderColContent
? renderColContent(values)
: renderItem();
? renderColContent(values)
: renderItem();
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@
realHeightRef.value = props.height
? props.height
: realHeight > maxHeight
? maxHeight
: realHeight;
? maxHeight
: realHeight;
}
emit('height-change', unref(realHeightRef));
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ export function useMenuSetting() {
return siderHidden
? 0
: collapsedShowTitle
? SIDE_BAR_SHOW_TIT_MINI_WIDTH
: SIDE_BAR_MINI_WIDTH;
? SIDE_BAR_SHOW_TIT_MINI_WIDTH
: SIDE_BAR_MINI_WIDTH;
});

const getCalcContentWidth = computed(() => {
const width =
unref(getIsTopMenu) || !unref(getShowMenu) || (unref(getSplit) && unref(getMenuHidden))
? 0
: unref(getIsMixSidebar)
? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) +
(unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0)
: unref(getRealWidth);
? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) +
(unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0)
: unref(getRealWidth);

return `calc(100% - ${unref(width)}px)`;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default {
savepoint: 'Trigger Savepoint',
detail: 'View Detail',
startLog: 'See Flink Start log',
force: 'Forced Stop Job',
abort: 'Abort Job',
copy: 'Copy Job',
remapping: 'Remapping Job',
deleteTip: 'Are you sure delete this job ?',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default {
savepoint: '触发 Savepoint',
detail: '作业详情',
startLog: '查看 Flink 启动日志',
force: '强制停止作业',
abort: '终止作业',
copy: '复制作业',
remapping: '重新映射作业',
deleteTip: '你确定要删除这个作业?',
Expand Down
51 changes: 26 additions & 25 deletions streampark-console/streampark-console-webapp/src/utils/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ type ResolveProp<T> = ExtractPropTypes<{
key: { type: T; required: true };
}>['key'];
type ResolvePropType<T> = ResolveProp<T> extends { type: infer V } ? V : ResolveProp<T>;
type ResolvePropTypeWithReadonly<T> =
Readonly<T> extends Readonly<Array<infer A>> ? ResolvePropType<A[]> : ResolvePropType<T>;
type ResolvePropTypeWithReadonly<T> = Readonly<T> extends Readonly<Array<infer A>>
? ResolvePropType<A[]>
: ResolvePropType<T>;

type IfUnknown<T, V> = [unknown] extends [T] ? V : T;

Expand All @@ -27,17 +28,17 @@ export type BuildPropOption<T, D extends BuildPropType<T, V, C>, R, V, C> = {
default?: R extends true
? never
: D extends Record<string, unknown> | Array<any>
? () => D
: (() => D) | D;
? () => D
: (() => D) | D;
validator?: ((val: any) => val is C) | ((val: any) => boolean);
};

type _BuildPropType<T, V, C> =
| (T extends PropWrapper<unknown>
? T[typeof wrapperKey]
: [V] extends [never]
? ResolvePropTypeWithReadonly<T>
: never)
? ResolvePropTypeWithReadonly<T>
: never)
| V
| C;
export type BuildPropType<T, V, C> = _BuildPropType<
Expand All @@ -52,8 +53,8 @@ type _BuildPropDefault<T, D> = [T] extends [
]
? D
: D extends () => T
? ReturnType<D>
: D;
? ReturnType<D>
: D;

export type BuildPropDefault<T, D, R> = R extends true
? { readonly default?: undefined }
Expand Down Expand Up @@ -145,12 +146,12 @@ export const buildProps = <
[K in keyof O]: O[K] extends BuildPropReturn<any, any, any, any, any>
? O[K]
: [O[K]] extends NativePropType
? O[K]
: O[K] extends BuildPropOption<infer T, infer D, infer R, infer V, infer C>
? D extends BuildPropType<T, V, C>
? BuildPropOption<T, D, R, V, C>
: never
: never;
? O[K]
: O[K] extends BuildPropOption<infer T, infer D, infer R, infer V, infer C>
? D extends BuildPropType<T, V, C>
? BuildPropOption<T, D, R, V, C>
: never
: never;
},
>(
props: O,
Expand All @@ -161,17 +162,17 @@ export const buildProps = <
[K in keyof O]: O[K] extends { [propKey]: boolean }
? O[K]
: [O[K]] extends NativePropType
? O[K]
: O[K] extends BuildPropOption<
infer T,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
infer _D,
infer R,
infer V,
infer C
>
? BuildPropReturn<T, O[K]['default'], R, V, C>
: never;
? O[K]
: O[K] extends BuildPropOption<
infer T,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
infer _D,
infer R,
infer V,
infer C
>
? BuildPropReturn<T, O[K]['default'], R, V, C>
: never;
};

export const definePropType = <T>(val: any) => ({ [wrapperKey]: val }) as PropWrapper<T>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export function getColumns(): BasicColumn[] {
text === ErrorTypeEnum.VUE
? 'green'
: text === ErrorTypeEnum.RESOURCE
? 'cyan'
: text === ErrorTypeEnum.PROMISE
? 'blue'
: ErrorTypeEnum.AJAX
? 'red'
: 'purple';
? 'cyan'
: text === ErrorTypeEnum.PROMISE
? 'blue'
: ErrorTypeEnum.AJAX
? 'red'
: 'purple';
return <Tag color={color}>{() => text}</Tag>;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import { useGo } from '/@/hooks/web/usePage';
import ProgramArgs from './components/ProgramArgs.vue';
import VariableReview from './components/VariableReview.vue';
import { ClusterStateEnum, ExecModeEnum, JobTypeEnum, UseStrategyEnum } from '/@/enums/flinkEnum';
import { ExecModeEnum, JobTypeEnum, UseStrategyEnum } from '/@/enums/flinkEnum';

const route = useRoute();
const go = useGo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { useRouter } from 'vue-router';
import { fetchCheckStart, fetchForcedStop, fetchStart } from '/@/api/flink/app';
import { fetchCheckStart, fetchAbort, fetchStart } from '/@/api/flink/app';
import { AppExistsEnum } from '/@/enums/flinkEnum';

const SelectOption = Select.Option;
Expand Down Expand Up @@ -116,7 +116,7 @@
id: receiveData.application.id,
});
if (resp.data.data === AppExistsEnum.IN_YARN) {
await fetchForcedStop({
await fetchAbort({
id: receiveData.application.id,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { Alert, Form, Input, Tag } from 'ant-design-vue';
import { h, onMounted, reactive, ref, unref, VNode } from 'vue';
import { handleAppBuildStatueText } from '../utils';
import { fetchCheckName, fetchCopy, fetchForcedStop, fetchMapping } from '/@/api/flink/app';
import { fetchCheckName, fetchCopy, fetchAbort, fetchMapping } from '/@/api/flink/app';
import { fetchBuild, fetchBuildDetail } from '/@/api/flink/flinkBuild';
import { fetchSavePonitHistory } from '/@/api/flink/savepoint';
import { fetchAppOwners } from '/@/api/system/user';
Expand Down Expand Up @@ -168,7 +168,7 @@ export const useFlinkApplication = (openStartModal: Fn) => {
}
return false;
}
function handleForcedStop(app: Recordable) {
function handleAbort(app: Recordable) {
let option = 'starting';
const optionState = app['optionState'];
const stateMap = {
Expand All @@ -189,21 +189,21 @@ export const useFlinkApplication = (openStartModal: Fn) => {
}
Swal.fire({
title: 'Are you sure?',
text: `current job is ${option}, are you sure forced stop?`,
text: `current job is ${option}, are you sure abort the job?`,
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, forced stop!',
confirmButtonText: 'Yes, abort job!',
denyButtonText: `No, cancel`,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
}).then(async (result) => {
if (result.isConfirmed) {
Swal.fire('forced stopping', '', 'success');
const res = await fetchForcedStop({
Swal.fire('abort job', '', 'success');
const res = await fetchAbort({
id: app.id,
});
if (res) {
createMessage.success('forced stopping');
createMessage.success('abort job starting');
}
return Promise.resolve();
}
Expand Down Expand Up @@ -383,7 +383,7 @@ export const useFlinkApplication = (openStartModal: Fn) => {
handleCheckReleaseApp,
handleAppCheckStart,
handleCanStop,
handleForcedStop,
handleAbort,
handleCopy,
handleMapping,
users,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const useAppTableAction = (
handleCheckReleaseApp,
handleAppCheckStart,
handleCanStop,
handleForcedStop,
handleAbort,
handleCopy,
handleMapping,
users,
Expand Down Expand Up @@ -130,11 +130,11 @@ export const useAppTableAction = (
onClick: handleSavepoint.bind(null, record),
},
{
tooltip: { title: t('flink.app.operation.force') },
tooltip: { title: t('flink.app.operation.abort') },
ifShow: handleCanStop(record),
auth: 'app:cancel',
icon: 'ant-design:pause-circle-outlined',
onClick: handleForcedStop.bind(null, record),
onClick: handleAbort.bind(null, record),
},
{
label: t('flink.app.operation.copy'),
Expand Down
Loading
Loading