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

Activity state display for plans in Gantt and Time list views #7370

Merged
merged 36 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7003f00
Add activity states domain object and interceptor to auto create one
shefalijoshi Jan 10, 2024
92a30a3
Add activity state inspector option
shefalijoshi Jan 10, 2024
4d4f83e
Only save status if we have a unique ids for activities
shefalijoshi Jan 10, 2024
02edb99
Include the id in the activity properties
shefalijoshi Jan 10, 2024
e47bfed
Don't show activity state section in the inspector if multiple activi…
shefalijoshi Jan 10, 2024
3c14025
Display activity properties when an activity row is selected in the t…
shefalijoshi Jan 10, 2024
65a7e7e
Use activity id as key if it is available
shefalijoshi Jan 18, 2024
176d344
Ensure the correct option is selected for activity states
shefalijoshi Jan 18, 2024
02c796a
Add status label
shefalijoshi Jan 19, 2024
b0a21d4
Refactor activity selection. Display activity properties
shefalijoshi Jan 19, 2024
dc1def5
Remove activity states plugin. Move the activity states interceptor t…
shefalijoshi Jan 19, 2024
b413a9b
Change activity states interceptor parameters to options
shefalijoshi Jan 19, 2024
bbf5454
Rename constants
shefalijoshi Jan 19, 2024
6def4c2
Fix activity states test
shefalijoshi Jan 19, 2024
9b85252
Merge branch 'master' of https://github.com/nasa/openmct into activit…
shefalijoshi Jan 19, 2024
5908f96
Merge branch 'master' into activity-state-display
shefalijoshi Jan 23, 2024
78f2852
Add e2e test for activity states feature.
shefalijoshi Jan 23, 2024
5c6a733
Address review comments. Rename variables, documentation.
shefalijoshi Jan 23, 2024
42ed592
No shallow copy
shefalijoshi Jan 23, 2024
122c84b
Suppress lint warning for conditionals
shefalijoshi Jan 25, 2024
6ee3177
Remove check for abort controller
shefalijoshi Jan 25, 2024
8e53866
Move classes to components
shefalijoshi Jan 25, 2024
619e253
number primitive
shefalijoshi Jan 25, 2024
6a7ea35
Closes #7369
charlesh88 Jan 25, 2024
6abfac7
Ensure 'notStarted' is the default state for activities
shefalijoshi Jan 25, 2024
fc64682
Remove extra quotes
shefalijoshi Jan 25, 2024
6d3242b
Closes #7369
charlesh88 Jan 25, 2024
795b35f
Merge remote-tracking branch 'origin/activity-state-display' into act…
charlesh88 Jan 25, 2024
875edd9
Merge branch 'master' into activity-state-display
shefalijoshi Jan 25, 2024
a5abc32
Merge branch 'activity-state-display' of https://github.com/nasa/open…
shefalijoshi Jan 25, 2024
2839246
Use generated key for vue
shefalijoshi Jan 25, 2024
e79b99e
Fix e2e tests
shefalijoshi Jan 25, 2024
4f6a792
Fix timelist test
shefalijoshi Jan 26, 2024
a494a24
Merge branch 'master' into activity-state-display
shefalijoshi Jan 26, 2024
e8637b1
Merge branch 'master' into activity-state-display
unlikelyzero Jan 26, 2024
f404116
Merge branch 'master' of https://github.com/nasa/openmct into activit…
shefalijoshi Jan 28, 2024
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
Prev Previous commit
Next Next commit
Refactor activity selection. Display activity properties
  • Loading branch information
shefalijoshi committed Jan 19, 2024
commit b0a21d40f6a790acdb36d822375311b53ae1fc34
28 changes: 5 additions & 23 deletions src/plugins/plan/components/ActivityTimeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,37 +135,19 @@ export default {
default: 22
}
},
emits: ['activitySelected'],
data() {
return {
lineHeight: 10
};
},
methods: {
setSelectionForActivity(activity, event) {
const element = event.currentTarget;
const multiSelect = event.metaKey;

event.stopPropagation();

this.openmct.selection.select(
[
{
element: element,
context: {
type: 'activity',
activity: activity
}
},
{
element: this.openmct.layout.$refs.browseObject.$el,
context: {
item: this.domainObject,
supportsMultiSelect: true
}
}
],
multiSelect
);
this.$emit('activitySelected', {
event,
selection: activity.selection
});
}
}
};
Expand Down
56 changes: 41 additions & 15 deletions src/plugins/plan/components/PlanView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
:width="group.width"
:is-nested="options.isChildObject"
:status="status"
@activity-selected="selectActivity"
/>
</div>
</div>
Expand Down Expand Up @@ -134,7 +135,7 @@
this.swimlaneVisibility = this.configuration.swimlaneVisibility;
this.clipActivityNames = this.configuration.clipActivityNames;
if (this.domainObject.type === 'plan') {
this.planData = getValidatedData(this.domainObject);
this.getPlanData(this.domainObject);
}

