Hima 5 anos atrás
pai
commit
629b0331a3

+ 1 - 0
src/app/Internal-Page/internal-page-content/internal-page-content.component.css

@@ -8,6 +8,7 @@ input,button {
     padding: 20px;
     border: 1px solid #e3dbd0;
     margin: 30px 0;
+    background: rgba(255, 255, 255, 0.5);
 }
 
 .internalPage-w {

+ 9 - 10
src/app/Internal-Page/internal-page-content/internal-page-content.component.html

@@ -20,17 +20,16 @@
                         <div class="col-12 col-md-8 order-1 order-sm-1 order-md-2">
                             <div class="slider">
                                 <div *ngIf="reportsData.length > 1">
-                                        <ngb-carousel #myCarousel="ngbCarousel">
-                                                <ng-template ngbSlide *ngFor="let report of reportsData; let i = index" id={{i}} >
-                                                    <img [src]="[authSer.pathImg + report.photo]" alt="Random first slide">
-                                                    <div class="carousel-caption">
-                                                    <p class="paragraphTemplate-w" [innerHTML] = "report.description"></p>
-                                                    <span class="extra" (click)="onExtraPage(report.id)" *ngIf="report.description">المزيد</span>
-                                                    </div>
-                                                </ng-template>
-                                            </ngb-carousel>
+                                    <ngb-carousel #myCarousel="ngbCarousel">
+                                        <ng-template ngbSlide *ngFor="let report of reportsData; let i = index" id={{i}} >
+                                            <img [src]="authSer.pathImg + report['photos'][0]" alt="Random first slide">
+                                            <div class="carousel-caption">
+                                            <p class="paragraphTemplate-w" [innerHTML] = "report.description"></p>
+                                            <span class="extra" (click)="onExtraPage(report.id)" *ngIf="report.description">المزيد</span>
+                                            </div>
+                                        </ng-template>
+                                    </ngb-carousel>
                                 </div>
-                               
                             </div>
                         </div>
                     </div>

+ 29 - 13
src/app/dashboard/department/department-list/department-list.component.ts

@@ -1,3 +1,4 @@
+import { Modal } from 'ngx-modialog/plugins/bootstrap';
 import { UserService } from './../../../shared/user.service';
 import { AuthServiceService } from './../../../shared/auth-service.service';
 import { DepartmentService } from './../../../shared/department.service';
@@ -18,6 +19,7 @@ export class DepartmentListComponent implements OnInit {
     private departService: DepartmentService,
     private router: Router,
     private spinner: NgxSpinnerService,
+    private modal: Modal,
     private authSer: AuthServiceService,
     private userSer: UserService,
     private toastr: ToastrService) { }
@@ -193,19 +195,33 @@ export class DepartmentListComponent implements OnInit {
         }
       }
 
-      console.log(this.departsId);
-
-      this.departService.deleteDepart(this.departsId).subscribe(
-        (responce) => {
-          console.log(responce);
-          this.toastr.success('تم المسح');
-          window.location.reload();
-        },
-        (error) => {
-          console.log(error);
-          this.spinner.hide();
-        },
-      );
+      if(this.departsId.length > 0) {
+        const dialogRef = this.modal.alert()
+        .size('sm')
+        .showClose(true)
+        .title('تأكيد الحذف')
+        .body(`
+            <h4>هل ترغب في حذف العناصر المحدده ؟ </h4>
+            `)
+        .open();
+        dialogRef.result
+        .then( result =>  
+          this.departService.deleteDepart(this.departsId).subscribe(
+            (responce) => {
+              console.log(responce);
+              this.toastr.success('تم المسح');
+              window.location.reload();
+            },
+            (error) => {
+              console.log(error);
+              this.spinner.hide();
+            },
+          )
+        );
+      } else{
+        this.toastr.warning('لم يتم إختيار أي عنصر للمسح !');
+      }
+      
     };
 
 

+ 33 - 31
src/app/dashboard/news/add-news/add-news.component.ts

