Skip to content

Commit

Permalink
Merge pull request #4 from squzy/feat/incident-1
Browse files Browse the repository at this point in the history
Feat/incident 1
  • Loading branch information
PxyUp authored Jul 7, 2020
2 parents cac2ee3 + f6f24c1 commit b14c92f
Show file tree
Hide file tree
Showing 54 changed files with 1,682 additions and 91 deletions.
5 changes: 5 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const routes: Routes = [
loadChildren: () =>
import('./modules/transaction/transaction.module').then((m) => m.TransactionModule),
},
{
path: 'incidents',
loadChildren: () =>
import('./modules/incidents/incidents.module').then((m) => m.IncidentsModule),
},
];

@NgModule({
Expand Down
7 changes: 5 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Component, ChangeDetectionStrategy, OnDestroy, OnInit } from '@angular/core';
import { AppService } from './shared/services/app.service';
import { TranslateService } from '@ngx-translate/core';
import { MatSelectChange } from '@angular/material/select';
import { Subject, BehaviorSubject } from 'rxjs';
import { takeUntil, startWith, tap } from 'rxjs/operators';
import { takeUntil, tap } from 'rxjs/operators';
import { StorageService } from './shared/services/storage.service';

@Component({
Expand Down Expand Up @@ -32,6 +31,10 @@ export class AppComponent implements OnInit, OnDestroy {
path: 'applications',
text: 'MENU.APPLICATIONS',
},
{
path: 'incidents',
text: 'MENU.INCIDNETS',
},
];

private readonly STORAGE_KEY = 'LANG';
Expand Down
1 change: 1 addition & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient } from '@angular/common/http';
import { MatMenuModule } from '@angular/material/menu';
import { RulesModule } from './shared/modules/rules/rules.module';

export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
Expand Down
2 changes: 2 additions & 0 deletions src/app/modules/agents/agents.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { OwlDateTimeModule, OwlNativeDateTimeModule } from '@busacca/ng-pick-dat
import { ReactiveFormsModule } from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { TranslateModule } from '@ngx-translate/core';
import { RulesModule } from 'src/app/shared/modules/rules/rules.module';

const routes: Routes = [
{
Expand Down Expand Up @@ -49,6 +50,7 @@ const routes: Routes = [
OwlNativeDateTimeModule,
ReactiveFormsModule,
MatInputModule,
RulesModule,
TranslateModule.forChild({}),
],
declarations: [AgentsComponent],
Expand Down
108 changes: 62 additions & 46 deletions src/app/modules/agents/components/overview/agents.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,68 @@
[active]="agentLink.isActive"
>{{ agent.agent_name ? agent.agent_name : agent.id }}</a>
</nav>
<ng-container *ngIf="currentId$ | async as id; else selectAgent">
<div class="agent-content">
<mat-card class="content">
<ng-container *ngIf="currentType$ | async as currentType">
<form class="date-form" *ngIf="currentType !== LIVE_TYPE" [formGroup]="rangeForm">
<mat-form-field>
<label for="dateFrom">{{ 'LABELS.FROM' | translate }}:</label>
<input
matInput
[owlDateTimeTrigger]="dateFromComponent"
[owlDateTime]="dateFromComponent"
formControlName="dateFrom"
autocomplete="off"
[errorStateMatcher]="errorMatcher"
>
<owl-date-time [pickerMode]="'dialog'" [showSecondsTimer]="true" #dateFromComponent></owl-date-time>
<mat-error
*ngIf="rangeForm.hasError('dateToLessThenFrom')"
>{{ 'ERRORS.dateToLessThenFrom' | translate }}</mat-error>
</mat-form-field>
<mat-form-field>
<label for="dateTo">{{ 'LABELS.TO' | translate }}:</label>
<input
matInput
[owlDateTimeTrigger]="dateToComponent"
[owlDateTime]="dateToComponent"
formControlName="dateTo"
autocomplete="off"
[errorStateMatcher]="errorMatcher"
>
<owl-date-time [pickerMode]="'dialog'" [showSecondsTimer]="true" #dateToComponent></owl-date-time>
<mat-error
*ngIf="rangeForm.hasError('dateToLessThenFrom')"
>{{ 'ERRORS.dateToLessThenFrom' | translate }}</mat-error>
</mat-form-field>
</form>

<mat-card class="content">
<ng-container *ngIf="currentId$ | async as id; else selectAgent">
<ng-container *ngIf="currentType$ | async as currentType">
<form class="date-form" *ngIf="currentType !== LIVE_TYPE" [formGroup]="rangeForm">
<mat-form-field>
<label for="dateFrom">{{ 'LABELS.FROM' | translate }}:</label>
<input
matInput
[owlDateTimeTrigger]="dateFromComponent"
[owlDateTime]="dateFromComponent"
formControlName="dateFrom"
autocomplete="off"
[errorStateMatcher]="errorMatcher"
>
<owl-date-time [pickerMode]="'dialog'" [showSecondsTimer]="true" #dateFromComponent></owl-date-time>
<mat-error
*ngIf="rangeForm.hasError('dateToLessThenFrom')"
>{{ 'ERRORS.dateToLessThenFrom' | translate }}</mat-error>
</mat-form-field>
<mat-form-field>
<label for="dateTo">{{ 'LABELS.TO' | translate }}:</label>
<input
matInput
[owlDateTimeTrigger]="dateToComponent"
[owlDateTime]="dateToComponent"
formControlName="dateTo"
autocomplete="off"
[errorStateMatcher]="errorMatcher"
>
<owl-date-time [pickerMode]="'dialog'" [showSecondsTimer]="true" #dateToComponent></owl-date-time>
<mat-error
*ngIf="rangeForm.hasError('dateToLessThenFrom')"
>{{ 'ERRORS.dateToLessThenFrom' | translate }}</mat-error>
</mat-form-field>
</form>
<div
class="checkers-layout"
*ngIf="rangeValues$ | async as range"
[ngSwitch]="currentType"
>
<sqd-live-stat [agentId]="id" *ngSwitchCase="LIVE_TYPE"></sqd-live-stat>
<sqd-cpu-stats [range]="range" [agentId]="id" *ngSwitchCase="CPU_TYPE"></sqd-cpu-stats>
<sqd-memory-stat [range]="range" [agentId]="id" *ngSwitchCase="MEMORY_TYPE"></sqd-memory-stat>
<sqd-disks-stat [range]="range" [agentId]="id" *ngSwitchCase="DISK_TYPE"></sqd-disks-stat>
<sqd-net-stat [range]="range" [agentId]="id" *ngSwitchCase="NET_TYPE"></sqd-net-stat>
</div>
</ng-container>
</mat-card>
<mat-card class="content">
<mat-card-header>
<mat-card-title>{{ 'MODULES.CHECKERS.PAGE.INCIDENT_RULES' | translate }}</mat-card-title>
</mat-card-header>
<mat-card-content>
<sqd-rule-list [ownerId]="id" [ownerType]="AGENT_TYPE"></sqd-rule-list>
</mat-card-content>
</mat-card>
</div>
</ng-container>

<div class="checkers-layout" *ngIf="rangeValues$ | async as range" [ngSwitch]="currentType">
<sqd-live-stat [agentId]="id" *ngSwitchCase="LIVE_TYPE"></sqd-live-stat>
<sqd-cpu-stats [range]="range" [agentId]="id" *ngSwitchCase="CPU_TYPE"></sqd-cpu-stats>
<sqd-memory-stat [range]="range" [agentId]="id" *ngSwitchCase="MEMORY_TYPE"></sqd-memory-stat>
<sqd-disks-stat [range]="range" [agentId]="id" *ngSwitchCase="DISK_TYPE"></sqd-disks-stat>
<sqd-net-stat [range]="range" [agentId]="id" *ngSwitchCase="NET_TYPE"></sqd-net-stat>
</div>
</ng-container>
</ng-container>
<ng-template #selectAgent>{{ 'MODULES.AGENT.PAGE.HOME_LABEL' | translate }}</ng-template>
</mat-card>
<ng-template #selectAgent>
<mat-card class="content">{{ 'MODULES.AGENT.PAGE.HOME_LABEL' | translate }}</mat-card>
</ng-template>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ErrorStateMatcher } from '@angular/material/core';
import { FormControl, FormGroupDirective, NgForm, Validators, FormBuilder } from '@angular/forms';
import { minusMinute, FormRangeValue } from 'src/app/shared/date/date';
import { dateFromToValidator } from 'src/app/shared/validators/date.validators';
import { OwnerType } from 'src/app/shared/enums/rules.type';

class CrossFieldErrorMatcher implements ErrorStateMatcher {
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
Expand Down Expand Up @@ -97,6 +98,8 @@ export class AgentsComponent implements OnDestroy {
[AgentsService.CPU]: 'laptop',
};

AGENT_TYPE = OwnerType.INCIDENT_OWNER_TYPE_AGENT;

constructor(
private agentService: AgentsService,
private route: ActivatedRoute,
Expand Down
2 changes: 2 additions & 0 deletions src/app/modules/applications/applications.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { MatSidenavModule } from '@angular/material/sidenav';
import { QueryParamModule } from '@ngqp/core';
import { ApplicationsService } from './services/applications.service';
import { TranslateModule } from '@ngx-translate/core';
import { RulesModule } from 'src/app/shared/modules/rules/rules.module';

const routes: Routes = [
{
Expand Down Expand Up @@ -83,6 +84,7 @@ const routes: Routes = [
MatIconModule,
MatSidenavModule,
QueryParamModule,
RulesModule,
TranslateModule.forChild({}),
],
entryComponents: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
</ng-template>
</mat-card>

<mat-card>
<mat-card-header>
<mat-card-title>{{ 'MODULES.CHECKERS.PAGE.INCIDENT_RULES' | translate }}</mat-card-title>
</mat-card-header>
<mat-card-content>
<sqd-rule-list [ownerId]="currentId$ | async" [ownerType]="APPLICATION_TYPE"></sqd-rule-list>
</mat-card-content>
</mat-card>

<mat-card>
<mat-card-header>
<mat-card-title>{{ 'MODULES.APPLICATIONS.PAGE.TRANSACTIONS' | translate }}</mat-card-title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ApplicationsService } from '../../services/applications.service';
import { ApplicationStatus } from 'src/app/shared/enums/application.type';
import { Subject } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';
import { OwnerType } from 'src/app/shared/enums/rules.type';

@Component({
selector: 'sqd-application',
Expand Down Expand Up @@ -36,6 +37,8 @@ export class ApplicationComponent implements OnDestroy {
},
];

APPLICATION_TYPE = OwnerType.INCIDENT_OWNER_TYPE_APPLICATION;

constructor(private route: ActivatedRoute, private applicationService: ApplicationsService) {}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ $padding: 40px;
width: 100%;
}
table {
width: 100%;
.mat-row {
&:hover {
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ng-container>

<ng-container matColumnDef="StartTime">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
<th class="no-focused" mat-header-cell *matHeaderCellDef mat-sort-header>
<mat-form-field>
<mat-label>{{ 'LABELS.FROM' | translate }}:</mat-label>
<input
Expand All @@ -29,7 +29,7 @@
</ng-container>

<ng-container matColumnDef="EndTime">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
<th class="no-focused" mat-header-cell *matHeaderCellDef mat-sort-header>
<mat-form-field>
<mat-label>{{ 'LABELS.TO' | translate }}:</mat-label>
<input
Expand Down Expand Up @@ -80,7 +80,7 @@
<th mat-header-cell *matHeaderCellDef>
<mat-form-field>
<mat-label>{{ 'MODULES.APPLICATIONS.TRANSACTION_LIST.STATUS' | translate}}</mat-label>
<mat-select (selectionChange)="onStatusChange($event)" [value]="type.value">
<mat-select (selectionChange)="onStatusChange($event)" [value]="status.value">
<mat-option
*ngFor="let trStatus of statuses"
[value]="trStatus"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
table {
width: 100%;
overflow-x: scroll;
display: block;
overflow-x: scroll;
.mat-row {
&:hover {
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ export class TransactionsListComponent implements AfterViewInit, OnInit, OnDestr

types = TransactionTypes;

// private autoRefresh_$ = new BehaviorSubject(false);

// private readonly refresh$ = new BehaviorSubject(null);

queryFilterGroup = this.qpb.group({
[TransactionsListComponent.queryParam.dateFrom]: this.qpb.param(
TransactionsListComponent.queryParam.dateFrom,
Expand Down
2 changes: 2 additions & 0 deletions src/app/modules/checkers/checkers.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { SchedulerConfigComponent } from './components/checker/config/config.com
import { SchedulerSnapshotComponent } from './components/checker/snapshot/snapshot.component';
import { MatSelectModule } from '@angular/material/select';
import { TranslateModule } from '@ngx-translate/core';
import { RulesModule } from 'src/app/shared/modules/rules/rules.module';

const routes: Routes = [
{
Expand Down Expand Up @@ -59,6 +60,7 @@ const routes: Routes = [
MatIconModule,
MatCheckboxModule,
MatProgressSpinnerModule,
RulesModule,
TranslateModule.forChild({}),
],
providers: [CheckersService],
Expand Down
13 changes: 11 additions & 2 deletions src/app/modules/checkers/components/checker/checker.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="flex">
<mat-card class="flex flex-column width-50" *ngIf="checkInfo$ | async as info">
<mat-card-header>
<mat-card-title>{{ 'MODULES.CHECKERS.PAGE.CONFIGURATION' | translate }}</mat-card-title>
<mat-card-title class="without-margin">{{ 'MODULES.CHECKERS.PAGE.CONFIGURATION' | translate }}</mat-card-title>
<button
*ngIf="info.status === statuses.STOPPED"
mat-icon-button
Expand Down Expand Up @@ -83,7 +83,7 @@
<mat-card class="flex flex-column width-50">
<ng-container *ngIf="uptime$ | async as info; else loading">
<mat-card-header>
<mat-card-title>{{ 'MODULES.CHECKERS.PAGE.STATISTICS' | translate }}</mat-card-title>
<mat-card-title class="without-margin">{{ 'MODULES.CHECKERS.PAGE.STATISTICS' | translate }}</mat-card-title>
</mat-card-header>
<mat-card-content class="flex">
<div class="column width-100">
Expand Down Expand Up @@ -111,6 +111,15 @@
</mat-card>
</div>

<mat-card>
<mat-card-header>
<mat-card-title>{{ 'MODULES.CHECKERS.PAGE.INCIDENT_RULES' | translate }}</mat-card-title>
</mat-card-header>
<mat-card-content>
<sqd-rule-list [ownerId]="currentId$ | async" [ownerType]="SCHDEDULER_TYPE"></sqd-rule-list>
</mat-card-content>
</mat-card>

<mat-card>
<mat-card-content class="flex">
<form [formGroup]="filterForm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ $padding: 40px;
mat-card {
mat-card-header::ng-deep {
mat-card-title {
margin-bottom: 0px;
&.without-margin {
margin-bottom: 0px;
}
}
width: 100%;
.mat-card-header-text {
Expand Down Expand Up @@ -56,8 +58,6 @@ $padding: 40px;
flex-direction: column;
}
table {
width: 100%;

.mat-row {
&:hover {
cursor: pointer;
Expand Down
11 changes: 9 additions & 2 deletions src/app/modules/checkers/components/checker/checker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ import { SchedulerConfigComponent } from './config/config.component';
import { dateFromToValidator } from 'src/app/shared/validators/date.validators';
import { SchedulerSnapshotComponent } from './snapshot/snapshot.component';
import { CheckerDataSource } from './datasource/checker.datasource';
import { SortSchedulerList, angularSortDirectionMap } from 'src/app/shared/enums/sort.table';
import { SchedulerStatus, SchedulerResponseCode } from 'src/app/shared/enums/schedulers.type';
import { angularSortDirectionMap } from 'src/app/shared/enums/sort.table';
import {
SchedulerStatus,
SchedulerResponseCode,
SortSchedulerList,
} from 'src/app/shared/enums/schedulers.type';
import { OwnerType } from 'src/app/shared/enums/rules.type';

class CrossFieldErrorMatcher implements ErrorStateMatcher {
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
Expand Down Expand Up @@ -90,6 +95,8 @@ export class CheckerComponent implements OnInit, OnDestroy {

currentId$ = this.route.params.pipe(map((p) => p.id as string));

SCHDEDULER_TYPE = OwnerType.INCIDENT_OWNER_TYPE_SCHEDULER;

dataSource = new CheckerDataSource(this.checkersService);

checkInfo$ = combineLatest(this.refresh$, this.currentId$).pipe(
Expand Down
Loading

0 comments on commit b14c92f

Please sign in to comment.