offers and discount and ERM

zohaib-huawei-q2
Sultan Khan 5 years ago
parent bce8df964f
commit b9baa8b12e

@ -137,11 +137,41 @@ export class AppComponent implements OnInit {
this.authService.checkAds({ this.authService.checkAds({
EmployeeNumber: '', EmployeeNumber: '',
ItgEnableAt: "Before Service Initiation", ItgEnableAt: "After Service Submission", //Before Service Initiation
ItgServiceName: "Ticket" ItgServiceName: "Login"
}, () => { }, this.ts.trPK('general', 'ok')).subscribe(res => { }, () => { }, this.ts.trPK('general', 'ok')).subscribe(res => {
console.log("Check Ads")
console.log(res); var result = JSON.parse(res.Mohemm_ITG_ResponseItem).result.data;
this.cs.sharedService.setSharedData(
result,
AuthenticationService.SERVEY_DATA
)
if (!CommonService.SKIP && result) {
if (result.notificationType == 'Survey') {
this.cs.navigateForward('/erm-channel/survey');
} else {
this.authService.adsDetails({
"ItgNotificationMasterId": result['notificationMasterId']
},
() => { }, this.ts.trPK('general', 'ok')
).subscribe((result) => {
var data = result.Mohemm_ITG_ResponseItem;
if (data) {
this.cs.sharedService.setSharedData(
JSON.parse(data),
AuthenticationService.ADS_DATA
);
this.cs.navigateForward('/erm-channel/home');
}
})
}
}
}); });
if (this.cs.getUpdateImage().status) { if (this.cs.getUpdateImage().status) {
@ -151,8 +181,8 @@ export class AppComponent implements OnInit {
} }
this.User_Job_name = user.JOB_NAME; this.User_Job_name = user.JOB_NAME;
//erm channel //erm channel
if (!CommonService.SKIP) // if (!CommonService.SKIP)
this.cs.navigateForward('/erm-channel/survey'); // this.cs.navigateForward('/erm-channel/survey');
} else { } else {
console.log(user); console.log(user);
} }

@ -1,13 +1,19 @@
<div class="full-ads" style="background-image: url(https://i.pinimg.com/564x/a8/b4/42/a8b442181f7c004f98d4eef842a76e76.jpg);"> <div class="full-ads" >
<div class="skip-btn" (click)="skip()" *ngIf="isSkip ==true">{{ts.trPK('worklistMain','skip')}}</div> <img [src]="advertisement.base64String" *ngIf="advertisement.contentType =='image/jpeg'"/>
<div class="seconds" *ngIf="isSkip ==false">{{setTime}}</div>
<div class="info-container"> <iframe *ngIf="advertisement.contentType =='video/mp4'" [src]="sanitizer.bypassSecurityTrustResourceUrl(advertisement.fileName)" allow="autoplay;" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<ion-icon name="thumbs-down" class="red"></ion-icon> <!-- <div class="skip-btn" (click)="skip()" *ngIf="isSkip ==true">{{ts.trPK('worklistMain','skip')}}</div> -->
<ion-icon name="information" class="white"></ion-icon>
<ion-icon name="thumbs-up" class="green"></ion-icon>
<div class="info-container">
<div class="seconds" *ngIf="isSkip ==false">{{setTime}}</div>
<div *ngIf="setTime ==0">
<ion-icon name="thumbs-down" class="red" (click)="setView('Dislike')"></ion-icon>
<ion-icon name="information" class="white" (click)="setView('Info')"></ion-icon>
<ion-icon name="thumbs-up" class="green" (click)="setView('Like')"></ion-icon>
</div>
</div> </div>
</div> </div>

@ -42,3 +42,7 @@
color: #000; color: #000;
} }
.seconds{
font-size: 28px;
font-weight: bold;
}

