diff --git a/app.js b/app.js index becb30e..83612e6 100644 --- a/app.js +++ b/app.js @@ -9,6 +9,8 @@ angular.module('adminApp', [ 'ngRoute', 'ngMessages', 'angularBootstrapMaterial', + 'app.navbar', + 'app.login', 'app.main', 'app.user', 'app.travel' @@ -16,5 +18,56 @@ angular.module('adminApp', [ config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) { $locationProvider.hashPrefix('!'); - $routeProvider.otherwise({redirectTo: '/main'}); -}]); + //$routeProvider.otherwise({redirectTo: '/main'}); + if((localStorage.getItem('cic_admin_token'))) + { + console.log(window.location.hash); + if(window.location.hash==='#!/login') + { + window.location='#!/main'; + } + + $routeProvider.otherwise({redirectTo: '/main'}); + }else{ + if(window.location!=='#!/login') + { + console.log('app, user no logged'); + + localStorage.removeItem('cic_admin_token'); + localStorage.removeItem('cic_admin_userdata'); + window.location='#!/login'; + $routeProvider.otherwise({redirectTo: '/login'}); + } + } +}]) + +.factory('httpInterceptor', function httpInterceptor () { + return { + request: function(config) { + return config; + }, + + requestError: function(config) { + return config; + }, + + response: function(res) { + return res; + }, + + responseError: function(res) { + return res; + } + }; +}) +.factory('api', function ($http) { + return { + init: function () { + $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('cic_admin_token'); + $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem('cic_admin_token'); + } + }; +}) +.run(function (api) { + api.init(); +}); diff --git a/bower.json b/bower.json index efeda97..bb49372 100644 --- a/bower.json +++ b/bower.json @@ -1,18 +1,20 @@ { - "name": "carsincommonAdminWeb", - "description": "carsincommonAdminWeb", - "version": "0.0.0", - "homepage": "https://github.com/arnaucode/carsincommonAdmin", - "license": "MIT", - "private": true, - "dependencies": { - "angular": "^1.6.2", - "angular-route": "^1.6.1", - "angular-chart.js": "^1.1.1", - "vis": "^4.18.1", - "mui": "^0.9.20", - "angular-bootstrap-material": "abm#^0.1.4", - "angular-bootstrap": "^2.5.0", - "angular-messages": "^1.6.5" - } + "name": "carsincommonAdminWeb", + "description": "carsincommonAdminWeb", + "version": "0.0.0", + "homepage": "https://github.com/arnaucode/carsincommonAdmin", + "license": "MIT", + "private": true, + "dependencies": { + "angular": "^1.6.2", + "angular-route": "^1.6.1", + "angular-chart.js": "^1.1.1", + "vis": "^4.18.1", + "mui": "^0.9.20", + "angular-bootstrap-material": "abm#^0.1.4", + "angular-bootstrap": "^2.5.0", + "angular-messages": "^1.6.5", + "components-font-awesome": "^4.7.0", + "ui-leaflet": "^2.0.0" + } } diff --git a/img/avatars/chameleon.png b/img/avatars/chameleon.png new file mode 100644 index 0000000..91f30f6 Binary files /dev/null and b/img/avatars/chameleon.png differ diff --git a/img/avatars/clown-fish.png b/img/avatars/clown-fish.png new file mode 100644 index 0000000..2473fcc Binary files /dev/null and b/img/avatars/clown-fish.png differ diff --git a/img/avatars/duck.png b/img/avatars/duck.png new file mode 100644 index 0000000..2c48212 Binary files /dev/null and b/img/avatars/duck.png differ diff --git a/img/avatars/owl.png b/img/avatars/owl.png new file mode 100644 index 0000000..732dc88 Binary files /dev/null and b/img/avatars/owl.png differ diff --git a/img/avatars/penguin.png b/img/avatars/penguin.png new file mode 100644 index 0000000..295e7f1 Binary files /dev/null and b/img/avatars/penguin.png differ diff --git a/img/avatars/racoon.png b/img/avatars/racoon.png new file mode 100644 index 0000000..c4d3418 Binary files /dev/null and b/img/avatars/racoon.png differ diff --git a/img/avatars/siberian-husky.png b/img/avatars/siberian-husky.png new file mode 100644 index 0000000..9de786f Binary files /dev/null and b/img/avatars/siberian-husky.png differ diff --git a/img/avatars/sloth.png b/img/avatars/sloth.png new file mode 100644 index 0000000..2f7322a Binary files /dev/null and b/img/avatars/sloth.png differ diff --git a/img/avatars/tiger.png b/img/avatars/tiger.png new file mode 100644 index 0000000..b85ee3d Binary files /dev/null and b/img/avatars/tiger.png differ diff --git a/img/avatars/toucan.png b/img/avatars/toucan.png new file mode 100644 index 0000000..d16afd8 Binary files /dev/null and b/img/avatars/toucan.png differ diff --git a/img/faircoinpublickey_sample.png b/img/faircoinpublickey_sample.png new file mode 100644 index 0000000..6932043 Binary files /dev/null and b/img/faircoinpublickey_sample.png differ diff --git a/img/userProfileBackground.png b/img/userProfileBackground.png new file mode 100644 index 0000000..2ae41b5 Binary files /dev/null and b/img/userProfileBackground.png differ diff --git a/index.html b/index.html index d76e1ca..b5a9bb8 100644 --- a/index.html +++ b/index.html @@ -11,6 +11,9 @@ + + + @@ -21,6 +24,8 @@ +
+
@@ -45,10 +50,10 @@ - + + + + @@ -57,6 +62,8 @@ + + diff --git a/views/login/login.html b/views/login/login.html new file mode 100644 index 0000000..9adf663 --- /dev/null +++ b/views/login/login.html @@ -0,0 +1,29 @@ +
+
+
+ +
+
+
+
+

Login

+
+
+
+ +
+
+ +
+ +
Login
+
+
+
+ + +
+ +
+
+
diff --git a/views/login/login.js b/views/login/login.js new file mode 100644 index 0000000..0c8f6af --- /dev/null +++ b/views/login/login.js @@ -0,0 +1,42 @@ +'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) { + $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("cic_admin_token", response.data.token); + localStorage.setItem("cic_admin_userdata", JSON.stringify(response.data.user)); + window.location.reload(); + }else{ + console.log("login failed"); + } + + + }, + function(response) { // optional + // failed + console.log(response); + }); + + }; +}); diff --git a/views/main/main.html b/views/main/main.html index 99453b4..763aafd 100644 --- a/views/main/main.html +++ b/views/main/main.html @@ -1,6 +1,3 @@ -
- -
@@ -18,6 +15,8 @@

{{user.username}}

{{user.description}}

+

{{user.travels.length}} published travels

+

{{user.likes.length}} likes

@@ -46,7 +45,11 @@ - {{travel.type}} + + + + + {{travel.title}} {{travel.date | date}} diff --git a/views/navbar.html b/views/navbar.html index 2d6ef0e..30ed14d 100644 --- a/views/navbar.html +++ b/views/navbar.html @@ -1,4 +1,4 @@ - +
+ +
diff --git a/views/navbar.js b/views/navbar.js new file mode 100644 index 0000000..d531496 --- /dev/null +++ b/views/navbar.js @@ -0,0 +1,19 @@ +'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.locationHash = $location.path(); + console.log($scope.locationHash); + $scope.goBack = function() { + console.log("goBack"); + window.history.back(); + }; + }); diff --git a/views/travel/travel.html b/views/travel/travel.html index ddc4132..988dacb 100644 --- a/views/travel/travel.html +++ b/views/travel/travel.html @@ -1,6 +1,3 @@ -
- -
@@ -9,11 +6,25 @@

{{travel.title}}

+

- From: {{travel.from.name}} + From: {{travel.from.name}}

- To: {{travel.from.name}} + To: {{travel.from.name}}

Can transport package @@ -25,11 +36,12 @@

Map

- here the map +
-
+

{{travel.joinPetitions.length}} Pendent joins

@@ -52,7 +64,7 @@
-
+

Accepted users {{travel.joins.length}}/{{travel.seats}}

@@ -74,4 +86,16 @@
+ +
+
+
+

Admin actions

+
+
+
Ban travel
+
Delete travel
+
+
+
diff --git a/views/travel/travel.js b/views/travel/travel.js index 5f70361..d38ff6c 100644 --- a/views/travel/travel.js +++ b/views/travel/travel.js @@ -1,23 +1,60 @@ 'use strict'; -angular.module('app.travel', ['ngRoute']) - -.config(['$routeProvider', function($routeProvider) { - $routeProvider.when('/travel/:travelid', { - templateUrl: 'views/travel/travel.html', - controller: 'TravelCtrl' - }); -}]) - -.controller('TravelCtrl', function($scope, $http, $routeParams) { - $scope.travel = {}; - $http.get(urlapi + 'travels/id/' + $routeParams.travelid) - .then(function(data, status, headers, config) { - console.log('data success'); - console.log(data); - - $scope.travel = data.data; - }, function(data, status, headers, config) { - console.log('data error'); - }); -}); +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: 'OpenStreetMap 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'); + }); + + }); diff --git a/views/user/user.html b/views/user/user.html index 295e791..ef23797 100644 --- a/views/user/user.html +++ b/views/user/user.html @@ -1,6 +1,3 @@ -
- -
@@ -10,7 +7,7 @@
-
+

User travels

@@ -60,7 +69,11 @@ - {{travel.type}} + + + + + {{travel.title}} {{travel.date | date}} @@ -76,5 +89,18 @@
+ + +
+
+
+

Admin actions

+
+
+
Ban user
+
Delete user
+
+
+
diff --git a/views/user/user.js b/views/user/user.js index 3a758ae..eeaa447 100644 --- a/views/user/user.js +++ b/views/user/user.js @@ -2,22 +2,33 @@ angular.module('app.user', ['ngRoute']) -.config(['$routeProvider', function($routeProvider) { - $routeProvider.when('/user/:userid', { - templateUrl: 'views/user/user.html', - controller: 'UserCtrl' - }); -}]) + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/user/:userid', { + templateUrl: 'views/user/user.html', + controller: 'UserCtrl' + }); + }]) -.controller('UserCtrl', function($scope, $http, $routeParams) { - $scope.user = {}; - $http.get(urlapi + 'users/id/' + $routeParams.userid) - .then(function(data, status, headers, config) { - console.log('data success'); - console.log(data); + .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'); - }); -}); + $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 + }); + });