mirror of
https://github.com/arnaucube/commonroutesWebApp.git
synced 2026-02-07 03:16:41 +01:00
starting, login and signup runs ok, implementing main dashboard layout
This commit is contained in:
30
views/login/login.html
Executable file
30
views/login/login.html
Executable file
@@ -0,0 +1,30 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<h1>Common Routes</h1>
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">Login</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group label-floating">
|
||||
<input ng-model="user.username" abmFormControl class="form-control" id="inputUsername" placeholder="Username" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input ng-model="user.password" abmFormControl class="form-control" id="inputPassword" placeholder="Password" type="password">
|
||||
</div>
|
||||
<a ng-href="#!/signup" class="btn btn-raised c_grey500">Signup</a>
|
||||
<div ng-click="doLogin()" class="btn btn-raised c_deepPurple300 pull-right">Login</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-4">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
43
views/login/login.js
Executable file
43
views/login/login.js
Executable file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.login', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/login', {
|
||||
templateUrl: 'views/login/login.html',
|
||||
controller: 'LoginCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('LoginCtrl', function($scope, $http, $routeParams, toastr) {
|
||||
$scope.user = {};
|
||||
$scope.doLogin = function() {
|
||||
console.log('Doing login', $scope.user);
|
||||
|
||||
$http({
|
||||
url: urlapi + 'admin/login',
|
||||
method: "POST",
|
||||
data: $scope.user
|
||||
})
|
||||
.then(function(response) {
|
||||
console.log("response: ");
|
||||
console.log(response.data);
|
||||
if (response.data.success == true)
|
||||
{
|
||||
localStorage.setItem("cr_webapp_token", response.data.token);
|
||||
localStorage.setItem("cr_webapp_userdata", JSON.stringify(response.data.user));
|
||||
window.location.reload();
|
||||
}else{
|
||||
console.log("login failed");
|
||||
toastr.error('Login failed');
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
function(response) { // optional
|
||||
// failed
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
112
views/main/main.html
Executable file
112
views/main/main.html
Executable file
@@ -0,0 +1,112 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div ng-repeat="travel in travels">
|
||||
<div class="card">
|
||||
<div class="card-body" style="color:#ffffff; background-image: url('img/userProfileBackground.png');">
|
||||
<div class="pull-right">{{travel.date | date}}</div>
|
||||
<h4 class="card-title"><b>{{travel.title}}</b></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="pull-right">
|
||||
<a ng-href="#!/user/{{travel.user._id}}">
|
||||
<img class="circle" style="max-width: 30px; max-height:30px;" ng-src="{{travel.user.avatar}}" />
|
||||
{{travel.user.username}}
|
||||
</a>
|
||||
</div>
|
||||
<p>
|
||||
From: <b>{{travel.from.name}}</b>
|
||||
</p>
|
||||
<p>
|
||||
To: <b>{{travel.to.name}}</b>
|
||||
</p>
|
||||
<p>
|
||||
{{travel.joins.length}}/{{travel.seats}}
|
||||
</p>
|
||||
<p ng-show="travel.package">
|
||||
Can transport package
|
||||
</p>
|
||||
<a href="#" class="card-link">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
<br><br>
|
||||
</div>
|
||||
<div ng-repeat="travel in travels">
|
||||
<div class="card">
|
||||
<img class="card-img-top" src="..." alt="Card image cap">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Card title</h4>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
<br><br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">
|
||||
Travels Feed
|
||||
<span class="badge badge-secondary pull-right c_deepPurpleG500to300">{{travels.length}}</span>
|
||||
</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>From</th>
|
||||
<th>To</th>
|
||||
<th>Date</th>
|
||||
<th>User</th>
|
||||
<th>nºJoins/Seats</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="travel in travels">
|
||||
<a ng-href="#!/travel/{{travel._id}}">
|
||||
<td>
|
||||
<i ng-show="travel.type=='offering'" title="offering" class="fa fa-car fa-2x"></i>
|
||||
<i ng-show="travel.type=='asking'" title="asking" class="fa fa-question fa-2x"></i>
|
||||
<i ng-show="travel.type=='package'" title="package" class="fa fa-archive fa-2x"></i>
|
||||
</td>
|
||||
<td>{{travel.title}}</td>
|
||||
<td>
|
||||
<b>{{travel.from.name}}</b>
|
||||
</td>
|
||||
<td>
|
||||
<b>{{travel.to.name}}</b>
|
||||
</td>
|
||||
<td>{{travel.date | date}}</td>
|
||||
<td>
|
||||
<a ng-href="#!/user/{{travel.user._id}}">
|
||||
<img class="circle" style="max-width: 30px; max-height:30px;" ng-src="{{travel.user.avatar}}" />
|
||||
{{travel.user.username}}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{travel.joins.length}}/{{travel.seats}}</td>
|
||||
<td><a ng-href="#!/travel/{{travel._id}}">View</a></td>
|
||||
</a>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">Actions</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="btn btn-block btn-sm c_green300">Create user</div>
|
||||
<div class="btn btn-block btn-sm c_blue300">Create travel</div>
|
||||
<a href="#!/network" class="btn btn-block btn-sm c_deepPurpleG500to300">View network</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
24
views/main/main.js
Executable file
24
views/main/main.js
Executable file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.main', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/main', {
|
||||
templateUrl: 'views/main/main.html',
|
||||
controller: 'MainCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('MainCtrl', function($scope, $http) {
|
||||
$scope.travels = [];
|
||||
$scope.pageTravels = 0;
|
||||
$http.get(urlapi + 'travels?page=' + $scope.pageTravels)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.travels = data.data;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
});
|
||||
45
views/navbar.html
Executable file
45
views/navbar.html
Executable file
@@ -0,0 +1,45 @@
|
||||
<div ng-controller="NavbarCtrl">
|
||||
<div ng-show="storageuser" class="navbar c_deepPurpleG500to300">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/">Common Routes</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a href="#!/users">Users</a></li>
|
||||
<li><a href="#!/travels">Travels</a></li>
|
||||
</ul>
|
||||
<form ng-submit="search()" class="navbar-form navbar-left">
|
||||
<div class="form-group">
|
||||
<input ng-model="searchString" class="form-control col-md-8" placeholder="Search" type="text">
|
||||
</div>
|
||||
</form>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><a href="#!/new">
|
||||
<i title="post new travel" class="fa fa-plus fa-2x"></i>
|
||||
</a></li>
|
||||
<li class="dropdown">
|
||||
<a href="" data-target="#" class="dropdown-toggle" data-toggle="dropdown">Settings
|
||||
<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="javascript:void(0)">Action</a></li>
|
||||
<li><a href="javascript:void(0)">Another action</a></li>
|
||||
<li><a href="javascript:void(0)">Something else here</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="javascript:void(0)">Separated link</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="" ng-click="logout()">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
<div ng-click="goBack()" class="btn"><span class="glyphicon glyphicon-arrow-left"></span> Back</div>
|
||||
-->
|
||||
</div>
|
||||
35
views/navbar.js
Executable file
35
views/navbar.js
Executable file
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.navbar', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/navbar', {
|
||||
templateUrl: 'views/navbar/navbar.html',
|
||||
controller: 'NavbarCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('NavbarCtrl', function($scope, $http, $routeParams, $location) {
|
||||
$scope.searchString = "";
|
||||
$scope.locationHash = $location.path();
|
||||
console.log($scope.locationHash);
|
||||
$scope.goBack = function() {
|
||||
console.log("goBack");
|
||||
window.history.back();
|
||||
};
|
||||
|
||||
$scope.search = function() {
|
||||
console.log($scope.searchString);
|
||||
window.location.href = "#!/search/" + $scope.searchString;
|
||||
};
|
||||
if (localStorage.getItem("cr_webapp_userdata")) {
|
||||
$scope.storageuser = JSON.parse(localStorage.getItem("cr_webapp_userdata"));
|
||||
console.log($scope.storageuser);
|
||||
}
|
||||
|
||||
$scope.logout = function() {
|
||||
localStorage.removeItem("cr_webapp_token");
|
||||
localStorage.removeItem("cr_webapp_userdata");
|
||||
window.location.reload();
|
||||
};
|
||||
});
|
||||
74
views/search/search.html
Executable file
74
views/search/search.html
Executable file
@@ -0,0 +1,74 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h2>
|
||||
Search: {{searchString}}
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">Users</h3>
|
||||
</div>
|
||||
<div class="panel-body" style="max-height: 500px;overflow-y: scroll;">
|
||||
<div class="list-group">
|
||||
<a ng-repeat="user in users" ng-href="#!/user/{{user._id}}" class="list-group-item">
|
||||
<div class="row-picture">
|
||||
<img class="circle" ng-src="{{user.avatar}}" alt="icon">
|
||||
</div>
|
||||
<div class="row-content">
|
||||
<h4 class="list-group-item-heading">{{user.username}}</h4>
|
||||
|
||||
<p class="list-group-item-text">{{user.description}}</p>
|
||||
<p class="list-group-item-text">{{user.travels.length}} published travels</p>
|
||||
<p class="list-group-item-text">{{user.likes.length}} likes</p>
|
||||
</div>
|
||||
<div class="list-group-separator"></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">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>
|
||||
</div>
|
||||
28
views/search/search.js
Executable file
28
views/search/search.js
Executable file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.search', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/search/:searchstring', {
|
||||
templateUrl: 'views/search/search.html',
|
||||
controller: 'SearchCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('SearchCtrl', function($scope, $http, $routeParams) {
|
||||
$scope.users = [];
|
||||
$scope.travels = [];
|
||||
$scope.loadMorePagination = true;
|
||||
$scope.page = 0;
|
||||
$scope.searchString = $routeParams.searchstring;
|
||||
$http.get(urlapi + 'search/' + $routeParams.searchstring)
|
||||
.then(function(data) {
|
||||
console.log('data success travels');
|
||||
console.log(data);
|
||||
$scope.users = data.data.users;
|
||||
$scope.travels = data.data.travels;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
});
|
||||
41
views/signup/signup.html
Executable file
41
views/signup/signup.html
Executable file
@@ -0,0 +1,41 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">Signup</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group label-floating">
|
||||
<input ng-model="user.username" abmFormControl class="form-control" id="inputUsername" placeholder="Username" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input ng-model="user.password" abmFormControl class="form-control" id="inputPassword" placeholder="Password" type="password">
|
||||
</div>
|
||||
<div class="form-group label-floating">
|
||||
<input ng-model="user.email" abmFormControl class="form-control" id="inputEmail" placeholder="Email" type="text">
|
||||
</div>
|
||||
<div class="form-group label-floating">
|
||||
<input ng-model="user.phone" abmFormControl class="form-control" id="inputPhone" placeholder="Phone" type="text">
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="staticEmail" class="col-sm-1 col-form-label">@</label>
|
||||
<div class="col-sm-10">
|
||||
<input ng-model="user.telegram" abmFormControl class="form-control" id="inputTelegram" placeholder="Telegram" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<a ng-href="#!/login" class="btn btn-raised c_grey500">Back</a>
|
||||
<div ng-click="doLogin()" class="btn btn-raised c_deepPurple300 pull-right">Login</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-4">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
43
views/signup/signup.js
Executable file
43
views/signup/signup.js
Executable file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.signup', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/signup', {
|
||||
templateUrl: 'views/signup/signup.html',
|
||||
controller: 'SignupCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('SignupCtrl', function($scope, $http, $routeParams) {
|
||||
$scope.user = {};
|
||||
$scope.doLogin = function() {
|
||||
console.log('Doing login', $scope.user);
|
||||
|
||||
$http({
|
||||
url: urlapi + 'signup',
|
||||
method: "POST",
|
||||
data: $scope.user
|
||||
})
|
||||
.then(function(response) {
|
||||
console.log("response: ");
|
||||
console.log(response.data);
|
||||
if (response.data.success == true)
|
||||
{
|
||||
localStorage.setItem("cr_webapp_token", response.data.token);
|
||||
localStorage.setItem("cr_webapp_userdata", JSON.stringify(response.data.user));
|
||||
window.location.reload();
|
||||
}else{
|
||||
console.log("signup failed");
|
||||
toastr.error('Signup failed');
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
function(response) { // optional
|
||||
// failed
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
101
views/travel/travel.html
Executable file
101
views/travel/travel.html
Executable file
@@ -0,0 +1,101 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">{{travel.title}}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
<a ng-href="#!/user/{{user._id}}" class="list-group-item">
|
||||
<div class="row-picture">
|
||||
<img class="circle" ng-src="{{travel.user.avatar}}" alt="icon">
|
||||
</div>
|
||||
<div class="row-content">
|
||||
<h4 class="list-group-item-heading">{{travel.user.username}}</h4>
|
||||
|
||||
<p class="list-group-item-text">@{{travel.user.telegram}}</p>
|
||||
<p class="list-group-item-text">{{travel.user.phone}}</p>
|
||||
</div>
|
||||
<div class="list-group-separator"></div>
|
||||
</a>
|
||||
</div>
|
||||
<p>
|
||||
From: <b>{{travel.from.name}}</b>
|
||||
</p>
|
||||
<p>
|
||||
To: <b>{{travel.from.name}}</b>
|
||||
</p>
|
||||
<p ng-show="travel.package">
|
||||
Can transport package
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">Map</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<leaflet width="100%" height="300px" markers="markers" center="center"
|
||||
tiles="tiles" id="map-simple-map"></leaflet>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">{{travel.joinPetitions.length}} Pendent joins</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
<a ng-repeat="user in travel.joinPetitions" ng-href="#!/user/{{user._id}}" class="list-group-item">
|
||||
<div class="row-picture">
|
||||
<img class="circle" ng-src="{{user.avatar}}" alt="icon">
|
||||
</div>
|
||||
<div class="row-content">
|
||||
<h4 class="list-group-item-heading">{{user.username}}</h4>
|
||||
|
||||
<p class="list-group-item-text">{{user.description}}</p>
|
||||
</div>
|
||||
<div class="list-group-separator"></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">Accepted users {{travel.joins.length}}/{{travel.seats}}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
<a ng-repeat="user in travel.joins" ng-href="#!/user/{{user._id}}" class="list-group-item">
|
||||
<div class="row-picture">
|
||||
<img class="circle" ng-src="{{user.avatar}}" alt="icon">
|
||||
</div>
|
||||
<div class="row-content">
|
||||
<h4 class="list-group-item-heading">{{user.username}}</h4>
|
||||
|
||||
<p class="list-group-item-text">{{user.description}}</p>
|
||||
</div>
|
||||
<div class="list-group-separator"></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurple500">
|
||||
<h3 class="panel-title">Admin actions</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<!--<div class="btn btn-block btn-sm c_orange300">Ban travel</div>-->
|
||||
<div ng-click="deleteTravel()" class="btn btn-block btn-sm c_red300">Delete travel</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
79
views/travel/travel.js
Executable file
79
views/travel/travel.js
Executable file
@@ -0,0 +1,79 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.travel', ['ngRoute', 'ui-leaflet'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/travel/:travelid', {
|
||||
templateUrl: 'views/travel/travel.html',
|
||||
controller: 'TravelCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('TravelCtrl', function($scope, $http, $routeParams,
|
||||
leafletData, leafletBoundsHelpers) {
|
||||
$scope.travel = {};
|
||||
|
||||
|
||||
//map
|
||||
$scope.center = {
|
||||
/*lat: 0,
|
||||
lng: 0,
|
||||
zoom: 1*/
|
||||
};
|
||||
$scope.bounds = {};
|
||||
$scope.markers = [];
|
||||
$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/id/' + $routeParams.travelid)
|
||||
.then(function(data, status, headers, config) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
|
||||
$scope.travel = data.data;
|
||||
|
||||
//map
|
||||
$scope.markers = [];
|
||||
$scope.markers.push({
|
||||
lat: Number($scope.travel.from.lat),
|
||||
lng: Number($scope.travel.from.long),
|
||||
message: $scope.travel.from.name
|
||||
});
|
||||
$scope.markers.push({
|
||||
lat: Number($scope.travel.to.lat),
|
||||
lng: Number($scope.travel.to.long),
|
||||
message: $scope.travel.to.name
|
||||
});
|
||||
$scope.center = {
|
||||
lat: (Number($scope.travel.from.lat) + Number($scope.travel.to.lat)) / 2,
|
||||
lng: (Number($scope.travel.from.long) + Number($scope.travel.to.long)) / 2,
|
||||
zoom: 4
|
||||
};
|
||||
}, function(data, status, headers, config) {
|
||||
console.log('data error');
|
||||
});
|
||||
|
||||
|
||||
//delete travel
|
||||
$scope.deleteTravel = function() {
|
||||
console.log("delete travel: " + $routeParams.travelid);
|
||||
$http({
|
||||
url: urlapi + '/admin/travels/id/' + $routeParams.travelid,
|
||||
method: "DELETE"
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log(data);
|
||||
$scope.travels = data.data;
|
||||
|
||||
window.location = "#!/main/";
|
||||
},
|
||||
function(data) { // optional
|
||||
// failed
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
54
views/travels/travels.html
Executable file
54
views/travels/travels.html
Executable 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
73
views/travels/travels.js
Executable 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');
|
||||
});
|
||||
});
|
||||
112
views/user/user.html
Executable file
112
views/user/user.html
Executable file
@@ -0,0 +1,112 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">User profile</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
<a class="list-group-item">
|
||||
<div class="row-picture">
|
||||
<img class="circle" ng-src="{{user.avatar}}" alt="icon">
|
||||
</div>
|
||||
<div class="row-content">
|
||||
<h4 class="list-group-item-heading">
|
||||
{{user.username}}
|
||||
<span ng-show="user.validated" class="badge badge-secondary c_deepPurpleG500to300">Validated</span>
|
||||
</h4>
|
||||
|
||||
<p class="list-group-item-text">{{user.description}}</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<p>
|
||||
{{user.email}}
|
||||
</p>
|
||||
<p>
|
||||
{{user.telegram}}
|
||||
</p>
|
||||
<p>
|
||||
{{user.phone}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">User received likes ({{user.likes.length}})</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
<a ng-repeat="user in likes" ng-href="#!/user/{{user._id}}" class="list-group-item">
|
||||
<div class="row-picture">
|
||||
<img class="circle" ng-src="{{user.avatar}}" alt="icon">
|
||||
</div>
|
||||
<div class="row-content">
|
||||
<h4 class="list-group-item-heading">{{user.username}}</h4>
|
||||
|
||||
<p class="list-group-item-text">{{user.description}}</p>
|
||||
</div>
|
||||
<div class="list-group-separator"></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">User travels</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<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 user.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-2">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurple500">
|
||||
<h3 class="panel-title">Admin actions</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<!--<div class="btn btn-block btn-sm c_orange300">Ban user</div>-->
|
||||
<div ng-show="!user.validated" ng-click="validateUser()" class="btn btn-block btn-sm c_deepPurpleG500to300">Validate User</div>
|
||||
<div ng-show="user.validated">Validated by: {{user.validatedBy.username}}</div>
|
||||
<div ng-show="user.validated" ng-click="unvalidateUser()" class="btn btn-block btn-sm c_red200">Unvalidate User</div>
|
||||
<div ng-click="deleteUser()" class="btn btn-block btn-sm c_red300">Delete user</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
77
views/user/user.js
Executable file
77
views/user/user.js
Executable file
@@ -0,0 +1,77 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.user', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/user/:userid', {
|
||||
templateUrl: 'views/user/user.html',
|
||||
controller: 'UserCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('UserCtrl', function($scope, $http, $routeParams) {
|
||||
$scope.user = {};
|
||||
$scope.likes = {};
|
||||
$http.get(urlapi + 'users/id/' + $routeParams.userid)
|
||||
.then(function(data, status, headers, config) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
|
||||
$scope.user = data.data;
|
||||
}, function(data, status, headers, config) {
|
||||
console.log('data error');
|
||||
});
|
||||
$http.get(urlapi + 'users/id/likes/' + $routeParams.userid)
|
||||
.then(function(data, status, headers, config) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.likes = data.data;
|
||||
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
|
||||
}, function(data, status, headers, config) {
|
||||
console.log('data error');
|
||||
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
|
||||
});
|
||||
|
||||
//delete user
|
||||
$scope.deleteUser = function() {
|
||||
console.log("delete user: " + $routeParams.userid);
|
||||
$http({
|
||||
url: urlapi + 'admin/users/id/' + $routeParams.userid,
|
||||
method: "DELETE"
|
||||
})
|
||||
.then(function(data) {
|
||||
window.location = "#!/main/";
|
||||
},
|
||||
function(data) { // optional
|
||||
// failed
|
||||
});
|
||||
};
|
||||
$scope.validateUser = function() {
|
||||
$http({
|
||||
url: urlapi + 'admin/users/validate/id/' + $routeParams.userid,
|
||||
method: "POST",
|
||||
data: {}
|
||||
})
|
||||
.then(function(data) {
|
||||
/*window.location = "#!/main/";*/
|
||||
$scope.user = data.data;
|
||||
},
|
||||
function(data) { // optional
|
||||
// failed
|
||||
});
|
||||
};
|
||||
$scope.unvalidateUser = function() {
|
||||
$http({
|
||||
url: urlapi + 'admin/users/unvalidate/id/' + $routeParams.userid,
|
||||
method: "POST",
|
||||
data: {}
|
||||
})
|
||||
.then(function(data) {
|
||||
/*window.location = "#!/main/";*/
|
||||
$scope.user = data.data;
|
||||
},
|
||||
function(data) { // optional
|
||||
// failed
|
||||
});
|
||||
};
|
||||
});
|
||||
47
views/users/users.html
Normal file
47
views/users/users.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">
|
||||
All users
|
||||
<span class="badge badge-secondary pull-right c_deepPurpleG500to300">{{users.length}}</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body" style="max-height: 500px;overflow-y: scroll;">
|
||||
<div class="list-group">
|
||||
<a ng-repeat="user in users" ng-href="#!/user/{{user._id}}" class="list-group-item">
|
||||
<div class="row-picture">
|
||||
<img class="circle" ng-src="{{user.avatar}}" alt="icon">
|
||||
</div>
|
||||
<div class="row-content">
|
||||
<h4 class="list-group-item-heading">
|
||||
{{user.username}}
|
||||
<span ng-show="user.validated" class="badge badge-secondary c_deepPurpleG500to300">Validated</span>
|
||||
</h4>
|
||||
|
||||
<p class="list-group-item-text">{{user.description}}</p>
|
||||
<p class="list-group-item-text">{{user.travels.length}} published travels</p>
|
||||
<p class="list-group-item-text">{{user.likes.length}} likes</p>
|
||||
</div>
|
||||
<div class="list-group-separator"></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">Actions</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="btn btn-block btn-sm c_green300">Create user</div>
|
||||
<div class="btn btn-block btn-sm c_blue300">Create travel</div>
|
||||
<a href="#!/network" class="btn btn-block btn-sm c_deepPurpleG500to300">View network</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
25
views/users/users.js
Normal file
25
views/users/users.js
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.users', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/users', {
|
||||
templateUrl: 'views/users/users.html',
|
||||
controller: 'UsersCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('UsersCtrl', function($scope, $http) {
|
||||
$scope.users = [];
|
||||
$scope.loadMorePagination = true;
|
||||
$scope.pageUsers = 0;
|
||||
$http.get(urlapi + 'users?page=' + $scope.pageUsers)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
$scope.users = data.data;
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user