Skip to content

Commit

Permalink
fix: fix controlhub/cronjobs operations
Browse files Browse the repository at this point in the history
  • Loading branch information
yongheng2016 committed Jul 30, 2024
1 parent ccc1781 commit 5963744
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 15 deletions.
Binary file modified apps/adminConsole/fonttools/MaterialSymbolsRounded3.woff2
Binary file not shown.
2 changes: 2 additions & 0 deletions apps/adminConsole/fonttools/unicodes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ efad
e89d
f569
e034
e1a2
e694
e037
e1c4
f1c5
e8ad
e645
Expand Down
Binary file modified apps/adminConsole/src/assets/fonts/MaterialSymbolsRounded3.woff2
Binary file not shown.
70 changes: 58 additions & 12 deletions apps/adminConsole/src/pages/Jobs/CronJobsDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
{{ $t(props.value) }}
</q-td>
</template>
<template v-slot:body-cell-uid="props">
<q-td :props="props" class="row items-center justify-center">
<QButtonStyle>
<q-btn
flat
dense
icon="sym_r_reopen_window"
@click="returnHandler(props.row)"
/>
</QButtonStyle>
</q-td>
</template>
<template #no-data>
<div class="row justify-center full-width q-mt-lg">
<Empty v-show="!tableLoading" @click="fetchRecords"></Empty>
Expand All @@ -52,11 +64,11 @@

<Yaml2
ref="yamlRef"
:apiVersion="apiVersion"
:apiVersion="apiVersion.replace('apis/', '')"
:name="detail.name"
:namespace="detail.namespace"
:originData="detail._originData"
readonly
:module="module"
@hide="hideHandler"
@change="fetchData"
>
Expand Down Expand Up @@ -84,7 +96,8 @@ import {
getJobEvent,
fetchListByK8s,
jobRerun,
deleteJob
deleteJob,
toggleJob
} from 'src/network';
import { API_VERSIONS, MODULE_KIND_MAP } from 'src/utils/constants';
import { useRoute, useRouter } from 'vue-router';
Expand All @@ -106,6 +119,7 @@ import { useI18n } from 'vue-i18n';
import { getJobStatus } from 'src/utils/status';
import MyLoading2 from '@packages/ui/src/components/MyLoading2.vue';
import Empty from '@packages/ui/src/components/Empty.vue';
import QButtonStyle from '@packages/ui/src/components/QButtonStyle.vue';
const $q = useQuasar();
const { t } = useI18n();
Expand All @@ -123,19 +137,19 @@ const tableList = ref([]);
const deleteDialogRef = ref();
const deleteLoading = ref(false);
const tableLoading = ref(false);
const options = [
const options = computed(() => [
{
label: t('RERUN'),
value: 'refresh',
icon: 'sym_r_refresh',
label: detail.value.suspend ? t('START') : t('PAUSE'),
value: 'pause',
icon: detail.value.suspend ? 'sym_r_play_circle' : 'sym_r_pause_circle',
onClick: () => {
rerunHanlder();
}
},
{
label: t('VIEW_YAML'),
label: t('EDIT_YAML'),
value: 'edit',
icon: 'sym_r_preview',
icon: 'sym_r_edit',
onClick: () => {
yamlRef.value.show();
}
Expand All @@ -148,7 +162,7 @@ const options = [
deleteDialogRef.value && deleteDialogRef.value.show();
}
}
];
]);
const metadata = computed(() => get(detail.value, '_originData.metadata', {}));
Expand Down Expand Up @@ -191,6 +205,11 @@ const columns = [
field: (row) =>
getLocalTime(row.status.completionTime).format('YYYY-MM-DD HH:mm:ss'),
align: 'left'
},
{
label: t('OPERATIONS'),
name: 'uid',
align: 'center'
}
];
const getAttrs = () => {
Expand Down Expand Up @@ -366,13 +385,40 @@ const rerunHanlder = async () => {
params
);
const resourceVersion = get(data, 'metadata.resourceVersion');
await jobRerun(resourceVersion, { name, namespace });
const params2 = { spec: { suspend: !detail.value.suspend } };
await toggleJob({ apiVersion, name, namespace }, params2);
fetchData();
} catch (error) {}
loading.value = false;
};
const returnHandler = async (row) => {
console.log('row', row);
// jobRerun()
const { namespace, name }: Record<string, any> = row;
const params = {};
const module = 'jobs';
const apiVersion = API_VERSIONS[module];
loading.value = true;
try {
const { data } = await getCornJobsDetail(
apiVersion,
namespace,
module,
name,
params
);
const resourceVersion = get(data, 'metadata.resourceVersion');
await jobRerun(resourceVersion, { name, namespace });
fetchData();
} catch (error) {
loading.value = false;
}
};
watch(
() => route.params.name,
() => {
Expand Down
4 changes: 3 additions & 1 deletion apps/adminConsole/src/pages/NamespacePods/Yaml2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ const update = async (
) => {
try {
loading2.value = true;
const { module } = route.params as Record<string, string>;
const { module: paramModule } = route.params as Record<string, string>;
const { module: metaModule } = route.meta as Record<string, string>;
const module = paramModule || metaModule;
const { data: result } = await getCustomresourceItem(
props.apiVersion,
props.namespace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ const onRequest = (props) => {
pagination.value = {
...pagination.value,
page,
rowsPerPage,
rowsPerPage: rowsPerPage || undefined,
sortBy,
descending
};
Expand Down
5 changes: 4 additions & 1 deletion apps/adminConsole/src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ const routes: RouteRecordRaw[] = [
},
{
path: '/jobs/cronjob/:namespace/:name/:jobUid',
component: () => import('src/pages/Jobs/CronJobsDetails.vue')
component: () => import('src/pages/Jobs/CronJobsDetails.vue'),
meta: {
module: 'cronjobs'
}
},
{
path: '/jobs/workloads/:kind/:namespace/:name/container/:container',
Expand Down
16 changes: 16 additions & 0 deletions apps/common/src/network/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,3 +890,19 @@ export const getWorkloadsPods = (
}
);
};

export const toggleJob = (
urlParams: PodMonitoringParamAll & { apiVersion: string },
params: any
): Promise<AxiosResponse<CustomresourcesResponse>> => {
const { apiVersion, name, cluster, namespace } = urlParams;

return api.patch(
`${apiVersion}${getPath({
cluster,
namespace
})}/cronjobs/${name}`,
params,
{ headers: { 'Content-Type': 'application/merge-patch+json' } }
);
};

0 comments on commit 5963744

Please sign in to comment.