Merge pull request 'Impliment file upload for company Logo' (#17) from working into main
Docker Build and Release Upload / build (push) Successful in 1m23s

Reviewed-on: #17
This commit was merged in pull request #17.
This commit is contained in:
2025-08-02 00:25:38 +00:00
9 changed files with 52 additions and 20 deletions
+1 -1
View File
@@ -130,7 +130,7 @@ CREATE TABLE IF NOT EXISTS `Company` (
`Email` varchar(255) DEFAULT NULL, `Email` varchar(255) DEFAULT NULL,
`EmailVerified` boolean DEFAULT 0, `EmailVerified` boolean DEFAULT 0,
`WebsiteURL` varchar(255) DEFAULT NULL, `WebsiteURL` varchar(255) DEFAULT NULL,
`LogoURL` varchar(2048) DEFAULT NULL, `Logo` mediumblob DEFAULT NULL,
`Phone` varchar(20) DEFAULT NULL, `Phone` varchar(20) DEFAULT NULL,
`PostalCode` varchar(20) NOT NULL, `PostalCode` varchar(20) NOT NULL,
`Country` char(2) NOT NULL, `Country` char(2) NOT NULL,
+1 -1
View File
@@ -4,7 +4,7 @@ export class Company {
public email: string = ""; public email: string = "";
public emailVerified: boolean = false; public emailVerified: boolean = false;
public websiteURL: string = ""; public websiteURL: string = "";
public logoURL: string = ""; public logo: string = "";
public phone: string = ""; public phone: string = "";
public postalCode: string = ""; public postalCode: string = "";
public country: string = ""; // 2 Letter Country Code public country: string = ""; // 2 Letter Country Code
@@ -8,7 +8,7 @@
<h1>{{ Comp.email }}</h1> <h1>{{ Comp.email }}</h1>
<h1>{{ Comp.emailVerified }}</h1> <h1>{{ Comp.emailVerified }}</h1>
<h1>{{ Comp.websiteURL }}</h1> <h1>{{ Comp.websiteURL }}</h1>
<h1>{{ Comp.logoURL }}</h1> <h1>{{ Comp.logo }}</h1>
<h1>{{ Comp.phone }}</h1> <h1>{{ Comp.phone }}</h1>
<h1>{{ Comp.postalCode }}</h1> <h1>{{ Comp.postalCode }}</h1>
<h1>{{ Comp.country }}</h1> <h1>{{ Comp.country }}</h1>
@@ -37,7 +37,12 @@
<div class="center"> <div class="center">
<div class="content-frame"> <div class="content-frame">
<label>Company Logo URL</label> <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)="prevStep()">Back</button>
<button type="button" (click)="nextStep()">Next</button> <button type="button" (click)="nextStep()">Next</button>
</div> </div>
@@ -126,7 +131,7 @@
<a href="mailto:{{ newListing.email }}">{{ newListing.email }}</a> <a href="mailto:{{ newListing.email }}">{{ newListing.email }}</a>
<a href="tel:{{ newListing.phone }}">{{ newListing.phone }}</a> <a href="tel:{{ newListing.phone }}">{{ newListing.phone }}</a>
</div> </div>
<div><img [src]="newListing.logoURL" /></div> <div><img [src]="newListing.logo" /></div>
<div class="split"> <div class="split">
<div class="half-frame"> <div class="half-frame">
<span>city: {{ newListing.city }}</span> <span>city: {{ newListing.city }}</span>
@@ -20,6 +20,7 @@ export class CompanyConnectComponent {
public newListing: Company = new Company(); public newListing: Company = new Company();
public ErrorMsg: string = ""; public ErrorMsg: string = "";
MaxFileMB: number = 3;
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Company - Connect | BoredCareers"); this.title.setTitle("Company - Connect | BoredCareers");
@@ -54,6 +55,30 @@ export class CompanyConnectComponent {
}, 500); }, 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(){ nextStep(){
this.currentStep += 1; this.currentStep += 1;
this.updateUI(0); this.updateUI(0);
@@ -85,7 +110,7 @@ export class CompanyConnectComponent {
return; return;
} }
if (this.isNullOrEmpty(company.logoURL)){ if (this.isNullOrEmpty(company.logo)){
this.focusFrame(2, 0); this.focusFrame(2, 0);
return; return;
} }
@@ -5,7 +5,7 @@
<h1>{{ jobsCompany.email }}</h1> <h1>{{ jobsCompany.email }}</h1>
<h1>{{ jobsCompany.websiteURL }}</h1> <h1>{{ jobsCompany.websiteURL }}</h1>
<h1>{{ jobsCompany.logoURL }}</h1> <h1>{{ jobsCompany.logo }}</h1>
<h1>{{ jobsCompany.phone }}</h1> <h1>{{ jobsCompany.phone }}</h1>
<h1>{{ jobsCompany.city }}</h1> <h1>{{ jobsCompany.city }}</h1>
+1 -1
View File
@@ -6,7 +6,7 @@ namespace BoredCareers.Entities {
public string Email { get; set; } = ""; public string Email { get; set; } = "";
public bool EmailVerified { get; set; } = false; public bool EmailVerified { get; set; } = false;
public string WebsiteURL { get; set; } = ""; public string WebsiteURL { get; set; } = "";
public string LogoURL { get; set; } = ""; public string Logo { get; set; } = "";
public string Phone { get; set; } = ""; public string Phone { get; set; } = "";
public string PostalCode { get; set; } = ""; public string PostalCode { get; set; } = "";
public string Country { get; set; } = ""; // 2 Letter Country Code public string Country { get; set; } = ""; // 2 Letter Country Code
@@ -2,6 +2,7 @@ using BoredCareers.Entities;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System.Data; using System.Data;
using System.Data.Common; using System.Data.Common;
using System.Text;
namespace BoredCareers.Services.DatabaseService { namespace BoredCareers.Services.DatabaseService {
public partial class DatabaseService { public partial class DatabaseService {
@@ -27,7 +28,7 @@ namespace BoredCareers.Services.DatabaseService {
string _email = reader.GetString("Email"); string _email = reader.GetString("Email");
bool _emailVerified = reader.GetBoolean("EmailVerified"); bool _emailVerified = reader.GetBoolean("EmailVerified");
string _websiteurl = reader.GetString("WebsiteURL"); string _websiteurl = reader.GetString("WebsiteURL");
string _logourl = reader.GetString( "LogoURL" ); string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
string _phone = reader.GetString( "Phone" ); string _phone = reader.GetString( "Phone" );
string _postalcode = reader.GetString( "PostalCode" ); string _postalcode = reader.GetString( "PostalCode" );
string _country = reader.GetString( "Country" ); string _country = reader.GetString( "Country" );
@@ -41,7 +42,7 @@ namespace BoredCareers.Services.DatabaseService {
Email = _email, Email = _email,
EmailVerified = _emailVerified, EmailVerified = _emailVerified,
WebsiteURL = _websiteurl, WebsiteURL = _websiteurl,
LogoURL = _logourl, Logo = _logo,
Phone = _phone, Phone = _phone,
PostalCode = _postalcode, PostalCode = _postalcode,
Country = _country, Country = _country,
@@ -61,15 +62,15 @@ namespace BoredCareers.Services.DatabaseService {
string command = @" string command = @"
INSERT INTO Company 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 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 ON DUPLICATE KEY UPDATE
Name = @Name, Name = @Name,
Email = @Email, Email = @Email,
EmailVerified = @EmailVerified, EmailVerified = @EmailVerified,
WebsiteURL = @WebsiteURL, WebsiteURL = @WebsiteURL,
LogoURL = @LogoURL, Logo = @Logo,
Phone = @Phone, Phone = @Phone,
PostalCode = @PostalCode, PostalCode = @PostalCode,
Country = @Country, Country = @Country,
@@ -86,7 +87,7 @@ namespace BoredCareers.Services.DatabaseService {
cmd.Parameters.AddWithValue("@Email", company.Email); cmd.Parameters.AddWithValue("@Email", company.Email);
cmd.Parameters.AddWithValue("@EmailVerified", company.EmailVerified); cmd.Parameters.AddWithValue("@EmailVerified", company.EmailVerified);
cmd.Parameters.AddWithValue("@WebsiteURL", company.WebsiteURL); 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("@Phone", company.Phone);
cmd.Parameters.AddWithValue("@PostalCode", company.PostalCode); cmd.Parameters.AddWithValue("@PostalCode", company.PostalCode);
cmd.Parameters.AddWithValue("@Country", company.Country); cmd.Parameters.AddWithValue("@Country", company.Country);
@@ -2,6 +2,7 @@ using BoredCareers.Entities;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System.Data; using System.Data;
using System.Data.Common; using System.Data.Common;
using System.Text;
namespace BoredCareers.Services.DatabaseService { namespace BoredCareers.Services.DatabaseService {
public partial class DatabaseService { public partial class DatabaseService {
@@ -30,7 +31,7 @@ namespace BoredCareers.Services.DatabaseService {
string _email = reader.GetString("Email"); string _email = reader.GetString("Email");
bool _emailVerified = reader.GetBoolean("EmailVerified"); bool _emailVerified = reader.GetBoolean("EmailVerified");
string _websiteurl = reader.GetString("WebsiteURL"); string _websiteurl = reader.GetString("WebsiteURL");
string _logourl = reader.GetString( "LogoURL" ); string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
string _phone = reader.GetString( "Phone" ); string _phone = reader.GetString( "Phone" );
string _postalcode = reader.GetString( "PostalCode" ); string _postalcode = reader.GetString( "PostalCode" );
string _country = reader.GetString( "Country" ); string _country = reader.GetString( "Country" );
@@ -47,7 +48,7 @@ namespace BoredCareers.Services.DatabaseService {
Email = _email, Email = _email,
EmailVerified = _emailVerified, EmailVerified = _emailVerified,
WebsiteURL = _websiteurl, WebsiteURL = _websiteurl,
LogoURL = _logourl, Logo = _logo,
Phone = _phone, Phone = _phone,
PostalCode = _postalcode, PostalCode = _postalcode,
Country = _country, Country = _country,
@@ -86,7 +87,7 @@ namespace BoredCareers.Services.DatabaseService {
string _email = reader.GetString("Email"); string _email = reader.GetString("Email");
bool _emailVerified = reader.GetBoolean("EmailVerified"); bool _emailVerified = reader.GetBoolean("EmailVerified");
string _websiteurl = reader.GetString("WebsiteURL"); string _websiteurl = reader.GetString("WebsiteURL");
string _logourl = reader.GetString( "LogoURL" ); string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
string _phone = reader.GetString( "Phone" ); string _phone = reader.GetString( "Phone" );
string _postalcode = reader.GetString( "PostalCode" ); string _postalcode = reader.GetString( "PostalCode" );
string _country = reader.GetString( "Country" ); string _country = reader.GetString( "Country" );
@@ -103,7 +104,7 @@ namespace BoredCareers.Services.DatabaseService {
Email = _email, Email = _email,
EmailVerified = _emailVerified, EmailVerified = _emailVerified,
WebsiteURL = _websiteurl, WebsiteURL = _websiteurl,
LogoURL = _logourl, Logo = _logo,
Phone = _phone, Phone = _phone,
PostalCode = _postalcode, PostalCode = _postalcode,
Country = _country, Country = _country,
@@ -142,7 +143,7 @@ namespace BoredCareers.Services.DatabaseService {
string _email = reader.GetString("Email"); string _email = reader.GetString("Email");
bool _emailVerified = reader.GetBoolean("EmailVerified"); bool _emailVerified = reader.GetBoolean("EmailVerified");
string _websiteurl = reader.GetString("WebsiteURL"); string _websiteurl = reader.GetString("WebsiteURL");
string _logourl = reader.GetString( "LogoURL" ); string _logo = Encoding.UTF8.GetString((byte[])reader["Logo"]);
string _phone = reader.GetString( "Phone" ); string _phone = reader.GetString( "Phone" );
string _postalcode = reader.GetString( "PostalCode" ); string _postalcode = reader.GetString( "PostalCode" );
string _country = reader.GetString( "Country" ); string _country = reader.GetString( "Country" );
@@ -159,7 +160,7 @@ namespace BoredCareers.Services.DatabaseService {
Email = _email, Email = _email,
EmailVerified = _emailVerified, EmailVerified = _emailVerified,
WebsiteURL = _websiteurl, WebsiteURL = _websiteurl,
LogoURL = _logourl, Logo = _logo,
Phone = _phone, Phone = _phone,
PostalCode = _postalcode, PostalCode = _postalcode,
Country = _country, Country = _country,