@ -1,6 +1,9 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { NavController } from '@ionic/angular'; import { NavController } from '@ionic/angular';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { DomSanitizer } from '@angular/platform-browser';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
@ -10,9 +13,19 @@ import { CommonService } from 'src/app/hmg-common/services/common/common.service
export class HomeComponent implements OnInit { export class HomeComponent implements OnInit {
isSkip: boolean = false; isSkip: boolean = false;
setTime: number = 5; setTime: number = 5;
constructor(public nav: NavController,) { } advertisement: any;
data: any;
constructor(public nav: NavController, public cs: CommonService, public sanitizer: DomSanitizer, public authService: AuthenticationService, public ts: TranslatorService) { }
ngOnInit() { } ngOnInit() {
this.data = this.cs.sharedService.getSharedData(
AuthenticationService.ADS_DATA,
false
);
this.advertisement = this.data.result.data.advertisement.viewAttachFileColl[0];
this.setTime = this.data.result.data.advertisement.durationInSeconds;
this.setTimer();
}
skip() { skip() {
this.nav.pop(); this.nav.pop();
CommonService.SKIP = true; CommonService.SKIP = true;
@ -27,4 +40,29 @@ export class HomeComponent implements OnInit {
} }
}, 1000); }, 1000);
} }
setView(status) {
// var request =
// {
// "ItgSurveyId": data.serviceId, "ItgNotificationMasterId": data.notificationMasterId, "ItgComments": this.note, "ItgQuestionResponses": [
// { "questionId": 1, "optionId": null, "starRating": parseInt(this.rate) },
// { "questionId": 2, "optionId": 4, "starRating": parseInt(this.satisfied) }
// ]
// };
this.authService.setViewAds({
"ItgNotificationMasterId": this.data.result.data.notificationMasterId,
"ItgAdvertisement": {
"advertisementId": this.data.result.data.advertisementId,
"acknowledgment": status
}
}, (
) => { }, this.ts.trPK('general', 'ok')).subscribe((result) => {
CommonService.SKIP = true;
this.cs.openHome();
})
}
} }

@ -1,6 +1,6 @@
<ion-content padding class="survey-content"> <ion-content padding class="survey-content">
<div class="skip-btn" (click)="skip()" *ngIf="isSkip ==true">{{ts.trPK('worklistMain','skip')}} </div> <!-- <div class="skip-btn" (click)="skip()" *ngIf="isSkip ==true">{{ts.trPK('worklistMain','skip')}} </div>
<div class="seconds" *ngIf="isSkip ==false">{{setTime}}</div> <div class="seconds" *ngIf="isSkip ==false">{{setTime}}</div> -->
<ion-grid class="ion-no-padding grid-parent"> <ion-grid class="ion-no-padding grid-parent">
<ion-row> <ion-row>
<ion-text class="title-text"> <ion-text class="title-text">
@ -57,7 +57,7 @@
<ion-col [size]="12"> <ion-col [size]="12">
<ion-textarea rows="6" cols="20" [(ngModel)]="Note" [placeholder]="ts.trPK('replacementRoll','enterNote')"></ion-textarea> <ion-textarea rows="6" cols="20" [(ngModel)]="note" [placeholder]="ts.trPK('replacementRoll','enterNote')"></ion-textarea>
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-card> </ion-card>
@ -65,7 +65,7 @@
</ion-content> </ion-content>
<ion-footer > <ion-footer >
<div class="centerDiv"> <div class="centerDiv">
<ion-button class="footer-button" ion-button (click)="submit()" [disabled]="!rate || (rate==1 && !Note)"> <ion-button class="footer-button" ion-button (click)="saveSurvey()" [disabled]="!rate || (rate==1 && !note)">
{{'general,submit' | translate}} </ion-button> {{'general,submit' | translate}} </ion-button>
</div> </div>

