Merge branch 'enad-pre-live' of https://gitlab.com/haroon6138/mohemmionic5 into enad-pre-live

MOHEMM-Q3-DEV-LATEST
enadhilal 4 years ago
commit 9a70d4faaf

@ -175,6 +175,26 @@
{{ts.trPK('userProfile','HR-Request')}}
</ion-label>
</ion-item>
<div *ngFor="let menu of menuList">
<ion-item (click)="oepnMyRequest(menu)" *ngIf="menu.REQUEST_GROUP_NAME =='MBL_RG_01' && menu.MENU_TYPE =='E'">
<ion-thumbnail slot="start" class="menu-thumb">
<img style= "height: 20px !important;" src="../assets/imgs/my-request.png" item-left>
</ion-thumbnail>
<ion-label class="profile">
{{menu.MENU_NAME}}
</ion-label>
</ion-item>
</div>
<ion-item (click)="oepnTransaction()">
<ion-thumbnail slot="start" class="menu-thumb">
<img style= "height: 20px !important;" src="../assets/imgs/pending-transaction.png" item-left>
</ion-thumbnail>
<ion-label class="profile">
{{ts.trPK('general','pending-transaction')}}
</ion-label>
</ion-item>
<ion-item (click)="openChangePassword()">
<ion-thumbnail slot="start" class="menu-thumb">
<img style= "height: 25px !important;" src="../assets/imgs/lock_icon.png" item-left>

