Skip to content

Commit

Permalink
chore: lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonflatval-cognite committed Jun 21, 2024
1 parent 2d1d8ab commit 35d3016
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@cognite/reveal';
import { type DomainObjectIntersection } from '../domainObjectsHelpers/DomainObjectIntersection';
import { VisualDomainObject } from '../domainObjects/VisualDomainObject';
import { DomainObject } from '../domainObjects/DomainObject';
import { type DomainObject } from '../domainObjects/DomainObject';

/**
* Represents an abstract class for a Three.js view that renders an Object3D.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Overlay3DCollection } from '@cognite/reveal';
import { Observation } from './models';
/*!
* Copyright 2024 Cognite AS
*/
import { type Overlay3DCollection } from '@cognite/reveal';
import { type Observation } from './models';
import { VisualDomainObject } from '../../base/domainObjects/VisualDomainObject';
import { ThreeView } from '../../base/views/ThreeView';
import { type ThreeView } from '../../base/views/ThreeView';
import { ObservationsView } from './ObservationsView';
import { TranslateKey } from '../../base/utilities/TranslateKey';
import { type TranslateKey } from '../../base/utilities/TranslateKey';

export class ObservationsDomainObject extends VisualDomainObject {
private _collection: Overlay3DCollection<Observation>;
private readonly _collection: Overlay3DCollection<Observation>;

public override get typeName(): TranslateKey {
return { fallback: ObservationsDomainObject.name };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import { IconType } from '@cognite/cogs.js';
import { TranslateKey } from '../../base/utilities/TranslateKey';
import { FdmSDK, InstanceFilter } from '../../../utilities/FdmSDK';
import { OBSERVATION_SOURCE, Observation, ObservationProperties } from './models';
/*!
* Copyright 2024 Cognite AS
*/
import { type IconType } from '@cognite/cogs.js';
import { type TranslateKey } from '../../base/utilities/TranslateKey';
import { type FdmSDK, type InstanceFilter } from '../../../utilities/FdmSDK';
import { OBSERVATION_SOURCE, type Observation, type ObservationProperties } from './models';
import { ObservationsDomainObject } from './ObservationsDomainObject';
import { Color, Vector2, Vector3 } from 'three';
import { CDF_TO_VIEWER_TRANSFORMATION, Overlay3D, Overlay3DCollection } from '@cognite/reveal';
import { Color, Vector3 } from 'three';
import { CDF_TO_VIEWER_TRANSFORMATION, type Overlay3D, Overlay3DCollection } from '@cognite/reveal';
import { NavigationTool } from '../../base/concreteCommands/NavigationTool';
import { RevealRenderTarget } from '../../base/renderTarget/RevealRenderTarget';
import { type RevealRenderTarget } from '../../base/renderTarget/RevealRenderTarget';

const DEFAULT_OVERLAY_COLOR = new Color('lightblue');
const SELECTED_OVERLAY_COLOR = new Color('red');

export class ObservationsTool extends NavigationTool {
// private _domainObjects: ObservationsDomainObject[] = [];
private _domainObjectPromise: Promise<ObservationsDomainObject>;
private readonly _domainObjectPromise: Promise<ObservationsDomainObject>;

private _selectedOverlay: Overlay3D<Observation> | undefined;

constructor(fdmSdk: FdmSDK) {
super();
this._domainObjectPromise = fetchObservations(fdmSdk).then((observations) =>
this.initializeDomainObjects(observations)
this._domainObjectPromise = fetchObservations(fdmSdk).then(
async (observations) => await this.initializeDomainObjects(observations)
);
}

Expand All @@ -40,8 +43,6 @@ export class ObservationsTool extends NavigationTool {
};
});

console.log('Observation overlays: ', observationOverlays);

const collection = new Overlay3DCollection<Observation>(observationOverlays, {
defaultOverlayColor: DEFAULT_OVERLAY_COLOR
});
Expand All @@ -59,30 +60,28 @@ export class ObservationsTool extends NavigationTool {
return { fallback: 'Show observations' };
}

public override attach(renderTarget: RevealRenderTarget) {
public override attach(renderTarget: RevealRenderTarget): void {
super.attach(renderTarget);
this._domainObjectPromise.then((domainObject) =>
renderTarget.rootDomainObject.addChildInteractive(domainObject)
);
void this._domainObjectPromise.then((domainObject) => {
renderTarget.rootDomainObject.addChildInteractive(domainObject);
});
}

public override onActivate() {
this._domainObjectPromise.then((domainObject) =>
public override onActivate(): void {
void this._domainObjectPromise.then((domainObject) =>
domainObject.setVisibleInteractive(true, this.renderTarget)
);
}

public override onDeactivate() {
this._domainObjectPromise.then((domainObject) => {
public override onDeactivate(): void {
void this._domainObjectPromise.then((domainObject) => {
domainObject.setVisibleInteractive(false, this.renderTarget);
});
}

public override async onClick(event: PointerEvent) {
public override async onClick(event: PointerEvent): Promise<void> {
const domainObject = await this._domainObjectPromise;
domainObject.overlayCollection
.getOverlays()
.forEach((overlay) => overlay.setColor(DEFAULT_OVERLAY_COLOR));
this._selectedOverlay?.setColor(DEFAULT_OVERLAY_COLOR);

const normalizedCoord = this.getNormalizedPixelCoordinates(event);
const intersection = domainObject.overlayCollection.intersectOverlays(
Expand All @@ -92,10 +91,14 @@ export class ObservationsTool extends NavigationTool {

if (intersection !== undefined) {
this.handleIntersectedOverlay(intersection);
} else {
this._selectedOverlay = undefined;
}

this.renderTarget.viewer.requestRedraw();
}

private handleIntersectedOverlay(overlay: Overlay3D<Observation>) {
private handleIntersectedOverlay(overlay: Overlay3D<Observation>): void {
overlay.setColor(SELECTED_OVERLAY_COLOR);
this.renderTarget.viewer.requestRedraw();
this._selectedOverlay = overlay;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/*!
* Copyright 2024 Cognite AS
*/
import { Box3 } from 'three';
import { ObservationsDomainObject } from './ObservationsDomainObject';
import { type ObservationsDomainObject } from './ObservationsDomainObject';
import { GroupThreeView } from '../../base/views/GroupThreeView';
import { Overlay3DCollection } from '@cognite/reveal';
import { Observation } from './models';
import { type Overlay3DCollection } from '@cognite/reveal';
import { type Observation } from './models';

export class ObservationsView extends GroupThreeView<ObservationsDomainObject> {
private _collection: Overlay3DCollection<Observation>;
private readonly _collection: Overlay3DCollection<Observation>;

constructor(collection: Overlay3DCollection<Observation>) {
super();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { DmsUniqueIdentifier, FdmNode, Source } from '../../../utilities/FdmSDK';
/*!
* Copyright 2024 Cognite AS
*/
import { type DmsUniqueIdentifier, type FdmNode, type Source } from '../../../utilities/FdmSDK';

export type ObservationProperties = {
// "ID as the node appears in the Source system"
Expand All @@ -12,13 +15,13 @@ export type ObservationProperties = {
// "Text based labels for generic use"
labels: string[];
// "Visibility of node (PUBLIC, PRIVATE, PROTECTED)"
visibility: String;
visibility: string;
// "Who created this node?"
createdBy: String;
createdBy: string;
// "Who was the last person to update this node?"
updatedBy: String;
updatedBy: string;
// "Is this item archived, and therefore hidden from most UIs?"
isArchived: Boolean;
isArchived: boolean;
// "The status of the observation (draft, completed, sent)"
status: string;
// "External ID of the associated CDF Asset"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ export class RevealButtons {
static FitView = (): ReactElement => (
<CommandButtonFromCommand commandConstructor={() => new FitViewCommand()} />
);

static NavigationTool = (): ReactElement => (
<CommandButtonFromCommand commandConstructor={() => new NavigationTool()} />
);

static SetAxisVisible = (): ReactElement => (
<CommandButtonFromCommand commandConstructor={() => new SetAxisVisibleCommand()} />
);

static Measurement = (): ReactElement => (
<CommandButtonFromCommand commandConstructor={() => new MeasurementTool()} />
);

static Clip = (): ReactElement => (
<CommandButtonFromCommand commandConstructor={() => new ClipTool()} />
);
Expand Down
4 changes: 3 additions & 1 deletion react-components/src/components/RevealToolbar/HelpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const HelpButton = ({ fallbackLanguage }: HelpButtonProps): ReactElement
<CogsTooltip content={t('HELP_TOOLTIP', 'Help')} placement="right" appendTo={document.body}>
<Dropdown
appendTo={document.body}
onHide={() => setHelpActive(false)}
onHide={() => {
setHelpActive(false);
}}
hideOnSelect={{ hideOnContentClick: true, hideOnOutsideClick: true }}
/* onClickOutside={() => {
setHelpActive(false);
Expand Down
4 changes: 2 additions & 2 deletions react-components/src/components/RuleBasedOutputs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*/

import { type TreeIndexNodeCollection, type NumericRange } from '@cognite/reveal';
import { type FdmNode, type EdgeItem, DmsUniqueIdentifier } from '../../utilities/FdmSDK';
import { type FdmNode, type EdgeItem, type DmsUniqueIdentifier } from '../../utilities/FdmSDK';
import { type AssetStylingGroup, type FdmPropertyType } from '../Reveal3DResources/types';
import { type Datapoints, type Asset, type Timeseries, type ExternalId } from '@cognite/sdk';
import { type Datapoints, type Asset, type Timeseries } from '@cognite/sdk';

// =========== RULE BASED OUTPUT DATA MODEL

Expand Down

0 comments on commit 35d3016

Please sign in to comment.