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

styles(ui): scss and ts linting errors fixed #2890

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
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
6 changes: 3 additions & 3 deletions ui/src/app/pages/fleet/agents/key/agent.key.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ nb-card {
border: 0 transparent;
color: #969fb9;
position: relative;
top: -0.10rem;
top: -0.1rem;
right: -0.15rem;
outline: none;
max-height: 28px !important;
Expand Down Expand Up @@ -104,13 +104,13 @@ a {
fill: #3089fc !important;
}
.command-card {
margin: 1.5rem 0 !important;
margin: 1.5rem 0 !important;
background-color: #1c2339 !important;
padding: 0 !important;
border: transparent;
nb-card-header {
border: none !important;
border-radius: 0px !important;
border-radius: 0 !important;
}
nb-card-body {
margin: 0 !important;
Expand Down
8 changes: 4 additions & 4 deletions ui/src/app/pages/fleet/agents/list/agent.list.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ input[type=checkbox] {
margin-left: 10px;
}
.selected-buttons {
width: 270px;
display: flex;
align-self: flex-end;
gap: 5px;
width: 270px;
display: flex;
align-self: flex-end;
gap: 5px;
}
.agent-reset {
color: #fff !important;
Expand Down
Loading
Loading