@ -46,7 +46,7 @@ export class HomeComponent implements OnInit {
this.selectedMenu = index;
}
}
if (page['FUNCTION_NAME'] == 'HR_TERM_SS') {
if (page['FUNCTION_NAME'] == 'HR_TERM_SS' || page['FUNCTION_NAME'] == 'HR_TERM_EMP_SS') {
this.cs.sharedService.setSharedData(page, TerminationServiceService.TERMINATION_PAGE);
this.cs.openTermination();

@ -114,6 +114,9 @@ import { CardCalendarComponent } from './ui/card-calendar/card-calendar.componen
import { WorklistSettingComponent } from '../notification/worklist-setting/worklist-setting.component';
import { SubmitAddressModalComponent } from '../profile/submit-eit-modal/submit-address-modal.component';
import { FileOpener } from '@ionic-native/file-opener/ngx';
import { FilePath } from '@ionic-native/file-path/ngx';
import { FileChooser } from "@ionic-native/file-chooser/ngx";
import { IOSFilePicker } from '@ionic-native/file-picker/ngx';
@NgModule({
imports: [
CommonModule,
@ -310,7 +313,10 @@ import { FileOpener } from '@ionic-native/file-opener/ngx';
OpenNativeSettings,
BarcodeScanner,
BackgroundGeolocation,
FileOpener
FileOpener,
FilePath,
FileChooser,
IOSFilePicker
],
entryComponents: [DateInfoModalComponent, WorklistSettingComponent],
})

@ -1376,6 +1376,9 @@ export class CommonService {
public openCreateitems() {
this.nav.navigateForward('/itemforsale/home');
}
public filterItemforSale() {
this.nav.navigateForward('/itemforsale/filter');
}
public navigatePage(path) {
this.nav.navigateForward([path]);
}
@ -1584,7 +1587,9 @@ export class CommonService {
return this.totalCounter;
}
setTotalNumberOfWorklistRequest() {
this.totalCounter -= 1;
if (this.totalCounter > 0) {
this.totalCounter -= 1;
}
this.sharedService.setSharedData(this.totalCounter, 'total-count');
}

@ -1,13 +1,40 @@
<input [id]="attachmentname" type="file" name="attachment" style="display:none" (change)='loadAttachment($event)'
accept="image/*,video/*,audio/*">
<ion-button (click)="openFile()" slot="end" expand="block" fill="outline">
<ion-icon name="attach" slot="start"></ion-icon>
{{'general,select-attachment' | translate}}
</ion-button>
<!-- <two-option-select (selected)="switchOptions($event)" [option1]="ts.trPK('settings','file')" [option2]="ts.trPK('settings','camera')"
[isOption1]="true"></two-option-select> -->
<div *ngIf="inputFiles.length>0" class="uploader-icons">
<ion-item *ngFor="let file of inputFiles; let i = index" lines="none">
<p slot="start"> <img [src]="attachmentImg" /> {{file.name}}</p>
<p slot="end"><img [src]="deleteImg" (click)="deleteFiles(i)"></p>
</ion-item>
</div>
<!-- <input [id]="attachmentname" type="file" name="attachment" style="display:none" (change)='loadAttachment($event)'
accept="jpg, jpeg, png, gif, pdf, doc, docx"> -->
<ion-button (click)="openFile()" slot="end" expand="block" fill="outline" class="uploader">
<ion-icon name="attach" slot="start" ></ion-icon>
{{'general,select-attachment' | translate}}
</ion-button>
<!-- <div class="uploader-icons">
<ion-item lines="none">
<p slot="start" class="file-name"> <img [src]="attachmentImg" /> {{file.name}}</p>
<p slot="end" class="delete-cont"><img [src]="deleteImg" (click)="deleteFiles(i)"></p>
</ion-item>
</div> -->
<ion-slides>
<ion-slide>
<ion-grid class=" gridAH" *ngIf="inputFiles.length>0">
<ion-row>
<ion-col lines="none" size="3" *ngFor="let file of inputFiles; let i = index">
<div class="image-container">
<div class="uploaded">
<div class="closed" (click)="deleteFiles(i)">X</div>
<img [src]="getImgContent(file.data) " />
</div>
</div>
</ion-col>
</ion-row>
</ion-grid>
</ion-slide>
</ion-slides>
<div *ngIf="errorMsg" class="error">
{{errorMsg}}
</div>

@ -2,4 +2,21 @@
width: .7cm;
height: .6cm;
vertical-align: middle;
}
.closed{
position: absolute;
right: 0;
font-size: 14px;
color: #fff;
top: -5px;
right: -10px;
font-weight: bolder;
background: red;
padding: 6px;
border-radius: 50%;
text-align: center;
line-height: .7;
}
.image-container{
margin-top: 10px;
}

@ -1,100 +1,288 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { AlertController } from '@ionic/angular';
import { Component, OnInit, Input, Output, EventEmitter, NgZone } from "@angular/core";
import { CommonService } from "src/app/hmg-common/services/common/common.service";
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service";
import { AlertController, ActionSheetController, Platform } from "@ionic/angular";
import {
Camera,
CameraOptions,
PictureSourceType
} from "@ionic-native/Camera/ngx";
import { FileChooser } from "@ionic-native/file-chooser/ngx";
import { File } from "@ionic-native/file/ngx";
import { FilePath } from "@ionic-native/file-path/ngx";
import { Base64 } from "@ionic-native/base64/ngx";
import { IOSFilePicker } from '@ionic-native/file-picker/ngx';
import { Location } from '@angular/common';
import { DomSanitizer, SafeUrl } from "@angular/platform-browser";
export interface CustomWindow extends Window {
File: any;
FileReader: any;
}
declare let window: CustomWindow;
@Component({
selector: 'file-uploader',
templateUrl: './file-uploader.component.html',
styleUrls: ['./file-uploader.component.scss']
selector: "file-uploader",
templateUrl: "./file-uploader.component.html",
styleUrls: ["./file-uploader.component.scss"]
})
export class FileUploaderComponent implements OnInit {
@Input() multiupload = false;
@Input() attachmentname = 'attachment-loader';
@Input() attachmentname = "attachment-loader";
public attachmentData: string;
@Input() maxFileSize = 10 * 1024 * 1024;
public errorMsg: string;
public selectedOpn: number = 1;
public allowdType: any = ["jpg", "jpeg", "png", "gif", "pdf", "doc", "docx"];
@Input() maxFileSize = 5 * 1024 * 1024;
@Output() fileSelected = new EventEmitter();
public inputFiles: any = [];
public attachmentImg = 'assets/icon/attachment.png';
public deleteImg = 'assets/icon/delete.png';
public attachmentImg = "assets/icon/attachment.png";
public deleteImg = "assets/icon/delete.png";
public nativePath: any;
public actionSheet: any;
public isActionSheetShown: boolean = false;
@Input() selectedAttachment = [];
constructor(
public cs: CommonService,
public ts: TranslatorService,
public alertController: AlertController
) {
}
public alertController: AlertController,
private cameraController: Camera,
private actionSheetController: ActionSheetController,
private fileChooser: FileChooser,
private file: File,
private filePath: FilePath,
public base64: Base64,
public platform: Platform,
private iOSfilePicker: IOSFilePicker,
public ngzone: NgZone,
public loc: Location,
public sanitizer: DomSanitizer
) { }
ngOnInit() {
this.platform.backButton.subscribeWithPriority(9999, () => {
// You decide what happens
if (this.isActionSheetShown)
this.actionSheet.dismiss();
else
this.loc.back();
});
this.inputFiles = this.selectedAttachment;
}
public loadAttachment(changeEvent) {
const fileInput = this.getFileElement();
if (this.isFileSupported()) {
if (fileInput.files != null && fileInput.files.length > 0) {
const file = fileInput.files[0];
const reader = new FileReader();
if (file.size <= this.maxFileSize) {
reader.onload = (data) => {
if (this.multiupload) {
this.inputFiles.push({name: file.name, data: data.target['result']});
} else {
this.inputFiles = [{name: file.name, data: data.target['result']}];
}
this.fileSelected.emit( {
name: file.name ,
data: data.target['result'],
inputFiles: this.inputFiles
});
};
reader.readAsDataURL(file);
} else {
this.attachmentData = null;
changeEvent.target.value = ''; // remove current selection
this.showFileExceededMaxSize();
}
} else {
this.attachmentData = null;
}
}
ngOnDestroy(): void {
}
async openFile() {
if (this.platform.is('ios'))
this.openiOSActionSheet();
else
this.openAndroidActionSheet();
//this.openiOSActionSheet();
private isFileSupported() {
return (window.FileReader && window.File);
}
async openAndroidActionSheet() {
this.actionSheet = await this.actionSheetController.create({
header: this.ts.trPK("itemforsale", "slect-source-file"), //"Select Image file",
private showFileExceededMaxSize() {
this.cs.presentConfirmDialog(
this.ts.trPK('general', 'large-file'),
() => {
this.openFile();
},
() => {
}
);
buttons: [
{
text: this.ts.trPK("itemforsale", "from-library"),
handler: () => {
this.takePictureiOS();
}
},
{
text: this.ts.trPK("itemforsale", "from-camera"),
handler: () => {
this.takePicture(this.cameraController.PictureSourceType.CAMERA);
}
},
{
text: this.ts.trPK("general", "cancel"),
role: "cancel"
}
]
});
this.isActionSheetShown = true;
await this.actionSheet.present();
}
private getFileElement(): HTMLInputElement {
return document.getElementById(this.attachmentname) as HTMLInputElement;
async openiOSActionSheet() {
this.actionSheet = await this.actionSheetController.create({
header: this.ts.trPK("itemforsale", "slect-source-file"), //"Select Image file",
buttons: [
{
text: this.ts.trPK("itemforsale", "from-library"),
handler: () => {
this.takePictureiOS();
}
},
{
text: this.ts.trPK("itemforsale", "from-camera"),
handler: () => {
this.takePicture(this.cameraController.PictureSourceType.CAMERA);
}
},
{
text: this.ts.trPK("itemforsale", "from-icloud"),
handler: () => {
this.takePicture(this.cameraController.PictureSourceType.PHOTOLIBRARY);
}
},
{
text: this.ts.trPK("general", "cancel"),
role: "cancel"
}
]
});
this.isActionSheetShown = true;
await this.actionSheet.present();
}
public openFile() {
const fileInput = this.getFileElement();
fileInput.click();
public takePictureiOS() {
const options: CameraOptions = {
quality: 60,
sourceType: this.cameraController.PictureSourceType.PHOTOLIBRARY,
destinationType: this.cameraController.DestinationType.DATA_URL,
encodingType: this.cameraController.EncodingType.JPEG,
mediaType: this.cameraController.MediaType.PICTURE,
correctOrientation: true,
}
this.cameraController.getPicture(options).then((imageData) => {
const data = "data:image/jpeg;base64," + imageData;
this.pushFiles(this.getFileName(), data);
}, (err) => {
});
}
public deleteFiles(index: number) {
this.inputFiles.splice(index, 1);
this.fileSelected.emit( {
this.fileSelected.emit({
name: null,
data: '',
data: "",
inputFiles: this.inputFiles
});
this.errorMsg = null;
}
public switchOptions($event) {
this.selectedOpn = $event;
}
public takePicture(sourceType: PictureSourceType) {
const options: CameraOptions = {
quality: 50,
destinationType: this.cameraController.DestinationType.DATA_URL,
encodingType: this.cameraController.EncodingType.JPEG,
sourceType: sourceType,
mediaType: this.cameraController.MediaType.PICTURE,
correctOrientation: true
};
if (sourceType === this.cameraController.PictureSourceType.PHOTOLIBRARY) {
if (this.platform.is('android')) {
this.fileChooser
.open()
.then(uri => {
this.readFile(uri);
})
.catch(e => { });
} else {
this.iOSfilePicker.pickFile(['public.content']).then(uri => {
let correctPath = uri.substr(0, uri.lastIndexOf('/') + 1);
let currentName = uri.substring(uri.lastIndexOf('/') + 1);
this.nativePath = uri;
this.file.readAsDataURL("file:///" + correctPath, currentName).then(result => {
this.pushFiles(currentName, result);
}).catch(e => { });
}).catch(e => { });
}
} else {
this.cameraController.getPicture(options).then(imageData => {
const data = "data:image/jpeg;base64," + imageData;
this.pushFiles(this.getFileName(), data);
});
}
}
pushFiles(name, files) {
this.ngzone.run(() => {
if (this.multiupload) {
this.inputFiles.push({ name: name, data: files });
} else {
this.inputFiles = [{ name: name, data: files }];
}
this.fileSelected.emit({
name: name,
data: files,
inputFiles: this.inputFiles
});
});
}
readFile(fileUrl: any) {
this.filePath.resolveNativePath(fileUrl).then(filePathResult => {
this.nativePath = filePathResult;
this.file.resolveLocalFilesystemUrl(this.nativePath).then(entry => {
entry.getMetadata(metadata => {
if (metadata.size <= this.maxFileSize) {
this.errorMsg = null;
this.encodeFiles(entry);
} else {
this.errorMsg = this.ts.trPK("general", "large-file");
}
}, (error) => {
console.log(error)
});
});
});
}
getImgContent(imgFile, data): SafeUrl {
console.log(imgFile);
return this.sanitizer.bypassSecurityTrustUrl(imgFile);
}
checkDuplicate(name: string) {
return this.inputFiles.filter(a => {
return a.name === name;
});
}
encodeFiles(entry) {
let fileName = entry.nativeURL.split('/').pop();
let path = entry.nativeURL.substring(0, entry.nativeURL.lastIndexOf("/") + 1);
this.file.readAsDataURL(path, fileName)
.then(base64File => {
})
.catch((err) => {
console.log('Error reading file', err);
})
this.base64.encodeFile(this.nativePath).then(
(base64File: string) => {
const type = this.nativePath.substr(
this.nativePath.lastIndexOf(".") + 1
);
if (this.allowdType.includes(type.toLowerCase())) {
if (this.checkDuplicate(entry.name).length === 0) {
this.pushFiles(entry.name, base64File);
this.errorMsg = null;
} else {
this.errorMsg = this.ts.trPK("general", "file-name-exist");
}
} else {
this.attachmentData = null;
this.errorMsg = this.ts.trPK("general", "not-supported");
}
},
err => {
console.log(err);
}
);
}
getFileName() {
const date = new Date().valueOf();
let text = "";
const possibleText =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < 5; i++) {
text += possibleText.charAt(
Math.floor(Math.random() * possibleText.length)
);
}
const imageName = date + "." + text + ".jpeg";
return imageName;
}
}

@ -0,0 +1,35 @@
<app-generic-header
showImage="false"
showBack="false"
navigate="false"
backlink="false"
[headerText]="'general,filter-offers' | translate">
</app-generic-header>
<ion-content>
<div class="container-icon" *ngIf="categories.length>0">
<ion-item lines="none" *ngFor="let key of categories" (click)="filterOffers(key)" [ngClass]="{'active':activeClass==key.title }">
<ion-label *ngIf="direction =='ltr'">
{{key.title}}
</ion-label>
<ion-label *ngIf="direction =='rtl'">
{{key.title_ar}}
</ion-label>
<ion-thumbnail slot="start">
<div class="top-filter" [innerHTML]="key.content | sanitizeHTMLPipe"></div>
</ion-thumbnail>
</ion-item>
</div>
<ion-footer >
<div class="centerDiv">
<ion-button class="footer-button" ion-button (click)="applyFilters()">
{{ts.trPK('general','apply-filters')}} </ion-button>
</div>
</ion-footer>
</ion-content>

@ -0,0 +1,38 @@
ion-label{
font-size: 14px !important;
}
ion-thumbnail img{
width: 40px;
height: 40px;
margin: 10px;
}
.active::before{
position: absolute;
right: 10px;
top: 15px;
padding: 0px;
background: #3cc353;
padding: 3px 2px 1px 3px;
border-radius: 60%;
font-size: 12px;
color: #fff;
content: '';
width: 20px;
height: 20px;
text-align: center;
z-index: 2;
}
ion-item{
border-bottom: 1px solid #ccc;
--padding-start: 0px;
margin: 0 20px 4px 20px;
}
.footer-button{
background: var(--newgreen)!important;border-radius: 10px; --background: transparent;
width: 80%;
}
ion-footer{
position: fixed;
bottom: 0;
}

@ -0,0 +1,27 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FilterComponent } from './filter.component';
describe('FilterComponent', () => {
let component: FilterComponent;
let fixture: ComponentFixture<FilterComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FilterComponent ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(FilterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,56 @@
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { ModalController } from '@ionic/angular';
import { OfferDiscountService } from 'src/app/offersdiscount/services/service';
import { ItemForSaleService } from '../services/service.service';
@Component({
selector: 'app-filter',
templateUrl: './filter.component.html',
styleUrls: ['./filter.component.scss'],
})
export class FilterComponent implements AfterViewInit {
segment: any = '1';
categoriesObj: any;
categories: any = [];
offersData: any = [];
activeClass: any;
tempSearch: any = [];
searchText: String;
public activeKey = {}
direction: any;
constructor(public ts: TranslatorService, public modalController: ModalController, public cs: CommonService, public offersService: OfferDiscountService) { }
ngAfterViewInit(): void {
this.direction = TranslatorService.getCurrentDirection();
this.categories = this.cs.sharedService.getSharedData(OfferDiscountService.categories, false);
// this.getOfferDiscount();
}
openDetails(offer) {
// this.cs.sharedService.setSharedData(offer, OfferDiscountService.selected_offers);
// var related = this.offersData.filter((res) => res.rowID != offer.rowID);
// this.cs.sharedService.setSharedData(related, OfferDiscountService.related_offers);
// this.cs.navigateForward('/offersdiscount/offer-details');
}
filterOffers(key) {
this.activeKey = key
this.activeClass = key.title;
}
applyFilters() {
this.cs.sharedService.setSharedData(this.activeKey, ItemForSaleService.selected_filters);
this.cs.back();
}
}

@ -128,7 +128,7 @@
<ion-col size="12">
<p>{{ts.trPK('itemforsale','item-price')}}</p>
<ion-item lines="none">
<ion-input [placeholder]="ts.trPK('itemforsale','item-price')" [(ngModel)]="itemPrice"></ion-input>
<ion-input [placeholder]="ts.trPK('itemforsale','item-price')" type="number" [(ngModel)]="itemPrice"></ion-input>
</ion-item>
</ion-col>
</ion-row>
@ -138,29 +138,14 @@
</ion-row>
<div>
<div class="fileUpload btn btn-primary">
<img slot="start" style=" height: 55px;"src="../assets/imgs/add-photo.svg">
<input end class="upload" type="file" ng2FileSelect [uploader]="uploader"
(change)="onFileSelected($event)" (click)="onFileSelectedclick($event)" />
<!-- <img slot="start" style=" height: 55px;"src="../assets/imgs/add-photo.svg"> -->
<!-- <input end class="upload" type="file" ng2FileSelect [uploader]="uploader"
(change)="onFileSelected($event)" (click)="onFileSelectedclick($event)" /> -->
<file-uploader (fileSelected)="attachmentSelected($event)" [maxFileSize]="maxFileSize"
[multiupload]="true" [selectedAttachment]="selectedPicture">
</file-uploader>
</div>
<ion-slides>
<ion-slide>
<ion-grid class=" gridAH" *ngIf="uploader?.queue?.length > 0 || addAttachRequest.length>0">
<ion-row>
<ion-col lines="none" size="3" *ngFor="let obj of addAttachRequest">
<div class="image-container">
<div class="uploaded">
<div class="closed" *ngIf="!obj.attachmentId">X</div>
<img [src]="getImgContent('data:image/png;base64, ' +obj.Base64Data) " />
</div>
</div>
</ion-col>
</ion-row>
</ion-grid>
</ion-slide>
</ion-slides>
</div>
</ion-grid>
@ -190,7 +175,7 @@
<ion-slides>
<ion-slide>
<ion-grid class=" gridAH" *ngIf="uploader?.queue?.length > 0 || addAttachRequest.length>0">
<ion-grid class=" gridAH" *ngIf="addAttachRequest.length>0">
<ion-row>
<ion-col lines="none" size="3" *ngFor="let obj of addAttachRequest">
@ -223,7 +208,7 @@
<ion-footer *ngIf="step==1">
<div class="centerDiv">
<ion-button class="footer-button red-button" ion-button>
<ion-button class="footer-button red-button" (click)="cancelItem()" ion-button>
{{ts.trPK('general','cancel')}} </ion-button>
@ -233,9 +218,9 @@
<ion-footer *ngIf="step>1">
<div class="centerDiv">
<ion-button class="footer-button red-button small-btn" ion-button (click)="step =1" *ngIf="step ==2 || step ==3">
<ion-button class="footer-button red-button small-btn" ion-button (click)="cancelItem()" *ngIf="step ==2 || step ==3">
{{ts.trPK('general','cancel')}} </ion-button>
<ion-button class="footer-button small-btn" ion-button (click)="step =3" *ngIf="step ==2">
<ion-button class="footer-button small-btn" ion-button (click)="step =3" *ngIf="step ==2" [disabled]="!validate()">
{{ts.trPK('general','next')}} </ion-button>
<ion-button class="footer-button small-btn" ion-button (click)="createItemForSale()" *ngIf="step ==3 && !editItem">

@ -19,6 +19,7 @@ export class HomeComponent implements OnInit {
public selectedFile: any;
indexLastObj: any = 0;
addAttachRequest: any = [];
selectedPicture = [];
selectedCategory: any;
filterAllowedType: any = [
"image/jpeg",
@ -37,6 +38,7 @@ export class HomeComponent implements OnInit {
ngOnInit() {
this.direction = TranslatorService.getCurrentDirection();
this.categories = this.cs.sharedService.getSharedData(ItemForSaleService.CATEGORIES, false);
this.categories.shift();
this.getRegion();
this.editItem = this.cs.sharedService.getSharedData(ItemForSaleService.EDIT_ITEMS);
if (this.editItem) {
@ -86,59 +88,59 @@ export class HomeComponent implements OnInit {
onFileSelected(input) {
if (!(this.filterAllowedType.indexOf(input.target.files[0].type) > -1)) {
let msg: string = "";
msg = this.ts.trPK("general", "notSupportFile");
this.cs.presentAlert(msg);
return;
} // todo: show alert that you tried uploading wrong files
else {
const file = input.target.files[0];
this.selectedFile = input.target.files;
// onFileSelected(input) {
// if (!(this.filterAllowedType.indexOf(input.target.files[0].type) > -1)) {
// let msg: string = "";
// msg = this.ts.trPK("general", "notSupportFile");
// this.cs.presentAlert(msg);
// return;
// } // todo: show alert that you tried uploading wrong files
// else {
// const file = input.target.files[0];
// this.selectedFile = input.target.files;
this.getBase64(file).then(data =>
this.pushObject(data, file.name, file.type)
);
}
}
// this.getBase64(file).then(data =>
// this.pushObject(data, file.name, file.type)
// );
// }
// }
getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
// getBase64(file) {
// return new Promise((resolve, reject) => {
// const reader = new FileReader();
// reader.readAsDataURL(file);
// reader.onload = () => resolve(reader.result);
// reader.onerror = error => reject(error);
// });
// }
pushObject(fileData, name, type) {
// pushObject(fileData, name, type) {
this.indexLastObj++;
try {
let array = name.split(".");
let attachType: string = array[array.length - 1];
// this.indexLastObj++;
// try {
// let array = name.split(".");
// let attachType: string = array[array.length - 1];
this.addAttachRequest.push({
AttachmentID: this.indexLastObj,
ContentType: 'image/' + attachType, //type.split('/')[1],
Base64Data: fileData.split(",")[1],
FileName: name, //.split('.')[0],
// this.addAttachRequest.push({
// AttachmentID: this.indexLastObj,
// ContentType: 'image/' + attachType, //type.split('/')[1],
// Base64Data: fileData.split(",")[1],
// FileName: name, //.split('.')[0],
});
} catch (e) { }
}
// });
// } catch (e) { }
// }
removeFile(objectitem) {
let objIndex1 = this.uploader.queue.findIndex(item => item == objectitem);
this.uploader.queue.splice(objIndex1, 1);
let objIndex = this.addAttachRequest.findIndex(
item => item.AttachmentID == objectitem.AttachmentID
);
this.addAttachRequest.splice(objIndex, 1);
}
getImgContent(imgFile): SafeUrl {
return this.sanitizer.bypassSecurityTrustUrl(imgFile);
}
@ -205,17 +207,17 @@ export class HomeComponent implements OnInit {
this.itemPrice = this.editItem.quotePrice;
this.regionID = this.editItem.regionID;
this.itemCondition = this.editItem.status.toLowerCase();
this.addAttachRequest = this.getAttachment(this.editItem.itemAttachments);
this.selectedPicture = this.getAttachment(this.editItem.itemAttachments);
}
getAttachment(itemsArray) {
let item = [];
itemsArray.forEach(element => {
item.push({
attachmentId: element.attachmentId,
ContentType: element.contentType,
Base64Data: element.content,
FileName: element.fileName,
// attachmentId: element.attachmentId,
// ContentType: element.contentType,
data: 'data:image/png;base64,' + element.content,
name: element.fileName,
});
});
@ -262,4 +264,52 @@ export class HomeComponent implements OnInit {
})
}
cancelItem() {
if (this.step == 2 || this.step == 3) {
this.step = 1;
} else {
this.cs.back();
}
}
validate() {
if (!this.validateChar(this.itemInfo) || !this.itemDescription || !this.itemPrice || !this.itemCondition) {
return false;
} else {
return true;
}
}
validateChar(text) {
var regExp = /^[a-zA-Z]*$/
if ((!regExp.test(text) && !this.hasArabicCharacters(text)) || !text) {
return false;
}
else {
return true;
}
}
hasArabicCharacters(text) {
var regex = new RegExp("[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufc3f]|[\ufe70-\ufefc]");
return regex.test(text);
}
public attachmentSelected(event: any) {
try {
this.addAttachRequest = event.inputFiles.map((res: any) => {
let array = res.name.split(".");
let attachType: string = array[array.length - 1];
this.indexLastObj++;
return { AttachmentID: this.indexLastObj, FileName: res.name, Base64Data: res.data.split(",")[1], ContentType: 'image/' + attachType };
});
} catch (e) { }
}
}

@ -12,6 +12,7 @@
<div >
<ion-card>
<ion-card-header>
<img *ngIf="!item.itemAttachments[0] || !item.itemAttachments[0].content" src="assets/imgs/no-images.png" />
<!-- <img *ngIf="itemDetails.itemAttachments[0]" [src]="item.itemAttachments[0]" />
<img *ngIf="!itemDetails.itemAttachments[0]" src="assets/imgs/no-images.png" /> -->
<ion-slides *ngIf="itemDetails.itemAttachments.length>0">

@ -13,6 +13,7 @@ import { MyAdsComponent } from './my-ads/my-ads.component';
import { HmgCommonModule } from '../hmg-common/hmg-common.module';
import { ItemForSaleService } from './services/service.service';
import { SanitizeHtmlPipe } from './services/domsafe';
import { FilterComponent } from './filter/filter.component';
const routes: Routes = [
{
@ -34,6 +35,10 @@ const routes: Routes = [
{
path: 'my-ads',
component: MyAdsComponent
},
{
path: 'filter',
component: FilterComponent
}
],
}
@ -47,7 +52,7 @@ const routes: Routes = [
HmgCommonModule,
RouterModule.forChild(routes)
],
declarations: [ItemforsalePage, HomeComponent, ItemsComponent, ItemDetailsComponent, MyAdsComponent, SanitizeHtmlPipe],
declarations: [ItemforsalePage, HomeComponent, ItemsComponent, ItemDetailsComponent, MyAdsComponent, SanitizeHtmlPipe, FilterComponent],
providers: [ItemForSaleService],
exports: [SanitizeHtmlPipe]
})

@ -37,7 +37,7 @@
<p class="filterText"> {{ts.trPK('itemforsale','browse-categories')}} </p>
</ion-col>
<ion-col size="2">
<img class="filter-icon" src="assets/imgs/itemsforsale/filter.svg">
<img class="filter-icon" src="assets/imgs/itemsforsale/filter.svg" (click)="openModel()">
</ion-col>
</ion-row>
</ion-grid>
@ -63,7 +63,7 @@
</div>
<ion-row *ngIf="items">
<ion-col size="6" (click)="openDetails(item)" *ngFor="let item of items">
<ion-card>
<ion-card *ngIf="item.status.toLowerCase() =='approved'">
<ion-card-header>
<img *ngIf="item.itemAttachments[0] && item.itemAttachments[0].content" [src]="getImgContent('data:image/png;base64, ' +item.itemAttachments[0].content)" />
<img *ngIf="!item.itemAttachments[0] || !item.itemAttachments[0].content" src="/assets/imgs/no-images.png" />

@ -22,13 +22,28 @@ export class ItemsComponent implements OnInit {
pageNo: number = 1;
tempSearch: any = [];
itemsByEmployee: any = [];
allCategory = {
categoryID: 0,
content: '<svg xmlns="http://www.w3.org/2000/svg" width="33.925" height="25.841" viewBox="0 0 33.925 25.841"><g id="More_Select" data-name="More Select"><path d="m30 1h-24a1 1 0 0 0 -1 1v1h21a3 3 0 0 1 3 3v21h1a1 1 0 0 0 1-1v-24a1 1 0 0 0 -1-1z"/><path d="m26 5h-24a1 1 0 0 0 -1 1v24a1 1 0 0 0 1 1h24a1 1 0 0 0 1-1v-24a1 1 0 0 0 -1-1zm-4.747 9.344-8.728 8.726a1 1 0 0 1 -1.414 0l-4.364-4.363a1 1 0 0 1 1.414-1.414l3.657 3.656 8.021-8.019a1 1 0 0 1 1.414 1.414z"/></g></svg>',
isActive: true,
title: "All",
title_Ar: "الجميع",
}
constructor(public ts: TranslatorService, public route: ActivatedRoute, private sanitizer: DomSanitizer, public cs: CommonService, private itemService: ItemForSaleService, private authService: AuthenticationService) {
this.route
.params.subscribe(val => {
setTimeout(() => {
this.cs.startLoading();
this.getItemsCategories();
this.getItemsByEmployee();
var selectedFilter = this.cs.sharedService.getSharedData(ItemForSaleService.selected_filters);
if (selectedFilter) {
this.selectCategory(selectedFilter);
}
else {
this.getItemsCategories();
this.getItemsByEmployee();
}
}, 100);
});
@ -43,6 +58,7 @@ export class ItemsComponent implements OnInit {
this.itemService.getCategories({}, () => { }, this.ts.trPK('general', 'retry')).subscribe((result) => {
this.categories = this.itemService.parser(result);
this.categories.unshift(this.allCategory);
this.cs.sharedService.setSharedData(this.categories, ItemForSaleService.CATEGORIES);
})
this.itemService.getItems({ pageNo: this.pageNo }, () => { }, this.ts.trPK('general', 'retry')).subscribe((result) => {
@ -149,4 +165,7 @@ export class ItemsComponent implements OnInit {
}
})
}
openModel() {
this.cs.filterItemforSale();
}
}

@ -17,6 +17,7 @@ export class ItemForSaleService {
public static ITEMS_SELECTED = 'item-selected';
public static CATEGORIES = 'categories';
public static EDIT_ITEMS = 'edit-items';
public static selected_filters = 'selected_filter';
constructor(
public con: ConnectorService,
private authService: AuthenticationService,

@ -323,7 +323,7 @@ export class HomeComponent implements OnInit {
} else if (allowVal == 'contact') {
this.openContact()
} else if ('add-update-contact') {
} else if (allowVal == 'add-update-contact') {
this.transactionNo++;
this.cs.sharedService.setSharedData({ dirfromNotificationPage: false, submitEITObjList: undefined, transNo: this.transactionNo }, 'AddEITData');
this.cs.openAddUpdateContact();

@ -48,7 +48,7 @@ export class ConcurrentReportComponent implements OnInit {
private validEitTransactionTbl: any = [];
eitSubmitAction: number = 0;
updatedValues: any = [];
comtransNo: any = 0;
comtransNo: any = 1;
programList: any = [];
public template: any;
constructor(public cs: CommonService, private elementRef: ElementRef, public reports: ReportServiceService, public ts: TranslatorService, public eitService: EitService) { }

@ -0,0 +1 @@
<svg height="512" viewBox="0 0 32 32" width="512" xmlns="http://www.w3.org/2000/svg"><g id="More_Select" data-name="More Select"><path d="m30 1h-24a1 1 0 0 0 -1 1v1h21a3 3 0 0 1 3 3v21h1a1 1 0 0 0 1-1v-24a1 1 0 0 0 -1-1z"/><path d="m26 5h-24a1 1 0 0 0 -1 1v24a1 1 0 0 0 1 1h24a1 1 0 0 0 1-1v-24a1 1 0 0 0 -1-1zm-4.747 9.344-8.728 8.726a1 1 0 0 1 -1.414 0l-4.364-4.363a1 1 0 0 1 1.414-1.414l3.657 3.656 8.021-8.019a1 1 0 0 1 1.414 1.414z"/></g></svg>

After

Width:  |  Height:  |  Size: 449 B

@ -3213,6 +3213,22 @@
}
},
"itemforsale": {
"slect-source-file": {
"en": "Select source file",
"ar": "حدد مصدر الملف"
},
"from-camera": {
"en": "Use Camera",
"ar": "استخدام الكاميرا"
},
"from-library": {
"en": "From Library",
"ar": "من ملفات الجهاز"
},
"from-icloud": {
"en": "From iCloud Drive",
"ar": "من iCloud Drive"
},
"warning": {
"en": "This ad will be valid for 2 week after approval",
"ar": "هذا الإعلان ساري المفعول لمدة أسبوعين بعد الموافقة"

Loading…
Cancel
Save