const canvas = document.createElement('canvas');
Expand Down Expand Up @@ -177,6 +178,9 @@
this.planViewConfiguration.destroy();
},
methods: {
getPlanData(object) {
this.planData = getValidatedData(object);
},

Check warning on line 183 in src/plugins/plan/components/PlanView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/components/PlanView.vue#L183

Added line #L183 was not covered by tests
activityNameFitsRect(activityName, rectWidth) {
return this.getTextWidth(activityName) + TEXT_LEFT_PADDING < rectWidth;
},
Expand Down Expand Up @@ -215,9 +219,7 @@
callback: () => {
this.removeFromComposition(this.planObject);
this.planObject = domainObject;
this.planData = getValidatedData(domainObject);
this.setStatus(this.openmct.status.get(domainObject.identifier));
this.setScaleAndGenerateActivities();
this.handleSelectFileChange();
dialog.dismiss();
}
},
Expand All @@ -237,9 +239,7 @@
} else {
this.planObject = domainObject;
this.swimlaneVisibility = this.configuration.swimlaneVisibility;
this.planData = getValidatedData(domainObject);
this.setStatus(this.openmct.status.get(domainObject.identifier));
this.setScaleAndGenerateActivities();
this.handleSelectFileChange(domainObject);
}
},
handleConfigurationChange(newConfiguration) {
Expand All @@ -259,8 +259,10 @@

this.setScaleAndGenerateActivities();
},
handleSelectFileChange() {
this.planData = getValidatedData(this.domainObject);
handleSelectFileChange(domainObject) {
const object = domainObject || this.domainObject;
this.getPlanData(object);
this.setStatus(this.openmct.status.get(object.identifier));
this.setScaleAndGenerateActivities();
},
removeFromComposition(domainObject) {
Expand Down Expand Up @@ -434,7 +436,7 @@
return;
}

rawActivities.forEach((rawActivity) => {
rawActivities.forEach((rawActivity, index) => {
if (!this.isActivityInBounds(rawActivity)) {
return;
}
Expand Down Expand Up @@ -481,14 +483,10 @@
const activity = {
color: color,
textColor: textColor,
name: rawActivity.name,
exceeds: {
start: this.xScale(this.viewBounds.start) > this.xScale(rawActivity.start),
end: this.xScale(this.viewBounds.end) < this.xScale(rawActivity.end)
},
start: rawActivity.start,
end: rawActivity.end,
description: rawActivity.description,
row: currentRow,
textLines: textLines,
textStart: textStart,
Expand All @@ -498,7 +496,10 @@
rectEnd: showTextInsideRect ? rectX2 : textStart + textWidth,
rectWidth: rectWidth,
clipPathId: this.getClipPathId(groupName, rawActivity, currentRow),
id: rawActivity.id
selection: {
groupName,
index
}
};
activitiesByRow[currentRow].push(activity);
});
Expand Down Expand Up @@ -575,6 +576,31 @@
const activityName = activity.name.toLowerCase().replace(/ /g, '-');

return `${groupName}-${activityName}-${activity.start}-${activity.end}-${row}`;
},
selectActivity({ event, selection }) {
const element = event.currentTarget;
const multiSelect = event.metaKey;
const { groupName, index } = selection;
const rawActivity = this.planData[groupName][index];
this.openmct.selection.select(
[
{
element: element,
context: {
type: 'activity',
activity: rawActivity
}
},
{
element: this.openmct.layout.$refs.browseObject.$el,
context: {
item: this.domainObject,
supportsMultiSelect: true
}
}
],
multiSelect
);
}
}
};
Expand Down
17 changes: 12 additions & 5 deletions src/plugins/plan/inspector/components/PlanActivitiesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@
v-if="canPersistState"
:key="activities[0].key"
class="c-inspector__properties c-inspect-properties"
:activity="activities[0]"
:execution-state="persistedActivityStates[activities[0].id]"
:heading="'Activity Status'"
@update-activity-state="persistedActivityState"
/>

Check warning on line 46 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L42-L46

Added lines #L42 - L46 were not covered by tests
</div>
</template>

<script>
import { getPreciseDuration } from 'utils/duration';

import { getDisplayProperties } from '../../util.js';

Check warning on line 53 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L53

Added line #L53 was not covered by tests
import PlanActivityPropertiesView from './PlanActivityPropertiesView.vue';
import PlanActivityStatusView from './PlanActivityStatusView.vue';
import PlanActivityTimeView from './PlanActivityTimeView.vue';
Expand All @@ -63,11 +64,11 @@
gap: 'Gap',
overlap: 'Overlap',
totalTime: 'Total Time',
description: 'Description'

Check warning on line 67 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L67

