|
@@ -16,164 +16,208 @@ import { ToastrService } from 'ngx-toastr';
|
|
|
})
|
|
|
export class AdvertisingServicesListComponent implements OnInit {
|
|
|
|
|
|
- constructor(private http: HttpClient,
|
|
|
- private route: ActivatedRoute,
|
|
|
- private router: Router,
|
|
|
- private modal: Modal,
|
|
|
- private userSer: UserService,
|
|
|
- private spinner: NgxSpinnerService,
|
|
|
- public authSer: AuthServiceService,
|
|
|
- private toastr: ToastrService,
|
|
|
- private dashboardSer: DashboardService) { }
|
|
|
+ constructor(private http: HttpClient,
|
|
|
+ private route: ActivatedRoute,
|
|
|
+ private router: Router,
|
|
|
+ private modal: Modal,
|
|
|
+ private userSer: UserService,
|
|
|
+ private spinner: NgxSpinnerService,
|
|
|
+ public authSer: AuthServiceService,
|
|
|
+ private toastr: ToastrService,
|
|
|
+ private dashboardSer: DashboardService) { }
|
|
|
|
|
|
- advertisingList = [];
|
|
|
- pages= [];
|
|
|
- pageId: number;
|
|
|
- advertisingListIds = [];
|
|
|
- count: number;
|
|
|
- perPagePagenation: number;
|
|
|
- currentPage:number = 1;
|
|
|
- filtterStatus = '';
|
|
|
- selectedAll: any;
|
|
|
- userLoginId:number;
|
|
|
- serviceId:number;
|
|
|
- dataTableNumber: number = 5;
|
|
|
+ advertisingList = [];
|
|
|
+ pages= [];
|
|
|
+ pageId: number;
|
|
|
+ advertisingListIds = [];
|
|
|
+ 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.params.subscribe(
|
|
|
- (parmas: Params) => {
|
|
|
- this.pageId = parmas['listPageId'];
|
|
|
- localStorage.setItem('pageIdActive', parmas['listPageId']);
|
|
|
- }
|
|
|
- );
|
|
|
-
|
|
|
- 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 == 22) {
|
|
|
- for(let j = 0; j < this.pages[i].permissions.length; j++) {
|
|
|
- if(this.pages[i].permissions[j].name == "add_advertising_service"){
|
|
|
- this.authSer.showAddBtn = true;
|
|
|
- }
|
|
|
- if(this.pages[i].permissions[j].name == "edit_advertising_service"){
|
|
|
- this.authSer.showEditBtn = true;
|
|
|
- }
|
|
|
- if(this.pages[i].permissions[j].name == "delete_advertising_services"){
|
|
|
- this.authSer.showDeleteBtn = true;
|
|
|
- }
|
|
|
+ this.route.params.subscribe(
|
|
|
+ (parmas: Params) => {
|
|
|
+ this.pageId = parmas['listPageId'];
|
|
|
+ localStorage.setItem('pageIdActive', parmas['listPageId']);
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ 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 == 22) {
|
|
|
+ for(let j = 0; j < this.pages[i].permissions.length; j++) {
|
|
|
+ if(this.pages[i].permissions[j].name == "add_advertising_service"){
|
|
|
+ this.authSer.showAddBtn = true;
|
|
|
+ }
|
|
|
+ if(this.pages[i].permissions[j].name == "edit_advertising_service"){
|
|
|
+ this.authSer.showEditBtn = true;
|
|
|
+ }
|
|
|
+ if(this.pages[i].permissions[j].name == "delete_advertising_services"){
|
|
|
+ this.authSer.showDeleteBtn = true;
|
|
|
}
|
|
|
- }else {
|
|
|
- console.log('no advertising services ');
|
|
|
}
|
|
|
+ }else {
|
|
|
+ console.log('no advertising services ');
|
|
|
}
|
|
|
- this.spinner.hide();
|
|
|
- },
|
|
|
- (error) => {console.log(error)}
|
|
|
- );
|
|
|
- }
|
|
|
- );
|
|
|
+ }
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ (error) => {console.log(error)}
|
|
|
+ );
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.advertisingList = responce['advertising_services'];
|
|
|
- this.count = responce['count'];
|
|
|
- this.perPagePagenation = responce['per_page'];
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- console.log(error);
|
|
|
- }
|
|
|
- );
|
|
|
+ this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.advertisingList = responce['advertising_services'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
- } //ngOnInit
|
|
|
+ } //ngOnInit
|
|
|
|
|
|
|
|
|
- //make all checkbox of user checked
|
|
|
- selectAll() {
|
|
|
- for (var i = 0; i < this.advertisingList.length; i++) {
|
|
|
- this.advertisingList[i].selected = this.selectedAll;
|
|
|
- }
|
|
|
- };
|
|
|
+ //make all checkbox of user checked
|
|
|
+ selectAll() {
|
|
|
+ for (var i = 0; i < this.advertisingList.length; i++) {
|
|
|
+ this.advertisingList[i].selected = this.selectedAll;
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- checkIfAllSelected() {
|
|
|
- this.selectedAll = this.advertisingList.every(function(item:any) {
|
|
|
- return item.selected == true;
|
|
|
- });
|
|
|
- };
|
|
|
+ checkIfAllSelected() {
|
|
|
+ this.selectedAll = this.advertisingList.every(function(item:any) {
|
|
|
+ return item.selected == true;
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
- //filtter function
|
|
|
- filtterFunc(data) {
|
|
|
- this.advertisingList = [];
|
|
|
- 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.advertisingList = responce['advertising_services'];
|
|
|
- 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)
|
|
|
- }
|
|
|
- );
|
|
|
- };
|
|
|
+ //filtter function
|
|
|
+ filtterFunc(data) {
|
|
|
+ this.advertisingList = [];
|
|
|
+ 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.advertisingList = responce['advertising_services'];
|
|
|
+ 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.advertisingList = [];
|
|
|
- //console.log(pagenationNumber);
|
|
|
- //console.log(this.pageId);
|
|
|
- this.dashboardSer.getListData(this.pageId, pagenationNumber, this.dataTableNumber).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.advertisingList = responce['advertising_services'];
|
|
|
- this.count = responce['count'];
|
|
|
- this.perPagePagenation = responce['per_page'];
|
|
|
- console.log(this.advertisingList);
|
|
|
- this.spinner.hide();
|
|
|
- },
|
|
|
- (error) => {
|
|
|
- console.log(error);
|
|
|
- this.spinner.hide();
|
|
|
- }
|
|
|
- );
|
|
|
- };
|
|
|
+ //change page
|
|
|
+ onPageChange(pagenationNumber) {
|
|
|
+ this.spinner.show();
|
|
|
+ this.currentPage = pagenationNumber;
|
|
|
+ this.advertisingList = [];
|
|
|
+ //console.log(pagenationNumber);
|
|
|
+ //console.log(this.pageId);
|
|
|
+ this.dashboardSer.getListData(this.pageId, pagenationNumber, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.advertisingList = responce['advertising_services'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ console.log(this.advertisingList);
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.spinner.hide();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ //determine the list count from select element
|
|
|
+ onGetValue(event) {
|
|
|
+ this.spinner.show();
|
|
|
+ this.advertisingList = [];
|
|
|
+ this.dataTableNumber = event.target.value;
|
|
|
+ this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.advertisingList = responce['advertising_services'];
|
|
|
+ this.count = responce['count'];
|
|
|
+ this.perPagePagenation = responce['per_page'];
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.spinner.hide();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
+ onDelete() {
|
|
|
|
|
|
- //determine the list count from select element
|
|
|
- onGetValue(event) {
|
|
|
+ this.advertisingListIds = [];
|
|
|
+ for(let i = 0; i < this.advertisingList.length; i++) {
|
|
|
+ if(this.advertisingList[i].selected == true) {
|
|
|
+ this.advertisingListIds.push(this.advertisingList[i].id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(this.advertisingListIds);
|
|
|
+
|
|
|
+ if(this.advertisingListIds.length > 0) {
|
|
|
+ const dialogRef = this.modal.alert()
|
|
|
+ .size('sm')
|
|
|
+ .showClose(true)
|
|
|
+ .title('تأكيد الحذف')
|
|
|
+ .body(`
|
|
|
+ <h4>هل ترغب في حذف العناصر المحدده ؟ </h4>
|
|
|
+ `)
|
|
|
+ .open();
|
|
|
+
|
|
|
+ dialogRef.result
|
|
|
+ .then( result =>
|
|
|
+ this.dashboardSer.deleteItem(this.advertisingListIds, this.pageId).subscribe(
|
|
|
+ (responce) => {
|
|
|
+ console.log(responce);
|
|
|
+ this.toastr.success('تم الحذف');
|
|
|
this.spinner.show();
|
|
|
this.advertisingList = [];
|
|
|
- this.dataTableNumber = event.target.value;
|
|
|
this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
(responce) => {
|
|
|
console.log(responce);
|
|
@@ -187,73 +231,29 @@ export class AdvertisingServicesListComponent implements OnInit {
|
|
|
this.spinner.hide();
|
|
|
}
|
|
|
);
|
|
|
- }
|
|
|
-
|
|
|
- onDelete() {
|
|
|
-
|
|
|
- this.advertisingListIds = [];
|
|
|
- for(let i = 0; i < this.advertisingList.length; i++) {
|
|
|
- if(this.advertisingList[i].selected == true) {
|
|
|
- this.advertisingListIds.push(this.advertisingList[i].id);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- console.log(this.advertisingListIds);
|
|
|
-
|
|
|
- if(this.advertisingListIds.length > 0) {
|
|
|
- const dialogRef = this.modal.alert()
|
|
|
- .size('sm')
|
|
|
- .showClose(true)
|
|
|
- .title('تأكيد الحذف')
|
|
|
- .body(`
|
|
|
- <h4>هل ترغب في حذف العناصر المحدده ؟ </h4>
|
|
|
- `)
|
|
|
- .open();
|
|
|
-
|
|
|
- dialogRef.result
|
|
|
- .then( result =>
|
|
|
- this.dashboardSer.deleteItem(this.advertisingListIds, this.pageId).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.toastr.success('تم الحذف');
|
|
|
- this.spinner.show();
|
|
|
- this.advertisingList = [];
|
|
|
- this.dashboardSer.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
|
|
|
- (responce) => {
|
|
|
- console.log(responce);
|
|
|
- this.advertisingList = responce['advertising_services'];
|
|
|
- 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('لم يتم إختيار أي عنصر للمسح !');
|
|
|
- }
|
|
|
- };
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ console.log(error);
|
|
|
+ this.spinner.hide();
|
|
|
+ },
|
|
|
+ )
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.toastr.warning('لم يتم إختيار أي عنصر للمسح !');
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- //add function
|
|
|
- onAdd() {
|
|
|
- console.log('service/' + this.userLoginId + '/' + this.serviceId + '/addAdvertising');
|
|
|
- this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/addAdvertising']);
|
|
|
- }
|
|
|
+ //add function
|
|
|
+ onAdd() {
|
|
|
+ console.log('service/' + this.userLoginId + '/' + this.serviceId + '/addAdvertising');
|
|
|
+ this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/addAdvertising']);
|
|
|
+ }
|
|
|
|
|
|
- //edit function
|
|
|
- onEdit(editTabID) {
|
|
|
- // localStorage.setItem('editeventCalendarIdStorage', editTabID);
|
|
|
- this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/advertising/edit/' + editTabID]);
|
|
|
- console.log('service/' + this.userLoginId + '/' + this.serviceId + '/advertising/edit/' + editTabID);
|
|
|
- };
|
|
|
+ //edit function
|
|
|
+ onEdit(editTabID) {
|
|
|
+ // localStorage.setItem('editeventCalendarIdStorage', editTabID);
|
|
|
+ this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/advertising/edit/' + editTabID]);
|
|
|
+ console.log('service/' + this.userLoginId + '/' + this.serviceId + '/advertising/edit/' + editTabID);
|
|
|
+ };
|
|
|
|
|
|
}
|