@@ -27,6 +27,7 @@ export class AddNewsComponent implements OnInit {
   typeLink: string = '';
   checkSaveClick: boolean = false;
   photoEdit:boolean = true;
+  checkAddMode: boolean = false;
 
 
   
@@ -45,15 +46,18 @@ export class AddNewsComponent implements OnInit {
   images = [{
     base64: '',
     photoType: '',
-    urlImg: '../../assets/image/avatar.png'
+    urlImg: '../../assets/image/avatar.png',
+    id: '',
   }];
 
   //add more div photo
   plusImage() {
+    this.checkAddMode = true;
     this.images.push({
      base64: '',
      photoType: '',
      urlImg: '../../assets/image/avatar.png',
+     id: '',
     });
   }
 
@@ -103,18 +107,12 @@ export class AddNewsComponent implements OnInit {
               this.new.description_en = newData.description_en;
               if(responce['report'].photos) {
                 this.checkValidImg = false;
-                for(let i = 0 ; i < newData.photos.length; i++) {
-                  // this.images[i] = {
-                  //   base64: '',
-                  //   photoType: '',
-                  //   urlImg: this.authSer.pathImg +  newData.photos[i].photo,
-                  // }
-
-                 
+                for(let i = 0 ; i < newData.photos.length; i++) { 
                   this.images.push({
                     base64: '',//this.onFileChanges(newData.photos[i].photo,i),
                     photoType: '',
                     urlImg : this.authSer.pathImg +  newData.photos[i].photo,
+                    id: newData.photos[i].id,
                   });
                   console.log('imageeeees' , this.images);
                 }
@@ -140,11 +138,21 @@ export class AddNewsComponent implements OnInit {
     let dateEditUplad = {};
 
     if(this.typeMode) {
-      dateEditUplad = {
-        'photo': event[0].base64,
-        'photo_type': event[0].type.split('/')[1],
-        report_id:  this.newId,
+      if(this.checkAddMode) {
+        dateEditUplad = {
+          'photo': event[0].base64,
+          'photo_type': event[0].type.split('/')[1],
+          'report_id':  this.newId,
+        }
+      } else {
+        dateEditUplad = {
+          'photo': event[0].base64,
+          'photo_type': event[0].type.split('/')[1],
+          'photo_id':  this.images[index].id,
+        }
       }
+
+      console.log(dateEditUplad);
       this.http.post(this.authSer.pathApi + '/upload_report_photo', dateEditUplad).subscribe(
         (responce) => {
           console.log(responce);
@@ -184,11 +192,6 @@ export class AddNewsComponent implements OnInit {
     const formData = this.newForm.value;
       
     if(this.typeMode){
-      if(this.photoType[1] != 'png' && this.photoEdit == true) {
-        this.toastr.warning('الصوره يجب أن تكون بصيغه Png');
-      } else if(this.imageBase64 == '' && this.photoEdit == true){
-        this.toastr.warning('قم باختيار صوره !');
-      } else {
         //to remove photo from object not has edit on it
         const images = [];
         for(let i = 0; i < this.images.length; i++) {
@@ -202,22 +205,21 @@ export class AddNewsComponent implements OnInit {
           }
         }
 
-        formData['images'] = images;
+        //formData['images'] = images;
 
         console.log(formData);
 
-        // this.newService.editNew(formData, this.newId).subscribe(
-        //   (responce) => {
-        //     console.log(responce);
-        //     this.toastr.success('تمت التعديل بنجاح');
-        //     this.location.back();
-        //   },
-        //   (error) => {
-        //     console.log(error);
-        //     this.toastr.error('خطأ في التعديل !');
-        //   }
-        // );
-      }
+        this.newService.editNew(formData, this.newId).subscribe(
+          (responce) => {
+            console.log(responce);
+            this.toastr.success('تمت التعديل بنجاح');
+            this.location.back();
+          },
+          (error) => {
+            console.log(error);
+            this.toastr.error('خطأ في التعديل !');
+          }
+        );
     } else {
       if(this.images[0].base64 == ''){
         this.toastr.warning('قم باختيار صوره !');

+ 29 - 1
src/app/dashboard/roles/roles-list/roles-list.component.ts

@@ -1,3 +1,4 @@
+import { Modal } from 'ngx-modialog/plugins/bootstrap';
 import { UserService } from './../../../shared/user.service';
 import { AuthServiceService } from './../../../shared/auth-service.service';
 import { RolesService } from './../../../shared/roles.service';
@@ -32,6 +33,7 @@ export class RolesListComponent implements OnInit {
       private router: Router,
       private rolesService: RolesService,
       private userSer: UserService,
+      private modal: Modal,
       private authSer: AuthServiceService, 
       private spinner: NgxSpinnerService, 
       private toastr: ToastrService) { }
@@ -196,7 +198,33 @@ export class RolesListComponent implements OnInit {
         }
       }
 
-      console.log(this.rolesId);
+      if(this.rolesId.length > 0) {
+        const dialogRef = this.modal.alert()
+        .size('sm')
+        .showClose(true)
+        .title('تأكيد الحذف')
+        .body(`
+            <h4>هل ترغب في حذف العناصر المحدده ؟ </h4>
+            `)
+        .open();
+        dialogRef.result
+        .then( result =>  
+          
+          this.rolesService.deleteUser(this.rolesId).subscribe(
+            (responce) => {
+              console.log(responce);
+              this.toastr.success('تم الحذف');
+              window.location.reload();
+            },
+            (error) => {
+              console.log(error);
+              this.spinner.hide();
+            },
+          )
+        )
+      } else {
+        this.toastr.warning('لم يتم إختيار أي عنصر للمسح !');
+      }
 
     this.rolesService.deleteUser(this.rolesId).subscribe(
       (responce) => {

+ 28 - 12
src/app/dashboard/sections/section-list/section-list.component.ts

@@ -1,3 +1,4 @@
+import { Modal } from 'ngx-modialog/plugins/bootstrap';
 import { UserService } from './../../../shared/user.service';
 import { SectionService } from './../../../shared/section.service';
 import { ActivatedRoute, Params, Router } from '@angular/router';
@@ -31,6 +32,7 @@ export class SectionListComponent implements OnInit {
       private authSer: AuthServiceService,
       private sectionService: SectionService,
       private userSer: UserService,
+      private modal: Modal,
       private router: Router) { }
 
   ngOnInit() {
@@ -183,18 +185,32 @@ export class SectionListComponent implements OnInit {
       }
 
       console.log(this.sectionsId);
-
-      this.sectionService.deleteSection(this.sectionsId).subscribe(
-        (responce) => {
-          console.log(responce);
-          window.location.reload();
-          this.toastr.success('تم الحذف');
-        },
-        (error) => {
-          console.log(error);
-          this.spinner.hide();
-        },
-      );
+      if(this.sectionsId.length > 0){
+        const dialogRef = this.modal.alert()
+        .size('sm')
+        .showClose(true)
+        .title('تأكيد الحذف')
+        .body(`
+            <h4>هل ترغب في حذف العناصر المحدده ؟ </h4>
+            `)
+        .open();
+        dialogRef.result
+        .then( result =>  
+          this.sectionService.deleteSection(this.sectionsId).subscribe(
+            (responce) => {
+              console.log(responce);
+              window.location.reload();
+              this.toastr.success('تم الحذف');
+            },
+            (error) => {
+              console.log(error);
+              this.spinner.hide();
+            },
+          )
+        );
+      } else {
+        this.toastr.warning('لم يتم إختيار أي عنصر للمسح !');
+      }
     }
 
     onAddSection(){

+ 25 - 8
src/app/dashboard/users/users.component.ts

@@ -1,3 +1,4 @@
+import { Modal } from 'ngx-modialog/plugins/bootstrap';
 import { AuthServiceService } from './../../shared/auth-service.service';
 import { HttpClient } from '@angular/common/http';
 import { UserService } from './../../shared/user.service';
@@ -20,6 +21,7 @@ export class UsersComponent implements OnInit {
     private route: ActivatedRoute, 
     private userSer: UserService, 
     private toastr: ToastrService,
+    private modal: Modal,
     private http: HttpClient,
     private authSer: AuthServiceService,
     private spinner: NgxSpinnerService) { }
@@ -256,15 +258,30 @@ export class UsersComponent implements OnInit {
         }
       }
 
+      if(this.usersId.length > 0) {
+        const dialogRef = this.modal.alert()
+        .size('sm')
+        .showClose(true)
+        .title('تأكيد الحذف')
+        .body(`
+            <h4>هل ترغب في حذف العناصر المحدده ؟ </h4>
+            `)
+        .open();
+        dialogRef.result
+        .then( result =>  
+          this.userSer.deleteUser(this.usersId, this.pageId).subscribe(
+            (responce) => {
+              console.log(responce);
+              this.toastr.success('تم الحذف');
+              window.location.reload();
+            },
+            (error) => {console.log(error)},
+          )
+        );
+      } else {
+        this.toastr.warning('لم يتم إختيار أي عنصر للمسح !');
+      }
 
-    this.userSer.deleteUser(this.usersId, this.pageId).subscribe(
-      (responce) => {
-        console.log(responce);
-        this.toastr.success('تم الحذف');
-        window.location.reload();
-      },
-      (error) => {console.log(error)},
-    );
   }
  
 //filtter function

+ 2 - 7
src/app/shared/department.service.ts

@@ -30,13 +30,8 @@ export class DepartmentService {
 
   //delete user 
   deleteDepart(departsIds) {
-    if(departsIds.length > 0){
-      console.log(departsIds);
-      return this.http.post(this.authService.pathApi + '/delete_adminstration' , {'adminstrations_id' : departsIds});
-    } else {
-      this.spinner.hide();
-      this.toastr.warning('لم يتم أختيار أي إداره للحذف !');
-    }
+    console.log(departsIds);
+    return this.http.post(this.authService.pathApi + '/delete_adminstration' , {'adminstrations_id' : departsIds});
   };
 
   addDepartment(formData) {

+ 2 - 7
src/app/shared/roles.service.ts

@@ -30,13 +30,8 @@ export class RolesService {
 
     //delete user 
     deleteUser(rolesIds) {
-      if(rolesIds.length > 0){
-        console.log(rolesIds);
-        return this.http.post(this.authService.pathApi + '/delete_role' , {'roles_id' : rolesIds});
-      } else {
-        this.spinner.hide();
-        this.toastr.warning('لم يتم أختيار أي مجموعه للحذف !');
-      }
+      console.log(rolesIds);
+      return this.http.post(this.authService.pathApi + '/delete_role' , {'roles_id' : rolesIds});      
     };
 
     addRoles(dataRoles) {

+ 2 - 6
src/app/shared/section.service.ts

@@ -29,12 +29,8 @@ export class SectionService {
 
     //delete user 
     deleteSection(sectionsIds) {
-      if(sectionsIds.length > 0){
-        console.log(sectionsIds);
-        return this.http.post(this.authService.pathApi + '/delete_department' , {'departments_id' : sectionsIds});
-      } else {
-        this.toastr.warning('لم يتم أختيار أي قسم للحذف !');
-      }
+      console.log(sectionsIds);
+      return this.http.post(this.authService.pathApi + '/delete_department' , {'departments_id' : sectionsIds});
     };
 
     //get section data

+ 5 - 14
src/app/shared/user.service.ts

@@ -119,21 +119,12 @@ export class UserService {
   //delete user 
   deleteUser(userIds, typePageId) {
     if(typePageId == 1){
-      if(userIds.length > 0){
-        console.log(userIds);
-        return this.http.post(this.authService.pathApi + '/delete_user' , {'users_id' : userIds});
-      } else {
-        this.spinner.hide();
-        this.toastr.warning('لم يتم أختيار أي مستخدم للحذف');
-      }
+      console.log(userIds);
+      return this.http.post(this.authService.pathApi + '/delete_user' , {'users_id' : userIds});
+      
     } else if(typePageId == 9) {
-      if(userIds.length > 0){
-        console.log(userIds);
-        return this.http.post(this.authService.pathApi + '/delete_join_us_users' , {'users_id' : userIds});
-      } else {
-        this.spinner.hide();
-        this.toastr.warning('لم يتم أختيار أي مستخدم للحذف');
-      }
+      console.log(userIds);
+      return this.http.post(this.authService.pathApi + '/delete_join_us_users' , {'users_id' : userIds});
     }
     
   }