Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MelsHyrule committed Jan 27, 2023
1 parent 41efa7d commit 1e21e88
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 28 deletions.
20 changes: 4 additions & 16 deletions app/javascript/components/timeline-options/timeline-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ export const timelineUiOptions = (title) => ({
title: __('# of Events'),
mapsTo: 'value',
scaleType: 'linear',
/**
* scaleType: "labels" - will only show the values we have
* (ex. if we have 9 events and 1 event, it will only show 1 and 9 equidistant from eachother)
* scaleType: "linear" - will show all the values including ones
* we dont have but on smaller cases (ie we only have 1 event) it will show decimals
* ^ fun fact the decimals disappear when you have 1 and *5* events, anything lower renders decimals
*/
},
},
legend: {
Expand All @@ -41,10 +34,6 @@ export const timelineUiOptions = (title) => ({
height: '400px',
});

/**
*
*/

const smartAndOrStatements = (group, array) => {
let shortUrl = '';
if (array.length === 1) {
Expand Down Expand Up @@ -76,7 +65,7 @@ export const buildUrl = (values) => {
/** Function to format the raw data such that it can be used by the Timeline Chart component */
export const buildChartDataObject = (rawData) => {
// https://codesandbox.io/s/tender-river-9t3vu5?file=/src/index.js
// Here is a link to how a dataset object should look for a timeline
// Link to how a dataset object should look like
const datasets = [];
rawData.resources.forEach((event) => {
const idx = datasets.findIndex((element) => {
Expand Down Expand Up @@ -105,17 +94,16 @@ export const buildChartDataObject = (rawData) => {
export const buildDataTableObject = (pointChoice) => {
const tableData = [];
pointChoice.eventsObj.forEach((event) => {
// TODO: something about this event host crashes us
const eventHost = (event.host === null) ? '' : event.host.name;
const eventObj = {
event_type: event.event_type,
source: event.source,
group_level: event.group_level,
provider: '', // hyperlink
provider: '', // TODO hyperlink
provider_username: '',
message: '',
host: eventHost, // hyperlink
source_vm: '', // hyperlink
host: eventHost, // TODO hyperlink
source_vm: '', // TODO hyperlink
source_vm_location: '',
timestamp: event.timestamp, // is Zulu time, should copnvert to user's timezone
id: event.id,
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/components/timeline-options/timeline-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const TimelinePage = ({ id }) => {

const submitChosenFormOptions = (formChoices) => {
API.get(buildUrl(formChoices)).then((chartValues) => {
miqSparkleOff(); // Turning off the sparkle caused by the form onSubmit()
miqSparkleOff();
setState((state) => ({
...state,
timelineFormChoices: formChoices,
Expand All @@ -35,7 +35,7 @@ const TimelinePage = ({ id }) => {
}));
};

// TODO: Have it be such that on page load its empty, but after pressing submit it would be NoRecordFound
// TODO: Have it be such that on page initial load it's empty, but after pressing submit it would be NoRecordFound
const timelineComponent = timelineChartData.length === 0 ? <NoRecordsFound />
: <TimelineChart data={timelineChartData} title={__('Timeline Data')} buildTableData={buildTableData} />;

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/oldjs/miq_timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
data[x].display = true;
}
}
var timeSpanMilliseconds = end.getTime() - start.getTime();
const timeSpanMilliseconds = end.getTime() - start.getTime();
timeline = d3.chart.timeline().end(end).start(start)
.minScale(1)
.maxScale(timeSpanMilliseconds / one_hour)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ import TimelineChart from '../../components/timeline-options/timeline-chart';
import { mount } from '../helpers/mountForm';

describe('Show Timeline Chart', () => {

const dummyBuildTableData = (foo) => { }

/*
* Render Page
*/

it('should render empty chart', async(done) => {
let wrapper;
await act(async() => {
Expand All @@ -23,5 +16,4 @@ const dummyBuildTableData = (foo) => { }
done();
});
});

});
1 change: 0 additions & 1 deletion app/views/layouts/_timeline.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
- tl_json ||= nil
= react 'TimelineChart', {:title => "this file can be deleted", :data => tl_json}
:javascript
miqInitTimeline('#{j_str tl_json}');

0 comments on commit 1e21e88

Please sign in to comment.