Skip to content

Commit

Permalink
Update UI for Notifications Integration (opensearch-project#126)
Browse files Browse the repository at this point in the history
Update reporting front-end for Notifications integration

Signed-off-by: David Cui <davidcui@amazon.com>
  • Loading branch information
davidcui1225 committed Jul 19, 2021
1 parent 8dece9c commit df1fbbe
Show file tree
Hide file tree
Showing 31 changed files with 2,306 additions and 3,101 deletions.
23 changes: 19 additions & 4 deletions .cypress/integration/02-edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ describe('Cypress', () => {
cy.get('#reportSettingsDescription').type(' update description');

cy.get('#editReportDefinitionButton').click({ force: true });

cy.wait(12500);

// check that re-direct to home page
cy.get('#reportDefinitionDetailsLink').should('exist');
});

it('Visit edit page, change report source and trigger', () => {
it('Visit edit page, change report trigger', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
Expand All @@ -71,13 +76,18 @@ describe('Cypress', () => {
cy.url().should('include', 'edit');

cy.wait(1000);
cy.get('#visualizationReportSource').check({ force: true });
cy.get('#reportDefinitionTriggerTypes > div:nth-child(2)').click({ force: true });

cy.get('#Schedule').check({ force: true });
cy.get('#editReportDefinitionButton').click({ force: true });

cy.wait(12500);

// check that re-direct to home page
cy.get('#reportDefinitionDetailsLink').should('exist');
});

it('Visit edit page, change report source back', () => {
it('Visit edit page, change report trigger back', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/reports-dashboards#/`);
cy.location('pathname', { timeout: 60000 }).should(
'include',
Expand All @@ -96,8 +106,13 @@ describe('Cypress', () => {

cy.wait(1000);

cy.get('#dashboardReportSource').check({ force: true });
cy.get('#reportDefinitionTriggerTypes > div:nth-child(1)').click({ force: true });

cy.get('#editReportDefinitionButton').click({ force: true });

cy.wait(12500);

// check that re-direct to home page
cy.get('#reportDefinitionDetailsLink').should('exist');
});
});
29 changes: 23 additions & 6 deletions public/components/main/main_utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,31 @@
import 'babel-polyfill';
import { i18n } from '@osd/i18n';
import { HttpFetchOptions, HttpSetup } from '../../../../../src/core/public';
import { placeholderChannels } from '../report_definitions/delivery/delivery_constants';

export const fileFormatsUpper = {
export const displayDeliveryChannels = (configIds: Array<string>) => {
let displayChannels = [];
for (let i = 0; i < configIds.length; ++i) {
for (let j = 0; j < placeholderChannels.length; ++j) {
if (configIds[i] === placeholderChannels[j].id) {
displayChannels.push(placeholderChannels[i].label);
}
}
}
return displayChannels.toString();
}

type fileFormatsOptions = {
[key: string]: string
}

export const fileFormatsUpper: fileFormatsOptions = {
csv: 'CSV',
pdf: 'PDF',
png: 'PNG',
};

export const humanReadableDate = (date) => {
export const humanReadableDate = (date: string | number | Date) => {
let readableDate = new Date(date);
return (
readableDate.toDateString() + ' @ ' + readableDate.toLocaleTimeString()
Expand All @@ -55,7 +72,7 @@ export const getFileFormatPrefix = (fileFormat: string) => {
return fileFormatPrefix;
};

export const addReportsTableContent = (data) => {
export const addReportsTableContent = (data: string | any[]) => {
let reportsTableItems = [];
for (let index = 0; index < data.length; ++index) {
let item = data[index];
Expand Down Expand Up @@ -110,7 +127,7 @@ export const addReportDefinitionsTableContent = (data: any) => {
return reportDefinitionsTableItems;
};

export const removeDuplicatePdfFileFormat = (filename) => {
export const removeDuplicatePdfFileFormat = (filename: string) => {
return filename.substring(0, filename.length - 4);
};

Expand Down Expand Up @@ -153,7 +170,7 @@ export const readStreamToFile = async (
};

export const generateReportFromDefinitionId = async (
reportDefinitionId,
reportDefinitionId: string,
httpClient: HttpSetup
) => {
let status = false;
Expand Down Expand Up @@ -188,7 +205,7 @@ export const generateReportFromDefinitionId = async (
};

export const generateReportById = async (
reportId,
reportId: string,
httpClient: HttpSetup,
handleSuccessToast,
handleErrorToast,
Expand Down
Loading

0 comments on commit df1fbbe

Please sign in to comment.