mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 05:37:53 +00:00
Add role attribution to notebook entries and export (#6793)
Co-authored-by: Jamie V <jamie.j.vigliotta@nasa.gov>
This commit is contained in:
parent
ac22bebe76
commit
5031010a00
@ -105,14 +105,16 @@ export default class ExportNotebookAsTextAction {
|
|||||||
if (changes.exportMetaData) {
|
if (changes.exportMetaData) {
|
||||||
const createdTimestamp = entry.createdOn;
|
const createdTimestamp = entry.createdOn;
|
||||||
const createdBy = this.getUserName(entry.createdBy);
|
const createdBy = this.getUserName(entry.createdBy);
|
||||||
|
const createdByRole = entry.createdByRole;
|
||||||
const modifiedBy = this.getUserName(entry.modifiedBy);
|
const modifiedBy = this.getUserName(entry.modifiedBy);
|
||||||
|
const modifiedByRole = entry.modifiedByRole;
|
||||||
const modifiedTimestamp = entry.modified ?? entry.created;
|
const modifiedTimestamp = entry.modified ?? entry.created;
|
||||||
notebookAsText += `Created on ${this.formatTimeStamp(
|
notebookAsText += `Created on ${this.formatTimeStamp(
|
||||||
createdTimestamp
|
createdTimestamp
|
||||||
)} by user ${createdBy}\n\n`;
|
)} by user ${createdBy}${createdByRole ? `: ${createdByRole}` : ''}\n\n`;
|
||||||
notebookAsText += `Updated on ${this.formatTimeStamp(
|
notebookAsText += `Updated on ${this.formatTimeStamp(
|
||||||
modifiedTimestamp
|
modifiedTimestamp
|
||||||
)} by user ${modifiedBy}\n\n`;
|
)} by user ${modifiedBy}${modifiedByRole ? `: ${modifiedByRole}` : ''}\n\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changes.exportTags) {
|
if (changes.exportTags) {
|
||||||
|
@ -37,7 +37,10 @@
|
|||||||
<span class="c-ne__created-date">{{ createdOnDate }}</span>
|
<span class="c-ne__created-date">{{ createdOnDate }}</span>
|
||||||
<span class="c-ne__created-time">{{ createdOnTime }}</span>
|
<span class="c-ne__created-time">{{ createdOnTime }}</span>
|
||||||
<span v-if="entry.createdBy" class="c-ne__creator">
|
<span v-if="entry.createdBy" class="c-ne__creator">
|
||||||
<span class="icon-person"></span> {{ entry.createdBy }}
|
<span class="icon-person"></span>
|
||||||
|
{{
|
||||||
|
entry.createdByRole ? `${entry.createdBy}: ${entry.createdByRole}` : entry.createdBy
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-if="!readOnly && !isLocked" class="c-ne__local-controls--hidden">
|
<span v-if="!readOnly && !isLocked" class="c-ne__local-controls--hidden">
|
||||||
@ -433,10 +436,17 @@ export default {
|
|||||||
this.timestampAndUpdate();
|
this.timestampAndUpdate();
|
||||||
},
|
},
|
||||||
async timestampAndUpdate() {
|
async timestampAndUpdate() {
|
||||||
const user = await this.openmct.user.getCurrentUser();
|
const [user, activeRole] = await Promise.all([
|
||||||
|
this.openmct.user.getCurrentUser(),
|
||||||
|
this.openmct.user.getActiveRole?.()
|
||||||
|
]);
|
||||||
if (user === undefined) {
|
if (user === undefined) {
|
||||||
this.entry.modifiedBy = UNKNOWN_USER;
|
this.entry.modifiedBy = UNKNOWN_USER;
|
||||||
|
} else {
|
||||||
|
this.entry.modifiedBy = user.getName();
|
||||||
|
if (activeRole) {
|
||||||
|
this.entry.modifiedByRole = activeRole;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entry.modified = Date.now();
|
this.entry.modified = Date.now();
|
||||||
|
@ -12,6 +12,15 @@ async function getUsername(openmct) {
|
|||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getActiveRole(openmct) {
|
||||||
|
let role = null;
|
||||||
|
if (openmct.user.hasProvider()) {
|
||||||
|
role = await openmct.user.getActiveRole?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
export const DEFAULT_CLASS = 'notebook-default';
|
export const DEFAULT_CLASS = 'notebook-default';
|
||||||
const TIME_BOUNDS = {
|
const TIME_BOUNDS = {
|
||||||
START_BOUND: 'tc.startBound',
|
START_BOUND: 'tc.startBound',
|
||||||
@ -156,11 +165,15 @@ export async function addNotebookEntry(
|
|||||||
const embeds = embed ? [embed] : [];
|
const embeds = embed ? [embed] : [];
|
||||||
|
|
||||||
const id = `entry-${uuid()}`;
|
const id = `entry-${uuid()}`;
|
||||||
const createdBy = await getUsername(openmct);
|
const [createdBy, createdByRole] = await Promise.all([
|
||||||
|
getUsername(openmct),
|
||||||
|
getActiveRole(openmct)
|
||||||
|
]);
|
||||||
const entry = {
|
const entry = {
|
||||||
id,
|
id,
|
||||||
createdOn: date,
|
createdOn: date,
|
||||||
createdBy,
|
createdBy,
|
||||||
|
createdByRole,
|
||||||
text: entryText,
|
text: entryText,
|
||||||
embeds
|
embeds
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user