mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
fix(alerts/reports): modal submit button, copy changes, select apis (#12110)
This commit is contained in:
parent
6e7f276775
commit
ddd2ec59af
@ -101,6 +101,7 @@ const RETENTION_OPTIONS = [
|
|||||||
|
|
||||||
const DEFAULT_RETENTION = 90;
|
const DEFAULT_RETENTION = 90;
|
||||||
const DEFAULT_WORKING_TIMEOUT = 3600;
|
const DEFAULT_WORKING_TIMEOUT = 3600;
|
||||||
|
const DEFAULT_CRON_VALUE = '* * * * *'; // every minute
|
||||||
|
|
||||||
const StyledIcon = styled(Icon)`
|
const StyledIcon = styled(Icon)`
|
||||||
margin: auto ${({ theme }) => theme.gridUnit * 2}px auto 0;
|
margin: auto ${({ theme }) => theme.gridUnit * 2}px auto 0;
|
||||||
@ -612,7 +613,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||||||
const loadOwnerOptions = (input = '') => {
|
const loadOwnerOptions = (input = '') => {
|
||||||
const query = rison.encode({ filter: input });
|
const query = rison.encode({ filter: input });
|
||||||
return SupersetClient.get({
|
return SupersetClient.get({
|
||||||
endpoint: `/api/v1/dashboard/related/owners?q=${query}`,
|
endpoint: `/api/v1/report/related/owners?q=${query}`,
|
||||||
}).then(
|
}).then(
|
||||||
response => {
|
response => {
|
||||||
return response.json.result.map((item: any) => ({
|
return response.json.result.map((item: any) => ({
|
||||||
@ -629,7 +630,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||||||
const loadSourceOptions = (input = '') => {
|
const loadSourceOptions = (input = '') => {
|
||||||
const query = rison.encode({ filter: input });
|
const query = rison.encode({ filter: input });
|
||||||
return SupersetClient.get({
|
return SupersetClient.get({
|
||||||
endpoint: `/api/v1/dataset/related/database?q=${query}`,
|
endpoint: `/api/v1/report/related/database?q=${query}`,
|
||||||
}).then(
|
}).then(
|
||||||
response => {
|
response => {
|
||||||
const list = response.json.result.map((item: any) => ({
|
const list = response.json.result.map((item: any) => ({
|
||||||
@ -678,12 +679,12 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||||||
const loadDashboardOptions = (input = '') => {
|
const loadDashboardOptions = (input = '') => {
|
||||||
const query = rison.encode({ filter: input });
|
const query = rison.encode({ filter: input });
|
||||||
return SupersetClient.get({
|
return SupersetClient.get({
|
||||||
endpoint: `/api/v1/dashboard?q=${query}`,
|
endpoint: `/api/v1/report/related/dashboard?q=${query}`,
|
||||||
}).then(
|
}).then(
|
||||||
response => {
|
response => {
|
||||||
const list = response.json.result.map((item: any) => ({
|
const list = response.json.result.map((item: any) => ({
|
||||||
value: item.id,
|
value: item.value,
|
||||||
label: item.dashboard_title,
|
label: item.text,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setDashboardOptions(list);
|
setDashboardOptions(list);
|
||||||
@ -727,12 +728,12 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||||||
const loadChartOptions = (input = '') => {
|
const loadChartOptions = (input = '') => {
|
||||||
const query = rison.encode({ filter: input });
|
const query = rison.encode({ filter: input });
|
||||||
return SupersetClient.get({
|
return SupersetClient.get({
|
||||||
endpoint: `/api/v1/chart?q=${query}`,
|
endpoint: `/api/v1/report/related/chart?q=${query}`,
|
||||||
}).then(
|
}).then(
|
||||||
response => {
|
response => {
|
||||||
const list = response.json.result.map((item: any) => ({
|
const list = response.json.result.map((item: any) => ({
|
||||||
value: item.id,
|
value: item.value,
|
||||||
label: item.slice_name,
|
label: item.text,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setChartOptions(list);
|
setChartOptions(list);
|
||||||
@ -771,12 +772,10 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||||||
|
|
||||||
// Updating alert/report state
|
// Updating alert/report state
|
||||||
const updateAlertState = (name: string, value: any) => {
|
const updateAlertState = (name: string, value: any) => {
|
||||||
const data = {
|
setCurrentAlert(currentAlertData => ({
|
||||||
...currentAlert,
|
...currentAlertData,
|
||||||
[name]: value,
|
[name]: value,
|
||||||
};
|
}));
|
||||||
|
|
||||||
setCurrentAlert(data);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle input/textarea updates
|
// Handle input/textarea updates
|
||||||
@ -960,7 +959,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||||||
) {
|
) {
|
||||||
setCurrentAlert({
|
setCurrentAlert({
|
||||||
active: true,
|
active: true,
|
||||||
crontab: '',
|
crontab: DEFAULT_CRON_VALUE,
|
||||||
log_retention: DEFAULT_RETENTION,
|
log_retention: DEFAULT_RETENTION,
|
||||||
working_timeout: DEFAULT_WORKING_TIMEOUT,
|
working_timeout: DEFAULT_WORKING_TIMEOUT,
|
||||||
name: '',
|
name: '',
|
||||||
@ -1047,7 +1046,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||||||
<div className="header-section">
|
<div className="header-section">
|
||||||
<StyledInputContainer>
|
<StyledInputContainer>
|
||||||
<div className="control-label">
|
<div className="control-label">
|
||||||
{t('Alert Name')}
|
{isReport ? t('Report Name') : t('Alert Name')}
|
||||||
<span className="required">*</span>
|
<span className="required">*</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="input-container">
|
<div className="input-container">
|
||||||
@ -1055,7 +1054,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||||||
type="text"
|
type="text"
|
||||||
name="name"
|
name="name"
|
||||||
value={currentAlert ? currentAlert.name : ''}
|
value={currentAlert ? currentAlert.name : ''}
|
||||||
placeholder={t('Alert Name')}
|
placeholder={isReport ? t('Report Name') : t('Alert Name')}
|
||||||
onChange={onTextChange}
|
onChange={onTextChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -1189,10 +1188,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||||||
)}
|
)}
|
||||||
<div className="column schedule">
|
<div className="column schedule">
|
||||||
<StyledSectionTitle>
|
<StyledSectionTitle>
|
||||||
<h4>{t('Alert Condition Schedule')}</h4>
|
<h4>
|
||||||
|
{isReport
|
||||||
|
? t('Report Schedule')
|
||||||
|
: t('Alert Condition Schedule')}
|
||||||
|
</h4>
|
||||||
</StyledSectionTitle>
|
</StyledSectionTitle>
|
||||||
<AlertReportCronScheduler
|
<AlertReportCronScheduler
|
||||||
value={(currentAlert && currentAlert.crontab) || undefined}
|
value={
|
||||||
|
(currentAlert && currentAlert.crontab) || DEFAULT_CRON_VALUE
|
||||||
|
}
|
||||||
onChange={newVal => updateAlertState('crontab', newVal)}
|
onChange={newVal => updateAlertState('crontab', newVal)}
|
||||||
/>
|
/>
|
||||||
<StyledSectionTitle>
|
<StyledSectionTitle>
|
||||||
|
@ -25,12 +25,12 @@ import { CronPicker, CronError } from 'src/common/components/CronPicker';
|
|||||||
import { StyledInputContainer } from '../AlertReportModal';
|
import { StyledInputContainer } from '../AlertReportModal';
|
||||||
|
|
||||||
interface AlertReportCronSchedulerProps {
|
interface AlertReportCronSchedulerProps {
|
||||||
value?: string;
|
value: string;
|
||||||
onChange: (change: string) => any;
|
onChange: (change: string) => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AlertReportCronScheduler: FunctionComponent<AlertReportCronSchedulerProps> = ({
|
export const AlertReportCronScheduler: FunctionComponent<AlertReportCronSchedulerProps> = ({
|
||||||
value = '* * * * *',
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
@ -161,7 +161,7 @@ class ReportScheduleRestApi(BaseSupersetModelRestApi):
|
|||||||
]
|
]
|
||||||
search_columns = ["name", "active", "created_by", "type", "last_state"]
|
search_columns = ["name", "active", "created_by", "type", "last_state"]
|
||||||
search_filters = {"name": [ReportScheduleAllTextFilter]}
|
search_filters = {"name": [ReportScheduleAllTextFilter]}
|
||||||
allowed_rel_fields = {"owners", "chart", "dashboard", "database"}
|
allowed_rel_fields = {"owners", "chart", "dashboard", "database", "created_by"}
|
||||||
filter_rel_fields = {
|
filter_rel_fields = {
|
||||||
"chart": [["id", ChartFilter, lambda: []]],
|
"chart": [["id", ChartFilter, lambda: []]],
|
||||||
"dashboard": [["id", DashboardFilter, lambda: []]],
|
"dashboard": [["id", DashboardFilter, lambda: []]],
|
||||||
|
Loading…
Reference in New Issue
Block a user