Skip to content

Commit 3c98173

Browse files
committed
photos working!!
1 parent fe1eab3 commit 3c98173

File tree

57 files changed

+356
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+356
-126
lines changed

bower.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"font-awesome": "^4.7.0",
2222
"ngSweetAlert": "latest",
2323
"ng-tags-input": "3.2.0",
24-
"angular-jwt": "^0.1.9"
24+
"angular-jwt": "^0.1.9",
25+
"ng-file-upload": "^12.2.13"
2526
}
2627
}

package-lock.json

+21-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Web about projects collabortive",
55
"main": "index.js",
66
"scripts": {
7-
"prestart": "bower install npm install",
7+
"prestart": "npm install && bower install",
88
"start": "node server/app.js",
99
"dev": "nodemon server/app.js",
1010
"build:scss": "node-sass src/scss/styles.scss public/css/styles.css",
@@ -17,13 +17,13 @@
1717
"dependencies": {
1818
"body-parser": "^1.17.2",
1919
"bower": "^1.8.0",
20+
"cloudinary": "^1.9.0",
2021
"del": "^3.0.0",
2122
"dotenv": "^4.0.0",
2223
"express": "^4.15.4",
2324
"jsonwebtoken": "^7.4.3",
2425
"mongoose": "^4.11.9",
2526
"multer": "^1.3.0",
26-
"node": "^8.3.0",
2727
"node-sass": "^4.5.3",
2828
"nodemailer": "^4.1.0",
2929
"passport": "^0.4.0",

public/app/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
angular.module('mainApp', ['ngRoute', 'oitozero.ngSweetAlert', 'ngTagsInput', 'angular-jwt'])
1+
angular.module('mainApp', ['ngRoute', 'oitozero.ngSweetAlert', 'ngTagsInput', 'angular-jwt', 'ngFileUpload'])
22

33
.config(function ($httpProvider) {
44
$httpProvider.interceptors.push('authInterceptor')

public/app/index.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
<script src="../bower_components/ng-tags-input/ng-tags-input.min.js"></script>
4747

4848
<!-- angular-jwt -->
49-
<script src="/bower_components/angular-jwt/dist/angular-jwt.min.js"></script>
49+
<script src="../bower_components/angular-jwt/dist/angular-jwt.min.js"></script>
50+
51+
<!-- ng-file-upload -->
52+
<script src="../bower_components/ng-file-upload/ng-file-upload-shim.min.js"></script>
53+
<script src="../bower_components/ng-file-upload/ng-file-upload.min.js"></script>
5054

5155
<!-- app js -->
5256
<script src="app.js"></script>

public/app/routes/favourites/template.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h1 class="text-center">Favourites</h1>
77
<li class="homeProjects" ng-repeat="cont in project">
88
<div>
99
<span class="fa fa-trash-o fa-3x" ng-click="noFav(cont.favouriteid._id)"></span>
10-
<a href="#!/project-page/{{cont.favouriteid._id}}"><img src="https://ksr-ugc.imgix.net/assets/017/613/234/902b1945bca81c8ce5b28a70a04b78b4_original.png?crop=faces&w=560&h=315&fit=crop&v=1500750535&auto=format&q=92&s=03cd36ad3063a3907ce330abda9f5801" alt=""></a>
10+
<a href="#!/project-page/{{cont.favouriteid._id}}"><img src="{{cont.favouriteid.projectImage}}" alt=""></a>
1111
<div>
1212
<div class="homeTag">
1313
<button class="btn btn-warning btn-sm" ng-repeat="tag in cont.favouriteid.tags"><small>{{tag}}</small></button>

public/app/routes/home/controller.js

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ angular.module('mainApp')
88
.then(data => {
99
$scope.project = data.data
1010
console.log(data.data)
11-
console.log($rootScope)
1211
})
1312

1413
dataService.getUserProjects()

public/app/routes/home/template.html

+20-24
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,31 @@ <h1>Start your own project!</h1>
99
</div>
1010

1111
<div class="container">
12-
<div class="row">
13-
<div class="col-md-3 col-md-offset-8">
14-
<div class="homeFilter">
15-
<p>Filter by lenguage</p>
16-
<input ng-model="lenguage" type="text" placeholder="Javascript">
17-
</div>
18-
</div>
19-
</div>
12+
<div class="homeFilter">
13+
<p>Filter by lenguage</p>
14+
<input ng-model="lenguage" type="text" placeholder="Javascript">
2015
</div>
16+
</div>
2117

22-
<ul class="projectsContent">
23-
<li class="homeProjects" ng-repeat="cont in project | filter: {tags: lenguage}">
24-
<div>
18+
<ul class="projectsContent">
19+
<li class="homeProjects" ng-repeat="cont in project | filter: {tags: lenguage}">
20+
<div>
2521
<!-- <span class="fa fa-star-o fa-2x" ng-click="favToggle(cont._id)" ng-class="{'fa-star' : toggleFav, 'fa-star-o' : !toggleFav}"></span> -->
26-
<a href="#!/project-page/{{cont._id}}"><img src="https://ksr-ugc.imgix.net/assets/017/613/234/902b1945bca81c8ce5b28a70a04b78b4_original.png?crop=faces&w=560&h=315&fit=crop&v=1500750535&auto=format&q=92&s=03cd36ad3063a3907ce330abda9f5801" ng-mouseenter="optionsImg=true" ng-mouseleave="optionsImg=false" alt="">
27-
</a>
22+
<a href="#!/project-page/{{cont._id}}"><img src="{{cont.projectImage}}" ng-mouseenter="optionsImg=true" ng-mouseleave="optionsImg=false" alt="">
23+
</a>
24+
<div>
25+
<div class="homeTag">
26+
<button class="btn btn-warning btn-sm" ng-repeat="tag in cont.tags" ng-click="getTagFilter(tag)"><small>{{tag}}</small></button>
27+
</div>
28+
<h4>{{cont.title}}</h4>
29+
<p class="textContent">{{cont.shortDescription}}</p>
2830
<div>
29-
<div class="homeTag">
30-
<button class="btn btn-warning btn-sm" ng-repeat="tag in cont.tags" ng-click="getTagFilter(tag)"><small>{{tag}}</small></button>
31-
</div>
32-
<h4>{{cont.title}}</h4>
33-
<p class="textContent">{{cont.shortDescription}}</p>
3431
<div>
35-
<div>
36-
<img src="{{cont.creatorImg}}"><p>de: <small>{{cont.creatorName}}</small></p>
37-
</div>
38-
<a href="#!/project-page/{{cont._id}}"><button class="btn btn-primary">Read more</button></a>
32+
<img src="{{cont.creatorImg}}"><p>de: <small>{{cont.creatorName}}</small></p>
3933
</div>
34+
<a href="#!/project-page/{{cont._id}}"><button class="btn btn-primary">Read more</button></a>
4035
</div>
4136
</div>
42-
</li>
43-
</ul>
37+
</div>
38+
</li>
39+
</ul>

public/app/routes/miPerfil/controller.js

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
angular.module('mainApp')
22

3-
.controller('miPerfilController', function ($scope, SweetAlert, dataService, authService, $rootScope, $location, $window) {
3+
.controller('miPerfilController', function ($scope, SweetAlert, dataService, authService, $rootScope, $location, $window, Upload) {
44

55
$scope.username = $rootScope.loggedUser
66
$scope.mail = $rootScope.mailLoggedUser
@@ -38,7 +38,7 @@ angular.module('mainApp')
3838
};
3939

4040
$scope.save = function(toggle) {
41-
let {username, mail, leng} = $scope
41+
let {username, mail, leng, profileImg} = $scope
4242
if (toggle === 'username') {
4343
dataService.editProfile(username, toggle)
4444
.then(() => {
@@ -82,4 +82,32 @@ angular.module('mainApp')
8282
})
8383
}
8484
}
85+
86+
$scope.fileSelected = (files) => {
87+
if (files && files.length) {
88+
$scope.file = files[0];
89+
}
90+
}
91+
92+
$scope.uploadFile = function() {
93+
const url = '/users/edit-profile'
94+
const file = $scope.file
95+
96+
// show spinning when uploading
97+
// $scope.uploading = true;
98+
// document.querySelector('.preview').onload = () => {
99+
// $scope.$apply( () => $scope.uploading = false )
100+
// }
101+
102+
Upload.upload({ url, file })
103+
.success( ({imageLink}) => {
104+
authService.logout()
105+
$location.path('/')
106+
} )
107+
//.progress( console.log )
108+
}
109+
110+
111+
112+
85113
})

public/app/routes/miPerfil/template.html

+25-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,31 @@ <h1>Update your profile</h1>
3535
</div>
3636
<div class="col-sm-6" ng-show="options">
3737
<!-- <label>Inser profile image</label> -->
38-
<form class="formImgProfile" ng-submit="submitImg()">
39-
<input type="file" ng-model="profileImg" accept="image/*">
40-
<button class="btn btn-primary">Send profile img</button>
41-
</form>
42-
</div>
43-
</div>
44-
</div>
38+
<div class="input-group image-preview">
39+
<input ng-model="file.name" placeholder="" type="text" class="form-control image-preview-filename" ng-disabled="true">
40+
<!-- don't give a name === doesn't send on POST/GET -->
41+
<span class="input-group-btn">
42+
<!-- image-preview-clear button -->
43+
<button type="button" class="btn btn-default image-preview-clear" style="display:none;">
44+
<span class="glyphicon glyphicon-remove"></span> Clear </button>
45+
<!-- image-preview-input -->
46+
<div class="btn btn-default image-preview-input">
47+
<span class="glyphicon glyphicon-folder-open"></span>
48+
<span class="image-preview-input-title">Browse</span>
49+
<input ngf-select="fileSelected($files)" type="file" accept="'image/*'" name="file" />
50+
<!-- rename it -->
51+
</div>
52+
<button ng-click="uploadFile()" type="button" class="btn btn-labeled btn-primary">
53+
<i ng-hide="uploading" class="glyphicon glyphicon-upload"></i>
54+
<i ng-show="uploading" class="glyphicon glyphicon-refresh"></i>
55+
<span>Upload</span>
56+
</button>
57+
</span>
58+
</div>
59+
60+
</div>
61+
</div>
62+
</div>
4563
</div>
4664
</div>
4765
</div>

public/app/routes/myProject/template.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h1 class="text-center">My projects</h1>
66
<ul class="projectsContent">
77
<li class="homeProjects" ng-repeat="cont in project">
88
<div>
9-
<a href="#!/project-page/{{cont.projectid._id}}"><img src='https://ksr-ugc.imgix.net/assets/017/613/234/902b1945bca81c8ce5b28a70a04b78b4_original.png?crop=faces&w=560&h=315&fit=crop&v=1500750535&auto=format&q=92&s=03cd36ad3063a3907ce330abda9f5801' alt=""></a>
9+
<a href="#!/project-page/{{cont.projectid._id}}"><img src='{{cont.projectid.projectImage}}' alt=""></a>
1010
<div>
1111
<div class="homeTag">
1212
<button class="btn btn-warning btn-sm" ng-repeat="tag in cont.projectid.tags"><small>{{tag}}</small></button>

public/app/routes/projectPage/template.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<button class="btn btn-primary" ng-click="clickMeToShowMessageEdit(options = !options)">Edit project</button>
88
</div>
99
<div class="col-md-3">
10-
<img src="https://s-media-cache-ak0.pinimg.com/originals/cc/03/be/cc03bea7894a8c3ba9aa2688894a88a7.jpg" alt="">
11-
<h3>Landon Jaworowski</h3>
10+
<img src="{{project.creatorImg}}" alt="">
11+
<h3>{{project.creatorName}}</h3>
1212
</div>
1313
<div class="col-md-9">
1414
<h3 class="hoverProjectPage" ng-click="enableEditor('title')" ng-model="title" ng-hide="editorEnabled">{{project.title}} <i ng-show="options" class="fa fa-pencil"></i></h3>
@@ -30,7 +30,7 @@ <h3 class="hoverProjectPage" ng-click="enableEditor('title')" ng-model="title" n
3030
<div class="row developersContent">
3131
<div class="col-md-6 col-md-offset-1">
3232
<div class="thumbnail">
33-
<img class="img-responsive" src="http://www.skylabcoders.com/images/19767/recommended_image_size.png" alt="">
33+
<img class="img-responsive" src="{{project.projectImage}}" alt="">
3434
</div>
3535
<div class="projectPageTag">
3636
<button class="btn btn-warning btn-sm" ng-repeat="tag in project.tags track by $index"><i ng-show="options" class="fa fa-trash-o" ng-click="deleteTag($index)"></i> <small>{{tag}}</small></button>
+19-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
angular.module('mainApp')
22

3-
.controller('startProjectController', function ($scope, $rootScope, $window, dataService) {
3+
.controller('startProjectController', function ($scope, $rootScope, $window, dataService, Upload) {
44

55
$scope.submit = function(){
66
let {title, tags, developer, image, shortDesc, longDesc, whyThisProject} = $scope
@@ -9,7 +9,16 @@ angular.module('mainApp')
99
let dev = developer.map(function(dev){ return dev.text})
1010

1111
dataService.projectTags(title, tag, dev, image, shortDesc, longDesc, whyThisProject)
12-
.then((url) => $window.location.href = url.data);
12+
.then((urlLink) =>{
13+
const idProject = urlLink.data.split('/')[4]
14+
const url = `/projects/${idProject}`
15+
const file = $scope.file
16+
Upload.upload({ url, file })
17+
.success( (imageLink) => {
18+
console.log(imageLink)
19+
$window.location.href = urlLink.data
20+
})
21+
});
1322

1423
dataService.getUserProjects()
1524
.then(data => {
@@ -18,4 +27,12 @@ angular.module('mainApp')
1827

1928
}
2029

30+
$scope.fileSelected = (files) => {
31+
if (files && files.length) {
32+
$scope.file = files[0];
33+
}
34+
}
35+
36+
37+
2138
})

0 commit comments

Comments
 (0)