Compare commits
4 Commits
release/3.
...
multi-user
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de5914b82d | ||
|
|
41bbbb136b | ||
|
|
0f199b6aff | ||
|
|
95e686038d |
@@ -42,7 +42,8 @@ import configStore from '../configuration/ConfigStore';
|
||||
import PlotConfigurationModel from '../configuration/PlotConfigurationModel';
|
||||
import LimitLine from './LimitLine.vue';
|
||||
import LimitLabel from './LimitLabel.vue';
|
||||
import Vue from 'vue';
|
||||
import mount from 'utils/mount';
|
||||
import { toRaw } from 'vue';
|
||||
|
||||
const MARKER_SIZE = 6.0;
|
||||
const HIGHLIGHT_SIZE = MARKER_SIZE * 2.0;
|
||||
@@ -315,7 +316,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
const elements = this.seriesElements.get(series);
|
||||
const elements = this.seriesElements.get(toRaw(series));
|
||||
elements.lines.forEach(function (line) {
|
||||
this.lines.splice(this.lines.indexOf(line), 1);
|
||||
line.destroy();
|
||||
@@ -333,7 +334,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
const elements = this.seriesElements.get(series);
|
||||
const elements = this.seriesElements.get(toRaw(series));
|
||||
if (elements.alarmSet) {
|
||||
elements.alarmSet.destroy();
|
||||
this.alarmSets.splice(this.alarmSets.indexOf(elements.alarmSet), 1);
|
||||
@@ -349,7 +350,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
const elements = this.seriesElements.get(series);
|
||||
const elements = this.seriesElements.get(toRaw(series));
|
||||
elements.pointSets.forEach(function (pointSet) {
|
||||
this.pointSets.splice(this.pointSets.indexOf(pointSet), 1);
|
||||
pointSet.destroy();
|
||||
@@ -473,7 +474,7 @@ export default {
|
||||
this.$emit('plotReinitializeCanvas');
|
||||
},
|
||||
removeChartElement(series) {
|
||||
const elements = this.seriesElements.get(series);
|
||||
const elements = this.seriesElements.get(toRaw(series));
|
||||
|
||||
elements.lines.forEach(function (line) {
|
||||
this.lines.splice(this.lines.indexOf(line), 1);
|
||||
@@ -576,7 +577,7 @@ export default {
|
||||
this.seriesLimits.set(series, limitElements);
|
||||
},
|
||||
clearLimitLines(series) {
|
||||
const seriesLimits = this.seriesLimits.get(series);
|
||||
const seriesLimits = this.seriesLimits.get(toRaw(series));
|
||||
|
||||
if (seriesLimits) {
|
||||
seriesLimits.limitLines.forEach(function (line) {
|
||||
@@ -747,16 +748,14 @@ export default {
|
||||
left: 0,
|
||||
top: this.drawAPI.y(limit.point.y)
|
||||
};
|
||||
let LimitLineClass = Vue.extend(LimitLine);
|
||||
const component = new LimitLineClass({
|
||||
propsData: {
|
||||
const { vNode } = mount(LimitLine, {
|
||||
props: {
|
||||
point,
|
||||
limit
|
||||
}
|
||||
});
|
||||
component.$mount();
|
||||
|
||||
return component.$el;
|
||||
return vNode.el;
|
||||
},
|
||||
getLimitOverlap(limit, overlapMap) {
|
||||
//calculate if limit lines are too close to each other
|
||||
@@ -792,16 +791,14 @@ export default {
|
||||
left: 0,
|
||||
top: this.drawAPI.y(limit.point.y)
|
||||
};
|
||||
let LimitLabelClass = Vue.extend(LimitLabel);
|
||||
const component = new LimitLabelClass({
|
||||
propsData: {
|
||||
const { vNode } = mount(LimitLabel, {
|
||||
props: {
|
||||
limit: Object.assign({}, overlap, limit),
|
||||
point
|
||||
}
|
||||
});
|
||||
component.$mount();
|
||||
|
||||
return component.$el;
|
||||
return vNode.el;
|
||||
},
|
||||
drawAlarmPoints(alarmSet) {
|
||||
this.drawAPI.drawLimitPoints(
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
import Timer from './components/Timer.vue';
|
||||
import mount from 'utils/mount';
|
||||
import { markRaw, toRaw } from 'vue';
|
||||
|
||||
export default function TimerViewProvider(openmct) {
|
||||
return {
|
||||
@@ -32,11 +33,12 @@ export default function TimerViewProvider(openmct) {
|
||||
return domainObject.type === 'timer';
|
||||
},
|
||||
|
||||
view: function (domainObject, objectPath) {
|
||||
view(domainObject, objectPath) {
|
||||
let _destroy = null;
|
||||
|
||||
return {
|
||||
show: function (element) {
|
||||
show(element) {
|
||||
const rawDomainObject = markRaw(toRaw(domainObject));
|
||||
const { destroy } = mount(
|
||||
{
|
||||
el: element,
|
||||
@@ -45,11 +47,11 @@ export default function TimerViewProvider(openmct) {
|
||||
},
|
||||
provide: {
|
||||
openmct,
|
||||
domainObject: rawDomainObject,
|
||||
currentView: this
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
domainObject,
|
||||
objectPath
|
||||
};
|
||||
},
|
||||
@@ -62,7 +64,7 @@ export default function TimerViewProvider(openmct) {
|
||||
);
|
||||
_destroy = destroy;
|
||||
},
|
||||
destroy: function () {
|
||||
destroy() {
|
||||
if (_destroy) {
|
||||
_destroy();
|
||||
}
|
||||
|
||||
@@ -43,19 +43,17 @@
|
||||
|
||||
<script>
|
||||
import raf from 'utils/raf';
|
||||
import throttle from '../../../utils/throttle';
|
||||
|
||||
const moment = require('moment-timezone');
|
||||
const momentDurationFormatSetup = require('moment-duration-format');
|
||||
const refreshRateSeconds = 2;
|
||||
|
||||
momentDurationFormatSetup(moment);
|
||||
|
||||
export default {
|
||||
inject: ['openmct', 'currentView'],
|
||||
inject: ['openmct', 'currentView', 'domainObject'],
|
||||
props: {
|
||||
domainObject: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
objectPath: {
|
||||
type: Array,
|
||||
required: true
|
||||
@@ -82,6 +80,10 @@ export default {
|
||||
return this.lastTimestamp - this.relativeTimestamp;
|
||||
},
|
||||
timeTextValue() {
|
||||
if(this.timerState !== 'started') {
|
||||
// THIS IS NOT RIGHT!!!
|
||||
return moment.duration(this.lastTimestamp - this.configuration.pausedTime, 'ms').format(this.format, { trim: false });
|
||||
}
|
||||
if (isNaN(this.timeDelta)) {
|
||||
return null;
|
||||
}
|
||||
@@ -178,12 +180,15 @@ export default {
|
||||
this.showOrHideAvailableActions();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.refreshTimerObject = throttle(this.refreshTimerObject, refreshRateSeconds * 1000);
|
||||
},
|
||||
mounted() {
|
||||
this.unobserve = this.openmct.objects.observe(
|
||||
this.domainObject,
|
||||
'configuration',
|
||||
(configuration) => {
|
||||
this.configuration = configuration;
|
||||
'*',
|
||||
(domainObject) => {
|
||||
this.configuration = domainObject.configuration;
|
||||
}
|
||||
);
|
||||
this.$nextTick(() => {
|
||||
@@ -219,6 +224,11 @@ export default {
|
||||
if (this.timerState === 'paused' && !this.lastTimestamp) {
|
||||
this.lastTimestamp = this.pausedTime;
|
||||
}
|
||||
|
||||
this.refreshTimerObject();
|
||||
},
|
||||
refreshTimerObject() {
|
||||
this.openmct.objects.refresh(this.domainObject);
|
||||
},
|
||||
restartTimer() {
|
||||
this.triggerAction('timer.restart');
|
||||
|
||||
34
src/utils/throttle.js
Normal file
34
src/utils/throttle.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Creates a throttled function that only invokes the provided function at most once every
|
||||
* specified number of milliseconds. Subsequent calls within the waiting period will be ignored.
|
||||
* @param {Function} func The function to throttle.
|
||||
* @param {number} wait The number of milliseconds to wait between successive calls to the function.
|
||||
* @return {Function} Returns the new throttled function.
|
||||
*/
|
||||
export default function throttle(func, wait) {
|
||||
let timeout;
|
||||
let result;
|
||||
let previous = 0;
|
||||
|
||||
return function (...args) {
|
||||
const now = new Date().getTime();
|
||||
const remaining = wait - (now - previous);
|
||||
|
||||
if (remaining <= 0 || remaining > wait) {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
|
||||
previous = now;
|
||||
result = func(...args);
|
||||
} else if (!timeout) {
|
||||
timeout = setTimeout(() => {
|
||||
previous = new Date().getTime();
|
||||
timeout = null;
|
||||
result = func(...args);
|
||||
}, remaining);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user