Skip to content

Commit

Permalink
patch for #39 that cleans up the spaghetti code
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarJ committed Oct 10, 2018
1 parent f9a225f commit d2375fc
Show file tree
Hide file tree
Showing 27 changed files with 2,061 additions and 2,289 deletions.
4,017 changes: 1,984 additions & 2,033 deletions talentboard-app/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion talentboard-app/src/app/column/column.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
vertical-align: top;
overflow: auto;
width: 100%;
height: calc(75vh);
height: calc(70vh);
white-space: nowrap;
margin-right: 2px;
margin-left: 1px;
Expand Down
2 changes: 0 additions & 2 deletions talentboard-app/src/app/column/column.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
</div>
</div>


<div class="job-column">
<app-applicant *ngFor="let applicant of applicants" [applicant]="applicant" dnd-draggable [dragEnabled]="true"
[dragData]="applicant" (onDragSuccess)="removeItem($event)"></app-applicant>
</div>

</div>

<ng-template let-context let-modal="modal" #applicantModal>
Expand Down
39 changes: 27 additions & 12 deletions talentboard-app/src/app/column/column.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import {Component, OnInit, Input, ViewChild, SimpleChanges, OnChanges} from '@angular/core';
import { Applicant } from '../model/Applicant';
import { User } from '../model/User';
import { Job } from '../model/Job';
import { SuiModalService, ModalTemplate, TemplateModalConfig } from '../../../node_modules/ng2-semantic-ui';
import { ApplicantService } from '../core/applicant.service';
import { UserService } from '../core/user.service';
Expand All @@ -16,40 +15,56 @@ export interface IContext {
templateUrl: './column.component.html',
styleUrls: ['./column.component.css']
})
export class ColumnComponent implements OnInit {
export class ColumnComponent implements OnChanges {

@Input() name: string;
@Input() applicants: Array<Applicant> = [];

applicant: Applicant;
currentUser: User;
currentJob: Job;

@ViewChild('applicantModal')
public applicantModal: ModalTemplate<IContext, void, void>;
public newApplicant: Applicant = new Applicant();

constructor(private modalService: SuiModalService, private applicantService: ApplicantService, private userService: UserService) { }
constructor(private modalService: SuiModalService, private applicantService: ApplicantService) { }

ngOnInit() {
ngOnChanges(changes: SimpleChanges) {
this.currentUser = JSON.parse(localStorage.getItem('user'));
this.sortItems();
}

removeDups(names) {
const unique = {};
names.forEach(function(i) {
if (!unique[i]) {
unique[i] = true;
}
});
return Object.keys(unique);
}

// ngOnInit() {
// this.currentUser = JSON.parse(localStorage.getItem('user'));
// }

removeItem(e: any) {
const applicant: Applicant = e.dragData;
const index = this.applicants.map((value: Applicant) => {
return value.name;
}).indexOf(applicant.name);
return value.id;
}).indexOf(applicant.id);
if (index !== -1) {
this.applicants.splice(index, 1);
}
}

addItem(e: any) {
const applicant: Applicant = e.dragData;
applicant.status = this.name;
this.applicantService.updateApplicant(applicant.id, applicant);
if (applicant.status === this.name) {
this.applicants.push(applicant);
} else {
applicant.status = this.name;
this.applicantService.updateApplicant(applicant.id, applicant);
}
}

sortItems() {
Expand All @@ -71,7 +86,7 @@ export class ColumnComponent implements OnInit {
.open(config)
.onApprove(_ => {
this.applicantService.addApplicant(this.newApplicant, this.currentUser.currentJobView);
location.reload();
this.newApplicant = new Applicant();
})
.onDeny(_ => { });
}
Expand Down
58 changes: 35 additions & 23 deletions talentboard-app/src/app/job/job.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class JobComponent implements OnInit {
currentJob: Job = new Job();

jobList: Array<Job> = [];
applicantList: Array<Applicant> = [];
applied: Array<Applicant> = [];
phoneInterview: Array<Applicant> = [];
personInterview: Array<Applicant> = [];
Expand All @@ -49,45 +48,67 @@ export class JobComponent implements OnInit {

ngOnInit() {
this.currentUser = JSON.parse(localStorage.getItem('user'));
this.fetchUserInfo();
for (const jobId of this.currentUser.jobIds) {
this.jobService.getJobById(jobId).subscribe(updatedJob => {
this.jobList.push(updatedJob);
});
if (this.currentUser.jobIds) {
for (const jobId of this.currentUser.jobIds) {
this.jobService.getJobById(jobId).subscribe(updatedJob => {
this.jobList.push(updatedJob);
});
}
}
if (this.currentUser.currentJobView) {
this.fetchApplicants();
}
this.fetchApplicants();
}

fetchApplicants() {
this.jobService.getJobById(this.currentUser.currentJobView).subscribe(currentJob => {
this.currentJob = currentJob;
if (currentJob.applicantIds != null) {
if (currentJob.applicantIds) {
for (const applicantId of Object.values(currentJob.applicantIds)) {
this.applicantService.getApplicantById(applicantId).subscribe(currentApplicant => {
switch (currentApplicant.status) {
case ('Applied'):
this.applied.push(currentApplicant);
if (!this.containsApplicant(currentApplicant, this.applied)) {
this.applied.push(currentApplicant);
}
break;
case ('Phone Interview'):
this.phoneInterview.push(currentApplicant);
if (!this.containsApplicant(currentApplicant, this.phoneInterview)) {
this.phoneInterview.push(currentApplicant);
}
break;
case ('In Person Interview'):
this.personInterview.push(currentApplicant);
if (!this.containsApplicant(currentApplicant, this.personInterview)) {
this.personInterview.push(currentApplicant);
}
break;
case ('Declined'):
this.declined.push(currentApplicant);
if (!this.containsApplicant(currentApplicant, this.declined)) {
this.declined.push(currentApplicant);
}
break;
case ('Sent Offer'):
this.offer.push(currentApplicant);
if (!this.containsApplicant(currentApplicant, this.offer)) {
this.offer.push(currentApplicant);
}
break;
}
this.applicantList.push(currentApplicant);
});
}
}
});
}

containsApplicant(applicant, applicants) {
let i;
for (i = 0; i < applicants.length; i++) {
if (applicants[i].id === applicant.id) {
return true;
}
}
return false;
}

openJobModal(title: string, job: Job) {
const config = new TemplateModalConfig<IContext, void, void>(this.jobModal);
config.isClosable = false;
Expand All @@ -104,7 +125,6 @@ export class JobComponent implements OnInit {
localStorage.setItem('user', JSON.stringify(this.currentUser));
location.reload();
} else {
console.log('manz was here');
this.jobService.addJob(this.newJob);
this.currentUser.jobIds.push(job.id);
this.currentUser.currentJobView = job.id;
Expand All @@ -125,7 +145,6 @@ export class JobComponent implements OnInit {
this.currentUser.currentJobView = job.id;
this.userService.updateUser(this.currentUser.id, this.currentUser);
localStorage.setItem('user', JSON.stringify(this.currentUser));
location.reload();
}

getNumberOfJobs() {
Expand All @@ -134,12 +153,5 @@ export class JobComponent implements OnInit {
}
return this.currentUser.jobIds.length;
}

fetchUserInfo() {
this.userService.getUserById(this.currentUser.id).subscribe(user => {
localStorage.setItem('user', JSON.stringify(user));
this.currentUser = JSON.parse(localStorage.getItem('user'));
});
}
}

2 changes: 1 addition & 1 deletion talentboard-app/src/app/login/login.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="ui container" id="container-log-in">
<img class="ui centered medium image" src="../../assets/images/logo-plain-black.svg">
<img class="ui centered medium image" src="../../assets/images/logo-black-variant.svg">
<div class="ui basic segment">
<div class="content">
<form class="ui form" (ngSubmit)="emailLogin()">
Expand Down
6 changes: 6 additions & 0 deletions talentboard-app/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export class LoginComponent {
location.reload();
} else {
this.userService.getUserById(fbUser.uid).subscribe(user => {
if (!user.jobIds) {
user.jobIds = []; // temp fix because firebase doesn't store empty lists
}
localStorage.setItem('user', JSON.stringify(user));
this.router.navigate(['/app']);
});
Expand All @@ -50,6 +53,9 @@ export class LoginComponent {
this.authService.emailLogin(this.credentials.email, this.credentials.password).then(res => {
const userId = res.user.uid;
this.userService.getUserById(userId).subscribe(user => {
if (!user.jobIds) {
user.jobIds = []; // temp fix because firebase doesn't store empty lists
}
localStorage.setItem('user', JSON.stringify(user));
this.router.navigate(['/app']);
});
Expand Down
2 changes: 1 addition & 1 deletion talentboard-app/src/app/nav-bar/nav-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<sui-sidebar class="inverted vertical" #sidebar>
<a class="item" href="/">
<div>
<img src="../../assets/images/logo-plain.svg" class="logo">
<img src="../../assets/images/logo-white-variant.svg" class="logo">
</div>
</a>
<a (click)="currentViewState = 'kanban'; sidebar.toggle()" class="item">
Expand Down
2 changes: 1 addition & 1 deletion talentboard-app/src/app/register/register.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="ui container" id="container-log-in">
<div class="ui header center aligned">
<a href="/">
<img class="ui medium image" href="/" style="display:inline; bottom: 6.5px; left: 2px;" src="../../assets/images/logo-plain-black.svg">
<img class="ui medium image" href="/" style="display:inline; bottom: 6.5px; left: 2px;" src="../../assets/images/logo-black-variant.svg">
</a>
</div>

Expand Down
7 changes: 5 additions & 2 deletions talentboard-app/src/app/register/register.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { UserService } from '../core/user.service';
import * as firebase from 'firebase';
import { User } from '../model/User';
import { AuthService } from '../core/auth.service';

Expand All @@ -28,6 +26,8 @@ export class RegisterComponent implements OnInit {
this.authService.registerUser(this.newUser.email, this.password).then(res => {
this.newUser.id = res.user.uid;
this.newUser.profileURL = 'https://cdn1.iconfinder.com/data/icons/mix-color-4/502/Untitled-1-512.png';
this.newUser.currentJobView = '';
this.newUser.jobIds = [];
localStorage.setItem('user', JSON.stringify(this.newUser));
this.userService.createUser(this.newUser);
this.router.navigate(['/app']);
Expand All @@ -52,6 +52,9 @@ export class RegisterComponent implements OnInit {
location.reload();
} else {
this.userService.getUserById(fbUser.uid).subscribe(user => {
if (!user.jobIds) {
user.jobIds = []; // temp fix because firebase doesn't store empty lists
}
localStorage.setItem('user', JSON.stringify(user));
this.router.navigate(['/app']);
});
Expand Down
Binary file removed talentboard-app/src/assets/images/User123.PNG
Binary file not shown.
Binary file removed talentboard-app/src/assets/images/board.PNG
Binary file not shown.
Binary file added talentboard-app/src/assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion talentboard-app/src/assets/images/logo-1.svg

This file was deleted.

1 change: 0 additions & 1 deletion talentboard-app/src/assets/images/logo-2.svg

This file was deleted.

Loading

0 comments on commit d2375fc

Please sign in to comment.