|
@@ -1,3 +1,4 @@
|
|
|
|
+import { DashboardService } from './../../../shared/dashboard.service';
|
|
import { AuthServiceService } from './../../../shared/auth-service.service';
|
|
import { AuthServiceService } from './../../../shared/auth-service.service';
|
|
import { ActivatedRoute, Params } from '@angular/router';
|
|
import { ActivatedRoute, Params } from '@angular/router';
|
|
import { Subscription } from 'rxjs';
|
|
import { Subscription } from 'rxjs';
|
|
@@ -23,6 +24,7 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
private spinner: NgxSpinnerService,
|
|
private spinner: NgxSpinnerService,
|
|
private toastr: ToastrService,
|
|
private toastr: ToastrService,
|
|
private authSer: AuthServiceService,
|
|
private authSer: AuthServiceService,
|
|
|
|
+ private dashboardService: DashboardService,
|
|
private location: Location) { }
|
|
private location: Location) { }
|
|
|
|
|
|
addHospitalForm: FormGroup;
|
|
addHospitalForm: FormGroup;
|
|
@@ -32,12 +34,16 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
typePageEdit: string = '';
|
|
typePageEdit: string = '';
|
|
typeCreatePage: string = '';
|
|
typeCreatePage: string = '';
|
|
typeLink = 'إنشاء جديد';
|
|
typeLink = 'إنشاء جديد';
|
|
|
|
+ showAppearance: boolean = false;
|
|
typeFirstLink: string;
|
|
typeFirstLink: string;
|
|
|
|
+ servicesType: string = '';
|
|
typeId: number;
|
|
typeId: number;
|
|
editSubscription: Subscription;
|
|
editSubscription: Subscription;
|
|
typeCreateSubscription: Subscription;
|
|
typeCreateSubscription: Subscription;
|
|
fieldsData = [];
|
|
fieldsData = [];
|
|
|
|
|
|
|
|
+ serviceID:number;
|
|
|
|
+
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
//show / hide notification search in header
|
|
//show / hide notification search in header
|
|
this.authSer.notificationLogin = true;
|
|
this.authSer.notificationLogin = true;
|
|
@@ -48,19 +54,39 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
this.authSer.internalHeader = false;
|
|
this.authSer.internalHeader = false;
|
|
|
|
|
|
//init form data
|
|
//init form data
|
|
- this.addHospitalForm = new FormGroup({
|
|
|
|
- name: new FormControl(null , Validators.required),
|
|
|
|
- name_en: new FormControl(null , Validators.required),
|
|
|
|
- fields: this.formBuilder.array([ this.createItem() ])
|
|
|
|
- });
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //set side navigation bar
|
|
|
|
+ this.route.parent.params.subscribe(
|
|
|
|
+ (params: Params) => {
|
|
|
|
+ this.serviceID = params['serviceID'];
|
|
|
|
+ if(params['serviceID'] == 2) {
|
|
|
|
+ this.servicesType = 'خدمه إداره الصفحه الخارجيه';
|
|
|
|
+ } else if(params['serviceID'] == 6) {
|
|
|
|
+ this.servicesType = 'خدمه إداره المحتوي';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
|
|
this.typeCreateSubscription = this.route.params.subscribe(
|
|
this.typeCreateSubscription = this.route.params.subscribe(
|
|
(params: Params) => {
|
|
(params: Params) => {
|
|
this.typeCreatePage = params['typeAdd'];
|
|
this.typeCreatePage = params['typeAdd'];
|
|
if(this.typeCreatePage == 'Hospital') {
|
|
if(this.typeCreatePage == 'Hospital') {
|
|
this.typeFirstLink = 'المستشفيات والمراكز';
|
|
this.typeFirstLink = 'المستشفيات والمراكز';
|
|
|
|
+ this.showAppearance = true;
|
|
|
|
+ this.addHospitalForm = new FormGroup({
|
|
|
|
+ name: new FormControl(null , Validators.required),
|
|
|
|
+ name_en: new FormControl(null , Validators.required),
|
|
|
|
+ display_location: new FormControl(null, Validators.required),
|
|
|
|
+ fields: this.formBuilder.array([ this.createItem() ])
|
|
|
|
+ });
|
|
} else if(this.typeCreatePage == 'Management') {
|
|
} else if(this.typeCreatePage == 'Management') {
|
|
this.typeFirstLink = 'الإدارات';
|
|
this.typeFirstLink = 'الإدارات';
|
|
|
|
+ this.addHospitalForm = new FormGroup({
|
|
|
|
+ name: new FormControl(null , Validators.required),
|
|
|
|
+ name_en: new FormControl(null , Validators.required),
|
|
|
|
+ fields: this.formBuilder.array([ this.createItem() ])
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
);
|
|
@@ -69,18 +95,21 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
this.editSubscription = this.route.params.subscribe(
|
|
this.editSubscription = this.route.params.subscribe(
|
|
(params: Params) => {
|
|
(params: Params) => {
|
|
if(params['typeHospitalMode'] == 'edithos') {
|
|
if(params['typeHospitalMode'] == 'edithos') {
|
|
|
|
+ this.spinner.show();
|
|
this.typeLink = 'تعديل';
|
|
this.typeLink = 'تعديل';
|
|
this.typeFirstLink = 'المستشفيات والمراكز';
|
|
this.typeFirstLink = 'المستشفيات والمراكز';
|
|
|
|
+ this.showAppearance = true;
|
|
this.addHospitalForm = new FormGroup({
|
|
this.addHospitalForm = new FormGroup({
|
|
name: new FormControl(null , Validators.required),
|
|
name: new FormControl(null , Validators.required),
|
|
name_en: new FormControl(null , Validators.required),
|
|
name_en: new FormControl(null , Validators.required),
|
|
|
|
+ display_location: new FormControl(null, Validators.required),
|
|
fields: this.formBuilder.array([])
|
|
fields: this.formBuilder.array([])
|
|
});
|
|
});
|
|
this.spinner.show();
|
|
this.spinner.show();
|
|
this.typeMode = true;
|
|
this.typeMode = true;
|
|
this.typePageEdit = 'edithos';
|
|
this.typePageEdit = 'edithos';
|
|
- this.typeId = params['editTypePageId'];
|
|
|
|
- this.hospitalService.getHospitalData(this.typeId, 'edithos').subscribe(
|
|
|
|
|
|
+ this.typeId = +params['editTypePageId'];
|
|
|
|
+ this.dashboardService.getItemData(this.typeId, 'hospital').subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
console.log('responcce', responce);
|
|
console.log('responcce', responce);
|
|
this.fieldsData = responce['hospital_center'].fields;
|
|
this.fieldsData = responce['hospital_center'].fields;
|
|
@@ -88,6 +117,7 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
this.addHospitalForm.patchValue({
|
|
this.addHospitalForm.patchValue({
|
|
name: responce['hospital_center'].name,
|
|
name: responce['hospital_center'].name,
|
|
name_en: responce['hospital_center'].name_en,
|
|
name_en: responce['hospital_center'].name_en,
|
|
|
|
+ display_location: responce['hospital_center'].display_location,
|
|
});
|
|
});
|
|
this.fields = this.addHospitalForm.get('fields') as FormArray;
|
|
this.fields = this.addHospitalForm.get('fields') as FormArray;
|
|
for(let i = 0; i < this.fieldsData.length; i++) {
|
|
for(let i = 0; i < this.fieldsData.length; i++) {
|
|
@@ -107,6 +137,7 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
}
|
|
}
|
|
);
|
|
);
|
|
} else if (params['typeHospitalMode'] == 'editman') {
|
|
} else if (params['typeHospitalMode'] == 'editman') {
|
|
|
|
+ this.spinner.show();
|
|
this.typeLink = 'تعديل';
|
|
this.typeLink = 'تعديل';
|
|
this.typeFirstLink = 'الإدارات';
|
|
this.typeFirstLink = 'الإدارات';
|
|
this.addHospitalForm = new FormGroup({
|
|
this.addHospitalForm = new FormGroup({
|
|
@@ -114,11 +145,13 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
name_en: new FormControl(null , Validators.required),
|
|
name_en: new FormControl(null , Validators.required),
|
|
fields: this.formBuilder.array([])
|
|
fields: this.formBuilder.array([])
|
|
});
|
|
});
|
|
- this.spinner.show();
|
|
|
|
this.typeMode = true;
|
|
this.typeMode = true;
|
|
this.typePageEdit = "editman";
|
|
this.typePageEdit = "editman";
|
|
- this.typeId = params['editTypePageId'];
|
|
|
|
- this.hospitalService.getHospitalData(this.typeId, 'editman').subscribe(
|
|
|
|
|
|
+ this.typeId = +params['editTypePageId'];
|
|
|
|
+
|
|
|
|
+ this.typeId = +params['editTypePageId'];
|
|
|
|
+
|
|
|
|
+ this.dashboardService.getItemData(this.typeId, 'managament').subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
console.log('responcce', responce);
|
|
console.log('responcce', responce);
|
|
this.fieldsData = responce['management'].fields;
|
|
this.fieldsData = responce['management'].fields;
|
|
@@ -172,7 +205,6 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
//submitted form
|
|
//submitted form
|
|
onSubmitted() {
|
|
onSubmitted() {
|
|
-
|
|
|
|
this.checkSaveClick = true;
|
|
this.checkSaveClick = true;
|
|
console.log(this.addHospitalForm.value);
|
|
console.log(this.addHospitalForm.value);
|
|
const formHospitalData = this.addHospitalForm.value;
|
|
const formHospitalData = this.addHospitalForm.value;
|
|
@@ -183,26 +215,8 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
this.toastr.warning('أدخل عنوان ووصف واحد علي الاقل !');
|
|
this.toastr.warning('أدخل عنوان ووصف واحد علي الاقل !');
|
|
this.checkSaveClick = false;
|
|
this.checkSaveClick = false;
|
|
} else {
|
|
} else {
|
|
- this.hospitalService.addHospital(formHospitalData, 'hospital').subscribe(
|
|
|
|
- (responce) => {
|
|
|
|
- this.checkSaveClick = false;
|
|
|
|
- console.log(responce);
|
|
|
|
- this.toastr.success('تم الاضافه بنجاح');
|
|
|
|
- this.location.back();
|
|
|
|
- },
|
|
|
|
- (error) => {
|
|
|
|
- this.checkSaveClick = false;
|
|
|
|
- this.toastr.error('خطأ في الإنشاء');
|
|
|
|
- console.log(error);
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- } else if(this.typeCreatePage == 'Management') {
|
|
|
|
- if(formHospitalData.fields[0].title == '' || formHospitalData.fields[0].description == '') {
|
|
|
|
- this.toastr.warning('أدخل عنوان ووصف واحد علي الاقل !');
|
|
|
|
- this.checkSaveClick = false;
|
|
|
|
- } else {
|
|
|
|
- this.hospitalService.addHospital(formHospitalData, 'management').subscribe(
|
|
|
|
|
|
+ if(this.serviceID == 6) {
|
|
|
|
+ this.dashboardService.addItem(formHospitalData, 'internalHospital').subscribe(
|
|
(responce) => {
|
|
(responce) => {
|
|
this.checkSaveClick = false;
|
|
this.checkSaveClick = false;
|
|
console.log(responce);
|
|
console.log(responce);
|
|
@@ -211,11 +225,61 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
},
|
|
},
|
|
(error) => {
|
|
(error) => {
|
|
this.checkSaveClick = false;
|
|
this.checkSaveClick = false;
|
|
- this.toastr.error('خطأ في الاضافه');
|
|
|
|
|
|
+ this.toastr.error('خطأ في الإنشاء');
|
|
|
|
+ console.log(error);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ } else if(this.serviceID == 2) {
|
|
|
|
+ this.dashboardService.addItem(formHospitalData, 'externalHospital').subscribe(
|
|
|
|
+ (responce) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(responce);
|
|
|
|
+ this.toastr.success('تم الاضافه بنجاح');
|
|
|
|
+ this.location.back();
|
|
|
|
+ },
|
|
|
|
+ (error) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ this.toastr.error('خطأ في الإنشاء');
|
|
console.log(error);
|
|
console.log(error);
|
|
}
|
|
}
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ } else if(this.typeCreatePage == 'Management') {
|
|
|
|
+ if(formHospitalData.fields[0].title == '' || formHospitalData.fields[0].description == '') {
|
|
|
|
+ this.toastr.warning('أدخل عنوان ووصف واحد علي الاقل !');
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ } else {
|
|
|
|
+ if(this.serviceID == 6) {
|
|
|
|
+ this.dashboardService.addItem(formHospitalData, 'internalManagement').subscribe(
|
|
|
|
+ (responce) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(responce);
|
|
|
|
+ this.toastr.success('تم الاضافه بنجاح');
|
|
|
|
+ this.location.back();
|
|
|
|
+ },
|
|
|
|
+ (error) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ this.toastr.error('خطأ في الاضافه');
|
|
|
|
+ console.log(error);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ } else if(this.serviceID == 2) {
|
|
|
|
+ this.dashboardService.addItem(formHospitalData, 'externalManagement').subscribe(
|
|
|
|
+ (responce) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(responce);
|
|
|
|
+ this.toastr.success('تم الاضافه بنجاح');
|
|
|
|
+ this.location.back();
|
|
|
|
+ },
|
|
|
|
+ (error) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ this.toastr.error('خطأ في الاضافه');
|
|
|
|
+ console.log(error);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if(this.typeMode) {
|
|
if(this.typeMode) {
|
|
@@ -225,34 +289,62 @@ export class AddHospitalComponent implements OnInit, OnDestroy {
|
|
this.toastr.warning('أدخل عنوان ووصف واحد علي الاقل !');
|
|
this.toastr.warning('أدخل عنوان ووصف واحد علي الاقل !');
|
|
this.checkSaveClick = false;
|
|
this.checkSaveClick = false;
|
|
} else {
|
|
} else {
|
|
- this.hospitalService.editHospital(this.typeId, formHospitalData, 'hospital').subscribe(
|
|
|
|
- (responce) => {
|
|
|
|
- this.checkSaveClick = false;
|
|
|
|
- console.log(responce);
|
|
|
|
- this.toastr.success('تم التعديل بنجاح ');
|
|
|
|
- }, (error) => {
|
|
|
|
- this.checkSaveClick = false;
|
|
|
|
- console.log(error);
|
|
|
|
- this.toastr.error('فشل التعديل !');
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
+ if(this.serviceID == 6) {
|
|
|
|
+ this.dashboardService.editItem(this.typeId, formHospitalData, 'internalHospital').subscribe(
|
|
|
|
+ (responce) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(responce);
|
|
|
|
+ this.toastr.success('تم التعديل بنجاح ');
|
|
|
|
+ }, (error) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(error);
|
|
|
|
+ this.toastr.error('فشل التعديل !');
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ } else if(this.serviceID == 2) {
|
|
|
|
+ this.dashboardService.editItem(this.typeId, formHospitalData, 'externalHospital').subscribe(
|
|
|
|
+ (responce) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(responce);
|
|
|
|
+ this.toastr.success('تم التعديل بنجاح ');
|
|
|
|
+ }, (error) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(error);
|
|
|
|
+ this.toastr.error('فشل التعديل !');
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if(this.typePageEdit == 'editman'){
|
|
} else if(this.typePageEdit == 'editman'){
|
|
if(formHospitalData.fields[0].title == '' || formHospitalData.fields[0].description == '') {
|
|
if(formHospitalData.fields[0].title == '' || formHospitalData.fields[0].description == '') {
|
|
this.toastr.warning('أدخل عنوان ووصف واحد علي الاقل !');
|
|
this.toastr.warning('أدخل عنوان ووصف واحد علي الاقل !');
|
|
this.checkSaveClick = false;
|
|
this.checkSaveClick = false;
|
|
} else {
|
|
} else {
|
|
- this.hospitalService.editHospital(this.typeId, formHospitalData, 'management').subscribe(
|
|
|
|
- (responce) => {
|
|
|
|
- this.checkSaveClick = false;
|
|
|
|
- console.log(responce);
|
|
|
|
- this.toastr.success('تم التعديل بنجاح ');
|
|
|
|
- }, (error) => {
|
|
|
|
- this.checkSaveClick = false;
|
|
|
|
- console.log(error);
|
|
|
|
- this.toastr.error('فشل التعديل !');
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
|
|
+ if(this.serviceID == 6) {
|
|
|
|
+ this.dashboardService.editItem(this.typeId, formHospitalData, 'internalManagement').subscribe(
|
|
|
|
+ (responce) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(responce);
|
|
|
|
+ this.toastr.success('تم التعديل بنجاح ');
|
|
|
|
+ }, (error) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(error);
|
|
|
|
+ this.toastr.error('فشل التعديل !');
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ } else if(this.serviceID == 2) {
|
|
|
|
+ this.dashboardService.editItem(this.typeId, formHospitalData, 'externalManagement').subscribe(
|
|
|
|
+ (responce) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(responce);
|
|
|
|
+ this.toastr.success('تم التعديل بنجاح ');
|
|
|
|
+ }, (error) => {
|
|
|
|
+ this.checkSaveClick = false;
|
|
|
|
+ console.log(error);
|
|
|
|
+ this.toastr.error('فشل التعديل !');
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|