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

fixes #3

Merged
merged 1 commit into from
Oct 18, 2022
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 @@ -64,7 +64,8 @@ export interface SavedObjectReference {
export interface PointInTime {
name: string,
keepAlive: string,
id: string
id: string,
title: string
}
export async function getIndexPatterns(savedObjectsClient) {
return (
Expand Down Expand Up @@ -131,6 +132,7 @@ export async function findByTitle(client, title: string) {

interface Props extends RouteComponentProps {
setIsFlyoutVisible: (isFlyoutVisible: boolean) => void;
isFlyoutVisible: boolean;
}
export const PointInTimeFlyout = (props:Props) => {

Expand Down Expand Up @@ -192,6 +194,7 @@ export const PointInTimeFlyout = (props:Props) => {
const response = await http.post(`${CREATE_POINT_IN_TIME_PATH}/${index}`);
const pit:PointInTime = {
name: pitName,
title: pitName,
keepAlive: keepAlive,
id: response.pit_id // Todo create pit and fill the pit id
}
Expand Down Expand Up @@ -229,7 +232,7 @@ export const PointInTimeFlyout = (props:Props) => {
pointintime.id = response.id;
setLoading(false);
setIsFlyoutVisible(false);
props.setIsFlyoutVisible(true);
props.setIsFlyoutVisible(!props.isFlyoutVisible);
return pointintime;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
} from '../../../../src/plugins/opensearch_dashboards_react/public';
import { PointInTimeFlyout } from '../point_in_time_flyout';
import { IndexPatternManagmentContext } from '../point_in_time_flyout/point_in_time_flyout';
import moment from 'moment';


const pagination = {
Expand Down Expand Up @@ -132,15 +133,17 @@ export async function getPits(savedObjects) {
const name = pattern.get('name');
const keepAlive = pattern.get('keepAlive');
const source = pattern.references[0].name;
const creation = pattern.updated_at;
const creation = moment(pattern.updated_at).format("YYYYMMDD HH:mm:ss");
var date1 = new Date();
var date2 = new Date(creation);
var diff = new Date(date2.getTime() - date1.getTime());
var date2 = new Date(pattern.updated_at);
var diff = new Date(date1.getTime() - date2.getTime());
console.log(diff);
var years = diff.getUTCFullYear() - 1970; // Gives difference as year
var months = diff.getUTCMonth(); // Gives month count of difference
var days = diff.getUTCDate()-1; // Gives day count of difference
const expiration = diff.getUTCHours();
let expiration = "0";
if(keepAlive < diff.getUTCHours() + 1)
expiration = "Expired";
else
expiration = (24 - (diff.getUTCHours() + 1)).toString();

return {
id,
title: name,
Expand Down Expand Up @@ -412,7 +415,7 @@ export const PointInTimeTable = ({ canSave, history }: Props) => {
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<PointInTimeFlyout setIsFlyoutVisible={setIsFlyoutVisible}/>
<PointInTimeFlyout setIsFlyoutVisible={setIsFlyoutVisible} isFlyoutVisible={isFlyoutVisible}/>
</EuiFlexItem>

</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const pointInTime: SavedObjectsType = {
defaultSearchField: 'title',
importableAndExportable: true,
getTitle(obj) {
return obj.attributes.title;
return obj.attributes.name;
},
// getEditUrl(obj) {
// return `/management/opensearch-dashboards/dataSources/${encodeURIComponent(obj.id)}`;
Expand Down