Create the Admin New Item Page
This commit is contained in:
@@ -9,6 +9,7 @@ import { SettingsComponent } from './pages/account/settings/settings.component';
|
|||||||
import { LogoutComponent } from './pages/account/logout/logout.component';
|
import { LogoutComponent } from './pages/account/logout/logout.component';
|
||||||
import { ResetPasswordComponent } from './pages/account/resetpassword/resetpassword.component';
|
import { ResetPasswordComponent } from './pages/account/resetpassword/resetpassword.component';
|
||||||
import { VerifyEmailComponent } from './pages/account/verifyemail/verifyemail.component';
|
import { VerifyEmailComponent } from './pages/account/verifyemail/verifyemail.component';
|
||||||
|
import { NewItemComponent } from './pages/store/admin/newitem/new.component';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
|
|
||||||
@@ -27,6 +28,9 @@ export const routes: Routes = [
|
|||||||
// Store
|
// Store
|
||||||
{ path: "store/catalog", component: CatalogComponent },
|
{ path: "store/catalog", component: CatalogComponent },
|
||||||
|
|
||||||
|
// AdminPages
|
||||||
|
{ path: "store/admin/new", component: NewItemComponent },
|
||||||
|
|
||||||
// Legal
|
// Legal
|
||||||
{ path: "about", component: AboutComponent },
|
{ path: "about", component: AboutComponent },
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
.gameCard {
|
||||||
|
position: relative;
|
||||||
|
background-color: var(--Mistox-Black);
|
||||||
|
float: left;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 10px;
|
||||||
|
break-inside: avoid;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
border: solid 2px var(--Mistox-Background);
|
||||||
|
transition-duration: 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard :hover{
|
||||||
|
border-color: var(--Mistox-Light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Name {
|
||||||
|
width: 100%;
|
||||||
|
text-align: left;
|
||||||
|
font-size: 25px;
|
||||||
|
padding: 5px 0 0 5px;
|
||||||
|
background-color: rgba(0,0,0,.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Grid {
|
||||||
|
column-count: 4;
|
||||||
|
column-gap: 2rem;
|
||||||
|
padding-top: 20px;
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1400px) {
|
||||||
|
.gameCard-Grid {
|
||||||
|
column-count: 3;
|
||||||
|
padding-top: 20px;
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1100px) {
|
||||||
|
.gameCard-Grid {
|
||||||
|
column-count: 2;
|
||||||
|
padding-top: 20px;
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.gameCard-Grid {
|
||||||
|
column-count: 1;
|
||||||
|
padding-top: 20px;
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Img {
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 10px 10px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Next,
|
||||||
|
.gameCard-Prev {
|
||||||
|
background-color: transparent;
|
||||||
|
color: var(--Mistox-White);
|
||||||
|
padding: 16px;
|
||||||
|
margin-top: -22px;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
border: none;
|
||||||
|
transition: background-color 0.6s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Next:hover,
|
||||||
|
.gameCard-Prev:hover {
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Prev {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Next {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Desc {
|
||||||
|
font-size: 13px;
|
||||||
|
margin: 5px;
|
||||||
|
color: var(--Mistox-Light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Price {
|
||||||
|
width: calc(50% - 10px);
|
||||||
|
float: left;
|
||||||
|
margin: 5px;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Button {
|
||||||
|
width: 40%;
|
||||||
|
margin: 5px 5%;
|
||||||
|
height: 38.4px;
|
||||||
|
color: var(--Mistox-Black);
|
||||||
|
background-color: var(--Mistox-Light);
|
||||||
|
font-size: 16px;
|
||||||
|
text-decoration: none;
|
||||||
|
text-transform: uppercase;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: 0.5s;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
border: 1px solid var(--Mistox-Light);
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gameCard-Button :hover{
|
||||||
|
background-color: var(--Mistox-Light);
|
||||||
|
color: var(--Mistox-White);
|
||||||
|
box-shadow: 4px 3px 6px var(--Mistox-Dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cartopen {
|
||||||
|
position: absolute;
|
||||||
|
background: var(--Mistox-Offset);
|
||||||
|
right: 10px;
|
||||||
|
top: 55px;
|
||||||
|
width: 400px;
|
||||||
|
border-radius: 5px;
|
||||||
|
backdrop-filter: blur(3px);
|
||||||
|
border: 1px solid var(--Mistox-Light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cartclosed {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<form class="center big-frame background-border" #accountForm="ngForm" (ngSubmit)="onSubmit()">
|
||||||
|
<h3>Login</h3>
|
||||||
|
|
||||||
|
<div class="frame-item">
|
||||||
|
<input type="text" [(ngModel)]="newItem.name" name="ItemName" placeholder=" " />
|
||||||
|
<label>Item Name</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="frame-item">
|
||||||
|
<input type="text" [(ngModel)]="newItem.description" name="ItemDesc" placeholder=" " />
|
||||||
|
<label>Description</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="frame-item">
|
||||||
|
<input type="number" [(ngModel)]="newItem.cost" name="ItemCost" placeholder=" " />
|
||||||
|
<label>Cost</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="frame-item">
|
||||||
|
<input type="text" [(ngModel)]="newItem.url" name="itemURL" placeholder=" " />
|
||||||
|
<label>URL</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="frame-item">
|
||||||
|
<!-- Need to fix for image file upload -->
|
||||||
|
<div id="FileUploadPlaceholder" ></div>
|
||||||
|
<input type="file" (change)="onFileSelected($event)" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex-row">
|
||||||
|
<div class="frame-button">
|
||||||
|
<input class="submit" type="submit" value="Create Item" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul *ngIf="errorMsgs.length > 0" >
|
||||||
|
<li *ngFor="let msg of errorMsgs" >{{ msg }}</li>
|
||||||
|
</ul>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
|
import { Title } from '@angular/platform-browser';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { Authentication } from '../../../../services/Authentication';
|
||||||
|
import { Product } from 'app/models/Product';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'item-new',
|
||||||
|
templateUrl: './new.component.html',
|
||||||
|
styleUrl: './new.component.css',
|
||||||
|
imports: [ FormsModule, CommonModule ]
|
||||||
|
})
|
||||||
|
export class NewItemComponent {
|
||||||
|
|
||||||
|
newItem: Product = new Product();
|
||||||
|
|
||||||
|
errorMsgs: string[] = [];
|
||||||
|
|
||||||
|
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
|
||||||
|
this.title.setTitle("New | ADMIN");
|
||||||
|
};
|
||||||
|
|
||||||
|
sleep(ms: number) {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedFiles: File[] = [];
|
||||||
|
onFileSelected(event: any){
|
||||||
|
this.selectedFiles = event.target.files;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit(){
|
||||||
|
// Add uploaded files to dto
|
||||||
|
if (this.selectedFiles.length > 0){
|
||||||
|
for(let i=0; i<this.selectedFiles.length; i++){
|
||||||
|
this.newItem.images.push( this.selectedFiles[i] );
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proccess data
|
||||||
|
this.http.post<boolean>( "https://mistox.com/api/product/create", this.newItem ).subscribe({
|
||||||
|
next: async (data) => {
|
||||||
|
if (data == true){
|
||||||
|
this.errorMsgs = ["Product Created Successfully"];
|
||||||
|
await this.sleep(3000);
|
||||||
|
this.router.navigate(["/catalog"]);
|
||||||
|
}else{
|
||||||
|
this.errorMsgs = ["Email was not able to be verified please resend email"];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: err => {
|
||||||
|
console.log("New Product Err: ", err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="auth.loggedInUser.siteData.role == 'Admin'">
|
<div *ngIf="auth.loggedInUser.siteData.role == 'Admin'">
|
||||||
<button style="width: calc(100% - 10px); margin: 5px;" onclick="">
|
<button style="width: calc(100% - 10px); margin: 5px;" [routerLink]="['/store/admin/new']" >
|
||||||
New
|
New
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user