Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(styles): fix lint issues #2892

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## How to Contribute
At NS1, it makes us very happy to get pull requests, and we appreciate the time
At NetboxLabs, it makes us very happy to get pull requests, and we appreciate the time
and effort it takes to put one together. Below are a few guidelines that can
help get your pull request approved and merged quickly and easily.

Expand All @@ -19,7 +19,7 @@ guidelines, but ideation and development may take longer or be more involved.
require cross-code base coordination. It can be challenging to identify if a
small change will have large ramifications, so we mainly ask that you keep
this in mind when writing or modifying code. Do your best to preserve
interfaces, and understand that NS1 may need to reject pull requests if they
interfaces, and understand that NetboxLabs may need to reject pull requests if they
would jeopardize platform stability or place an undue burden on other users.

* If there are unit and/or integration tests, keeping the test suites passing
Expand All @@ -35,7 +35,7 @@ guidelines, but ideation and development may take longer or be more involved.

## Opening an issue

Below are a few guidelines for opening an issue on one of NS1's open-source
Below are a few guidelines for opening an issue on one of NetboxLabs's open-source
repositories. Adhering to these guidelines to the best of your ability will
help ensure that requests are resolved quickly and efficiently.

Expand All @@ -47,7 +47,7 @@ help ensure that requests are resolved quickly and efficiently.
the particular problem you are trying to solve. In other words, help us
avoid the "[XY Problem](http://xyproblem.info)".
* **Indicate which products, software versions, and programming languages you
are using.** In your request, indicate which NS1 product(s) you're using and,
are using.** In your request, indicate which NetboxLabs product(s) you're using and,
if relevant, which versions you are running. Also include any third-party
software and versions that are relevant to the issue. If not obvious, include
which programming language(s) you are using.
Expand All @@ -60,19 +60,19 @@ help ensure that requests are resolved quickly and efficiently.

* If an issue is closed by a commit, reference the relevant PR or commit when
closing.
* If an issue is closed by NS1 for any reason, you should expect us to include
* If an issue is closed by NetboxLabs for any reason, you should expect us to include
a reason for it.
* If the fix does not work or is incomplete, you are welcome to re-open or
recreate the issue. When doing so, it's important to be clear about why the
previous fix was inadequate, to clarify the previous problem statement,
and/or to modify the scope of the request. Please keep in mind that project
status consideration or conflicting priorities may require us to close or
defer work on the new or reopened issue. If that happens, feel free to reach
out of support@ns1.com for more information.
out of support@NetboxLabs.com for more information.

## Tags on issues

In some projects we (NS1) may apply basic tags on some issues, for
In some projects we (NetboxLabs) may apply basic tags on some issues, for
organizational purposes. Note: we do not use tags to indicate timelines or
priorities.

