Skip to content

Commit

Permalink
Cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
MelsHyrule committed Oct 26, 2022
1 parent 007ee0a commit d8dacc1
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 193 deletions.
6 changes: 0 additions & 6 deletions app/controllers/application_controller/timelines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ module ApplicationController::Timelines

# Process changes to timeline selection
def tl_chooser
require 'byebug'
# byebug
@record = identify_tl_or_perf_record
@tl_record = @record # Use related server vm record
tl_build_timeline
@tl_options.date.update_from_params(params)
p "mels geting params"
p params
## #<ActionController::Parameters {"tl_show"=>"timeline", "tl_categories"=>["Configuration/Reconfiguration", "Console Activity", "Creation/Addition", "Deletion/Removal", "Devices", "Firmware", "General Activity", "Import/Export", "Login", "Migration/Vmotion", "Network", "Power Activity", "Security", "Snapshot Activity", "Status", "Storage", "Update"], "tl_timerange"=>"months", "tl_timepivot"=>"centered", "tl_result"=>"success", "tl_range_count"=>"2", "tl_date"=>"Sun Oct 02 2022 00:00:00 GMT-0400 (Eastern Daylight Time)", "tl_levels"=>["critical", "detail", "warning"], "tl_typ"=>"Daily", "tl_days"=>"60", "miq_date"=>"11/01/2022", "controller"=>"host", "action"=>"tl_chooser", "id"=>"9"} permitted: false>

if @tl_options.management_events?
@tl_options.management.update_from_params(params)
Expand Down Expand Up @@ -182,7 +177,6 @@ def tl_gen_timeline_data(refresh = nil)
else
@report.extras[:browser_name] = browser_info(:name)
@tl_json = @report.to_timeline
#
# START of TIMELINE TIMEZONE Code
session[:tl_position] = @report.extras[:tl_position]
# session[:tl_position] = format_timezone(@report.extras[:tl_position],Time.zone,"tl")
Expand Down
17 changes: 0 additions & 17 deletions app/controllers/application_controller/timelines/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,17 @@ def update_start_end(sdate, edate)
def update_from_params(params)
self.levels = params[:tl_levels]&.map(&:to_sym) || group_levels
self.categories = {}
require 'byebug'
p "mels v1"
params.fetch(:tl_categories, []).each do |category_display_name|
# category_display_name.to_sym
next if category_display_name == "Other"
group_data = event_groups[events[category_display_name]]

if group_data === nil
p "mels inside the group data nil check"
p category_display_name # in the "Other" case
p events[category_display_name] # this and the below are nil
p event_groups[events[category_display_name]]
end

category = {
:display_name => category_display_name,
:include_set => [],
:exclude_set => [],
:regexes => []
}

# byebug

group_levels.each do |lvl|
p "mels hyrule group_data[lvl]"
p group_data # there is a case wehre group data turns up nil
p lvl
next unless group_data[lvl]

strings, regexes = group_data[lvl].partition { |typ| typ.kind_of?(String) }
Expand All @@ -72,7 +56,6 @@ def update_from_params(params)
end
next if category[:include_set].empty? && category[:regexes].empty?

# category_display_name.to_sym
categories[events[category_display_name]] = category
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/components/timeline-options/helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// File can be safely deleted but ill leave it here for now, for good luck

