mirror of
https://github.com/arnaucube/commonroutesWebApp.git
synced 2026-02-07 03:16:41 +01:00
update
This commit is contained in:
1
app.js
1
app.js
@@ -18,6 +18,7 @@ angular.module('webapp', [
|
||||
'app.travels',
|
||||
'app.users',
|
||||
'app.user',
|
||||
'app.userLikes',
|
||||
'app.travel',
|
||||
'app.newTravel',
|
||||
'app.notifications'
|
||||
|
||||
@@ -133,7 +133,9 @@
|
||||
background: #311B92!important;
|
||||
color: #ffffff!important;
|
||||
}
|
||||
|
||||
.ct_deepPurple300{
|
||||
color: #9575CD!important;
|
||||
}
|
||||
.c_deepPurpleG000to200{
|
||||
background: -moz-linear-gradient(0deg, #ffffff 0%, #D1C4E9 100%)!important; /* ff3.6+ */
|
||||
background: -webkit-gradient(linear, left top, right top, color-stop(0%, #ffffff), color-stop(100%, #D1C4E9))!important; /* safari4+,chrome */
|
||||
@@ -252,6 +254,9 @@
|
||||
color: #ffffff!important;
|
||||
}
|
||||
|
||||
.ct_blue300{
|
||||
color: #64B5F6;
|
||||
}
|
||||
|
||||
/* cyan */
|
||||
.c_cyan50{
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<body ng-app="webapp">
|
||||
<div ng-include="'views/navbar.html'"></div>
|
||||
|
||||
<br><br><br><br>
|
||||
<div ng-view></div>
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<script src="views/travels/travels.js"></script>
|
||||
<script src="views/users/users.js"></script>
|
||||
<script src="views/user/user.js"></script>
|
||||
<script src="views/userLikes/userLikes.js"></script>
|
||||
<script src="views/travel/travel.js"></script>
|
||||
<script src="views/newTravel/newTravel.js"></script>
|
||||
<script src="views/notifications/notifications.js"></script>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"http-server": "^0.9.0"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "bower install",
|
||||
"postinstall": "bower install --allow-root",
|
||||
"prestart": "npm install",
|
||||
"start": "http-server -p 8080 -c-1 ./"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div ng-controller="NavbarCtrl">
|
||||
<div ng-show="storageuser" class="navbar c_deepPurpleG500to300">
|
||||
<nav ng-show="storageuser" class="navbar navbar-fixed-top c_deepPurpleG500to300">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
|
||||
@@ -31,6 +31,12 @@
|
||||
<i title="Post new travel" class="fa fa-plus fa-2x"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a ng-href="#!/user/{{storageuser._id}}">
|
||||
<img class="circle" ng-src="{{storageuser.avatar}}" style="max-width:30px; max-height:30px;" alt="icon">
|
||||
{{storageuser.username}}
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="" data-target="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i title="Post new travel" class="fa fa-cog fa-2x"></i>
|
||||
@@ -52,7 +58,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<!--
|
||||
<div ng-click="goBack()" class="btn"><span class="glyphicon glyphicon-arrow-left"></span> Back</div>
|
||||
-->
|
||||
|
||||
@@ -25,18 +25,20 @@ angular.module('app.navbar', ['ngRoute'])
|
||||
if (localStorage.getItem("cr_webapp_userdata")) {
|
||||
$scope.storageuser = JSON.parse(localStorage.getItem("cr_webapp_userdata"));
|
||||
console.log($scope.storageuser);
|
||||
|
||||
//get the num of pendent notifications each time
|
||||
$http.get(urlapi + 'numnotifications')
|
||||
.then(function(data) {
|
||||
$scope.storageuser.notifications = data.data;
|
||||
console.log(data.data);
|
||||
localStorage.setItem("cr_webapp_storageuser", JSON.stringify($scope.storageuser));
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//get the num of pendent notifications each time
|
||||
$http.get(urlapi + 'numnotifications')
|
||||
.then(function(data) {
|
||||
$scope.storageuser.notifications = data.data;
|
||||
console.log(data.data);
|
||||
localStorage.setItem("cr_webapp_storageuser", JSON.stringify($scope.storageuser));
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
|
||||
});
|
||||
|
||||
|
||||
$scope.logout = function() {
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
</a>
|
||||
<a ng-repeat="notification in notifications | orderBy: '-date'" ng-show="notification.state=='viewed'" class="list-group-item" href="#!/{{notification.link}}">
|
||||
<div class="pull-right">
|
||||
<div class="o_text_purple600">{{notification.date | date:"dd/MM"}}</div>
|
||||
<div class="o_text_purple600">{{notification.date | date:"HH:mm:ss"}}</div>
|
||||
<div class="">{{notification.date | date:"dd/MM"}}</div>
|
||||
<div class="">{{notification.date | date:"HH:mm:ss"}}</div>
|
||||
</div>
|
||||
<i ng-show="notification.state=='viewed'" class="icon {{notification.icon}}"></i>
|
||||
<h2>{{notification.message}}</h2>
|
||||
|
||||
@@ -23,6 +23,7 @@ angular.module('app.notifications', ['ngRoute'])
|
||||
}
|
||||
//store the notifications
|
||||
localStorage.setItem("cr_webapp_notifications", JSON.stringify($scope.notifications));
|
||||
console.log($scope.notifications);
|
||||
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</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 ng-click="doSignup()" class="btn btn-raised c_deepPurple300 pull-right">Signup</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,7 +11,7 @@ angular.module('app.signup', ['ngRoute'])
|
||||
|
||||
.controller('SignupCtrl', function($scope, $http, $routeParams) {
|
||||
$scope.user = {};
|
||||
$scope.doLogin = function() {
|
||||
$scope.doSignup = function() {
|
||||
console.log('Doing login', $scope.user);
|
||||
|
||||
$http({
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="pull-right">
|
||||
<a ng-href="#!/user/{{travel.user._id}}">
|
||||
<a ng-href="#!/user/{{travel.user._id}}" class="btn" style="text-transform:none;" ng-show="travel.user">
|
||||
<img class="circle" style="max-width: 30px; max-height:30px;" ng-src="{{travel.user.avatar}}" />
|
||||
{{travel.user.username}}
|
||||
</a>
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
</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>
|
||||
{{user.username}} <i ng-show="user.validated" class="fa fa-check-circle ct_blue300" title="user validated"></i>
|
||||
</h4>
|
||||
|
||||
<p class="list-group-item-text">{{user.description}}</p>
|
||||
@@ -25,36 +24,54 @@
|
||||
{{user.email}}
|
||||
</p>
|
||||
<p>
|
||||
{{user.telegram}}
|
||||
<a ng-show="user.telegram" ng-href="https://t.me/{{user.telegram}}" target="_blank" class="ct_deepPurple300">
|
||||
<i class="fa fa-telegram fa-2x"></i> @{{user.telegram}}
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
{{user.phone}}
|
||||
<p ng-show="user.phone">
|
||||
<i class="fa fa-phone fa-2x"></i> {{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 class="text-right">
|
||||
<a ng-href="#!/userLikes/{{user._id}}" class="ct_deepPurple300">
|
||||
{{user.likes.length}} likes
|
||||
</a>
|
||||
<div ng-show="arrayObjectIndexOf(user.likes, storageuser._id)==-1"
|
||||
ng-click="likeUser()" class="btn" title="click to like user">
|
||||
<i class="fa fa-heart fa-2x"></i> Like
|
||||
</div>
|
||||
<div ng-show="arrayObjectIndexOf(user.likes, storageuser._id)>-1"
|
||||
ng-click="unlikeUser()" class="btn" title="click to unlike user">
|
||||
<i class="fa fa-heart fa-2x ctext_red600"></i> Unlike
|
||||
</div>
|
||||
|
||||
</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>
|
||||
<img ng-src="{{user.faircoin}}" class="img-responsive">
|
||||
{{user.faircoinString}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="panel">
|
||||
<div class="col-sm-8">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div ng-repeat="travel in user.travels" ng-if="$index % 2 == 0">
|
||||
<a ng-href="#!/travel/{{travel._id}}">
|
||||
<div ng-include="'views/travelCardTemplate.html'"></div>
|
||||
</a>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div ng-repeat="travel in user.travels" ng-if="$index % 2 == 1">
|
||||
<a ng-href="#!/travel/{{travel._id}}">
|
||||
<div ng-include="'views/travelCardTemplate.html'"></div>
|
||||
</a>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
<h3 class="panel-title">User travels</h3>
|
||||
</div>
|
||||
@@ -90,23 +107,7 @@
|
||||
</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>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,9 @@ angular.module('app.user', ['ngRoute'])
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('UserCtrl', function($scope, $http, $routeParams) {
|
||||
.controller('UserCtrl', function($scope, $http, $routeParams, toastr) {
|
||||
$scope.storageuser = JSON.parse(localStorage.getItem("cr_webapp_userdata"));
|
||||
|
||||
$scope.user = {};
|
||||
$scope.likes = {};
|
||||
$http.get(urlapi + 'users/id/' + $routeParams.userid)
|
||||
@@ -32,46 +34,55 @@ angular.module('app.user', ['ngRoute'])
|
||||
$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"
|
||||
$scope.likeUser = function() {
|
||||
$http({
|
||||
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
|
||||
url: urlapi + 'users/id/like/' + $scope.user._id,
|
||||
method: "POST",
|
||||
data: {}
|
||||
})
|
||||
.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: {}
|
||||
// success
|
||||
if (data.data.success == false) {
|
||||
console.log("failed");
|
||||
toastr.error("Error on like");
|
||||
} else {
|
||||
$scope.user = data.data; // for UI
|
||||
}
|
||||
},
|
||||
function(response) { // optional
|
||||
// failed
|
||||
});
|
||||
};
|
||||
$scope.unlikeUser = function() {
|
||||
$http({
|
||||
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
|
||||
url: urlapi + 'users/id/unlike/' + $scope.user._id,
|
||||
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
|
||||
});
|
||||
};
|
||||
// success
|
||||
if (data.data.success == false) {
|
||||
console.log("failed");
|
||||
toastr.error("Error on unlike");
|
||||
} else {
|
||||
$scope.user = data.data; // for UI
|
||||
}
|
||||
},
|
||||
function(response) { // optional
|
||||
// failed
|
||||
});
|
||||
};
|
||||
|
||||
$scope.arrayObjectIndexOf = function(myArray, searchTerm) {
|
||||
if (myArray) {
|
||||
for (var i = 0, len = myArray.length; i < len; i++) {
|
||||
if (myArray[i] === searchTerm) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
});
|
||||
|
||||
27
views/userLikes/userLikes.html
Normal file
27
views/userLikes/userLikes.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<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">User received likes ({{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>
|
||||
</div>
|
||||
26
views/userLikes/userLikes.js
Normal file
26
views/userLikes/userLikes.js
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.userLikes', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/userLikes/:userid', {
|
||||
templateUrl: 'views/userLikes/userLikes.html',
|
||||
controller: 'UserLikesCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('UserLikesCtrl', function($scope, $http, $routeParams) {
|
||||
$scope.likes = {};
|
||||
$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
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-3"></div>
|
||||
<div class="col-sm-6">
|
||||
<div class="panel">
|
||||
<div class="panel-heading c_deepPurpleG500to300">
|
||||
@@ -17,7 +18,7 @@
|
||||
<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>
|
||||
<i ng-show="user.validated" class="fa fa-check-circle ct_blue300" title="user validated"></i>
|
||||
</h4>
|
||||
|
||||
<p class="list-group-item-text">{{user.description}}</p>
|
||||
@@ -32,16 +33,7 @@
|
||||
</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>
|
||||
|
||||
Reference in New Issue
Block a user