Make img carousel work
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ CREATE TABLE IF NOT EXISTS `ProductImage` (
|
|||||||
`ImageID` int(11) NOT NULL AUTO_INCREMENT,
|
`ImageID` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`ProductID` int(11) NOT NULL,
|
`ProductID` int(11) NOT NULL,
|
||||||
`Image` MEDIUMBLOB,
|
`Image` MEDIUMBLOB,
|
||||||
`Name` varchar(60) DEFAULT NULL,
|
`Name` varchar(200) DEFAULT NULL,
|
||||||
PRIMARY KEY (`ImageID`,`ProductID`)
|
PRIMARY KEY (`ImageID`,`ProductID`)
|
||||||
) AUTO_INCREMENT=1;
|
) AUTO_INCREMENT=1;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
<div class="gameCard" *ngFor="let product of Products">
|
<div class="gameCard" *ngFor="let product of Products">
|
||||||
<div style="position: relative;">
|
<div style="position: relative;">
|
||||||
<div *ngIf="product.images.length > 1">
|
<div *ngIf="product.images.length > 1">
|
||||||
<button class="gameCard-Prev" onclick="">❮</button>
|
<button class="gameCard-Prev" (click)="nextImg(product)">❮</button>
|
||||||
<button class="gameCard-Next" onclick="">❯</button>
|
<button class="gameCard-Next" (click)="prevImg(product)">❯</button>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="product.images.length > 0" >
|
<div *ngIf="product.images.length > 0" >
|
||||||
<img class="gameCard-Img" [src]="product.images[product.curShowingIMG].imageSrc">
|
<img class="gameCard-Img" [src]="product.images[product.curShowingIMG].imageSrc">
|
||||||
|
|||||||
@@ -40,6 +40,20 @@ export class CatalogComponent {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nextImg( prod: Product ){
|
||||||
|
prod.curShowingIMG += 1;
|
||||||
|
if (prod.curShowingIMG == prod.images.length){
|
||||||
|
prod.curShowingIMG = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prevImg( prod: Product ){
|
||||||
|
prod.curShowingIMG -= 1;
|
||||||
|
if (prod.curShowingIMG == -1){
|
||||||
|
prod.curShowingIMG = prod.images.length -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DeleteItem( ProductID: number ) {
|
DeleteItem( ProductID: number ) {
|
||||||
const body = new HttpParams()
|
const body = new HttpParams()
|
||||||
.set("productID", ProductID);
|
.set("productID", ProductID);
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ namespace MistoxWebsite.Server.Controllers {
|
|||||||
obj.Images = building.ToArray();
|
obj.Images = building.ToArray();
|
||||||
await _databaseService.NewProduct(obj);
|
await _databaseService.NewProduct(obj);
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user