business and users
This commit is contained in:
parent
4307745647
commit
853cec925a
@ -34,7 +34,8 @@
|
||||
"calendar-utils/date-adapters/date-fns",
|
||||
"contra/emitter",
|
||||
"@mattlewis92/dom-autoscroller",
|
||||
"CommonJS"
|
||||
"CommonJS",
|
||||
"sweetalert2"
|
||||
],
|
||||
"styles": [
|
||||
"node_modules/quill/dist/quill.snow.css",
|
||||
|
||||
@ -19,7 +19,7 @@ const routes: Routes = [ {
|
||||
|
||||
{
|
||||
path: 'add-user-list',
|
||||
component: AddUserListComponent
|
||||
component: UserListComponent
|
||||
},
|
||||
// {
|
||||
// path: 'user-list',
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
{{business.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="businessselect.hasError('required')">Please choose an animal</mat-error>
|
||||
<mat-error *ngIf="businessselect.hasError('required')">Please Business</mat-error>
|
||||
<mat-error *ngIf="businessselect.hasError('invalidValue')">Please choose any other</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
@ -19,6 +19,20 @@
|
||||
<mat-error *ngIf="myError('bus_name', 'required')">Name is required</mat-error>
|
||||
<mat-error *ngIf="myError('bus_name', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput type="text" placeholder="Email" formControlName="email" id="email">
|
||||
<mat-error *ngIf="!form.get('email')?.errors?.required && (form.get('email')?.errors?.pattern)">
|
||||
Please enter a valid email address
|
||||
</mat-error>
|
||||
<mat-error *ngIf="form.get('email')?.invalid && (form.get('email')?.dirty || form.get('email')?.touched) && form.get('email')?.errors?.required">
|
||||
Email is required
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput type="text" placeholder="Enter Phone No" formControlName="contact_no" id="contact_no">
|
||||
<mat-error *ngIf="myError('contact_no', 'required')">Contact No is required</mat-error>
|
||||
<mat-error *ngIf="myError('contact_no', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput type="text" placeholder="Enter Address" formControlName="address" id="address">
|
||||
<mat-error *ngIf="myError('address', 'required')">Address is required</mat-error>
|
||||
@ -34,20 +48,7 @@
|
||||
<mat-error *ngIf="myError('city', 'required')">City is required</mat-error>
|
||||
<mat-error *ngIf="myError('city', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput type="text" placeholder="Email" formControlName="email" id="email">
|
||||
<mat-error *ngIf="!form.get('email')?.errors?.required && (form.get('email')?.errors?.pattern)">
|
||||
Please enter a valid email address
|
||||
</mat-error>
|
||||
<mat-error *ngIf="form.get('email')?.invalid && (form.get('email')?.dirty || form.get('email')?.touched) && form.get('email')?.errors?.required">
|
||||
Email is required
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput type="text" placeholder="Enter Contact No" formControlName="contact_no" id="contact_no">
|
||||
<mat-error *ngIf="myError('contact_no', 'required')">Contact No is required</mat-error>
|
||||
<mat-error *ngIf="myError('contact_no', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-checkbox color="primary" formControlName="go_Admin"></mat-checkbox>
|
||||
<div class="vertical-center">
|
||||
<button class="mat-green" mat-raised-button type="submit">Submit</button>
|
||||
</div>
|
||||
|
||||
@ -3,6 +3,7 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { MatTable, MatTableDataSource } from '@angular/material/table';
|
||||
import { Router } from '@angular/router';
|
||||
import Swal from 'sweetalert2/dist/sweetalert2.js';
|
||||
import { BusinessService } from '../business-service/business.service';
|
||||
import { DialogBoxComponent } from '../dialog-box/dialog-box.component';
|
||||
@ -45,7 +46,7 @@ export class BusinessListComponent implements OnInit {
|
||||
businessList: any;
|
||||
|
||||
|
||||
constructor(public dialog: MatDialog,public _bus:BusinessService) {}
|
||||
constructor(private router:Router,public dialog: MatDialog,public _bus:BusinessService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.dataSource = new MatTableDataSource(ELEMENT_DATA)
|
||||
@ -129,14 +130,16 @@ export class BusinessListComponent implements OnInit {
|
||||
console.log('add')
|
||||
let addFormData = {
|
||||
address: row_obj.address,
|
||||
logo:row_obj.logo,
|
||||
// busId: 'abc123',
|
||||
city: row_obj.city,
|
||||
busName: row_obj.busName,
|
||||
email: row_obj.email,
|
||||
contactNo: row_obj.contactNo,
|
||||
pincode: row_obj.pincode,
|
||||
// pincode: row_obj.pincode,
|
||||
state: row_obj.state ,
|
||||
workingHrsJson: row_obj.workingHrsJson
|
||||
createdBy:row_obj.createdBy
|
||||
// workingHrsJson: row_obj.workingHrsJson
|
||||
};
|
||||
formValue.push(addFormData);
|
||||
}else if(result.event == 'Update'){
|
||||
@ -157,7 +160,10 @@ export class BusinessListComponent implements OnInit {
|
||||
this._bus.addFormDetails(formValue[0]).subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
// this.customersList = res.data;
|
||||
this.getBusinessList()
|
||||
this.getBusinessList()
|
||||
// if(result.event == 'Add' && row_obj.admin_checked == true){
|
||||
// this.router.navigate(['/add-user-list'])
|
||||
// }
|
||||
}
|
||||
else{
|
||||
// this.customersList=[];
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder=" Phone" matInput [(ngModel)]="local_data.contactNo" formControlName="contactNo">
|
||||
<input placeholder="Phone No" matInput [(ngModel)]="local_data.contactNo" formControlName="contactNo">
|
||||
<mat-error *ngIf="myError('contactNo', 'required')">Contact No is required</mat-error>
|
||||
<mat-error *ngIf="myError('contactNo', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
@ -33,7 +33,7 @@
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder=" State" matInput [(ngModel)]="local_data.state" formControlName="state">
|
||||
<mat-error *ngIf="myError('state', 'required')">City is required</mat-error>
|
||||
<mat-error *ngIf="myError('state', 'required')">State is required</mat-error>
|
||||
<mat-error *ngIf="myError('state', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
@ -41,13 +41,14 @@
|
||||
<mat-error *ngIf="myError('city', 'required')">City is required</mat-error>
|
||||
<mat-error *ngIf="myError('city', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<!-- <mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder="Working Hrs" matInput formControlName="workingHrsJson">
|
||||
<mat-error *ngIf="myError('workingHrsJson', 'required')">Working Hrs is required</mat-error>
|
||||
<mat-error *ngIf="myError('workingHrsJson', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
</mat-form-field> -->
|
||||
<img class="image mb-2" [src]="url" height="50">
|
||||
<input type='file' (change)="onSelectFile($event)" formControlName="logo">
|
||||
<input type='file' (change)="onSelectFile($event)" formControlName="logo">
|
||||
<!-- <mat-checkbox class="example-margin mt-2" formControlName="admin_checked" (change)="showOptions($event)">Add Admin</mat-checkbox> -->
|
||||
|
||||
</div>
|
||||
</ng-scrollbar>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Component, Inject, OnInit, Optional } from '@angular/core';
|
||||
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { Router } from '@angular/router';
|
||||
export interface UsersData {
|
||||
@ -28,8 +29,10 @@ export class DialogBoxComponent implements OnInit {
|
||||
get f(){
|
||||
return this.form.controls;
|
||||
}
|
||||
// doAction(){
|
||||
|
||||
// showOptions(event:MatCheckboxChange): void {
|
||||
// console.log(event.checked);
|
||||
// this.form['value'].admin_checked = event.checked
|
||||
// console.log(this.form['value'].admin_checked)
|
||||
// }
|
||||
closeDialog(){
|
||||
this.dialogRef.close({event:'Cancel'});
|
||||
@ -47,8 +50,10 @@ export class DialogBoxComponent implements OnInit {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
ngOnInit() {
|
||||
let userrole = localStorage.getItem('user_role')
|
||||
this.form = new FormGroup({
|
||||
workingHrsJson: new FormControl('', [Validators.required]),
|
||||
// admin_checked: new FormControl('', [Validators.required]),
|
||||
// workingHrsJson: new FormControl('', [Validators.required]),
|
||||
logo: new FormControl('', null),
|
||||
busName: new FormControl('', [Validators.required, Validators.maxLength(20)]),
|
||||
address: new FormControl('', [Validators.required, Validators.maxLength(50)]),
|
||||
@ -58,6 +63,7 @@ export class DialogBoxComponent implements OnInit {
|
||||
'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$',
|
||||
),]),
|
||||
contactNo: new FormControl('', [Validators.required, Validators.maxLength(10)]),
|
||||
createdBy:new FormControl(userrole,[Validators.required]),
|
||||
});
|
||||
|
||||
this.form.patchValue(this.local_data)
|
||||
|
||||
@ -5,19 +5,42 @@
|
||||
<ng-scrollbar class="scrollHV">
|
||||
<div mat-dialog-content class="my-table">
|
||||
<form [formGroup]="form" (ngSubmit)="submit()">
|
||||
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<mat-form-field appearance="outline" class="mat-pane">
|
||||
<mat-select placeholder="Select Business" formControlName="businessselect" required>
|
||||
<mat-option>--</mat-option>
|
||||
<mat-option *ngFor="let business of businessList" [value]="business.busId">
|
||||
{{business.busName}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="myError('businessselect', 'required')">role is required</mat-error>
|
||||
<!-- <mat-error *ngIf="businessselect.hasError('required')">Please Business</mat-error>
|
||||
<mat-error *ngIf="businessselect.hasError('invalidValue')">Please choose any other</mat-error> -->
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane" [disabled]="true">
|
||||
<input placeholder="Role" matInput formControlName="role">
|
||||
<mat-error *ngIf="myError('role', 'required')">role is required</mat-error>
|
||||
<mat-error *ngIf="myError('role', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder="User Name" matInput formControlName="userName">
|
||||
<input placeholder="Name" matInput formControlName="userName">
|
||||
<mat-error *ngIf="myError('userName', 'required')">Username is required</mat-error>
|
||||
<mat-error *ngIf="myError('userName', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder=" Email" matInput [(ngModel)]="local_data.email" formControlName="email">
|
||||
<mat-error *ngIf="!form.get('email')?.errors?.required && (form.get('email')?.errors?.pattern)">
|
||||
Please enter a valid email address
|
||||
</mat-error>
|
||||
<mat-error *ngIf="form.get('email')?.invalid && (form.get('email')?.dirty || form.get('email')?.touched) && form.get('email')?.errors?.required">
|
||||
Email is required
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput type="text" placeholder="Enter Phone No" formControlName="contactNo" id="contactNo">
|
||||
<mat-error *ngIf="myError('contactNo', 'required')">Contact No is required</mat-error>
|
||||
<mat-error *ngIf="myError('contactNo', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder="Password" matInput formControlName="password">
|
||||
<mat-error *ngIf="myError('password', 'required')">Password is required</mat-error>
|
||||
@ -28,29 +51,7 @@
|
||||
<input placeholder="ConfirmPassword" matInput formControlName="confirmPassword">
|
||||
<mat-error *ngIf="myError('confirmPassword', 'required')">confirmPassword is required</mat-error>
|
||||
<mat-error *ngIf="myError('confirmPassword', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field> -->
|
||||
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder="First Name" matInput formControlName="firstName">
|
||||
<mat-error *ngIf="myError('firstName', 'required')">FirstName is required</mat-error>
|
||||
<mat-error *ngIf="myError('firstName', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder="Last Name" matInput formControlName="lastName">
|
||||
<mat-error *ngIf="myError('lastName', 'required')">LastName is required</mat-error>
|
||||
<mat-error *ngIf="myError('lastName', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder=" Email" matInput [(ngModel)]="local_data.email" formControlName="email">
|
||||
<mat-error *ngIf="!form.get('email')?.errors?.required && (form.get('email')?.errors?.pattern)">
|
||||
Please enter a valid email address
|
||||
</mat-error>
|
||||
<mat-error *ngIf="form.get('email')?.invalid && (form.get('email')?.dirty || form.get('email')?.touched) && form.get('email')?.errors?.required">
|
||||
Email is required
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</mat-form-field> -->
|
||||
</form>
|
||||
</div>
|
||||
</ng-scrollbar>
|
||||
|
||||
@ -2,6 +2,7 @@ import { Component, Inject, OnInit, Optional } from '@angular/core';
|
||||
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { Router } from '@angular/router';
|
||||
import { BusinessService } from 'app/appoinment/business/business-service/business.service';
|
||||
export interface UsersData {
|
||||
userName: string;
|
||||
id: number;
|
||||
@ -19,13 +20,33 @@ export class UserDialogBoxComponent implements OnInit {
|
||||
action:string;
|
||||
local_data:any;
|
||||
url: string | ArrayBuffer;
|
||||
businessList: any;
|
||||
constructor(private router: Router,private formBuilder: FormBuilder,
|
||||
public dialogRef: MatDialogRef<UserDialogBoxComponent>,
|
||||
@Optional() @Inject(MAT_DIALOG_DATA) public data: UsersData) {
|
||||
@Optional() @Inject(MAT_DIALOG_DATA) public data: UsersData,public _bus:BusinessService) {
|
||||
console.log(data);
|
||||
this.local_data = {...data};
|
||||
this.action = this.local_data.action;
|
||||
this.getBusinessList()
|
||||
}
|
||||
|
||||
getBusinessList() {
|
||||
//this._pd.getTabStatusPdDetails(this.tabStatus)
|
||||
this._bus.getBusinessListDetails().subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
let businessFilter = res['data'].filter(val => val.busName)
|
||||
this.businessList = businessFilter;
|
||||
console.log(this.businessList)
|
||||
}
|
||||
}
|
||||
// , error => {this.errorMessage = <any> error});
|
||||
,error => {
|
||||
// this.errorMessage.push(error);
|
||||
// this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!');
|
||||
// alert(error.html_format);
|
||||
})
|
||||
}
|
||||
|
||||
get f(){
|
||||
return this.form.controls;
|
||||
}
|
||||
@ -47,16 +68,19 @@ export class UserDialogBoxComponent implements OnInit {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
ngOnInit() {
|
||||
let userrole = localStorage.getItem('user_role')
|
||||
this.form = new FormGroup({
|
||||
role: new FormControl('', [Validators.required, Validators.maxLength(20)]),
|
||||
businessselect: new FormControl('',[Validators.required]),
|
||||
role: new FormControl('BADMIN', [Validators.required, Validators.maxLength(20)]),
|
||||
userName: new FormControl('', [Validators.required, Validators.maxLength(20)]),
|
||||
firstName: new FormControl('', [Validators.required, Validators.maxLength(20)]),
|
||||
lastName: new FormControl('', [Validators.required, Validators.maxLength(20)]),
|
||||
contactNo: new FormControl('', [Validators.required, Validators.maxLength(20)]),
|
||||
// lastName: new FormControl('', [Validators.required, Validators.maxLength(20)]),
|
||||
email: new FormControl('', [Validators.required, Validators.email,Validators.pattern(
|
||||
'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$',
|
||||
),]),
|
||||
password: new FormControl('', [Validators.required, Validators.minLength(6)]),
|
||||
// confirmPassword: new FormControl('', [Validators.required, Validators.minLength(6)]),
|
||||
createdBy:new FormControl(userrole,[Validators.required]),
|
||||
});
|
||||
this.form.patchValue(this.local_data)
|
||||
}
|
||||
|
||||
@ -155,27 +155,29 @@ export class UserListComponent implements OnInit {
|
||||
let formValue = []
|
||||
if(result.event == 'Add'){
|
||||
console.log('add')
|
||||
let addFormData = {
|
||||
let addFormData = {
|
||||
// logo: row_obj.logo,
|
||||
id: row_obj.id,
|
||||
// id: row_obj.id,
|
||||
busId:row_obj.businessselect,
|
||||
userName: row_obj.userName,
|
||||
contactNo: row_obj.contactNo,
|
||||
password: row_obj.password,
|
||||
firstName: row_obj.firstName,
|
||||
lastName: row_obj.lastName,
|
||||
email: row_obj.email,
|
||||
role: row_obj.role,
|
||||
role: row_obj.role,
|
||||
createdBy:row_obj.createdBy
|
||||
};
|
||||
formValue.push(addFormData);
|
||||
}else if(result.event == 'Update'){
|
||||
console.log('Update')
|
||||
let updatevalue = {
|
||||
id: row_obj.id,
|
||||
busId:row_obj.businessselect,
|
||||
userName: row_obj.userName,
|
||||
contactNo: row_obj.contactNo,
|
||||
password: row_obj.password,
|
||||
firstName: row_obj.firstName,
|
||||
lastName: row_obj.lastName,
|
||||
email: row_obj.email,
|
||||
role: row_obj.role,
|
||||
role: row_obj.role,
|
||||
createdBy:row_obj.createdBy
|
||||
}
|
||||
formValue.push(updatevalue);
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ export class RoleMenuItemsPipe implements PipeTransform {
|
||||
// if(type=="1"){
|
||||
switch(localStorage.getItem('user_role')){
|
||||
case 'SADMIN': return value.filter(val=>val.state!="appoinments" && val.state!="customers" && val.state!="consultants" && val.state != "services" && val.state != "consultant-setting");
|
||||
case 'ADMIN': return value.filter(val=>val.state !="business" && val.state!="appoinments" && val.state!="customers");
|
||||
case 'BADMIN': return value.filter(val=>val.state !="business" && val.state!="appoinments" && val.state!="consultants" && val.state != "users");
|
||||
// case 'CONSULT':
|
||||
// case '3': return value.filter(val=>val.state!="settings");
|
||||
// case '4': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="reports" && val.state!="sales-pd-list");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user