Impliment file upload for company Logo
This commit is contained in:
+1
-1
@@ -130,7 +130,7 @@ CREATE TABLE IF NOT EXISTS `Company` (
|
||||
`Email` varchar(255) DEFAULT NULL,
|
||||
`EmailVerified` boolean DEFAULT 0,
|
||||
`WebsiteURL` varchar(255) DEFAULT NULL,
|
||||
`LogoURL` varchar(2048) DEFAULT NULL,
|
||||
`Logo` mediumblob DEFAULT NULL,
|
||||
`Phone` varchar(20) DEFAULT NULL,
|
||||
`PostalCode` varchar(20) NOT NULL,
|
||||
`Country` char(2) NOT NULL,
|
||||
|
||||
@@ -4,7 +4,7 @@ export class Company {
|
||||
public email: string = "";
|
||||
public emailVerified: boolean = false;
|
||||
public websiteURL: string = "";
|
||||
public logoURL: string = "";
|
||||
public logo: string = "";
|
||||
public phone: string = "";
|
||||
public postalCode: string = "";
|
||||
public country: string = ""; // 2 Letter Country Code
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<h1>{{ Comp.email }}</h1>
|
||||
<h1>{{ Comp.emailVerified }}</h1>
|
||||
<h1>{{ Comp.websiteURL }}</h1>
|
||||
<h1>{{ Comp.logoURL }}</h1>
|
||||
<h1>{{ Comp.logo }}</h1>
|
||||
<h1>{{ Comp.phone }}</h1>
|
||||
<h1>{{ Comp.postalCode }}</h1>
|
||||
<h1>{{ Comp.country }}</h1>
|
||||
|
||||
@@ -37,7 +37,12 @@
|
||||
<div class="center">
|
||||
<div class="content-frame">
|
||||
<label>Company Logo URL</label>
|
||||
<input class="input-field" name="logoURL" [(ngModel)]="newListing.logoURL" type="text" placeholder="https://mistox.com/img/logo.png" />
|
||||
|
||||
<img [src]="newListing.logo" />
|
||||
<!-- Need to fix for image file upload -->
|
||||
<div id="FileUploadPlaceholder" ></div>
|
||||
<input type="file" (change)="onFileSelected($event)" accept="image/*" />
|
||||
|
||||
<button type="button" (click)="prevStep()">Back</button>
|
||||
<button type="button" (click)="nextStep()">Next</button>
|
||||
</div>
|
||||
@@ -126,7 +131,7 @@
|
||||
<a href="mailto:{{ newListing.email }}">{{ newListing.email }}</a>
|
||||
<a href="tel:{{ newListing.phone }}">{{ newListing.phone }}</a>
|
||||
</div>
|
||||
<div><img [src]="newListing.logoURL" /></div>
|
||||
<div><img [src]="newListing.logo" /></div>
|
||||
<div class="split">
|
||||
<div class="half-frame">
|
||||
<span>city: {{ newListing.city }}</span>
|
||||
|
||||
@@ -20,6 +20,7 @@ export class CompanyConnectComponent {
|
||||
|
||||
public newListing: Company = new Company();
|
||||
public ErrorMsg: string = "";
|
||||
MaxFileMB: number = 3;
|
||||
|
||||
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
|
||||
this.title.setTitle("Company - Connect | BoredCareers");
|
||||
@@ -54,6 +55,30 @@ export class CompanyConnectComponent {
|
||||
}, 500);
|
||||
}
|
||||
|
||||
selectedFile: File | null = null;
|
||||
onFileSelected(event: Event){
|
||||
const fileInput = event.target as HTMLInputElement;
|
||||
this.selectedFile = null;
|
||||
|
||||
if (!fileInput.files?.length){
|
||||
return;
|
||||
}
|
||||
|
||||
let file = fileInput.files[0];
|
||||
if (file.size > this.MaxFileMB * 1024 * 1024){
|
||||
this.ErrorMsg = "File exceeds max file size of 16MB";
|
||||
return;
|
||||
}
|
||||
// No issues add file to the list
|
||||
this.selectedFile = file;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload= () => {
|
||||
this.newListing.logo = reader.result as string;
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
nextStep(){
|
||||
this.currentStep += 1;
|
||||
this.updateUI(0);
|
||||
@@ -85,7 +110,7 @@ export class CompanyConnectComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isNullOrEmpty(company.logoURL)){
|
||||
if (this.isNullOrEmpty(company.logo)){
|
||||
this.focusFrame(2, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<h1>{{ jobsCompany.email }}</h1>
|
||||
<h1>{{ jobsCompany.websiteURL }}</h1>
|
||||
|
||||
<h1>{{ jobsCompany.logoURL }}</h1>
|
||||
<h1>{{ jobsCompany.logo }}</h1>
|
||||
<h1>{{ jobsCompany.phone }}</h1>
|
||||
|
||||
<h1>{{ jobsCompany.city }}</h1>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace BoredCareers.Entities {
|
||||
public string Email { get; set; } = "";
|
||||
public bool EmailVerified { get; set; } = false;
|
||||
public string WebsiteURL { get; set; } = "";
|
||||
public string LogoURL { get; set; } = "";
|
||||
public string Logo { get; set; } = "";
|
||||
public string Phone { get; set; } = "";
|
||||
public string PostalCode { get; set; } = "";
|
||||
public string Country { get; set; } = ""; // 2 Letter Country Code
|
||||
|
||||
@@ -2,6 +2,7 @@ using BoredCareers.Entities;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Text;
|
||||
|
||||
namespace BoredCareers.Services.DatabaseService {
|
||||
public partial class DatabaseService {
|
||||
@@ -27,7 +28,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
string _email = reader.GetString("Email");
|
||||
bool _emailVerified = reader.GetBoolean("EmailVerified");
|
||||
string _websiteurl = reader.GetString("WebsiteURL");
|
||||
string _logourl = reader.GetString( "LogoURL" );
|
||||
string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
|
||||
string _phone = reader.GetString( "Phone" );
|
||||
string _postalcode = reader.GetString( "PostalCode" );
|
||||
string _country = reader.GetString( "Country" );
|
||||
@@ -41,7 +42,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
Email = _email,
|
||||
EmailVerified = _emailVerified,
|
||||
WebsiteURL = _websiteurl,
|
||||
LogoURL = _logourl,
|
||||
Logo = _logo,
|
||||
Phone = _phone,
|
||||
PostalCode = _postalcode,
|
||||
Country = _country,
|
||||
@@ -61,15 +62,15 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
|
||||
string command = @"
|
||||
INSERT INTO Company
|
||||
(ID,Name,Email,EmailVerified,WebsiteURL,LogoURL,Phone,PostalCode,Country,StateOrRegion,City,Description)
|
||||
(ID,Name,Email,EmailVerified,WebsiteURL,Logo,Phone,PostalCode,Country,StateOrRegion,City,Description)
|
||||
VALUES
|
||||
(@ID,@Name,@Email,@EmailVerified,@WebsiteURL,@LogoURL,@Phone,@PostalCode,@Country,@StateOrRegion,@City,@Description)
|
||||
(@ID,@Name,@Email,@EmailVerified,@WebsiteURL,@Logo,@Phone,@PostalCode,@Country,@StateOrRegion,@City,@Description)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Name = @Name,
|
||||
Email = @Email,
|
||||
EmailVerified = @EmailVerified,
|
||||
WebsiteURL = @WebsiteURL,
|
||||
LogoURL = @LogoURL,
|
||||
Logo = @Logo,
|
||||
Phone = @Phone,
|
||||
PostalCode = @PostalCode,
|
||||
Country = @Country,
|
||||
@@ -86,7 +87,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
cmd.Parameters.AddWithValue("@Email", company.Email);
|
||||
cmd.Parameters.AddWithValue("@EmailVerified", company.EmailVerified);
|
||||
cmd.Parameters.AddWithValue("@WebsiteURL", company.WebsiteURL);
|
||||
cmd.Parameters.AddWithValue("@LogoURL", company.LogoURL);
|
||||
cmd.Parameters.AddWithValue("@Logo", Encoding.UTF8.GetBytes(company.Logo));
|
||||
cmd.Parameters.AddWithValue("@Phone", company.Phone);
|
||||
cmd.Parameters.AddWithValue("@PostalCode", company.PostalCode);
|
||||
cmd.Parameters.AddWithValue("@Country", company.Country);
|
||||
|
||||
@@ -2,6 +2,7 @@ using BoredCareers.Entities;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Text;
|
||||
|
||||
namespace BoredCareers.Services.DatabaseService {
|
||||
public partial class DatabaseService {
|
||||
@@ -30,7 +31,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
string _email = reader.GetString("Email");
|
||||
bool _emailVerified = reader.GetBoolean("EmailVerified");
|
||||
string _websiteurl = reader.GetString("WebsiteURL");
|
||||
string _logourl = reader.GetString( "LogoURL" );
|
||||
string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
|
||||
string _phone = reader.GetString( "Phone" );
|
||||
string _postalcode = reader.GetString( "PostalCode" );
|
||||
string _country = reader.GetString( "Country" );
|
||||
@@ -47,7 +48,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
Email = _email,
|
||||
EmailVerified = _emailVerified,
|
||||
WebsiteURL = _websiteurl,
|
||||
LogoURL = _logourl,
|
||||
Logo = _logo,
|
||||
Phone = _phone,
|
||||
PostalCode = _postalcode,
|
||||
Country = _country,
|
||||
@@ -86,7 +87,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
string _email = reader.GetString("Email");
|
||||
bool _emailVerified = reader.GetBoolean("EmailVerified");
|
||||
string _websiteurl = reader.GetString("WebsiteURL");
|
||||
string _logourl = reader.GetString( "LogoURL" );
|
||||
string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
|
||||
string _phone = reader.GetString( "Phone" );
|
||||
string _postalcode = reader.GetString( "PostalCode" );
|
||||
string _country = reader.GetString( "Country" );
|
||||
@@ -103,7 +104,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
Email = _email,
|
||||
EmailVerified = _emailVerified,
|
||||
WebsiteURL = _websiteurl,
|
||||
LogoURL = _logourl,
|
||||
Logo = _logo,
|
||||
Phone = _phone,
|
||||
PostalCode = _postalcode,
|
||||
Country = _country,
|
||||
@@ -142,7 +143,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
string _email = reader.GetString("Email");
|
||||
bool _emailVerified = reader.GetBoolean("EmailVerified");
|
||||
string _websiteurl = reader.GetString("WebsiteURL");
|
||||
string _logourl = reader.GetString( "LogoURL" );
|
||||
string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
|
||||
string _phone = reader.GetString( "Phone" );
|
||||
string _postalcode = reader.GetString( "PostalCode" );
|
||||
string _country = reader.GetString( "Country" );
|
||||
@@ -159,7 +160,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
Email = _email,
|
||||
EmailVerified = _emailVerified,
|
||||
WebsiteURL = _websiteurl,
|
||||
LogoURL = _logourl,
|
||||
Logo = _logo,
|
||||
Phone = _phone,
|
||||
PostalCode = _postalcode,
|
||||
Country = _country,
|
||||
|
||||
Reference in New Issue
Block a user