Browse Source

update

master
arnaucode 7 years ago
parent
commit
e0073cadb3
16 changed files with 183 additions and 110 deletions
  1. +1
    -0
      app.js
  2. +6
    -1
      css/colors.css
  3. +2
    -1
      index.html
  4. +1
    -1
      package.json
  5. +8
    -2
      views/navbar.html
  6. +12
    -10
      views/navbar.js
  7. +2
    -2
      views/notifications/notifications.html
  8. +1
    -0
      views/notifications/notifications.js
  9. +1
    -1
      views/signup/signup.html
  10. +1
    -1
      views/signup/signup.js
  11. +1
    -1
      views/travelCardTemplate.html
  12. +41
    -40
      views/user/user.html
  13. +50
    -39
      views/user/user.js
  14. +27
    -0
      views/userLikes/userLikes.html
  15. +26
    -0
      views/userLikes/userLikes.js
  16. +3
    -11
      views/users/users.html

+ 1
- 0
app.js

@ -18,6 +18,7 @@ angular.module('webapp', [
'app.travels', 'app.travels',
'app.users', 'app.users',
'app.user', 'app.user',
'app.userLikes',
'app.travel', 'app.travel',
'app.newTravel', 'app.newTravel',
'app.notifications' 'app.notifications'

+ 6
- 1
css/colors.css

@ -133,7 +133,9 @@
background: #311B92!important; background: #311B92!important;
color: #ffffff!important; color: #ffffff!important;
} }
.ct_deepPurple300{
color: #9575CD!important;
}
.c_deepPurpleG000to200{ .c_deepPurpleG000to200{
background: -moz-linear-gradient(0deg, #ffffff 0%, #D1C4E9 100%)!important; /* ff3.6+ */ 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 */ 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; color: #ffffff!important;
} }
.ct_blue300{
color: #64B5F6;
}
/* cyan */ /* cyan */
.c_cyan50{ .c_cyan50{

+ 2
- 1
index.html

@ -25,7 +25,7 @@
<body ng-app="webapp"> <body ng-app="webapp">
<div ng-include="'views/navbar.html'"></div> <div ng-include="'views/navbar.html'"></div>
<br><br><br><br>
<div ng-view></div> <div ng-view></div>
@ -69,6 +69,7 @@
<script src="views/travels/travels.js"></script> <script src="views/travels/travels.js"></script>
<script src="views/users/users.js"></script> <script src="views/users/users.js"></script>
<script src="views/user/user.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/travel/travel.js"></script>
<script src="views/newTravel/newTravel.js"></script> <script src="views/newTravel/newTravel.js"></script>
<script src="views/notifications/notifications.js"></script> <script src="views/notifications/notifications.js"></script>

+ 1
- 1
package.json

@ -10,7 +10,7 @@
"http-server": "^0.9.0" "http-server": "^0.9.0"
}, },
"scripts": { "scripts": {
"postinstall": "bower install",
"postinstall": "bower install --allow-root",
"prestart": "npm install", "prestart": "npm install",
"start": "http-server -p 8080 -c-1 ./" "start": "http-server -p 8080 -c-1 ./"
}, },

+ 8
- 2
views/navbar.html

@ -1,5 +1,5 @@
<div ng-controller="NavbarCtrl"> <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="container-fluid">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse"> <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> <i title="Post new travel" class="fa fa-plus fa-2x"></i>
</a> </a>
</li> </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"> <li class="dropdown">
<a href="" data-target="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="" data-target="#" class="dropdown-toggle" data-toggle="dropdown">
<i title="Post new travel" class="fa fa-cog fa-2x"></i> <i title="Post new travel" class="fa fa-cog fa-2x"></i>
@ -52,7 +58,7 @@
</ul> </ul>
</div> </div>
</div> </div>
</div>
</nav>
<!-- <!--
<div ng-click="goBack()" class="btn"><span class="glyphicon glyphicon-arrow-left"></span> Back</div> <div ng-click="goBack()" class="btn"><span class="glyphicon glyphicon-arrow-left"></span> Back</div>
--> -->

+ 12
- 10
views/navbar.js

@ -25,18 +25,20 @@ angular.module('app.navbar', ['ngRoute'])
if (localStorage.getItem("cr_webapp_userdata")) { if (localStorage.getItem("cr_webapp_userdata")) {
$scope.storageuser = JSON.parse(localStorage.getItem("cr_webapp_userdata")); $scope.storageuser = JSON.parse(localStorage.getItem("cr_webapp_userdata"));
console.log($scope.storageuser); 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() { $scope.logout = function() {

+ 2
- 2
views/notifications/notifications.html

@ -24,8 +24,8 @@
</a> </a>
<a ng-repeat="notification in notifications | orderBy: '-date'" ng-show="notification.state=='viewed'" class="list-group-item" href="#!/{{notification.link}}"> <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="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> </div>
<i ng-show="notification.state=='viewed'" class="icon {{notification.icon}}"></i> <i ng-show="notification.state=='viewed'" class="icon {{notification.icon}}"></i>
<h2>{{notification.message}}</h2> <h2>{{notification.message}}</h2>

+ 1
- 0
views/notifications/notifications.js

@ -23,6 +23,7 @@ angular.module('app.notifications', ['ngRoute'])
} }
//store the notifications //store the notifications
localStorage.setItem("cr_webapp_notifications", JSON.stringify($scope.notifications)); localStorage.setItem("cr_webapp_notifications", JSON.stringify($scope.notifications));
console.log($scope.notifications);
}, function(data) { }, function(data) {
console.log('data error'); console.log('data error');

+ 1
- 1
views/signup/signup.html

@ -28,7 +28,7 @@
</div> </div>
</div> </div>
<a ng-href="#!/login" class="btn btn-raised c_grey500">Back</a> <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> </div>
</div> </div>

+ 1
- 1
views/signup/signup.js

@ -11,7 +11,7 @@ angular.module('app.signup', ['ngRoute'])
.controller('SignupCtrl', function($scope, $http, $routeParams) { .controller('SignupCtrl', function($scope, $http, $routeParams) {
$scope.user = {}; $scope.user = {};
$scope.doLogin = function() {
$scope.doSignup = function() {
console.log('Doing login', $scope.user); console.log('Doing login', $scope.user);
$http({ $http({

+ 1
- 1
views/travelCardTemplate.html

@ -11,7 +11,7 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="pull-right"> <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}}" /> <img class="circle" style="max-width: 30px; max-height:30px;" ng-src="{{travel.user.avatar}}" />
{{travel.user.username}} {{travel.user.username}}
</a> </a>

+ 41
- 40
views/user/user.html

@ -13,8 +13,7 @@
</div> </div>
<div class="row-content"> <div class="row-content">
<h4 class="list-group-item-heading"> <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> </h4>
<p class="list-group-item-text">{{user.description}}</p> <p class="list-group-item-text">{{user.description}}</p>
@ -25,36 +24,54 @@
{{user.email}} {{user.email}}
</p> </p>
<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>
<p>
{{user.phone}}
<p ng-show="user.phone">
<i class="fa fa-phone fa-2x"></i> {{user.phone}}
</p> </p>
</div> </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>
<div class="panel-body"> <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>
<img ng-src="{{user.faircoin}}" class="img-responsive">
{{user.faircoinString}}
</div>
</div>
</div>
<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> </a>
<br>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="col-sm-6">
<div class="panel">
<!--<div class="panel">
<div class="panel-heading c_deepPurpleG500to300"> <div class="panel-heading c_deepPurpleG500to300">
<h3 class="panel-title">User travels</h3> <h3 class="panel-title">User travels</h3>
</div> </div>
@ -90,23 +107,7 @@
</tbody> </tbody>
</table> </table>
</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 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> </div>
</div> </div>

+ 50
- 39
views/user/user.js

@ -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.user = {};
$scope.likes = {}; $scope.likes = {};
$http.get(urlapi + 'users/id/' + $routeParams.userid) $http.get(urlapi + 'users/id/' + $routeParams.userid)
@ -32,46 +34,55 @@ angular.module('app.user', ['ngRoute'])
$scope.$broadcast('scroll.refreshComplete'); //refresher stop $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: {}
$scope.likeUser = function() {
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
url: urlapi + 'users/id/like/' + $scope.user._id,
method: "POST",
data: {}
}) })
.then(function(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: {}
// 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) { .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
- 0
views/userLikes/userLikes.html

@ -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
- 0
views/userLikes/userLikes.js

@ -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
});
});

+ 3
- 11
views/users/users.html

@ -1,5 +1,6 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-sm-3"></div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="panel"> <div class="panel">
<div class="panel-heading c_deepPurpleG500to300"> <div class="panel-heading c_deepPurpleG500to300">
@ -17,7 +18,7 @@
<div class="row-content"> <div class="row-content">
<h4 class="list-group-item-heading"> <h4 class="list-group-item-heading">
{{user.username}} {{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> </h4>
<p class="list-group-item-text">{{user.description}}</p> <p class="list-group-item-text">{{user.description}}</p>
@ -32,16 +33,7 @@
</div> </div>
<div class="col-sm-2"> <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> </div>
</div> </div>

Loading…
Cancel
Save