Redesign timeline cards and drilldown UX
This commit is contained in:
107
migrations/0018_timeline_ui_facets/down.sql
Normal file
107
migrations/0018_timeline_ui_facets/down.sql
Normal file
@@ -0,0 +1,107 @@
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE() AND table_name = 'timeline_events' AND index_name = 'idx_timeline_subject_action_time'
|
||||
),
|
||||
'ALTER TABLE timeline_events DROP INDEX idx_timeline_subject_action_time',
|
||||
'SELECT 1'
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE() AND table_name = 'timeline_events' AND index_name = 'idx_timeline_subject_source_time'
|
||||
),
|
||||
'ALTER TABLE timeline_events DROP INDEX idx_timeline_subject_source_time',
|
||||
'SELECT 1'
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE() AND table_name = 'timeline_events' AND index_name = 'idx_timeline_subject_slot_time'
|
||||
),
|
||||
'ALTER TABLE timeline_events DROP INDEX idx_timeline_subject_slot_time',
|
||||
'SELECT 1'
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE() AND table_name = 'timeline_events' AND index_name = 'idx_timeline_subject_device_time'
|
||||
),
|
||||
'ALTER TABLE timeline_events DROP INDEX idx_timeline_subject_device_time',
|
||||
'SELECT 1'
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE() AND table_name = 'timeline_events' AND index_name = 'idx_timeline_subject_component_serial_time'
|
||||
),
|
||||
'ALTER TABLE timeline_events DROP INDEX idx_timeline_subject_component_serial_time',
|
||||
'SELECT 1'
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE() AND table_name = 'timeline_events' AND index_name = 'idx_timeline_subject_component_model_time'
|
||||
),
|
||||
'ALTER TABLE timeline_events DROP INDEX idx_timeline_subject_component_model_time',
|
||||
'SELECT 1'
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE() AND table_name = 'timeline_events' AND index_name = 'idx_timeline_subject_asset_serial_time'
|
||||
),
|
||||
'ALTER TABLE timeline_events DROP INDEX idx_timeline_subject_asset_serial_time',
|
||||
'SELECT 1'
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- drop columns if present
|
||||
SET @cols = 'source_type,visual_action,component_serial,component_model,asset_serial,asset_name_cached,slot_name,device_name,changed_fields_json';
|
||||
SET @dummy = @cols;
|
||||
|
||||
SET @sql = (SELECT IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='timeline_events' AND column_name='changed_fields_json'), 'ALTER TABLE timeline_events DROP COLUMN changed_fields_json', 'SELECT 1'));
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql = (SELECT IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='timeline_events' AND column_name='device_name'), 'ALTER TABLE timeline_events DROP COLUMN device_name', 'SELECT 1'));
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql = (SELECT IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='timeline_events' AND column_name='slot_name'), 'ALTER TABLE timeline_events DROP COLUMN slot_name', 'SELECT 1'));
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql = (SELECT IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='timeline_events' AND column_name='asset_name_cached'), 'ALTER TABLE timeline_events DROP COLUMN asset_name_cached', 'SELECT 1'));
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql = (SELECT IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='timeline_events' AND column_name='asset_serial'), 'ALTER TABLE timeline_events DROP COLUMN asset_serial', 'SELECT 1'));
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql = (SELECT IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='timeline_events' AND column_name='component_model'), 'ALTER TABLE timeline_events DROP COLUMN component_model', 'SELECT 1'));
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql = (SELECT IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='timeline_events' AND column_name='component_serial'), 'ALTER TABLE timeline_events DROP COLUMN component_serial', 'SELECT 1'));
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql = (SELECT IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='timeline_events' AND column_name='visual_action'), 'ALTER TABLE timeline_events DROP COLUMN visual_action', 'SELECT 1'));
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql = (SELECT IF(EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='timeline_events' AND column_name='source_type'), 'ALTER TABLE timeline_events DROP COLUMN source_type', 'SELECT 1'));
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
53
migrations/0018_timeline_ui_facets/up.sql
Normal file
53
migrations/0018_timeline_ui_facets/up.sql
Normal file
@@ -0,0 +1,53 @@
|
||||
ALTER TABLE timeline_events
|
||||
ADD COLUMN source_type VARCHAR(32) NULL;
|
||||
|
||||
ALTER TABLE timeline_events
|
||||
ADD COLUMN visual_action VARCHAR(64) NULL;
|
||||
|
||||
ALTER TABLE timeline_events
|
||||
ADD COLUMN component_serial VARCHAR(255) NULL;
|
||||
|
||||
ALTER TABLE timeline_events
|
||||
ADD COLUMN component_model VARCHAR(255) NULL;
|
||||
|
||||
ALTER TABLE timeline_events
|
||||
ADD COLUMN asset_serial VARCHAR(255) NULL;
|
||||
|
||||
ALTER TABLE timeline_events
|
||||
ADD COLUMN asset_name_cached VARCHAR(255) NULL;
|
||||
|
||||
ALTER TABLE timeline_events
|
||||
ADD COLUMN slot_name VARCHAR(255) NULL;
|
||||
|
||||
ALTER TABLE timeline_events
|
||||
ADD COLUMN device_name VARCHAR(255) NULL;
|
||||
|
||||
ALTER TABLE timeline_events
|
||||
ADD COLUMN changed_fields_json JSON NULL;
|
||||
|
||||
CREATE INDEX idx_timeline_subject_action_time ON timeline_events(subject_type, subject_id, is_deleted, visual_action, event_time, id);
|
||||
CREATE INDEX idx_timeline_subject_source_time ON timeline_events(subject_type, subject_id, is_deleted, source_type, event_time, id);
|
||||
CREATE INDEX idx_timeline_subject_slot_time ON timeline_events(subject_type, subject_id, is_deleted, slot_name, event_time, id);
|
||||
CREATE INDEX idx_timeline_subject_device_time ON timeline_events(subject_type, subject_id, is_deleted, device_name, event_time, id);
|
||||
CREATE INDEX idx_timeline_subject_component_serial_time ON timeline_events(subject_type, subject_id, is_deleted, component_serial, event_time, id);
|
||||
CREATE INDEX idx_timeline_subject_component_model_time ON timeline_events(subject_type, subject_id, is_deleted, component_model, event_time, id);
|
||||
CREATE INDEX idx_timeline_subject_asset_serial_time ON timeline_events(subject_type, subject_id, is_deleted, asset_serial, event_time, id);
|
||||
|
||||
UPDATE timeline_events t
|
||||
LEFT JOIN component_change_events ce ON t.logical_entity_type = 'component' AND ce.id = t.logical_event_id
|
||||
LEFT JOIN asset_change_events ae ON t.logical_entity_type = 'asset' AND ae.id = t.logical_event_id
|
||||
LEFT JOIN parts p ON p.id = t.part_id
|
||||
LEFT JOIN machines m ON m.id = t.machine_id
|
||||
SET
|
||||
t.source_type = COALESCE(t.source_type, ce.source_type, ae.source_type),
|
||||
t.component_serial = COALESCE(t.component_serial, p.vendor_serial),
|
||||
t.component_model = COALESCE(t.component_model, p.model),
|
||||
t.asset_serial = COALESCE(t.asset_serial, m.vendor_serial),
|
||||
t.asset_name_cached = COALESCE(t.asset_name_cached, m.name)
|
||||
WHERE
|
||||
t.source_type IS NULL
|
||||
OR t.component_serial IS NULL
|
||||
OR t.component_model IS NULL
|
||||
OR t.asset_serial IS NULL
|
||||
OR t.asset_name_cached IS NULL;
|
||||
|
||||
Reference in New Issue
Block a user