|
@@ -15,7 +15,7 @@ import { ToastrService } from 'ngx-toastr';
|
|
|
})
|
|
|
export class AdvertisimentComponent implements OnInit {
|
|
|
|
|
|
- constructor(private http: HttpClient,
|
|
|
+ constructor(private http: HttpClient,
|
|
|
private route: ActivatedRoute,
|
|
|
private router: Router,
|
|
|
private modal: Modal,
|
|
@@ -25,91 +25,91 @@ export class AdvertisimentComponent implements OnInit {
|
|
|
private toastr: ToastrService,
|
|
|
private dashboardSer: DashboardService) { }
|
|
|
|
|
|
- advertisimentsList = [];
|
|
|
- pages= [];
|
|
|
- pageId: number;
|
|
|
- advertisimentsListIds = [];
|
|
|
- count: number;
|
|
|
- perPagePagenation: number;
|
|
|
- currentPage:number = 1;
|
|
|
- filtterStatus = '';
|
|
|
- selectedAll: any;
|
|
|
- userLoginId:number;
|
|
|
- serviceId:number;
|
|
|
- dataTableNumber: number = 5;
|
|
|
+ advertisimentsList = [];
|
|
|
+ pages= [];
|
|
|
+ pageId: number;
|
|
|
+ advertisimentsListIds = [];
|
|
|
+ count: number;
|
|
|
+ perPagePagenation: number;
|
|
|
+ currentPage:number = 1;
|
|
|
+ filtterStatus = '';
|
|
|
+ selectedAll: any;
|
|
|
+ userLoginId:number;
|
|
|
+ serviceId:number;
|
|
|
+ dataTableNumber: number = 5;
|
|
|
|
|
|
- ngOnInit() {
|
|
|
- //init values of permisions
|
|
|
- this.authSer.showAddBtn = false;
|
|
|
- this.authSer.showDeleteBtn = false;
|
|
|
- this.authSer.showEditBtn = false;
|
|
|
- this.authSer.showPermissionsBtn = false;
|
|
|
- //show / hide notification search in header
|
|
|
- this.authSer.notificationLogin = true;
|
|
|
- this.authSer.showSearchHeader = false;
|
|
|
- this.authSer.showHeaderLogin = false;
|
|
|
- this.authSer.showHeaderDashBoard = true;
|
|
|
- this.authSer.showDashboardHeader = true;
|
|
|
- this.authSer.internalHeader = false;
|
|
|
- //to show / hide permissions
|
|
|
+ ngOnInit() {
|
|
|
+ //init values of permisions
|
|
|
+ this.authSer.showAddBtn = false;
|
|
|
+ this.authSer.showDeleteBtn = false;
|
|
|
+ this.authSer.showEditBtn = false;
|
|
|
+ this.authSer.showPermissionsBtn = false;
|
|
|
+ //show / hide notification search in header
|
|
|
+ this.authSer.notificationLogin = true;
|
|
|
+ this.authSer.showSearchHeader = false;
|
|
|
+ this.authSer.showHeaderLogin = false;
|
|
|
+ this.authSer.showHeaderDashBoard = true;
|
|
|
+ this.authSer.showDashboardHeader = true;
|
|
|
+ this.authSer.internalHeader = false;
|
|
|
+ //to show / hide permissions
|
|
|
|
|
|
- this.route.parent.params.subscribe(
|
|
|
- (params:Params) => {
|
|
|
- this.userLoginId = params['userID'];
|
|
|
- this.serviceId = params['serviceID'];
|
|
|
- this.userSer.getPagesPermetiotns(this.userLoginId, this.serviceId).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.pages = responce['pages'];
|
|
|
- for(let i = 0; i< this.pages.length; i++) {
|
|
|
- if(this.pages[i].id == 24) {
|
|
|
- for(let j = 0; j < this.pages[i].permissions.length; j++) {
|
|
|
- if(this.pages[i].permissions[j].name == 'add_main_ad'){
|
|
|
- this.authSer.showAddBtn = true;
|
|
|
- }
|
|
|
- if(this.pages[i].permissions[j].name == 'edit_main_ad'){
|
|
|
- this.authSer.showEditBtn = true;
|
|
|
- }
|
|
|
- if(this.pages[i].permissions[j].name == 'delete_main_ads'){
|
|
|
- this.authSer.showDeleteBtn = true;
|
|
|
+ this.route.parent.params.subscribe(
|
|
|
+ (params:Params) => {
|
|
|
+ this.userLoginId = params['userID'];
|
|
|
+ this.serviceId = params['serviceID'];
|
|
|
+ this.userSer.getPagesPermetiotns(this.userLoginId, this.serviceId).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.pages = responce['pages'];
|
|
|
+ for(let i = 0; i< this.pages.length; i++) {
|
|
|
+ if(this.pages[i].id == 24) {
|
|
|
+ for(let j = 0; j < this.pages[i].permissions.length; j++) {
|
|
|
+ if(this.pages[i].permissions[j].name == 'add_main_ad'){
|
|
|
+ this.authSer.showAddBtn = true;
|
|
|
+ }
|
|
|
+ if(this.pages[i].permissions[j].name == 'edit_main_ad'){
|
|
|
+ this.authSer.showEditBtn = true;
|
|
|
+ }
|
|
|
+ if(this.pages[i].permissions[j].name == 'delete_main_ads'){
|
|
|
+ this.authSer.showDeleteBtn = true;
|
|
|
+ }
|
|
|
}
|
|
|
+ }else {
|
|
|
+ console.log('no events');
|
|
|
}
|
|
|
- }else {
|
|
|
- console.log('no events');
|
|
|
}
|
|
|
- }
|
|
|
- this.spinner.hide();
|
|
|
- },
|
|
|
- (error) => {console.log(error)}
|
|
|
- );
|
|
|
- }
|
|
|
- );
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.route.params.subscribe(
|
|
|
- (parmas: Params) => {
|
|
|
- this.pageId = parmas['adverId'];
|
|
|
- }
|
|
|
- );
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ (error) => {console.log(error)}
|
|
|
+ );
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
|
|
|
- this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.advertisimentsList = responce['main_ads'];
|
|
|
- this.count = responce['count'];
|
|
|
- this.perPagePagenation = responce['per_page'];
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- console.log(error);
|
|
|
- }
|
|
|
- );
|
|
|
|
|
|
- }
|
|
|
+ this.route.params.subscribe(
|
|
|
+ (parmas: Params) => {
|
|
|
+ this.pageId = parmas['adverId'];
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
|
|
|
- //make all checkbox of user checked
|
|
|
- selectAll() {
|
|
|
+ this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.advertisimentsList = responce['main_ads'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //make all checkbox of user checked
|
|
|
+ selectAll() {
|
|
|
for (var i = 0; i < this.advertisimentsList.length; i++) {
|
|
|
this.advertisimentsList[i].selected = this.selectedAll;
|
|
|
}
|
|
@@ -121,120 +121,120 @@ export class AdvertisimentComponent implements OnInit {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- //filtter function
|
|
|
- filtterFunc(data) {
|
|
|
- this.advertisimentsList = [];
|
|
|
- console.log(data.target.value);
|
|
|
- const dataSearch = data.target.value;
|
|
|
- this.currentPage = 1;
|
|
|
- console.log('search curent page', this.currentPage);
|
|
|
- this.dashboardSer.getDataUSerSearchBar(dataSearch, this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.advertisimentsList = responce['main_ads'];
|
|
|
- this.count = responce['count'];
|
|
|
- this.perPagePagenation = responce['per_page'];
|
|
|
- console.log('filtter count', this.count);
|
|
|
- console.log('filtter perPagePAgenation', this.perPagePagenation);
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- console.log(error)
|
|
|
- }
|
|
|
- );
|
|
|
- };
|
|
|
-
|
|
|
- //change page
|
|
|
- onPageChange(pagenationNumber) {
|
|
|
- this.spinner.show();
|
|
|
- this.currentPage = pagenationNumber;
|
|
|
- this.advertisimentsList = [];
|
|
|
- //console.log(pagenationNumber);
|
|
|
- //console.log(this.pageId);
|
|
|
- this.dashboardSer.getListData(this.pageId, pagenationNumber, this.dataTableNumber).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.advertisimentsList = responce['main_ads'];
|
|
|
- this.count = responce['count'];
|
|
|
- this.perPagePagenation = responce['per_page'];
|
|
|
- console.log(this.advertisimentsList);
|
|
|
- this.spinner.hide();
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- console.log(error);
|
|
|
- this.spinner.hide();
|
|
|
- }
|
|
|
- );
|
|
|
- };
|
|
|
+ //filtter function
|
|
|
+ filtterFunc(data) {
|
|
|
+ this.advertisimentsList = [];
|
|
|
+ console.log(data.target.value);
|
|
|
+ const dataSearch = data.target.value;
|
|
|
+ this.currentPage = 1;
|
|
|
+ console.log('search curent page', this.currentPage);
|
|
|
+ this.dashboardSer.getDataUSerSearchBar(dataSearch, this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.advertisimentsList = responce['main_ads'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ console.log('filtter count', this.count);
|
|
|
+ console.log('filtter perPagePAgenation', this.perPagePagenation);
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
- //determine the list count from select element
|
|
|
- onGetValue(event) {
|
|
|
- this.spinner.show();
|
|
|
- this.advertisimentsList = [];
|
|
|
- this.dataTableNumber = event.target.value;
|
|
|
- this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.advertisimentsList = responce['main_ads'];
|
|
|
- this.count = responce['count'];
|
|
|
- this.perPagePagenation = responce['per_page'];
|
|
|
- this.spinner.hide();
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- console.log(error);
|
|
|
- this.spinner.hide();
|
|
|
- }
|
|
|
- );
|
|
|
+//change page
|
|
|
+onPageChange(pagenationNumber) {
|
|
|
+this.spinner.show();
|
|
|
+this.currentPage = pagenationNumber;
|
|
|
+this.advertisimentsList = [];
|
|
|
+//console.log(pagenationNumber);
|
|
|
+//console.log(this.pageId);
|
|
|
+this.dashboardSer.getListData(this.pageId, pagenationNumber, this.dataTableNumber).subscribe(
|
|
|
+(responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.advertisimentsList = responce['main_ads'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ console.log(this.advertisimentsList);
|
|
|
+ this.spinner.hide();
|
|
|
+},
|
|
|
+(error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.spinner.hide();
|
|
|
+}
|
|
|
+);
|
|
|
+};
|
|
|
+
|
|
|
+//determine the list count from select element
|
|
|
+onGetValue(event) {
|
|
|
+this.spinner.show();
|
|
|
+this.advertisimentsList = [];
|
|
|
+this.dataTableNumber = event.target.value;
|
|
|
+this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.advertisimentsList = responce['main_ads'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.spinner.hide();
|
|
|
}
|
|
|
+);
|
|
|
+}
|
|
|
|
|
|
- onDelete() {
|
|
|
+onDelete() {
|
|
|
|
|
|
- this.advertisimentsListIds = [];
|
|
|
- for(let i = 0; i < this.advertisimentsList.length; i++) {
|
|
|
- if(this.advertisimentsList[i].selected == true) {
|
|
|
- this.advertisimentsListIds.push(this.advertisimentsList[i].id);
|
|
|
- }
|
|
|
+ this.advertisimentsListIds = [];
|
|
|
+ for(let i = 0; i < this.advertisimentsList.length; i++) {
|
|
|
+ if(this.advertisimentsList[i].selected == true) {
|
|
|
+ this.advertisimentsListIds.push(this.advertisimentsList[i].id);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- console.log(this.advertisimentsListIds);
|
|
|
+ console.log(this.advertisimentsListIds);
|
|
|
|
|
|
- if(this.advertisimentsListIds.length > 0) {
|
|
|
- const dialogRef = this.modal.alert()
|
|
|
- .size('sm')
|
|
|
- .showClose(true)
|
|
|
- .title('تأكيد الحذف')
|
|
|
- .body(`
|
|
|
- <h4>هل ترغب في حذف العناصر المحدده ؟ </h4>
|
|
|
- `)
|
|
|
+ if(this.advertisimentsListIds.length > 0) {
|
|
|
+ const dialogRef = this.modal.alert()
|
|
|
+ .size('sm')
|
|
|
+ .showClose(true)
|
|
|
+ .title('تأكيد الحذف')
|
|
|
+ .body(`
|
|
|
+ <h4>هل ترغب في حذف العناصر المحدده ؟ </h4>
|
|
|
+ `)
|
|
|
.open();
|
|
|
-
|
|
|
- dialogRef.result
|
|
|
- .then( result =>
|
|
|
- this.dashboardSer.deleteItem(this.advertisimentsListIds, this.pageId).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.toastr.success('تم الحذف');
|
|
|
- this.spinner.show();
|
|
|
- this.advertisimentsList = [];
|
|
|
- this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.advertisimentsList = responce['main_ads'];
|
|
|
- this.count = responce['count'];
|
|
|
- this.perPagePagenation = responce['per_page'];
|
|
|
- this.spinner.hide();
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- console.log(error);
|
|
|
- this.spinner.hide();
|
|
|
- }
|
|
|
- );
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- console.log(error);
|
|
|
- this.spinner.hide();
|
|
|
+
|
|
|
+ dialogRef.result
|
|
|
+ .then( result =>
|
|
|
+ this.dashboardSer.deleteItem(this.advertisimentsListIds, this.pageId).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.toastr.success('تم الحذف');
|
|
|
+ this.spinner.show();
|
|
|
+ this.advertisimentsList = [];
|
|
|
+ this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.advertisimentsList = responce['main_ads'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ this.spinner.hide();
|
|
|
},
|
|
|
- )
|
|
|
- );
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.spinner.hide();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ )
|
|
|
+ );
|
|
|
} else {
|
|
|
this.toastr.warning('لم يتم إختيار أي عنصر للمسح !');
|
|
|
}
|
|
@@ -243,16 +243,16 @@ export class AdvertisimentComponent implements OnInit {
|
|
|
|
|
|
//add function
|
|
|
onAdd() {
|
|
|
- console.log('service/' + this.userLoginId + '/' + this.serviceId + '/advertisiment/add');
|
|
|
- this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/advertisiment/add']);
|
|
|
- }
|
|
|
+ console.log('service/' + this.userLoginId + '/' + this.serviceId + '/advertisiment/add');
|
|
|
+ this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/advertisiment/add']);
|
|
|
+}
|
|
|
|
|
|
- //edit function
|
|
|
- onEdit(editTabID) {
|
|
|
- localStorage.setItem('editAdevIdStorage', editTabID);
|
|
|
- this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/advertisiment/edit/']);
|
|
|
- console.log('service/' + this.userLoginId + '/' + this.serviceId + '/advertisiment/edit/');
|
|
|
- };
|
|
|
+//edit function
|
|
|
+onEdit(editTabID) {
|
|
|
+localStorage.setItem('editAdevIdStorage', editTabID);
|
|
|
+this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/advertisiment/edit/']);
|
|
|
+console.log('service/' + this.userLoginId + '/' + this.serviceId + '/advertisiment/edit/');
|
|
|
+};
|
|
|
|
|
|
|
|
|
|