Skip to content

Commit

Permalink
spellcheck added
Browse files Browse the repository at this point in the history
  • Loading branch information
yesoreyeram committed Dec 16, 2022
1 parent 596ff0d commit 8f169eb
Show file tree
Hide file tree
Showing 24 changed files with 675 additions and 55 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

## v1.2.1

- Fix for paginaton issue that lead to partial data on the dashboard
- Fix for pagination issue that lead to partial data on the dashboard
- Fix minor bugs with the Scene Viewer and Video Player panels

## v1.2.0
Expand Down
2 changes: 1 addition & 1 deletion Magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// Drone signs the Drone configuration file
// This needs to be run everytime the drone.yml file is modified
// This needs to be run every time the drone.yml file is modified
// See https://github.com/grafana/deployment_tools/blob/master/docs/infrastructure/drone/signing.md for more info
func Drone() error {
if err := sh.RunV("drone", "lint"); err != nil {
Expand Down
51 changes: 51 additions & 0 deletions cspell.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"language": "en",
"ignorePaths": [
"coverage/**",
"cypress/**",
"dist/**",
"go.sum",
"mage_output_file.go",
"node_modules/**",
"pkg/**/*_test.go",
"provisioning/**/*.yaml",
"**/testdata/*.json",
"**/dashboards/*.json",
"src/static/**",
"vendor/**",
"yarn.lock"
],
"words": [
"awsds",
"awserr",
"awsui",
"cacheable",
"datasource",
"datasources",
"entityid",
"esmodules",
"Grafana",
"healthcheck",
"httpadapter",
"httpclient",
"httplogger",
"initalized",
"instancemgmt",
"iottwinmaker",
"magefile",
"patrickmn",
"popperjs",
"queryeditor",
"Roci",
"sceneviewer",
"sitewise",
"testdata",
"testid",
"timeseries",
"TMQE",
"twinmaker",
"undecorate",
"Unsubscribable",
"videoplayer"
]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.3.0",
"description": "Grafana IoT TwinMaker App Plugin",
"scripts": {
"spellcheck": "cspell -c cspell.config.json \"**/*.{ts,tsx,js,go,md,mdx,yml,yaml,json,scss,css}\"",
"build": "rm -rf dist && npx grafana-toolkit plugin:build && mage build:backend",
"test": "grafana-toolkit plugin:test",
"dev": "grafana-toolkit plugin:dev",
Expand All @@ -27,6 +28,7 @@
"@types/react-router-dom": "^5.3.3",
"@types/three": "0.131.0",
"@types/uuid": "^8.3.1",
"cspell": "6.13.3",
"file-loader": "^6.2.0",
"loader-utils": "^2.0.4",
"ts-jest": "26.4.4",
Expand Down
4 changes: 2 additions & 2 deletions pkg/models/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ type TwinMakerQuery struct {
TimeRange backend.TimeRange `json:"-"`
}

func (q *TwinMakerQuery) CacheKey(pfix string) string {
func (q *TwinMakerQuery) CacheKey(prefix string) string {
if q.NextToken != "" {
return "" // not cacheable
}

key := pfix + "~" + q.WorkspaceId + "/" + q.EntityId + "/" + q.ComponentName + "/" + q.ComponentTypeId
key := prefix + "~" + q.WorkspaceId + "/" + q.EntityId + "/" + q.ComponentName + "/" + q.ComponentTypeId

for _, p := range q.Properties {
if p != nil {
Expand Down
22 changes: 11 additions & 11 deletions pkg/plugin/twinmaker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ func NewTwinMakerClient(settings models.TwinMakerDataSourceSetting) (TwinMakerCl
}

// STS client can not use scoped down role to generate tokens
stssettings := noEndpointSettings
stssettings.AssumeRoleARN = ""
stsSettings := noEndpointSettings
stsSettings.AssumeRoleARN = ""

stsSessionConfig := awsds.SessionConfig{
Settings: stssettings,
Settings: stsSettings,
HTTPClient: httpClient,
UserAgentName: &agent,
}

twinMakerService := func() (*iottwinmaker.IoTTwinMaker, error) {
sess, err := sessions.GetSession(noEndpointSessionConfig)
session, err := sessions.GetSession(noEndpointSessionConfig)
if err != nil {
return nil, err
}
sess.Config.Endpoint = &settings.AWSDatasourceSettings.Endpoint
session.Config.Endpoint = &settings.AWSDatasourceSettings.Endpoint

svc := iottwinmaker.New(sess, aws.NewConfig())
svc := iottwinmaker.New(session, aws.NewConfig())
svc.Handlers.Send.PushFront(func(r *request.Request) {
r.HTTPRequest.Header.Set("User-Agent", agent)

Expand All @@ -112,13 +112,13 @@ func NewTwinMakerClient(settings models.TwinMakerDataSourceSetting) (TwinMakerCl
if writerSessionConfig.Settings.AssumeRoleARN == "" {
return nil, fmt.Errorf("writer role not configured")
}
sess, err := sessions.GetSession(writerSessionConfig)
session, err := sessions.GetSession(writerSessionConfig)
if err != nil {
return nil, err
}
sess.Config.Endpoint = &settings.AWSDatasourceSettings.Endpoint
session.Config.Endpoint = &settings.AWSDatasourceSettings.Endpoint

svc := iottwinmaker.New(sess, aws.NewConfig())
svc := iottwinmaker.New(session, aws.NewConfig())
svc.Handlers.Send.PushFront(func(r *request.Request) {
r.HTTPRequest.Header.Set("User-Agent", agent)

Expand All @@ -127,11 +127,11 @@ func NewTwinMakerClient(settings models.TwinMakerDataSourceSetting) (TwinMakerCl
}

tokenService := func() (*sts.STS, error) {
sess, err := sessions.GetSession(stsSessionConfig)
session, err := sessions.GetSession(stsSessionConfig)
if err != nil {
return nil, err
}
svc := sts.New(sess, aws.NewConfig())
svc := sts.New(session, aws.NewConfig())
svc.Handlers.Send.PushFront(func(r *request.Request) {
r.HTTPRequest.Header.Set("User-Agent", agent)
})
Expand Down
16 changes: 8 additions & 8 deletions pkg/plugin/twinmaker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ func (s *twinMakerHandler) GetPropertyValue(ctx context.Context, query models.Tw
frame := data.NewFrame("")

if len(results.PropertyValues) > 0 {
propVals := make([]string, 0, len(results.PropertyValues))
propValues := make([]string, 0, len(results.PropertyValues))
for k := range results.PropertyValues {
propVals = append(propVals, k)
propValues = append(propValues, k)
}
sort.Strings(propVals)
sort.Strings(propValues)

for _, propVal := range propVals {
for _, propVal := range propValues {
prop := results.PropertyValues[propVal]
if v := prop.PropertyValue.ListValue; v != nil {
fr := s.processListValue(v, propVal)
Expand Down Expand Up @@ -382,13 +382,13 @@ func (s *twinMakerHandler) processHistory(results *iottwinmaker.GetPropertyValue
}
fields := newTwinMakerFrameBuilder(len(prop.Values))
// Must return value field first so its labels can be used for the Time field
v, conv := fields.Value(prop.Values[0].Value)
v, conv := fields.Value(prop.Values[0].Value) // cspell:disable-line
t := fields.Time()
v.Name = "" // filled in with value below
for i, history := range prop.Values {
if timeValue, err := getTimeObjectFromStringTime(history.Time); err == nil {
t.Set(i, timeValue)
v.Set(i, conv(history.Value))
v.Set(i, conv(history.Value)) // cspell:disable-line
} else {
dr.Error = fmt.Errorf("error parsing timestamp while loading propertyValueHistory")
}
Expand Down Expand Up @@ -629,8 +629,8 @@ func (s *twinMakerHandler) GetWriteSessionToken(ctx context.Context, duration ti
}

func HandleGetTokenError(err error) error {
if aerr, ok := err.(awserr.Error); ok {
log.DefaultLogger.Error("error getting session token", "code", aerr.Code(), "error", aerr)
if aErr, ok := err.(awserr.Error); ok {
log.DefaultLogger.Error("error getting session token", "code", aErr.Code(), "error", aErr)
return err
}
log.DefaultLogger.Error("error getting session token", "error", err)
Expand Down
4 changes: 2 additions & 2 deletions src/common/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export interface TwinMakerPanelInstance {

/**
* TODO?
* callback when the dashbaord manager discovers an event
* callback when the dashboard manager discovers an event
*/
onDashboardAction: (cmd: any) => void;
}
Expand All @@ -164,7 +164,7 @@ export interface TwinMakerDashboardManager {
*/
getQueryTopics: (panelId?: number) => TwinMakerPanelTopicInfo[];

/** Called when a scene panel initalizes */
/** Called when a scene panel initializes */
registerTwinMakerPanel: (panelId: number, panel: TwinMakerPanelInstance) => void;

/** Called when a scene panel is unmounted */
Expand Down
2 changes: 1 addition & 1 deletion src/common/managerSimple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class SimpleTwinMakerDashboardManager implements TwinMakerDashboardManage
return panelTopicInfo;
}

/** Called when a scene panel initalizes */
/** Called when a scene panel initializes */
registerTwinMakerPanel(panelId: number, panel: TwinMakerPanelInstance) {
const subj = this.getTwinMakerPanelInstance(panelId);
subj.next(panel);
Expand Down
2 changes: 1 addition & 1 deletion src/datasource/appendFrames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getSchemaKey(frame: DataFrame): string {
return key;
}

// TODO: this could likley use the builtin merge transformer, however it was behaving weirdly
// TODO: this could likely use the builtin merge transformer, however it was behaving weirdly
// with arrow time fields ;(
export function appendMatchingFrames(prev: DataFrame[], b: DataFrame[]): DataFrame[] {
const byKey = new Map<string, MutableDataFrame>();
Expand Down
4 changes: 2 additions & 2 deletions src/datasource/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TwinMakerDataSource extends DataSourceWithBackend<TwinMakerQuery, T
return []; // nothing
}
const entityId = getTemplateSrv().replace(query.entityId || '');
const einf = await this.info.getEntityInfo(entityId);
return einf.map((t) => ({ text: t.label!, value: t.value! }));
const eInf = await this.info.getEntityInfo(entityId);
return eInf.map((t) => ({ text: t.label!, value: t.value! }));
}

// put a small cache on this?
Expand Down
2 changes: 1 addition & 1 deletion src/datasource/queryInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const twinMakerQueryTypes: QueryTypeInfo[] = [
{
label: 'Get Property Value History by Component Type',
value: TwinMakerQueryType.ComponentHistory,
description: `Gets the history of a property within a componet of a specific componentType.`,
description: `Gets the history of a property within a component of a specific componentType.`,
defaultQuery: {},
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/usePanelRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect } from 'react';
import { throwError } from 'rxjs';
import { getTwinMakerDashboardManager } from 'common/manager';

export const usePanelRegisteration = (id: number) => {
export const usePanelRegistration = (id: number) => {
useEffect(() => {
getTwinMakerDashboardManager().registerTwinMakerPanel(id, {
twinMakerPanelQueryRunner: () => throwError(() => `not implemented yet (see twinmaker debug panel)`),
Expand Down
6 changes: 3 additions & 3 deletions src/panels/alarm-configuration/AlarmConfigurationPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Entries } from 'aws-sdk/clients/iottwinmaker';

import { getTwinMakerDatasource } from 'common/datasourceSrv';
import { TwinMakerQuery } from 'common/manager';
import { usePanelRegisteration } from 'hooks/usePanelRegistration';
import { usePanelRegistration } from 'hooks/usePanelRegistration';

import { AlarmEditModal } from './AlarmEditModal';
import { processAlarmQueryInput, processAlarmResult } from './alarmParser';
Expand All @@ -35,7 +35,7 @@ export const AlarmConfigurationPanel: React.FunctionComponent<Props> = ({ id, da
() => processAlarmQueryInput(data.request as DataQueryRequest<TwinMakerQuery>),
[data.request]
);
usePanelRegisteration(id);
usePanelRegistration(id);

useEffect(() => {
const doAsync = async () => {
Expand Down Expand Up @@ -116,7 +116,7 @@ export const AlarmConfigurationPanel: React.FunctionComponent<Props> = ({ id, da
<dl>
<dt>Alarm ID</dt>
<dd>{alarmName}</dd>
<dt>Thresold</dt>
<dt>Threshold</dt>
<dd>{alarmThreshold}</dd>
<dt>Notifications</dt>
<dd>{alarmNotificationRecipient}</dd>
Expand Down
2 changes: 1 addition & 1 deletion src/panels/alarm-configuration/alarmParser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function processAlarmResult(data: DataFrame[]): AlarmInfo {
return info;
}

// latest only verison
// latest only version
for (const frame of data) {
const cache = new FieldCache(frame);
if (!frame.length) {
Expand Down
6 changes: 3 additions & 3 deletions src/panels/alarm/alarms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export interface AlarmState {
entityName: string;
}

export interface AlaramInfo {
export interface AlarmInfo {
invalidFormat?: boolean;
warning?: string;
status: Record<string, number>;
alarms: AlarmState[];
}

export function processAlarmResult(data: DataFrame[]): AlaramInfo {
const info: AlaramInfo = { status: {}, alarms: [] };
export function processAlarmResult(data: DataFrame[]): AlarmInfo {
const info: AlarmInfo = { status: {}, alarms: [] };
if (!data?.length) {
info.invalidFormat = true;
info.warning = 'missing data';
Expand Down
2 changes: 1 addition & 1 deletion src/panels/layout/LayoutPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class LayoutPanel extends Component<Props, State> {
}

/**
* Example implementaiton within a panel
* Example implementation within a panel
*/
twinMakerPanelQueryRunner = (query: TwinMakerPanelQuery, options: BaseDataQueryOptions) => {
if (!query.topic) {
Expand Down
2 changes: 1 addition & 1 deletion src/panels/layout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To set up your Dashboard Layout panel (numbers reference the image above):
3. Select the template variables that store the most recently selected entityId and componentName on your dashboard. Template variables can be automatically set by the [Scene Viewer panel](https://github.com/grafana/grafana-iot-twinmaker-app/tree/main/src/panels/scene-viewer/README.md).

4. Define rules that perform an action when a componentTypeId is matched with the selected entityId and componentName.
a. Set the value of tempate variables
a. Set the value of template variables
b. Merge the panels of another Grafana dashboard with the current dashboard

## Panel visuals
Expand Down
2 changes: 1 addition & 1 deletion src/panels/oldStuffFromDatasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { initialize } from '@iot-app-kit/source-iottwinmaker';
import { TMQueryEditorAwsConfig } from 'panels/query-editor/types';

/**
* The initalization process needs revisited here. This simply moves things from
* The initialization process needs revisited here. This simply moves things from
* The Datasource into this temporary file.
*/
export class OldDatasourceStuff {
Expand Down
2 changes: 1 addition & 1 deletion src/panels/scene-viewer/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('panel helpers', () => {
// should use panel gridPos from new panel
expect(mockNewPanels[0].gridPos).toEqual({ h: 4, w: 4, x: 4, y: 4 });
expect(mockCurrentPanels[0].gridPos).toEqual({ h: 4, w: 4, x: 4, y: 4 });
// should keep ther panels
// should keep the panels
expect((mockNewPanels[1] as any).type).toEqual('random-panel');
});

Expand Down
2 changes: 1 addition & 1 deletion src/panels/video-player/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To set up your Video Player panel (numbers reference the image above):

Click "Apply" then save your dashboard.

## Custom time scubber
## Custom time scrubber

Available video:

Expand Down
4 changes: 2 additions & 2 deletions src/transformer/registerTwinMakerLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export function applyTwinMakerLinks(
if (rowIndex != null) {
for (const v of options.vars) {
if (v.fieldName && v.name) {
const vname = 'var-' + v.name.replace('${', '').replace('}', '');
const vName = 'var-' + v.name.replace('${', '').replace('}', '');
const f = data.fields.find((f) => f.name === v.fieldName);
query[vname] = f?.values.get(rowIndex);
query[vName] = f?.values.get(rowIndex);
}
}
}
Expand Down
Loading

0 comments on commit 8f169eb

Please sign in to comment.