Merge in feat/ui-v2-rebase-services
This commit is contained in:
commit
c5e6e97980
66 files changed
+3390
-3355
No files matched your search
@@ -47,6 +47,7 @@ const MEASUREMENT_SCHEMA_KEYS = [
|
||||
const EVENTS = {
|
||||
MEASUREMENT_UPDATED: 'event::measurement_updated',
|
||||
MEASUREMENT_ADDED: 'event::measurement_added',
|
||||
MEASUREMENT_REMOVED: 'event::measurement_removed',
|
||||
};
|
||||
|
||||
const VALUE_TYPES = {
|
||||
@@ -136,6 +137,9 @@ class MeasurementService {
|
||||
source.addOrUpdate = (definition, measurement) => {
|
||||
return this.addOrUpdate(source, definition, measurement);
|
||||
};
|
||||
source.remove = id => {
|
||||
return this.remove(source, id);
|
||||
};
|
||||
source.getAnnotation = (definition, measurementId) => {
|
||||
return this.getAnnotation(source, definition, measurementId);
|
||||
};
|
||||
@@ -338,6 +342,16 @@ class MeasurementService {
|
||||
return newMeasurement.id;
|
||||
}
|
||||
|
||||
remove(source, id) {
|
||||
if (!id || !this.measurements[id]) {
|
||||
log.warn(`No id provided, or unable to find measurement by id.`);
|
||||
return;
|
||||
}
|
||||
|
||||
delete this.measurements[id];
|
||||
this._broadcastChange(this.EVENTS.MEASUREMENT_REMOVED, source, id);
|
||||
}
|
||||
|
||||
_getMappingByMeasurementSource(measurementId, definition) {
|
||||
const measurement = this.getMeasurement(measurementId);
|
||||
if (this._isValidSource(measurement.source)) {
|
||||
|
||||
@@ -17,7 +17,8 @@ const publicAPI = {
|
||||
};
|
||||
|
||||
const serviceImplementation = {
|
||||
_viewports: [],
|
||||
_hide: () => console.warn('hide() NOT IMPLEMENTED'),
|
||||
_show: () => console.warn('show() NOT IMPLEMENTED'),
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -25,39 +26,21 @@ const serviceImplementation = {
|
||||
*
|
||||
* @param {ViewportDialogProps} props { content, contentProps, viewportIndex }
|
||||
*/
|
||||
function _show({ content = null, contentProps = null, viewportIndex }) {
|
||||
const viewportIndexImplementation =
|
||||
(viewportIndex !== undefined &&
|
||||
serviceImplementation._viewports[viewportIndex]) ||
|
||||
{};
|
||||
|
||||
if (!viewportIndexImplementation._show) {
|
||||
console.warn('show() NOT IMPLEMENTED');
|
||||
return;
|
||||
}
|
||||
|
||||
return viewportIndexImplementation._show({
|
||||
content,
|
||||
contentProps,
|
||||
function _show({ viewportIndex, type, message, actions, onSubmit }) {
|
||||
return serviceImplementation._show({
|
||||
viewportIndex,
|
||||
type,
|
||||
message,
|
||||
actions,
|
||||
onSubmit,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides/dismisses the viewport dialog, if currently shown
|
||||
*
|
||||
* @param {*} { viewportIndex }
|
||||
*/
|
||||
function _hide({ viewportIndex }) {
|
||||
const viewportIndexImplementation =
|
||||
(viewportIndex && serviceImplementation._viewports[viewportIndex]) || {};
|
||||
|
||||
if (!viewportIndexImplementation._hide) {
|
||||
console.warn('hide() NOT IMPLEMENTED');
|
||||
return;
|
||||
}
|
||||
|
||||
return viewportIndexImplementation._hide();
|
||||
function _hide() {
|
||||
return serviceImplementation._hide();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,22 +55,12 @@ function _hide({ viewportIndex }) {
|
||||
function setServiceImplementation({
|
||||
hide: hideImplementation,
|
||||
show: showImplementation,
|
||||
viewportIndex,
|
||||
}) {
|
||||
if (viewportIndex !== undefined) {
|
||||
const newImplementations = {};
|
||||
if (hideImplementation) {
|
||||
newImplementations._hide = hideImplementation;
|
||||
}
|
||||
if (showImplementation) {
|
||||
newImplementations._show = showImplementation;
|
||||
}
|
||||
|
||||
serviceImplementation._viewports[viewportIndex] = Object.assign(
|
||||
{},
|
||||
serviceImplementation._viewports[viewportIndex],
|
||||
newImplementations
|
||||
);
|
||||
if (hideImplementation) {
|
||||
serviceImplementation._hide = hideImplementation;
|
||||
}
|
||||
if (showImplementation) {
|
||||
serviceImplementation._show = showImplementation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user