starting, login and signup runs ok, implementing main dashboard layout

This commit is contained in:
arnaucode
2017-10-21 17:25:25 +02:00
commit e50263b6f7
42 changed files with 2463 additions and 0 deletions

54
views/travels/travels.html Executable file
View File

@@ -0,0 +1,54 @@
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="panel">
<div class="panel-heading c_deepPurpleG500to300">
<h3 class="panel-title">All travels</h3>
</div>
<div class="panel-body" style="max-height: 500px;overflow-y: scroll;">
<table class="table table-striped table-hover ">
<thead>
<tr>
<th>Type</th>
<th>Title</th>
<th>Date</th>
<th>User</th>
<th>nºJoins</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="travel in travels">
<td>
<i ng-show="travel.type=='offering'" class="fa fa-car fa-2x"></i>
<i ng-show="travel.type=='asking'" class="fa fa-question fa-2x"></i>
<i ng-show="travel.type=='package'" class="fa fa-archive fa-2x"></i>
</td>
<td>{{travel.title}}</td>
<td>{{travel.date | date}}</td>
<td>
<a ng-href="#!/user/{{travel.user._id}}">
{{travel.user.username}}
</a>
</td>
<td>{{travel.joins.length}}</td>
<td><a ng-href="#!/travel/{{travel._id}}">View</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-sm-8">
<div class="panel">
<div class="panel-heading c_deepPurpleG500to300">
<h3 class="panel-title">Map</h3>
</div>
<div class="panel-body">
<leaflet width="100%" height="600px" markers="markers" paths="paths" center="center"
tiles="tiles" id="map-simple-map"></leaflet>
</div>
</div>
</div>
</div>
</div>

73
views/travels/travels.js Executable file
View File

@@ -0,0 +1,73 @@
'use strict';
angular.module('app.travels', ['ngRoute', 'ui-leaflet'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/travels', {
templateUrl: 'views/travels/travels.html',
controller: 'TravelsCtrl'
});
}])
.controller('TravelsCtrl', function($scope, $http) {
$scope.travels = [];
$scope.loadMorePagination = true;
$scope.page = 0;
//map
$scope.center = {};
$scope.bounds = {};
$scope.markers = [];
$scope.paths = [];
$scope.tiles = {
url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
options: {
attribution: '<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}
};
$http.get(urlapi + 'travels?page=' + $scope.page)
.then(function(data) {
console.log('data success');
console.log(data);
$scope.travels = data.data;
//draw markers on map
$scope.markers = [];
for (var i = 0; i < $scope.travels.length; i++) {
$scope.markers.push({
lat: Number($scope.travels[i].from.lat),
lng: Number($scope.travels[i].from.long),
message: $scope.travels[i].from.name
});
$scope.markers.push({
lat: Number($scope.travels[i].to.lat),
lng: Number($scope.travels[i].to.long),
message: $scope.travels[i].to.name
});
}
//draw lines between markers on map
$scope.paths = {};
var paths = [];
for (var i = 0; i < $scope.markers.length; i++) {
var x = $scope.markers[i].lat;
var y = $scope.markers[i].lng;
paths.push([x, y]);
}
$scope.paths = {
p1: {
color: '#9575CD',
weight: 8,
latlngs: paths
}
};
//var maplines = L.polyline(lines).addTo(map)
$scope.center = {
lat: (Number($scope.travels[0].from.lat) + Number($scope.travels[0].to.lat)) / 2,
lng: (Number($scope.travels[0].from.long) + Number($scope.travels[0].to.long)) / 2,
zoom: 4
};
}, function(data) {
console.log('data error');
});
});