Expand Down
1 change: 1 addition & 0 deletions ui/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"defaultSeverity": "warning",
"rules": {
"color-hex-case": "lower",
"color-no-invalid-hex": true,
Expand Down
6 changes: 3 additions & 3 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"build:prod:beta": "npm run config:env && npm run build -- --configuration beta --aot",
"test": "ng test",
"test:coverage": "rimraf coverage && npm run test -- --code-coverage",
"lint": "ng lint",
"lint": "tslint -c ./tslint.json 'src/**/*{.ts,.tsx}'",
"lint:fix": "tslint --fix -c ./tslint.json 'src/**/*{.ts,.tsx}'",
"lint:styles": "stylelint ./src/**/*.scss",
"lint:styles:fix": "stylelint ./src/**/*.scss --fix",
"lint:styles": "npx stylelint './src/**/*.{css,scss}'",
"lint:styles:fix": "npx stylelint './src/**/*.{css,scss}' --fix",
"lint:ci": "npm run lint && npm run lint:styles",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "ng e2e",
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/auth/pages/register/register.component.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@import '../login/login.component';

.accept-group-display{
.accept-group-display {
display: inline-flex;
margin-top: 0.5rem;
align-items: stretch;
.label {
margin-top: 0.9rem;
}
}
}
10 changes: 5 additions & 5 deletions ui/src/app/common/services/filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export class FilterService {
const storedFiltersList = JSON.parse(storedFilters);
let found = false;

storedFiltersList.map((filter) => {
if (filter.name === 'Name' && filter.prop === 'name') {
this.searchName = filter.param;
storedFiltersList.map((f) => {
if (f.name === 'Name' && f.prop === 'name') {
this.searchName = f.param;
found = true;
}
});
Expand Down Expand Up @@ -98,8 +98,8 @@ export class FilterService {
}

getMultiAppliedParams(filterName: string) {
const filter = this._filters.find((f) => f.name === filterName);
return filter?.param ? filter.param : [];
const _filter = this._filters.find((f) => f.name === filterName);
return _filter?.param ? _filter.param : [];
}

// make a decorator out of this?
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/common/services/http-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { StatusCodes } from 'http-status-codes';

export function getStatusCodeText(statusCode: number): string {
return StatusCodes[statusCode];
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@ import { Component, OnInit, ViewChild } from '@angular/core';
import { NotificationsService } from 'app/common/services/notifications/notifications.service';
import { ActivatedRoute, Router } from '@angular/router';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AgentPolicy, AgentPolicyBackend } from 'app/common/interfaces/orb/agent.policy.interface';
import {
AgentPolicy,
AgentPolicyBackend,
} from 'app/common/interfaces/orb/agent.policy.interface';
import { AgentPoliciesService } from 'app/common/services/agents/agent.policies.service';
import { STRINGS } from '../../../../../assets/text/strings';
import { Tags } from 'app/common/interfaces/orb/tag';
import { CodeEditorService } from 'app/common/services/code.editor.service';
import { POLICY_DIODE_CONFIG_JSON, POLICY_DIODE_CONFIG_YAML, POLICY_OTEL_CONFIG_JSON, POLICY_OTEL_CONFIG_YAML, POLICY_PKTVISOR_CONFIG_JSON, POLICY_PKTVISOR_CONFIG_YAML } from 'app/shared/configurations/configurations_schemas';
import {
POLICY_DIODE_CONFIG_JSON,
POLICY_DIODE_CONFIG_YAML,
POLICY_OTEL_CONFIG_JSON,
POLICY_OTEL_CONFIG_YAML,
POLICY_PKTVISOR_CONFIG_JSON,
POLICY_PKTVISOR_CONFIG_YAML,
} from 'app/shared/configurations/configurations_schemas';
const CONFIG = {
TAPS: 'TAPS',
BACKEND: 'BACKEND',
Expand Down Expand Up @@ -37,9 +47,9 @@ export class AgentPolicyAddComponent implements OnInit {
// hold info retrieved
availableBackends: {
[propName: string]: {
backend: string,
description: string,
},
backend: string;
description: string;
};
};

agentPolicy: AgentPolicy;
Expand Down Expand Up @@ -105,11 +115,10 @@ export class AgentPolicyAddComponent implements OnInit {
format = 'yaml';

// #load controls
isLoading = Object.entries(CONFIG)
.reduce((acc, [value]) => {
acc[value] = false;
return acc;
}, {}) as { [propName: string]: boolean };
isLoading = Object.entries(CONFIG).reduce((acc, [value]) => {
acc[value] = false;
return acc;
}, {}) as { [propName: string]: boolean };

selectedTags: Tags;

Expand Down Expand Up @@ -137,9 +146,14 @@ export class AgentPolicyAddComponent implements OnInit {
Promise.all([
this.isEdit ? this.retrieveAgentPolicy() : Promise.resolve(),
this.getBackendsList(),
]).catch(reason => console.warn(`Couldn't fetch data. Reason: ${reason}`))
])
.catch((reason) => console.warn(`Couldn't fetch data. Reason: ${reason}`))
.then(() => this.updateForms())
.catch((reason) => console.warn(`Couldn't fetch ${this.agentPolicy?.backend} data. Reason: ${reason}`));
.catch((reason) =>
console.warn(
`Couldn't fetch ${this.agentPolicy?.backend} data. Reason: ${reason}`,
),
);
}
ngOnInit() {
this.selectedTags = this.agentPolicy?.tags || {};
Expand Down Expand Up @@ -175,29 +189,35 @@ export class AgentPolicyAddComponent implements OnInit {
}

retrieveAgentPolicy() {
return new Promise(resolve => {
this.agentPoliciesService.getAgentPolicyById(this.agentPolicyID).subscribe(policy => {
this.agentPolicy = policy;
this.isLoading[CONFIG.AGENT_POLICY] = false;
resolve(policy);
});
return new Promise((resolve) => {
this.agentPoliciesService
.getAgentPolicyById(this.agentPolicyID)
.subscribe((policy) => {
this.agentPolicy = policy;
this.isLoading[CONFIG.AGENT_POLICY] = false;
resolve(policy);
});
});
}

isLoadComplete() {
return !Object.values(this.isLoading).reduce((prev, curr) => prev || curr, false);
return !Object.values(this.isLoading).reduce(
(prev, curr) => prev || curr,
false,
);
}

readyForms() {
this.detailsFG = this._formBuilder.group({
name: [name, [
name: [
name,
[
Validators.required,
Validators.pattern('^[a-zA-Z_][a-zA-Z0-9_-]*$'),
Validators.maxLength(64),
]],
description: [[
Validators.maxLength(64),
]],
],
],
description: [[Validators.maxLength(64)]],
backend: [[Validators.required]],
});
}
Expand All @@ -209,9 +229,7 @@ export class AgentPolicyAddComponent implements OnInit {
backend,
format,
policy_data,
policy: {
handlers,
},
policy: { handlers },
} = this.agentPolicy;

const wizard = format !== this.format;
Expand All @@ -224,18 +242,22 @@ export class AgentPolicyAddComponent implements OnInit {
this.detailsFG.patchValue({ name, description, backend });

if (wizard) {
this.onBackendSelected(backend).catch(reason => console.warn(`${reason}`));
this.onBackendSelected(backend).catch((reason) =>
console.warn(`${reason}`),
);
}
}

getBackendsList() {
return new Promise((resolve) => {
this.isLoading[CONFIG.BACKEND] = true;
this.agentPoliciesService.getAvailableBackends().subscribe(backends => {
this.availableBackends = !!backends && backends.reduce((acc, curr) => {
acc[curr.backend] = curr;
return acc;
}, {});
this.agentPoliciesService.getAvailableBackends().subscribe((backends) => {
this.availableBackends =
!!backends &&
backends.reduce((acc, curr) => {
acc[curr.backend] = curr;
return acc;
}, {});

this.isLoading[CONFIG.BACKEND] = false;

Expand Down Expand Up @@ -263,7 +285,7 @@ export class AgentPolicyAddComponent implements OnInit {
const reader: FileReader = new FileReader();

reader.onload = (e: any) => {
const fileContent = e.target.result;
const fileContent = e.target.result;
if (this.isJsonMode) {
this.codejson = fileContent;
} else {
Expand All @@ -283,7 +305,11 @@ export class AgentPolicyAddComponent implements OnInit {
description: this.detailsFG.controls.description.value,
backend: this.detailsFG.controls.backend.value,
policy: policy,
version: !!this.isEdit && !!this.agentPolicy.version && this.agentPolicy.version || 1,
version:
(!!this.isEdit &&
!!this.agentPolicy.version &&
this.agentPolicy.version) ||
1,
tags: this.selectedTags,
};
} else {
Expand All @@ -293,7 +319,11 @@ export class AgentPolicyAddComponent implements OnInit {
backend: this.detailsFG.controls.backend.value,
format: this.format,
policy_data: this.codeyaml,
version: !!this.isEdit && !!this.agentPolicy.version && this.agentPolicy.version || 1,
version:
(!!this.isEdit &&
!!this.agentPolicy.version &&
this.agentPolicy.version) ||
1,
tags: this.selectedTags,
};
}
Expand All @@ -303,7 +333,10 @@ export class AgentPolicyAddComponent implements OnInit {
submit(payload) {
this.agentPoliciesService.addAgentPolicy(payload).subscribe(
(next) => {
this.notificationsService.success('Agent Policy successfully created', '');
this.notificationsService.success(
'Agent Policy successfully created',
'',
);
this.viewPolicy(next.id);
},
(error) => {
Expand All @@ -321,21 +354,29 @@ export class AgentPolicyAddComponent implements OnInit {
this.errorConfigMessage = '';
return true;
} else {
this.errorConfigMessage = 'Invalid JSON configuration, check syntax errors.';
this.errorConfigMessage =
'Invalid JSON configuration, check syntax errors.';
return false;
}
} else {
if (this.editor.isYaml(this.codeyaml) && !this.editor.isJson(this.codeyaml)) {
if (
this.editor.isYaml(this.codeyaml) &&
!this.editor.isJson(this.codeyaml)
) {
this.errorConfigMessage = '';
return true;
} else {
this.errorConfigMessage = 'Invalid YAML configuration, check syntax errors.';
this.errorConfigMessage =
'Invalid YAML configuration, check syntax errors.';
return false;
}
}
}
refreshEditor() {
this.editorVisible = false; setTimeout(() => { this.editorVisible = true; }, 0);
this.editorVisible = false;
setTimeout(() => {
this.editorVisible = true;
}, 0);
}
defineDefaultConfig() {
if (this.backendName === AgentPolicyBackend.otel) {
Expand All @@ -344,8 +385,7 @@ export class AgentPolicyAddComponent implements OnInit {
} else if (this.backendName === AgentPolicyBackend.pktvisor) {
this.codeyaml = POLICY_PKTVISOR_CONFIG_YAML;
this.codejson = POLICY_PKTVISOR_CONFIG_JSON;
}
else {
} else {
this.codeyaml = POLICY_DIODE_CONFIG_YAML;
this.codejson = POLICY_DIODE_CONFIG_JSON;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,12 @@ header {
background-color: transparent;
border: none;
outline: none;
font-family: Open Sans,sans-serif;
font-size: .875rem;
font-family: Open Sans, sans-serif;
font-size: 0.875rem;
font-weight: 700;
line-height: 1rem;
text-transform: uppercase;
color: #969fb9;
border: none;
border-bottom: solid 2px transparent;
&:hover {
color: #5aa1ff;
Expand Down
Loading
Loading