export const tempData = { // 1 week
"tl_show": "timeline",
"tl_categories": [
Expand Down
74 changes: 6 additions & 68 deletions app/javascript/components/timeline-options/timeline-options.jsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,9 @@
import React, { useState, useEffect } from 'react';
import MiqFormRenderer from '@@ddf';
import createSchemaSimple from './timeline-options-simple.schema';
import miqRedirectBack from '../../helpers/miq-redirect-back';
import mapper from '../../forms/mappers/componentMapper';
import { tableData, buildUr, tempData } from './helper';
import MiqDataTable from '../miq-data-table';
import NoRecordsFound from '../no-records-found';

// const tempData1 = { // 1 week
// "tl_show": "timeline",
// "tl_categories": [
// "Configuration/Reconfiguration",
// "Console Activity",
// "Creation/Addition",
// "Deletion/Removal",
// "Devices",
// "Firmware",
// "General Activity",
// "Import/Export",
// "Login",
// "Migration/Vmotion",
// "Network",
// "Power Activity",
// "Security",
// "Snapshot Activity",
// "Status",
// "Storage",
// "Update"
// ],
// "tl_timerange": "weeks",
// "tl_timepivot": "ending",
// "tl_result": "success", // set by thing not actually ever updated
// "tl_range_count": 1,
// "tl_date": "2022-10-18T04:00:00.000Z", //chosen date
// "tl_levels": [
// "critical",
// "detail",
// "warning"
// ],
// "tl_typ": "Daily",
// "tl_days": 7,
// "miq_date": "10/18/2022"
// }

const TimelineOptions = ({ url, recordId }) => {
const TimelineOptions = ({ url }) => {
const [{
isLoading, timelineEvents, managementGroupNames, managementGroupLevels, policyGroupNames, policyGroupLevels, tableContent,
}, setState] = useState({
Expand Down Expand Up @@ -82,7 +42,7 @@ const TimelineOptions = ({ url, recordId }) => {
policyGroupLevels.push({ label: value, value: key });
});

// TODO: is there a way to make the above more elegant/shorter
// TODO: is there a way to make the above more elegant/shorter?
setState((state) => ({
...state,
isLoading: false,
Expand All @@ -101,18 +61,14 @@ const TimelineOptions = ({ url, recordId }) => {
let show = values.timelineEvents === 'EmsEvent' ? "timeline" : "policy_timeline"
let categories = values.timelineEvents === 'EmsEvent' ? values.managementGroupNames : values.policyGroupNames
let result = values.timelineEvents === 'EmsEvent' ? values.managementGroupLevels : values.policyGroupLevels

// detemining what we need by looking at /app/controllers/application_controller/timelines/options.rb
let vmData = { // 1 week
"tl_show": show, // i think its "timeline" or "policy_timeline"
"tl_categories": categories, // we're gonna test passing in the lable not the id for now
let vmData = {
"tl_show": show,
"tl_categories": categories,
"tl_levels": result,
"tl_result": "success", // set by thing not actually ever updated i think, also defaults to success
"tl_result": "success",
}

window.ManageIQ.calendar.calDateFrom = values.startDate
window.ManageIQ.calendar.calDateTo = values.endDate

window.miqJqueryRequest(url, {beforeSend: true, data: vmData});
};

Expand All @@ -123,22 +79,6 @@ const TimelineOptions = ({ url, recordId }) => {
}));
};

const exitPage = () => {
miqSparkleOn();
const returnURL = '/vm_infra/explorer/';
const message = sprintf(__('Returned to previous page'));
// miqRedirectBack(message, 'warning', returnURL); // esot explota fix it
};

const miqTableContent = tableContent.rows.length > 0 ? (
<MiqDataTable
rows={tableContent.rows}
headers={tableContent.headers}
onCellClick={() => {}}
mode="db-list"
/>
) : <NoRecordsFound />;

return !isLoading && (
<>
<MiqFormRenderer
Expand All @@ -147,11 +87,9 @@ const TimelineOptions = ({ url, recordId }) => {
timelineEvents, managementGroupNames, managementGroupLevels, policyGroupNames, policyGroupLevels,
)}
onSubmit={onSubmit}
// onCancel={exitPage}
onReset={onReset}
canReset
/>
{/* <>{miqTableContent}</> */}
</>
);
};
Expand Down
1 change: 0 additions & 1 deletion app/javascript/oldjs/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ require('./ops/pglogical_replication_form_controller.js');
require('./playbook-reusable-code-mixin.js');
require('./reconfigure/reconfigure_form_controller.js');
require('./schedule/schedule_form_controller.js');
require('./timeline/timeline_options_controller.js'); // delete later
require('./tree_view_controller.js');
require('./vm_cloud/vm_cloud_live_migrate_form_controller.js');

This file was deleted.

3 changes: 1 addition & 2 deletions app/javascript/oldjs/miq_timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
};
})(ManageIQ);

// TODO: Convert this file to React
window.miqInitTimeline = function(json) {
if (!json) {
return;
Expand All @@ -180,8 +181,6 @@ window.miqInitTimeline = function(json) {

var start;
var end;
// i think this says if we dont set these values we default to today (or whatever the global variable has been previously set to)
// but im not seeing that behavior, i honeslty cant tell how the dates are set here but we can leave that for last
if (!ManageIQ.calendar.calDateFrom || !ManageIQ.calendar.calDateTo) {
end = new Date();
start = new Date(end - 24 * 60 * 60 * 1000 * 7);
Expand Down
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
- p "here we render the table and the timeline"
:javascript
miqInitTimeline('#{j_str tl_json}');
11 changes: 2 additions & 9 deletions app/views/layouts/_tl_show.html.haml
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
-# Create from/to date JS vars to limit calendar selection range
- url = url_for_only_path(:action => 'tl_chooser', :id => @record.id)
= react 'TimelineOptions', {:url => url, :recordId => @record.id}

:javascript
ManageIQ.calendar.calDateFrom = new Date(#{@tl_options.date.start});
ManageIQ.calendar.calDateTo = new Date(#{@tl_options.date.end});

%h1
= @title
= render :partial => "layouts/flash_msg"
= render :partial => "layouts/tl_options"
- url = url_for_only_path(:action => 'tl_chooser', :id => @record.id)
= react 'TimelineOptions', {:url => url}
= render :partial => 'layouts/tl_detail'

= _("* Dates/Times on this page are based on time zone: %{time_zone}.") % {:time_zone => session[:user_tz]}

0 comments on commit d8dacc1

Please sign in to comment.