Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

596 failure to display kits and links of a campaign #605

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/app/campaigns/ad-pools/ad-pools.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ export class AdPoolsComponent implements OnInit, OnDestroy {
const newCampaignsArray = concat(draftsAndApplyElements, campaignsPendingFinished);
this.campaignsList = newCampaignsArray;
this.campaignsList2 = newCampaignsArray;
console.log({newCampaignsArray})
this.campaignsList?.forEach((element: Campaign) => {
if (
['SATTPOLYGON', 'SATTBEP20', 'SATTBTT'].includes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@
>
</label>
</div>
<div class="p-0" *ngIf="countImages() !== 0">
<owl-carousel-o [options]="customOptions">
<ng-container
*ngFor="let elem of kits; index as i; trackBy: trackByKits"
>

<!--

<owl-carousel-o [options]="customOptions" >


<ng-template
carouselSlide
id="{{ i }}"
Expand Down Expand Up @@ -128,8 +129,68 @@
</span>
</div>
</ng-template>
</ng-container>

</owl-carousel-o>
-->
<div class="p-0" style="display: flex">
<ng-container
*ngFor="let elem of kits; index as i; trackBy: trackByKits"
>
<div
class="div-uploaded-pic d-flex justify-content-center align-items-center" *ngIf="!elem.link"
>
<img
src="/assets/Images/delete-kit-new.svg"
alt=""
class="img-kit cursor-pointer"
(click)="deleteKitElement(i)"
/>

<img
class="uploaded-pic"
[src]="elem.url || elem.selectedFile"
*ngIf="elem.contentType !== 'application/pdf'"
id="imagekit{{ i }}"
alt="your image"
/>
<img
class="img-responsive"
src="{{ pdf }}"
*ngIf="elem.contentType === 'application/pdf'"
/>

<span>
<img
*ngIf="zoomIn"
src="/assets/Images/zoom-in-eye.svg"
alt=""
class="eye-uploaded-pic cursor-pointer"
data-toggle="modal"
data-target="#exampleModal"
(click)="
elem.selectedFile
? openModalZoomIn(elem.selectedFile)
: openModalZoomIn(elem.url)
"
/>
<img
*ngIf="zoomOut"
src="/assets/Images/zoom-out-eye.svg"
alt=""
class="eye-uploaded-pic cursor-pointer"
(click)="zoomout(i)"
/>

<img
src="/assets/Images/download-kit-2.svg"
alt=""
id="btn"
class="download-uploaded-pic cursor-pointer"
(click)="downloadMyFile(i, id)"
/>
</span>
</div>
</ng-container>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import FileSaver from 'file-saver';
selector: 'app-draft-campaign-kit',
templateUrl: './draft-campaign-kit.component.html',
styleUrls: ['./draft-campaign-kit.component.css'],
providers: [DraftCampaignService]
})
export class DraftCampaignKitComponent implements OnInit {
@Input()
Expand Down Expand Up @@ -99,8 +98,11 @@ export class DraftCampaignKitComponent implements OnInit {
iTestData: number;
testDataShown: any;
images: any = [];
showKits: boolean = false;
private isDestroyed = new Subject();



pdf: String = 'assets/Images/img_satt/pdf-xs.png';

@ViewChild('divUploadedFiles') divUploadedFiles: ElementRef | any;
Expand All @@ -110,6 +112,7 @@ export class DraftCampaignKitComponent implements OnInit {
pdfZoom = false;

constructor(

private service: DraftCampaignService,
private CampaignService: CampaignHttpApiService,
public translate: TranslateService,
Expand All @@ -120,6 +123,8 @@ export class DraftCampaignKitComponent implements OnInit {
private windowRefService: WindowRefService,
private renderer: Renderer2
) {


this.form = new UntypedFormGroup({
url: new UntypedFormControl('', [Validators.pattern(urlValidator)]),
file: new UntypedFormControl('')
Expand All @@ -128,13 +133,15 @@ export class DraftCampaignKitComponent implements OnInit {
}

ngOnInit(): void {

this.scrollright = false;
this.scrollrightdisable = true;
this.saveForm();
this.emitFormStatus();
this.getKits(this.id);
this.getKits(this.id);

}

customOptions: OwlOptions = {
loop: false,
mouseDrag: true,
Expand Down Expand Up @@ -191,19 +198,24 @@ export class DraftCampaignKitComponent implements OnInit {
// }

ngOnChanges(changes: SimpleChanges) {

if (changes.draftData && changes.draftData.currentValue.id) {
this.populateForm(this.draftData);
}
}
ngAfterViewInit() {}
ngAfterViewInit() {

}
getKits(id: string) {

this.CampaignService.getCampaignKitUrl(id)
.pipe(
map((res: any) => res.data),
mergeMap((data: any) => {
if (data) {
data.forEach((kit: any) => {
if (kit.link) {

this.kits = [
...this.kits,
{
Expand All @@ -213,6 +225,7 @@ export class DraftCampaignKitComponent implements OnInit {
kits: kit.id
}
];

}
if (!kit.link) {
this.firstimage = false;
Expand All @@ -224,7 +237,7 @@ export class DraftCampaignKitComponent implements OnInit {
];
}
});

if (this.kits.length === 1) {
this.firstscrol = true;
}
Expand Down Expand Up @@ -262,20 +275,26 @@ export class DraftCampaignKitComponent implements OnInit {
arrayOfObs.push(of(null));
}
});

return forkJoin(arrayOfObs).pipe(
map((resArray) => {
return { resArray, data };
})
);

}

return of(null);
})
)
.pipe(

/*.pipe(
filter((res) => res !== null),
takeUntil(this.isDestroyed)
)

)*/
.subscribe(({ resArray, data }: any) => {


resArray?.forEach((file: any, index: number) => {
if (file !== null) {
let imageUrl;
Expand All @@ -288,12 +307,10 @@ export class DraftCampaignKitComponent implements OnInit {
this.kits[index] = data[index];
}
});
/* if (this.countImages() > 3) {
this.customOptions.loop = true;
} else {
this.customOptions.loop = false;
}*/
// console.log(file);




});
}
onFileChange(e: any) {
Expand Down Expand Up @@ -361,9 +378,12 @@ export class DraftCampaignKitComponent implements OnInit {
this.isAcceptedImageFileType = false;
}
}

countImages() {
let count = 0;

for (let i = 0; i < this.kits.length; i++) {

if (!this.kits[i].link) {
count++;
}
Expand Down Expand Up @@ -408,13 +428,16 @@ export class DraftCampaignKitComponent implements OnInit {

addLinkToKits() {
let url = this.form?.get('url')?.value;

if (url && this.form.controls.url.valid) {

this.kits.push({
new: true,
name: url,
link: url,
campaign: this.draftData?.id
});

this.service.autoSavekitFormOnValueChanges({
kits: this.kits,
id: this.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@
type="button"
class="buttom_camp3"
(click)="getMyGains(prom)"
[disabled]="harvestAvailable"
*ngIf="prom.type === 'harvest' && !isOwner && prom.campaign.remuneration !== 'publication'"
[ngClass]="{ graybtn: harvestAvailable }"
>
Expand Down Expand Up @@ -651,6 +652,7 @@
type="button"
class="buttom_camp3"
(click)="getMyGains(prom)"
[disabled]="prom.campaign.type !== 'finished'"
*ngIf="prom.type === 'harvest' && !isOwner && prom.campaign.remuneration === 'publication'"
[ngClass]="{ graybtn: prom.campaign.type === 'apply' }"
>
Expand Down