Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e8a7200b5f | |||
| ce01a52e0f | |||
| 783b198eba | |||
| 99966f03cd | |||
| e5344b4e7d | |||
| da96f2ea7d |
@@ -1,9 +1,35 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
import { environment } from '../../environments/environment';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
|
const httpOptions = {
|
||||||
|
headers: new HttpHeaders({
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: '',
|
||||||
|
Accept: 'application/json'
|
||||||
|
})
|
||||||
|
};
|
||||||
|
const httpFileOptions = {
|
||||||
|
headers: new HttpHeaders({
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
Accept: 'multipart/form-data'
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class ApiService {
|
export class ApiService {
|
||||||
|
|
||||||
constructor() { }
|
constructor(private http: HttpClient) { }
|
||||||
|
|
||||||
|
// get variable values
|
||||||
|
public getVariableValus(imei:any): Observable<any> {
|
||||||
|
return this.http.get<any>(`http://13.202.55.56/backend/Sadmin/EniAnalyticsRawData/getRawData?imei=${imei}`,)
|
||||||
|
.pipe(map(user => {
|
||||||
|
return user;
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { BehaviorSubject, Observable } from 'rxjs';
|
|||||||
import { User } from '../_models';
|
import { User } from '../_models';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { map } from 'rxjs/operators';
|
||||||
|
import { environment } from 'src/environments/environment';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -22,4 +24,24 @@ export class AuthService {
|
|||||||
public get userValue(): User {
|
public get userValue(): User {
|
||||||
return this.userSubject.value;
|
return this.userSubject.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// API's
|
||||||
|
|
||||||
|
login(adminData: any) {
|
||||||
|
return this.http
|
||||||
|
.post<any>(`${environment.apiUrl}authorize/web-login/`, adminData)
|
||||||
|
.pipe(
|
||||||
|
map((user) => {
|
||||||
|
localStorage.removeItem('currentUser');
|
||||||
|
if (user && user.token) {
|
||||||
|
localStorage.setItem('currentUser', JSON.stringify(user));
|
||||||
|
localStorage.setItem('token', user.token.access);
|
||||||
|
this.userSubject.next(user);
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { AuthService } from 'src/app/_services';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
@@ -10,7 +12,7 @@ export class LoginComponent implements OnInit {
|
|||||||
public loginForm!: FormGroup
|
public loginForm!: FormGroup
|
||||||
public submited: boolean = false
|
public submited: boolean = false
|
||||||
|
|
||||||
constructor(private formBuilder: FormBuilder) { }
|
constructor(private formBuilder: FormBuilder,private auth:AuthService, private router: Router) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.loginForm = this.formBuilder.group(
|
this.loginForm = this.formBuilder.group(
|
||||||
@@ -35,7 +37,22 @@ export class LoginComponent implements OnInit {
|
|||||||
this.submited = true;
|
this.submited = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const reqObj = {
|
||||||
|
userName: this.loginForm.value.username,
|
||||||
|
password: this.loginForm.value.password,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.auth.login(reqObj).subscribe(
|
||||||
|
(data: any) => {
|
||||||
|
this.router.navigateByUrl('/admin/dashboard');
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
localStorage.clear();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
import { ConfirmPasswordValidator } from 'src/app/_helper/matchpassword.validators';
|
import { ConfirmPasswordValidator } from 'src/app/_helper/matchpassword.validators';
|
||||||
|
import { AuthService } from 'src/app/_services';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-sign-up',
|
selector: 'app-sign-up',
|
||||||
templateUrl: './sign-up.component.html',
|
templateUrl: './sign-up.component.html',
|
||||||
@@ -9,14 +11,13 @@ import { ConfirmPasswordValidator } from 'src/app/_helper/matchpassword.validato
|
|||||||
export class SignUpComponent implements OnInit {
|
export class SignUpComponent implements OnInit {
|
||||||
public signupForm!: FormGroup;
|
public signupForm!: FormGroup;
|
||||||
public submitted: boolean = false;
|
public submitted: boolean = false;
|
||||||
constructor(private formBuilder: FormBuilder) {}
|
constructor(private formBuilder: FormBuilder, private router: Router, private auth: AuthService) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.signupForm = this.formBuilder.group(
|
this.signupForm = this.formBuilder.group(
|
||||||
{
|
{
|
||||||
fullname: ['', Validators.required],
|
fullname: ['', Validators.required],
|
||||||
imei: ['', Validators.required],
|
imei: ['', Validators.required],
|
||||||
email: ['', [Validators.required, Validators.email]],
|
|
||||||
password: [
|
password: [
|
||||||
'',
|
'',
|
||||||
[
|
[
|
||||||
@@ -42,5 +43,19 @@ export class SignUpComponent implements OnInit {
|
|||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const reqObj = {
|
||||||
|
fullName: this.signupForm.value.fullname,
|
||||||
|
imei: this.signupForm.value.imei,
|
||||||
|
password: this.signupForm.value.password,
|
||||||
|
confirmPassword : this.signupForm.value.confirmPassword,
|
||||||
|
};
|
||||||
|
this.auth.login(reqObj).subscribe(
|
||||||
|
(data: any) => {
|
||||||
|
this.router.navigateByUrl('/login');
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
localStorage.clear();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ import { AppRoutingModule } from './app-routing.module';
|
|||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { SignUpComponent } from './_shared/sign-up/sign-up.component';
|
import { SignUpComponent } from './_shared/sign-up/sign-up.component';
|
||||||
import { LoginComponent } from './_shared/login/login.component';
|
import { LoginComponent } from './_shared/login/login.component';
|
||||||
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
||||||
import { JwtInterceptor } from './_helper/jwt.interceptor';
|
import { JwtInterceptor } from './_helper/jwt.interceptor';
|
||||||
import { ErrorInterceptor } from './_helper/error.interceptor';
|
import { ErrorInterceptor } from './_helper/error.interceptor';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
import { NumberOnlyDirective } from './_helper/number-only.directive';
|
import { NumberOnlyDirective } from './_helper/number-only.directive';
|
||||||
import { VeriableFormComponent } from './pages/veriable-form/veriable-form.component';
|
import { VeriableFormComponent } from './pages/veriable-form/veriable-form.component';
|
||||||
|
import { HeaderComponent } from './pages/header/header.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -20,6 +21,7 @@ import { VeriableFormComponent } from './pages/veriable-form/veriable-form.compo
|
|||||||
LoginComponent,
|
LoginComponent,
|
||||||
NumberOnlyDirective,
|
NumberOnlyDirective,
|
||||||
VeriableFormComponent,
|
VeriableFormComponent,
|
||||||
|
HeaderComponent,
|
||||||
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
@@ -27,6 +29,7 @@ import { VeriableFormComponent } from './pages/veriable-form/veriable-form.compo
|
|||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
|
HttpClientModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
|
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
|
||||||
|
|||||||
24
src/app/pages/header/header.component.html
Normal file
24
src/app/pages/header/header.component.html
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<header class=" bg-light">
|
||||||
|
<div class="container">
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light">
|
||||||
|
<a class="navbar-brand" href="#"> <img src="https://enianalytics.com/images/eni-tech-logo.png" alt="lohi"> </a>
|
||||||
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item active">
|
||||||
|
<a class="nav-link" href="#">form 1 <span class="sr-only">(current)</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">form 2</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#">form 3</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
20
src/app/pages/header/header.component.sass
Normal file
20
src/app/pages/header/header.component.sass
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
header
|
||||||
|
border-bottom: 1px solid #cccccc3b
|
||||||
|
box-shadow: 0 0 8px #c2c2c252
|
||||||
|
|
||||||
|
.bg-light
|
||||||
|
background: #fff!important
|
||||||
|
|
||||||
|
nav img
|
||||||
|
width: 100px
|
||||||
|
|
||||||
|
ul li a
|
||||||
|
font-weight: 600
|
||||||
|
font-family: 'Inter', sans-serif
|
||||||
|
font-size: 14px
|
||||||
|
text-transform: uppercase
|
||||||
|
color: #444444
|
||||||
|
|
||||||
|
ul li.active a, ul li:hover a
|
||||||
|
color:#e76b20
|
||||||
|
|
||||||
25
src/app/pages/header/header.component.spec.ts
Normal file
25
src/app/pages/header/header.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { HeaderComponent } from './header.component';
|
||||||
|
|
||||||
|
describe('HeaderComponent', () => {
|
||||||
|
let component: HeaderComponent;
|
||||||
|
let fixture: ComponentFixture<HeaderComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ HeaderComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(HeaderComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
15
src/app/pages/header/header.component.ts
Normal file
15
src/app/pages/header/header.component.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-header',
|
||||||
|
templateUrl: './header.component.html',
|
||||||
|
styleUrls: ['./header.component.sass']
|
||||||
|
})
|
||||||
|
export class HeaderComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,46 +1,41 @@
|
|||||||
|
<app-header></app-header>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="variableCal">
|
<div class="variableCal">
|
||||||
<form [formGroup]="formGroup">
|
<form [formGroup]="form" (ngSubmit)="onSubmit()">
|
||||||
|
<div formArrayName="rows">
|
||||||
<div class="form-group" formArrayName="items" *ngFor="let item of items.controls; let i = index">
|
<div *ngFor="let row of rows.controls; let rowIndex = index" [formGroupName]="rowIndex" class="row-section">
|
||||||
<div class="row" [formGroupName]="i">
|
<div formArrayName="columns" class="add-col-section">
|
||||||
<div class="col-md-3">
|
<div class="" *ngFor="let column of getColumns(row).controls; let colIndex = index" [formGroupName]="colIndex" class="column-section">
|
||||||
<select formControlName="type" (change)="onTypeChange(i)" class="form-control">
|
<div class="form-group">
|
||||||
<option value="" selected disabled > Select </option>
|
<select formControlName="type" class="form-control">
|
||||||
<option value="variable">Variable</option>
|
<option value="" selected disabled>--Select--</option>
|
||||||
<option value="text">Text</option>
|
<option value="text">Text</option>
|
||||||
</select>
|
<option value="variable">Variable</option>
|
||||||
</div>
|
</select>
|
||||||
|
</div>
|
||||||
<div class="col-md-3" *ngIf="item.get('type')?.value === 'variable'">
|
<div class="form-group" *ngIf="isText(row, colIndex)">
|
||||||
<select formControlName="variable" class="form-control">
|
<input type="text" formControlName="textValue" placeholder="Enter text" class="form-control"
|
||||||
<option value="" selected disabled > Select </option>
|
(change)="onParamChange($event, rowIndex, colIndex)"> <span> {{inputValue}} </span>
|
||||||
<option *ngFor="let v of variableList" [value]="v">{{ v }}</option>
|
</div>
|
||||||
</select>
|
<div class="form-group" *ngIf="isVariable(row, colIndex)">
|
||||||
<div>
|
<input formControlName="variableValue" class="form-control" placeholder="Enter variable">
|
||||||
<p>Variable Calculation: {{ calculateVariable(i) }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="item.get('type')?.value === 'text'" class="col-md-3">
|
|
||||||
<input formControlName="text" placeholder="Enter text here" class="form-control" />
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<button class="btn btn-danger" (click)="removeRow(i)" *ngIf="items.length > 1">Remove Row</button>
|
|
||||||
<button class="btn btn-primary ml-2" (click)="addRow()" *ngIf="i === items.length - 1">Add Row</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Button to add a new column in the same row -->
|
||||||
|
<button type="button" class="add-column-btn btn btn-success mt-0 " (click)="addColumn(rowIndex)">Add</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
</div>
|
||||||
<div class="col-md-12">
|
|
||||||
<button type="submit" class="btn btn-primary" (click)="onSubmit()" >Submit</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
<!-- Button to add a new row -->
|
||||||
</div>
|
<button type="button" class="add-row-btn btn btn-secondary mr-2 mt-0" (click)="addRow()">Add</button>
|
||||||
|
|
||||||
|
<button type="submit" class="submit-btn btn btn-success mt-0">Submit</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
.container
|
||||||
|
margin-top: 20px
|
||||||
|
|
||||||
|
.add-col-section
|
||||||
|
display: flex
|
||||||
|
flex-direction: row
|
||||||
|
|
||||||
|
.add-col-section div
|
||||||
|
display:flex
|
||||||
|
flex-direction: row
|
||||||
|
|
||||||
|
.column-section
|
||||||
|
width: auto
|
||||||
|
display: flex
|
||||||
|
flex-direction: row
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
margin-bottom: 15px
|
||||||
|
width: 150px
|
||||||
|
display: flex
|
||||||
|
margin-right: 10px!important
|
||||||
|
|
||||||
|
.add-column-btn
|
||||||
|
margin-top: 10px
|
||||||
|
display: block
|
||||||
|
|
||||||
|
.add-row-btn
|
||||||
|
margin-top: 20px
|
||||||
|
|
||||||
|
.submit-btn
|
||||||
|
margin-top: 30px
|
||||||
|
|
||||||
|
.row-section
|
||||||
|
border: 1px solid #ccc
|
||||||
|
padding: 20px
|
||||||
|
margin-bottom: 20px
|
||||||
|
position: relative
|
||||||
|
|
||||||
|
@media (min-width: 768px)
|
||||||
|
.add-col-section
|
||||||
|
display: flex // Ensures that the columns are stacked vertically
|
||||||
|
|
||||||
|
.column-section
|
||||||
|
display: flex
|
||||||
|
margin-bottom: 15px
|
||||||
|
flex-direction: row
|
||||||
|
|
||||||
|
.row-section
|
||||||
|
padding: 20px
|
||||||
|
overflow-y: auto
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||||
|
import { Observable, Subject } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
import { ApiService } from 'src/app/_services';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-veriable-form',
|
selector: 'app-veriable-form',
|
||||||
@@ -7,57 +11,90 @@ import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
|||||||
styleUrls: ['./veriable-form.component.sass']
|
styleUrls: ['./veriable-form.component.sass']
|
||||||
})
|
})
|
||||||
export class VeriableFormComponent implements OnInit {
|
export class VeriableFormComponent implements OnInit {
|
||||||
formGroup: FormGroup;
|
form: FormGroup;
|
||||||
variableList = ['Variable1', 'Variable2', 'Variable3']; // Example variable list
|
public componentDestroyed = new Subject();
|
||||||
|
rdsValues: any;
|
||||||
|
selectedParamValue: any = {};
|
||||||
|
inputValue: any;
|
||||||
|
|
||||||
constructor(private fb: FormBuilder) {
|
constructor(private fb: FormBuilder, private api: ApiService) {
|
||||||
this.formGroup = this.fb.group({
|
this.form = this.fb.group({
|
||||||
items: this.fb.array([this.createItem()])
|
rows: this.fb.array([])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
// Initialize with one row
|
||||||
|
this.addRow();
|
||||||
|
this.getVarbaleValusData();
|
||||||
}
|
}
|
||||||
|
|
||||||
get items() {
|
get rows(): FormArray {
|
||||||
return this.formGroup.get('items') as FormArray;
|
return this.form.get('rows') as FormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
createItem(): FormGroup {
|
getColumns(row: any): FormArray {
|
||||||
|
return row.get('columns') as FormArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
isText(row: any, colIndex: number): boolean {
|
||||||
|
const columns = this.getColumns(row);
|
||||||
|
return columns.at(colIndex).get('type')?.value === 'text';
|
||||||
|
}
|
||||||
|
|
||||||
|
isVariable(row: any, colIndex: number): boolean {
|
||||||
|
const columns = this.getColumns(row);
|
||||||
|
return columns.at(colIndex).get('type')?.value === 'variable';
|
||||||
|
}
|
||||||
|
|
||||||
|
createColumn(): FormGroup {
|
||||||
return this.fb.group({
|
return this.fb.group({
|
||||||
type: [''],
|
type: [''],
|
||||||
variable: [''],
|
textValue: [''],
|
||||||
text: ['']
|
variableValue: ['']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addRow() {
|
addColumn(rowIndex: number): void {
|
||||||
this.items.push(this.createItem());
|
const row = this.rows.at(rowIndex).get('columns') as FormArray;
|
||||||
|
row.push(this.createColumn());
|
||||||
}
|
}
|
||||||
|
|
||||||
removeRow(index: number) {
|
addRow(): void {
|
||||||
this.items.removeAt(index);
|
const row = this.fb.group({
|
||||||
|
columns: this.fb.array([this.createColumn()])
|
||||||
|
});
|
||||||
|
this.rows.push(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
onTypeChange(index: number) {
|
getVarbaleValusData(){
|
||||||
const type = this.items?.at(index)?.get('type')?.value;
|
const imei = 869009061127230
|
||||||
if (type === 'variable') {
|
this.api.getVariableValus(imei)
|
||||||
this.items?.at(index)?.get('text')?.setValue('');
|
.pipe(takeUntil(this.componentDestroyed))
|
||||||
} else {
|
.subscribe((res:any)=>{
|
||||||
this.items?.at(index)?.get('variable')?.setValue('');
|
this.rdsValues = res.resultObject
|
||||||
|
},(error:HttpErrorResponse)=>{
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onParamChange(event: any, rowIndex: number, colIndex: number) {
|
||||||
|
const selectedParam = event.target.value;
|
||||||
|
|
||||||
|
for (let item of this.rdsValues.modbus) {
|
||||||
|
if (item.hasOwnProperty(selectedParam)) {
|
||||||
|
if (!this.selectedParamValue[rowIndex]) {
|
||||||
|
this.selectedParamValue[rowIndex] = {};
|
||||||
|
}
|
||||||
|
this.selectedParamValue[rowIndex][colIndex] = item[selectedParam];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.inputValue = this.selectedParamValue[rowIndex][colIndex]
|
||||||
|
console.log(`Row: ${rowIndex}, Column: ${colIndex}, Value:`, this.selectedParamValue[rowIndex][colIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateVariable(index: number): string {
|
|
||||||
const selectedVariable = this.items?.at(index)?.get('variable')?.value;
|
onSubmit(): void {
|
||||||
return `Calculated value for ${selectedVariable}`;
|
console.log(this.form.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
|
||||||
const formData = this.formGroup.value;
|
|
||||||
console.log(formData);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body class="mat-typography">
|
<body class="mat-typography">
|
||||||
<app-root></app-root>
|
<app-root></app-root>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user