Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create manager user #13

Merged
merged 11 commits into from
Jun 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<name>googol</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
<content original-src="index.html" src="http://10.0.0.9:8100" />
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
Expand Down Expand Up @@ -84,6 +84,6 @@
<plugin name="cordova-plugin-statusbar" spec="^2.4.2" />
<allow-navigation href="http://10.0.0.9:8101" />
<allow-navigation href="http://10.0.0.9:8100" />
<engine name="ios" spec="4.5.4" />
<engine name="android" spec="7.0.0" />
<engine name="ios" spec="~4.5.4" />
</widget>
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@agm/core": "^1.0.0-beta.3",
"@angular/animations": "5.2.10",
"@angular/common": "5.2.10",
"@angular/compiler": "5.2.10",
Expand All @@ -25,11 +26,12 @@
"@ionic-native/splash-screen": "4.7.0",
"@ionic-native/status-bar": "4.7.0",
"@ionic/storage": "2.1.3",
"@types/googlemaps": "^3.30.8",
"cordova-android": "7.0.0",
"cordova-ios": "4.5.4",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^1.1.19",
"cordova-plugin-ionic-keyboard": "^2.1.2",
"cordova-plugin-ionic-webview": "^1.2.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
Expand Down
189 changes: 189 additions & 0 deletions src/_config/maps.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
export const Maps = {
apiKey: "AIzaSyCnahpwY4LRTYlzEHnER3B_Y8NR1HzmrVE",
styles: [
{
"elementType": "geometry",
"stylers": [
{
"color": "#212121"
}
]
},
{
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#757575"
}
]
},
{
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#212121"
}
]
},
{
"featureType": "administrative",
"elementType": "geometry",
"stylers": [
{
"color": "#757575"
}
]
},
{
"featureType": "administrative.country",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#9e9e9e"
}
]
},
{
"featureType": "administrative.land_parcel",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "administrative.locality",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#bdbdbd"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#757575"
}
]
},
{
"featureType": "poi.park",
"elementType": "geometry",
"stylers": [
{
"color": "#181818"
}
]
},
{
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#616161"
}
]
},
{
"featureType": "poi.park",
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#1b1b1b"
}
]
},
{
"featureType": "road",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#2c2c2c"
}
]
},
{
"featureType": "road",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#8a8a8a"
}
]
},
{
"featureType": "road.arterial",
"elementType": "geometry",
"stylers": [
{
"color": "#373737"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [
{
"color": "#3c3c3c"
}
]
},
{
"featureType": "road.highway.controlled_access",
"elementType": "geometry",
"stylers": [
{
"color": "#4e4e4e"
}
]
},
{
"featureType": "road.local",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#616161"
}
]
},
{
"featureType": "transit",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#757575"
}
]
},
{
"featureType": "water",
"elementType": "geometry",
"stylers": [
{
"color": "#000000"
}
]
},
{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#3d3d3d"
}
]
}
],
}
4 changes: 4 additions & 0 deletions src/_config/url.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const AppUrl = {
root: 'https://googol-api.herokuapp.com/api'
//root: 'http://localhost:4040/api'
};
19 changes: 19 additions & 0 deletions src/_models/bar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export class Bar{

placeId: string;
name: string;
latitude: number;
longitude: number;

//from api only
createdAt: Date;
eventHistory: any[];

constructor(placeId:string, name:string, latitude:number, longitude:number){
this.placeId = placeId;
this.name = name;
this.latitude = latitude;
this.longitude = longitude;
}

}
19 changes: 19 additions & 0 deletions src/_models/owner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Bar } from "./bar";

export class Owner{

email: string;
password:string;

//Location
bar: Bar;

//auth
ownerId: string;
token: string;

constructor(email?:string, password?:string){
this.email = email;
this.password = password;
}
}
38 changes: 29 additions & 9 deletions src/_services/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';

import { User } from '../_models/user';
import { appConfig } from '../app/app.config';
import { AppUrl } from '../_config/url.config';
import { Owner } from '../_models/owner';

@Injectable()
export class AuthService{

public token: string;
private url: string = appConfig.apiUrl + '/auth/login';
private userUrl: string = AppUrl.root + '/auth/login';
private ownerUrl: string = AppUrl.root + '/auth/ownerLogin';
private httpOptions = {headers: new HttpHeaders({ 'Content-Type': 'application/json' })};

constructor(private http: HttpClient) {
}

/**
* Realiza o signin na aplicação. O retorno representa um login realizado ou não.
* @param email
* @param password
/** Sign in for any user
* @param email
* @param password
* @param url
*/
signIn(email: string, password: string) : Observable<boolean>{
private signIn(email: string, password: string, url: string) : Observable<boolean>{

let body = { email: email, password: password };

return this.http.post<User>( this.url, body, this.httpOptions)
return this.http.post<User>( url, body, this.httpOptions)
.map( user => {
let token = user && user.token;
if (token) {
Expand All @@ -40,7 +42,25 @@ export class AuthService{
}

/**
* Retorna se existe ou não um usuário autorizado no local storage
* Sign in with a normal user
* @param email
* @param password
*/
userSignIn(email: string, password: string){
return this.signIn(email, password, this.userUrl);
}

/**
* Sign in with a bar owner
* @param email
* @param password
*/
ownerSignIn(email: string, password: string){
return this.signIn(email, password, this.ownerUrl);
}

/**
* Return if an user is auth
*/
isAuthenticated() : boolean{
if(localStorage.getItem('authUser')){
Expand Down
47 changes: 47 additions & 0 deletions src/_services/bar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs/observable';
import 'rxjs/add/operator/map';

import { AppUrl } from '../_config/url.config';
import { Bar } from '../_models/bar';

@Injectable()
export class BarService {

private url: string = AppUrl.root + '/bar';
private httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };

constructor(private http: HttpClient) { }

/**
* Create a new bar
* @param bar
*/
create(bar: Bar): Observable<Bar> {

let body = {
"placeId": bar.placeId,
"name": bar.name,
"latitude": bar.latitude,
"longitude": bar.longitude
}

return this.http.post<Bar>(this.url, body, this.httpOptions)
.map(bar => {
return bar;
})
}

/**
* Get one bar with a given id
* @param id
*/
getOne(id: string) : Observable<Bar> {
return this.http.get<Bar>(this.url + '/' + id, this.httpOptions)
.map( bar => {
return bar;
})
}

}
Loading