Added line #L67 was not covered by tests
};
export default {
components: {
PlanActivityTimeView,

Check warning on line 71 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L71

Added line #L71 was not covered by tests
PlanActivityPropertiesView,
PlanActivityStatusView
},
Expand All @@ -76,20 +77,20 @@
return {
name: '',
activities: [],
selectedActivities: [],
persistedActivityStates: {},

Check warning on line 81 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L80-L81

Added lines #L80 - L81 were not covered by tests
heading: ''
};
},
computed: {
canPersistState() {

Check warning on line 86 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L86

Added line #L86 was not covered by tests
return this.selectedActivities.length === 1 && this.activities[0].id;
}
},
mounted() {
this.setFormatters();
this.getPlanData(this.selection);
this.getActivityStates();

Check warning on line 93 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L93

Added line #L93 was not covered by tests
this.getActivities();
this.openmct.selection.on('change', this.updateSelection);
this.openmct.time.on('timeSystem', this.setFormatters);
Expand All @@ -97,9 +98,9 @@
beforeUnmount() {
this.openmct.selection.off('change', this.updateSelection);
this.openmct.time.off('timeSystem', this.setFormatters);
if (this.stopObservingActivityStatesObject) {
this.stopObservingActivityStatesObject();
}

Check warning on line 103 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L101-L103

Added lines #L101 - L103 were not covered by tests
},
methods: {
async getActivityStates() {
Expand Down Expand Up @@ -158,22 +159,28 @@
},
end: {
label: propertyLabels.end,
value: this.formatTime(selectedActivity.end)
},

Check warning on line 163 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L162-L163

Added lines #L162 - L163 were not covered by tests
duration: {
label: propertyLabels.duration,

Check warning on line 165 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L165

Added line #L165 was not covered by tests
value: this.formatDuration(selectedActivity.end - selectedActivity.start)
}
}
};
activity.metadata = {};

Check warning on line 170 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L170

Added line #L170 was not covered by tests
if (selectedActivity.description) {
activity.metadata = {
description: {
label: propertyLabels.description,
value: selectedActivity.description
}
activity.metadata.description = {
label: propertyLabels.description,
value: selectedActivity.description
};
}

Check warning on line 176 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L175-L176

Added lines #L175 - L176 were not covered by tests

const displayProperties = getDisplayProperties(selectedActivity);

Check warning on line 178 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L178

Added line #L178 was not covered by tests
activity.metadata = {
...activity.metadata,
...displayProperties

Check warning on line 181 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L180-L181

Added lines #L180 - L181 were not covered by tests
};

this.activities[index] = activity;
});
},
Expand All @@ -197,7 +204,7 @@
let latestEnd;
let gap;
let overlap;
let id;

Check warning on line 207 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L207

Added line #L207 was not covered by tests
let key;

//Sort by start time
Expand All @@ -217,8 +224,8 @@
earliestStart = Math.min(earliestStart, selectedActivity.start);
latestEnd = Math.max(latestEnd, selectedActivity.end);
} else {
id = selectedActivity.id;
key = selectedActivity.id ?? selectedActivity.name;

Check warning on line 228 in src/plugins/plan/inspector/components/PlanActivitiesView.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/inspector/components/PlanActivitiesView.vue#L227-L228

Added lines #L227 - L228 were not covered by tests
earliestStart = selectedActivity.start;
latestEnd = selectedActivity.end;
}
Expand Down
39 changes: 39 additions & 0 deletions src/plugins/plan/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@
groupActivity.end = activity[sourceMap.end];
}

if (sourceMap.id) {
groupActivity.id = activity[sourceMap.id];

Check warning on line 49 in src/plugins/plan/util.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/util.js#L48-L49

Added lines #L48 - L49 were not covered by tests
}

if (sourceMap.displayProperties) {
groupActivity.displayProperties = sourceMap.displayProperties;

Check warning on line 53 in src/plugins/plan/util.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/util.js#L52-L53

Added lines #L52 - L53 were not covered by tests
}

if (!mappedJson[groupIdKey]) {
mappedJson[groupIdKey] = [];
}
Expand Down Expand Up @@ -104,6 +108,41 @@
return orderedGroupNames;
}

export function getDisplayProperties(activity) {
let displayProperties = {};
if (activity?.displayProperties) {
const keys = Object.keys(activity.displayProperties);
if (keys.length) {
keys.forEach((key) => {
const displayPropertyLabel = activity.displayProperties[key];
const value = _.get(activity, key);
if (value) {
displayProperties[key] = {

Check warning on line 120 in src/plugins/plan/util.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/util.js#L112-L120

Added lines #L112 - L120 were not covered by tests
label: displayPropertyLabel,
value
};
}
});
}
} else if (activity?.properties) {
const keys = Object.keys(activity?.properties);
if (keys.length) {
keys.forEach((key) => {
const displayPropertyLabel = key;
const value = activity.properties[key];
if (value) {
displayProperties[key] = {

Check warning on line 134 in src/plugins/plan/util.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/util.js#L127-L134

Added lines #L127 - L134 were not covered by tests
label: displayPropertyLabel,
value
};
}
});
}
}

return displayProperties;

Check warning on line 143 in src/plugins/plan/util.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/plan/util.js#L143

Added line #L143 was not covered by tests
}

export function getContrastingColor(hexColor) {
function cutHex(h, start, end) {
const hStr = h.charAt(0) === '#' ? h.substring(1, 7) : h;
Expand Down
Loading