Skip to content
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 @@ -3,6 +3,10 @@
"scheduledtasks": {
"label": "Geplante Tasks",
"no_scheduledtasks": "Keine geplanten Aufgaben.",
"custom": {
"title": "Benutzerdefinierte Trigger",
"trigger": "Trigger"
},
"cron": {
"expression": "Expression",
"runnable": "Runnable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"last_execution": "Last Execution",
"last_execution_status": "Last Execution State",
"next_execution": "Next Execution",
"custom": {
"title": "Custom Triggers",
"trigger": "Trigger"
},
"cron": {
"expression": "Expression",
"runnable": "Runnable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"scheduledtasks": {
"label": "Tareas programadas",
"no_scheduledtasks": "No se encontraron tareas programadas.",
"custom": {
"title": "Disparadores personalizados",
"trigger": "Disparador"
},
"cron": {
"expression": "Expresión",
"runnable": "Ejecutable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"scheduledtasks": {
"label": "Tâches programmées",
"no_scheduledtasks": "Aucune tâches présente.",
"custom": {
"title": "Déclencheurs personnalisés",
"trigger": "Déclencheur"
},
"cron": {
"expression": "Expression",
"runnable": "Exécutable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"scheduledtasks": {
"label": "Fastsett verkefni",
"no_scheduledtasks": "Engin fastsett verkefni",
"custom": {
"title": "Sérsniðnir kveikjar",
"trigger": "Kveikja"
},
"cron": {
"expression": "Expression",
"runnable": "Runnable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"scheduledtasks": {
"label": "스케쥴 작업",
"no_scheduledtasks": "스케쥴 작업이 없습니다.",
"custom": {
"title": "사용자 정의 트리거",
"trigger": "트리거"
},
"cron": {
"expression": "표현식",
"runnable": "실행가능",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"scheduledtasks": {
"label": "Tarefas Agendados",
"no_scheduledtasks": "Nenhuma tarefa agendada presente.",
"custom": {
"title": "Gatilhos personalizados",
"trigger": "Gatilho"
},
"cron": {
"expression": "Expressão",
"runnable": "Executável",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"scheduledtasks": {
"label": "Планировщик заданий",
"no_scheduledtasks": "Нет запланированных заданий.",
"custom": {
"title": "Пользовательские триггеры",
"trigger": "Триггер"
},
"cron": {
"expression": "Выражение",
"runnable": "Выполняемый объект",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"scheduledtasks": {
"label": "计划任务",
"no_scheduledtasks": "没有计划任务。",
"custom": {
"title": "自定义触发器",
"trigger": "触发器"
},
"cron": {
"expression": "表达式",
"runnable": "可运行",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"last_execution": "上次執行",
"last_execution_status": "上次執行狀態",
"next_execution": "下次執行",
"custom": {
"title": "自訂觸發器",
"trigger": "觸發器"
},
"cron": {
"expression": "表達式",
"runnable": "可執行項目",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { screen } from '@testing-library/vue';
import { HttpResponse, http } from 'msw';
import { expect, it } from 'vitest';

import ScheduledTasks from './index.vue';

import { applications } from '@/mocks/applications/data';
import { scheduledtasksResponse } from '@/mocks/instance/scheduledtasks/data';
import { server } from '@/mocks/server';
import Application from '@/services/application';
import { render } from '@/test-utils';

it('shows a task registered with a custom trigger when there are no periodic tasks', async () => {
server.use(
http.get('*/actuator/scheduledtasks', () =>
HttpResponse.json({
cron: [],
fixedRate: [],
fixedDelay: [],
custom: [
{
runnable: { target: 'com.example.RefreshCatalog' },
trigger: 'CatalogTrigger',
lastExecution: { status: 'SUCCESS', time: '2025-03-04T10:15:00Z' },
},
],
}),
),
);
render(ScheduledTasks, {
props: { instance: new Application(applications[0]).instances[0] },
});
expect(await screen.findByText('CatalogTrigger')).toBeVisible();
expect(screen.getByTitle('com.example.RefreshCatalog')).toBeVisible();
expect(screen.getByRole('status')).toHaveTextContent('SUCCESS');
expect(
screen.queryByText('instances.scheduledtasks.no_scheduledtasks'),
).not.toBeInTheDocument();
});

it('shows cron and custom triggers together', async () => {
server.use(
http.get('*/actuator/scheduledtasks', () =>
HttpResponse.json(scheduledtasksResponse),
),
);
render(ScheduledTasks, {
props: { instance: new Application(applications[0]).instances[0] },
});
expect(
await screen.findByTitle(scheduledtasksResponse.cron[0].expression),
).toBeVisible();
expect(
screen.getByText(scheduledtasksResponse.custom[0].trigger),
).toBeVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,27 @@
</div>

<div class="flex flex-col">
<template v-if="hasCronData">
<sba-panel :title="$t('instances.scheduledtasks.cron.title')" seamless>
<template v-for="schedule in triggerSchedules" :key="schedule.type">
<sba-panel
:title="$t(`instances.scheduledtasks.${schedule.type}.title`)"
seamless
>
<table class="table w-full table-striped">
<thead>
<tr>
<th v-text="$t('instances.scheduledtasks.cron.runnable')" />
<th v-text="$t('instances.scheduledtasks.cron.expression')" />
<th v-text="$t(schedule.columnLabel)" />
<th v-text="$t('instances.scheduledtasks.next_execution')" />
<th v-text="$t('instances.scheduledtasks.last_execution')" />
<th
v-text="$t('instances.scheduledtasks.last_execution_status')"
/>
</tr>
</thead>
<tbody v-for="task in cron" :key="task.runnable.target">
<tbody
v-for="task in schedule.tasks"
:key="task.runnable.target + (task.expression ?? task.trigger)"
>
<tr>
<td
class="scheduledtasks__target"
Expand All @@ -47,8 +53,12 @@
/>
<td
class="font-mono text-sm"
:title="task.expression"
v-text="formatCron(task.expression)"
:title="task.expression ?? task.trigger"
v-text="
schedule.type === 'cron'
? formatCron(task.expression)
: task.trigger
"
/>
<scheduled-task-executions :task="task" />
</tr>
Expand Down Expand Up @@ -205,12 +215,24 @@ export default {
hasLoaded: false,
error: null,
cron: null,
custom: null,
fixedDelay: null,
fixedRate: null,
}),
computed: {
hasCronData: function () {
return this.cron && this.cron.length;
triggerSchedules() {
return [
{
type: 'cron',
tasks: this.cron,
columnLabel: 'instances.scheduledtasks.cron.expression',
},
{
type: 'custom',
tasks: this.custom,
columnLabel: 'instances.scheduledtasks.custom.trigger',
},
].filter((schedule) => schedule.tasks?.length);
},
hasFixedDelayData: function () {
return this.fixedDelay && this.fixedDelay.length;
Expand All @@ -220,7 +242,9 @@ export default {
},
hasData: function () {
return (
this.hasCronData || this.hasFixedDelayData || this.hasFixedRateData
this.triggerSchedules.length ||
this.hasFixedDelayData ||
this.hasFixedRateData
);
},
},
Expand All @@ -233,6 +257,7 @@ export default {
try {
const res = await this.instance.fetchScheduledTasks();
this.cron = res.data.cron;
this.custom = res.data.custom;
this.fixedDelay = res.data.fixedDelay;
this.fixedRate = res.data.fixedRate;
} catch (error) {
Expand Down
Loading