@ -14,7 +14,7 @@ export class SurveyComponent implements OnInit {
isSkip: boolean = false; isSkip: boolean = false;
setTime: number = 5; setTime: number = 5;
satisfied: any = '5'; satisfied: any = '5';
note: any;
constructor(public ts: TranslatorService, public cs: CommonService, public nav: NavController, public authService: AuthenticationService) { } constructor(public ts: TranslatorService, public cs: CommonService, public nav: NavController, public authService: AuthenticationService) { }
ngOnInit() { ngOnInit() {
@ -34,11 +34,26 @@ export class SurveyComponent implements OnInit {
} }
}, 1000); }, 1000);
} }
saveSruvey() { saveSurvey() {
var request = {} var data = this.cs.sharedService.getSharedData(
this.authService.saveAdsStatus(request, () => { }, this.ts.trPK('general', 'ok')).subscribe((result) => { AuthenticationService.SERVEY_DATA,
false
)
var request =
{
"ItgSurveyId": data.serviceId, "ItgNotificationMasterId": data.notificationMasterId, "ItgComments": this.note, "ItgQuestionResponses": [
{ "questionId": 1, "optionId": null, "starRating": parseInt(this.rate) },
{ "questionId": 2, "optionId": 4, "starRating": parseInt(this.satisfied) }
]
};
this.authService.saveAdsStatus(request, () => { }, this.ts.trPK('general', 'ok')).subscribe((result) => {
CommonService.SKIP = true;
this.cs.openHome();
}) })
} }
select(rating) { select(rating) {

@ -79,7 +79,7 @@ export class AuthenticationService {
public static getITGPageNotification = 'Services/COCWS.svc/REST/Mohemm_ITG_GetPageNotification'; public static getITGPageNotification = 'Services/COCWS.svc/REST/Mohemm_ITG_GetPageNotification';
public static getITGPageNotificationDetails = 'Services/COCWS.svc/REST/Mohemm_ITG_GetPageNotificationDetails'; public static getITGPageNotificationDetails = 'Services/COCWS.svc/REST/Mohemm_ITG_GetPageNotificationDetails';
public static saveSurveyAds = 'Services/COCWS.svc/REST/Mohemm_ITG_Survey_Response'; public static saveSurveyAds = 'Services/COCWS.svc/REST/Mohemm_ITG_Survey_Response';
public static setViewAdvertisement = 'Services/COCWS.svc/REST/Mohemm_ITG_UpdateAdvertisementAsViewed';
public static LOGIN_EVENT = 'user-login-event'; public static LOGIN_EVENT = 'user-login-event';
@ -89,8 +89,8 @@ export class AuthenticationService {
public static DEVICE_TOKEN = "device_token"; public static DEVICE_TOKEN = "device_token";
public static LAST_LOGIN = 'last-login'; public static LAST_LOGIN = 'last-login';
public static IMEI_USER_DATA = "imei-user-data"; public static IMEI_USER_DATA = "imei-user-data";
public static SERVEY_DATA = "survey-data";
public static ADS_DATA = "ads-data";
// private static user: AuthenticatedUser; // private static user: AuthenticatedUser;
constructor( constructor(
public con: ConnectorService, public con: ConnectorService,
@ -756,6 +756,13 @@ export class AuthenticationService {
return this.con.post(AuthenticationService.saveSurveyAds, request, onError, errorLabel); return this.con.post(AuthenticationService.saveSurveyAds, request, onError, errorLabel);
} }
setViewAds(request, onError, errorLabel) {
request = this.authenticateRequest(request);
request.EmployeeNumber = request.UserName;
return this.con.post(AuthenticationService.setViewAdvertisement, request, onError, errorLabel);
}
//**************************// //**************************//

@ -638,7 +638,7 @@ export class HomePage implements OnInit {
} }
openNotificationsDashbored() { openNotificationsDashbored() {
this.DS.getOpenNotifications('', '', this.isPostNoLoad).subscribe((result: GetOpenNotificationsResponse) => { this.DS.getOpenNotifications('', '', false).subscribe((result: GetOpenNotificationsResponse) => {
if (this.common.validResponse(result)) { if (this.common.validResponse(result)) {
const key = 'P_OPEN_NTF_NUMBER'; const key = 'P_OPEN_NTF_NUMBER';
this.countAllNotification = result[key]; this.countAllNotification = result[key];
@ -788,7 +788,7 @@ export class HomePage implements OnInit {
offersDiscount() { offersDiscount() {
this.common.navigateForward('/offersdiscount/home'); this.common.navigateForward('/offersdiscount/home');
} }
openAnnouncement(){ openAnnouncement() {
this.common.openAnnouncement(); this.common.openAnnouncement();
} }
} }

@ -33,12 +33,13 @@
<div class="container-icon" *ngIf="categories.length>0"> <div class="container-icon" *ngIf="categories.length>0">
<div class="box-icon" *ngFor="let key of categories"> <div class="box-icon" *ngFor="let key of categories">
<div class="sale-icon" (click)="filterOffers(key)" [ngClass]="{'active':activeClass==key }"> <div class="sale-icon" (click)="filterOffers(key)" [ngClass]="{'active':activeClass==key.name }">
<div class="top"> <div class="top">
<!-- <ion-icon name="images"></ion-icon> --> <!-- <ion-icon name="images"></ion-icon> -->
<img [src]="key.icon" />
</div> </div>
<div class="bottom-icon"> <div class="bottom-icon">
<p>{{key}}</p> <p>{{key.name}}</p>
</div> </div>
</div> </div>
</div> </div>
@ -65,7 +66,7 @@
<ion-col size="10" *ngIf="checkDate(item['End Date']) ==true"> <ion-col size="10" *ngIf="checkDate(item['End Date']) ==true">
<p class="offer-valid">{{ts.trPK('general','offer-valid')}}</p> <p class="offer-valid">{{ts.trPK('general','offer-valid')}}</p>
</ion-col> </ion-col>
<ion-col size="10"> <ion-col size="10" *ngIf="checkDate(item['End Date']) ==false">
<p class="offer-valid"> {{ts.trPK('general','expired')}}</p> <p class="offer-valid"> {{ts.trPK('general','expired')}}</p>
</ion-col> </ion-col>
<ion-col size="2" *ngIf="checkDate(item['End Date']) ==false"> <ion-col size="2" *ngIf="checkDate(item['End Date']) ==false">

@ -42,9 +42,9 @@
} }
.sale-icon{ .sale-icon{
box-shadow: 1px 1px 5px 1px #cccc; box-shadow: 1px 1px 5px 1px #cccc;
padding: 5px; padding: 0px;
margin: 5px; margin: 3px;
border-radius: 10px; border-radius: 8px;
background: #fff; background: #fff;
position: relative; position: relative;
} }
@ -52,16 +52,18 @@
font-size: 25px; font-size: 25px;
} }
.sale-icon p{ .sale-icon p{
margin-top:5px; margin-top: 5px;
margin-bottom: 5px; margin-bottom: 5px;
text-transform: capitalize; text-transform: capitalize;
font-size: 15px; font-size: 17px;
text-align: center;
} }
.bottom-icon{ .bottom-icon{
text-overflow: clip; text-overflow: clip;
white-space: normal; white-space: normal;
font-size: 14px; font-size: 14px;
padding: 4px; padding:1px;
font-weight: bold; font-weight: bold;
} }
ion-card{ ion-card{
@ -149,3 +151,9 @@ margin: 5px;
ion-content{ ion-content{
--background:#F5F5F5 ; --background:#F5F5F5 ;
} }
.top{
text-align: center;
}
.top img{
height:40px
}

@ -47,20 +47,36 @@ export class HomeComponent implements AfterViewInit {
if (data['data']) { if (data['data']) {
var parseJSON = data['data']; var parseJSON = data['data'];
var offers = JSON.parse(parseJSON) var offers = JSON.parse(parseJSON)
this.categoriesObj = this.groupBy(offers, 'categoryName'); this.categoriesObj = this.groupBy(offers, TranslatorService.getCurrentDirection() == 'ltr' ? 'categoryName_en' : 'categoryName_ar');
this.categories = Object.keys(this.categoriesObj); // = Object.keys(this.categoriesObj);
for (var x in this.categoriesObj) {
for (var y in offers) {
if (x == offers[y].categoryName_en && this.categories.filter(item => item.name.includes(x)) == false) {
this.categories.push({
name: x,
icon: offers[y].icon
})
}
}
}
this.filterOffers(this.categories[0]); this.filterOffers(this.categories[0]);
} }
} }
groupBy(xs, key) { groupBy(xs, key) {
return xs.reduce((rv, x) => { return xs.reduce((rv, x) => {
(rv[x[key]] = rv[x[key]] || []).push(x);
return rv; (rv[x[key.trim()]] = rv[x[key]] || []).push(x);
return rv
}, {}); }, {});
}; };
filterOffers(key) { filterOffers(key) {
this.activeClass = key; this.activeClass = key.name;
this.offersData = this.categoriesObj[key]; this.offersData = this.categoriesObj[key.name];
this.tempSearch = JSON.parse(JSON.stringify(this.offersData)); this.tempSearch = JSON.parse(JSON.stringify(this.offersData));
} }
checkDate(date) { checkDate(date) {

@ -68,7 +68,7 @@
<ion-col size="10" *ngIf="checkDate(item['End Date']) ==true"> <ion-col size="10" *ngIf="checkDate(item['End Date']) ==true">
<p class="offer-valid">{{ts.trPK('general','offer-valid')}}</p> <p class="offer-valid">{{ts.trPK('general','offer-valid')}}</p>
</ion-col> </ion-col>
<ion-col size="10"> <ion-col size="10" *ngIf="checkDate(item['End Date']) ==false">
<p class="offer-valid"> {{ts.trPK('general','expired')}}</p> <p class="offer-valid"> {{ts.trPK('general','expired')}}</p>
</ion-col> </ion-col>
<ion-col size="2" *ngIf="checkDate(item['End Date']) ==false"> <ion-col size="2" *ngIf="checkDate(item['End Date']) ==false">

Loading…
Cancel
Save