Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/brianalois/ng-client into…
Browse files Browse the repository at this point in the history
… dev_a
  • Loading branch information
aaronglang committed Feb 26, 2018
2 parents db7267f + 9b3d83b commit f6a2a77
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/app/components/auth/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<mat-card ngClass.lt-sm="width-300" ngClass.gt-sm="width-500">

<div fxLayout="row" fxLayoutAlign="center" class="mat-display-1">{{title}}</div>
<div *ngIf="register===true" fxLayout="row" fxLayoutAlign="center"><a (click)="onTryLogin()">Click Here </a> to log in.</div>
<div *ngIf="register===true" fxLayout="row" fxLayoutAlign="center"><a (click)="onTryLogin()">Click Here&nbsp;</a>to log in.</div>
<form (ngSubmit)="onSubmit()" [formGroup]="loginForm">

<mat-form-field class="full-width">
Expand Down
5 changes: 3 additions & 2 deletions src/app/components/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ export class LoginComponent implements OnInit {

onTryLogin(){
this.register = false;
this.user_info.unique='';
this.title="Log in / Register";
let unique = this.user_info.unique;
this.loginForm.reset({unique:unique});
this.loginForm.setErrors(null);
}

async login(data: Object){
Expand All @@ -91,7 +93,6 @@ export class LoginComponent implements OnInit {

async create(data: Object){
if(this.user_info.confirm_password!=this.user_info.password){
this.throwInputError('password', 'Passwords do not match');
this.throwInputError('confirmPassword', 'Passwords do not match');
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export class CompanyListComponent implements OnInit {
this.companies = await Company.getAllAuthCompanies();

this.user = User.Auth();
console.log(this.user.Companies())
}

}
10 changes: 10 additions & 0 deletions src/app/components/partials/footer/footer.component.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
footer{
background-color:var(--footer)
}

.footer1{
padding: 30px;
margin-top:30px
}
.footer2{
background-color:var(--footer2);
color:white;
padding:10px;
}
6 changes: 3 additions & 3 deletions src/app/components/partials/footer/footer.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<footer>
<!--the links will only display when the user is logged out. can be changed easily by editing ngIf statement-->
<div *ngIf="!user" fxLayoutAlign="space-around center" style="padding: 30px;" >
<div *ngIf="!user" fxLayoutAlign="space-around center" class="footer1" >
<div fxLayout="column" *ngFor="let link_groups of footer_links">
<div fxLayout="column">
<h3 style="padding-bottom: 10px;">{{link_groups.header}}</h3>
Expand All @@ -10,7 +10,7 @@ <h3 style="padding-bottom: 10px;">{{link_groups.header}}</h3>
</div>
</div>
</div>
<div style="padding:10px;" fxLayout="row" fxLayoutAlign="center center">
&copy; {{date}}<a routerLink="/home">&nbsp;{{env.app_first}}<span>&nbsp;{{env.app_second}}</span></a>
<div class="footer2" fxLayout="row" fxLayoutAlign="center center">
&copy; {{date}}<a style="color:white" routerLink="/home">&nbsp;{{env.app_first}}<span>&nbsp;{{env.app_second}}</span></a>
</div>
</footer>
2 changes: 1 addition & 1 deletion src/app/interfaces/login-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export interface LoginInfo {
token?:string,
auth_info?:Object,
user?:User,

id?:string,
}
24 changes: 9 additions & 15 deletions src/app/models/company.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Util } from './../helpers/util.helper';
export class Company extends Model {
apiUpdateValues:Array<string> = ['name'];//these are the values that will be sent to the API

_id;
id;
name;

static SCHEMA = {
_id:{type:'string', primary:true},//this means every time you make a new object you must give it a _id
id:{type:'string', primary:true},//this means every time you make a new object you must give it a _id
name:{type:'string'},
test:{name:{type:'string'}},
users:[{user:{type:'string'}, permissions:[{type:'string'}]}],
Expand All @@ -23,19 +23,19 @@ export class Company extends Model {
}

Users(){
return this.belongsToMany(User, 'users.user', '_id', true);
return this.belongsToMany(User, 'users.user', 'id', true);
}

to(action){
return Util.route('/company/'+action+'/'+this._id);
return Util.route('/company/'+action+'/'+this.id);
}

async saveAPI(){
return API.save(this, '/v1/companies/'+this._id);
return API.save(this, '/v1/companies/'+this.id);
}

async removeAPI(){
return API.remove(this, '/v1/companies/'+this._id);
return API.remove(this, '/v1/companies/'+this.id);
}

//Static
Expand All @@ -61,17 +61,12 @@ export class Company extends Model {
}

static resCreate(res_company){//create company instance from a company response
let company = this.findById(res_company._id);
let company = this.findById(res_company.id);
if(company) return company;

let company_info = res_company;
company_info.id = res_company.id;

// let user_ids = company_info.users.map(user=>user.user);
// company_info.user_ids = user_ids;

company_info.users = company_info.users

company_info.test = {name:'test'};
company_info.users = res_company.users;

company = this.create(company_info);
return company;
Expand All @@ -82,7 +77,6 @@ export class Company extends Model {
[err, res] = await Util.to(Util.post('/v1/companies', companyInfo));
if(err) Util.TE(err.message, true);
if(!res.success) Util.TE(res.error, true);

let company = this.resCreate(res.company);
company.emit(['newly-created'], companyInfo, true);
return company;
Expand Down
17 changes: 11 additions & 6 deletions src/app/models/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Util } from './../helpers/util.helper';
export class User extends Model {
apiUpdateValues:Array<string> = ['email', 'phone', 'first', 'last'];//these are the values that will be sent to the API

_id;
id;
first;
last;
auth;
Expand All @@ -21,7 +21,7 @@ export class User extends Model {
phone;

static SCHEMA = {
_id:{type:'string', primary:true},//this means every time you make a new object you must give it a _id
id:{type:'string', primary:true},//this means every time you make a new object you must give it a _id
first:{type:'string'},
last:{type:'string'},
email:{type:'string'},
Expand Down Expand Up @@ -50,6 +50,7 @@ export class User extends Model {

logout(){
this.remove();
localStorage.clear();//remove all data in storage
Util.route('/home');
this.emit(['logout', 'auth'], 'logout', true);
}
Expand All @@ -59,7 +60,7 @@ export class User extends Model {
}

Companies(){
return this.belongsToMany(Company, 'users.user', '_id');
return this.belongsToMany(Company, 'users.user', 'id');
}

to(action){
Expand Down Expand Up @@ -98,9 +99,13 @@ export class User extends Model {
}

static Login(info: LoginInfo){
info.user.auth = true;
info.user.token = info.token;
let user = <User> User.create(info.user);

let user_info:any = info.user;

user_info.auth = true;
user_info.token = info.token;

let user = <User> User.create(user_info);
user.emit(['login', 'auth'], 'login', true);
return user;
}
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export const environment = {
apiUrl:'http://127.0.0.1:8080',
facebook_app_id:'1234567890',

app_name:'Your Company',
app_name:'Website ProdName',
url:'http://localhost:1515',
};
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export const environment = {
apiUrl:'http://127.0.0.1:3000',
facebook_app_id:'1234567890',

app_name:'Your Company',
app_name:'Website DevName',
url:'http://localhost:1515',
};
3 changes: 2 additions & 1 deletion src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

:root {
--header: #c6dcff;
--footer: #d8d8d8;
--footer: #e2e2e2;
--footer2:#a8a8a8;
--color1: grey;
--color2: red;
--color3: purple;
Expand Down

0 comments on commit f6a2a77

Please sign in to comment.