From 644ad79712cb216a56c4a4f0437059713e3f8b2e Mon Sep 17 00:00:00 2001 From: arnaucode Date: Sat, 21 Oct 2017 23:59:51 +0200 Subject: [PATCH] improved main, implementing new travel --- app.js | 3 +- index.html | 1 + views/main/main.html | 117 ++++----------------------- views/navbar.html | 78 ++++++++++-------- views/navbar.js | 4 +- views/newTravel/newTravel.html | 34 ++++++++ views/newTravel/newTravel.js | 66 +++++++++++++++ views/newTravel/newofferingForm.html | 52 ++++++++++++ views/travel/travel.html | 58 ++----------- views/travelCardTemplate.html | 32 ++++++++ 10 files changed, 257 insertions(+), 188 deletions(-) create mode 100644 views/newTravel/newTravel.html create mode 100644 views/newTravel/newTravel.js create mode 100644 views/newTravel/newofferingForm.html create mode 100644 views/travelCardTemplate.html diff --git a/app.js b/app.js index b900215..899f7b1 100755 --- a/app.js +++ b/app.js @@ -18,7 +18,8 @@ angular.module('webapp', [ 'app.travels', 'app.users', 'app.user', - 'app.travel' + 'app.travel', + 'app.newTravel' ]). config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) { $locationProvider.hashPrefix('!'); diff --git a/index.html b/index.html index e29dee4..1290e2b 100755 --- a/index.html +++ b/index.html @@ -70,6 +70,7 @@ + diff --git a/views/main/main.html b/views/main/main.html index 1f3bbba..560f796 100755 --- a/views/main/main.html +++ b/views/main/main.html @@ -1,112 +1,29 @@
-
-
-
-
{{travel.date | date}}
-

{{travel.title}}

-
-
- -

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

-

- To: {{travel.to.name}} -

-

- {{travel.joins.length}}/{{travel.seats}} -

-

- Can transport package -

- Go somewhere -
-
-

-
-
-
- Card image cap -
-

Card title

-

Some quick example text to build on the card title and make up the bulk of the card's content.

- Go somewhere -
-
-

+
+ +
+
+
-
-
-

- Travels Feed - {{travels.length}} -

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeTitleFromToDateUsernºJoins/Seats
- - - - {{travel.title}} - {{travel.from.name}} - - {{travel.to.name}} - {{travel.date | date}} - - - {{travel.user.username}} - - {{travel.joins.length}}/{{travel.seats}}View
-
+
+ +
+
+
-
-
-
-

Actions

-
-
-
Create user
-
Create travel
- View network -
+
+
+ +
+
+
+
diff --git a/views/navbar.html b/views/navbar.html index 9731bd6..ac11a75 100755 --- a/views/navbar.html +++ b/views/navbar.html @@ -1,45 +1,53 @@
- -
-
diff --git a/views/navbar.js b/views/navbar.js index d1221e6..848b00b 100755 --- a/views/navbar.js +++ b/views/navbar.js @@ -23,8 +23,8 @@ angular.module('app.navbar', ['ngRoute']) 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.storageuser = JSON.parse(localStorage.getItem("cr_webapp_userdata")); + console.log($scope.storageuser); } $scope.logout = function() { diff --git a/views/newTravel/newTravel.html b/views/newTravel/newTravel.html new file mode 100644 index 0000000..2bf98b0 --- /dev/null +++ b/views/newTravel/newTravel.html @@ -0,0 +1,34 @@ +
+
+
+
+
+ +
+
+
+
+

+ + + + + New {{travel.type}} travel +

+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
diff --git a/views/newTravel/newTravel.js b/views/newTravel/newTravel.js new file mode 100644 index 0000000..804c649 --- /dev/null +++ b/views/newTravel/newTravel.js @@ -0,0 +1,66 @@ +'use strict'; + +angular.module('app.newTravel', ['ngRoute']) + + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/newTravel', { + templateUrl: 'views/newTravel/newTravel.html', + controller: 'NewTravelCtrl' + }); + }]) + + .controller('NewTravelCtrl', function($scope, $http, toastr) { + $scope.travel = {}; + + $scope.selectType = function(type) { + $scope.travel.type = type; + }; + + //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' + } + }; + + $scope.doNewTravel = function() { + $scope.postNewTravel(); + }; + $scope.postNewTravel = function() { + $http({ + url: urlapi + 'travels', + method: "POST", + data: $scope.travel + }) + .then(function(data) { + console.log(data); + window.location = "#app/travels"; + }, + function(data) { // optional + // failed + console.log(data); + toastr.warning('Complete all parameters first'); + + }); + }; + $scope.allParametersCompleted = function() { + if (($scope.travel.title != undefined) && + ($scope.travel.from != undefined) && + ($scope.travel.to != undefined) && + ($scope.travel.date != undefined) && + ($scope.travel.seats != undefined) && + ($scope.travel.type != undefined)) { + return true; + } else { + return false; + } + }; + }); diff --git a/views/newTravel/newofferingForm.html b/views/newTravel/newofferingForm.html new file mode 100644 index 0000000..a4ac328 --- /dev/null +++ b/views/newTravel/newofferingForm.html @@ -0,0 +1,52 @@ +
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+
+ + +
+
+ + +
+
+
+
+ +
+ +

+ + +

+ diff --git a/views/travel/travel.html b/views/travel/travel.html index 773195a..18d3e58 100755 --- a/views/travel/travel.html +++ b/views/travel/travel.html @@ -1,47 +1,8 @@
-
-
-

{{travel.title}}

-
-
- -

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

-

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

-

- Can transport package -

-
-
-
-
-

Map

-
-
- -
-
-
-
+
+

{{travel.joinPetitions.length}} Pendent joins

@@ -62,9 +23,6 @@
-
- -

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

@@ -86,16 +44,16 @@
- -
+
-
-

Admin actions

+
+

Map

- -
Delete travel
+
+
diff --git a/views/travelCardTemplate.html b/views/travelCardTemplate.html new file mode 100644 index 0000000..ab5b3d7 --- /dev/null +++ b/views/travelCardTemplate.html @@ -0,0 +1,32 @@ +
+
+
{{travel.date | date}}
+

+ + + + + {{travel.title}} +

+
+
+ +

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

+

+ To: {{travel.to.name}} +

+

+ Seats: {{travel.joins.length}}/{{travel.seats}} +

+

+ Can transport package +

+
+