Skip to content

started lab, added thumbnails and upload to gallery folder #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"presets": ["es2015"]}
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_URL='http://localhost:3000'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey man you really got to start gitignoring this. I'm going to have to take a point off for this.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build/
Empty file.
25 changes: 25 additions & 0 deletions app/component/gallery/create-gallery/create-gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<section>
<form name="createGalleryForm"
ng-submit="createGalleryCtrl.createGallery()">
<fieldset>
<label for="name">Name</label>
<input
type="text"
name="name"
placeholder="name"
ng-model="createGalleryCtrl.gallery.name"
required>
</fieldset>
<fieldset>
<label for="description">Description</label>
<input
type="text"
name="description"
placeholder="description"
ng-model="createGalleryCtrl.gallery.desc"
required>
</fieldset>

<button type="submit">Create Gallery</button>
</form>
</section>
31 changes: 31 additions & 0 deletions app/component/gallery/create-gallery/create-gallery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

require('./_create-gallery.scss');

module.exports = {
template: require('./create-gallery.html'),
controllerAs: 'createGalleryCtrl',
controller: [
'$log',
'galleryService',
CreateGalleryController,
],
};

function CreateGalleryController($log, galleryService) {
this.$onInit = () => {
$log.debug('Create Gallery Controller');
this.gallery = {};

this.createGallery = () => {
return galleryService.createGallery(this.gallery)
.then(() => {
let res = this.gallery;
this.gallery.name = null;
this.gallery.desc = null;
return res;
})
.catch(err => $log.error(err.message));
};
};
}
Empty file.
17 changes: 17 additions & 0 deletions app/component/gallery/edit-gallery/edit-gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<section>
<form
name="editGalleryForm"
ng-submit="editGalleryCtrl.updateGallery()"
novalidate>
<fieldset>
<label for="name">Nombre</label>
<input type="text" name="name" ng-model="editGalleryCtrl.gallery.name">
</fieldset>
<fieldset>
<label for="description">Description</label>
<input type="text" name="description" ng-model="editGalleryCtrl.gallery.desc">
</fieldset>

<button type="submit" name="submit update">Oopdate</button>
</form>
</section>
21 changes: 21 additions & 0 deletions app/component/gallery/edit-gallery/edit-gallery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

module.exports = {
template: require('./edit-gallery.html'),
controllerAs: 'editGalleryCtrl',
bindings: {
gallery: '<'
},
controller: ['$log', 'galleryService', function($log, galleryService) {
this.$onInit = () => {
$log.debug('Edit Gallery Controller');
this.updateGallery = () => {
galleryService.updateGallery(this.gallery._id, this.gallery)
.then(
() => $log.log('updated successfully'),
err => $log.error(err)
);
};
};
}]
};
Empty file.
13 changes: 13 additions & 0 deletions app/component/gallery/gallery-item/gallery-item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<li>
<div ng-if="!galleryItemCtrl.showEditGallery">
<div>
<span>name: {{ galleryItemCtrl.gallery.name }}</span>
<span>description: {{ galleryItemCtrl.gallery.desc }}</span>
<span>id: {{ galleryItemCtrl.gallery._id }}</span>
</div>
</div>

<edit-gallery ng-if="galleryItemCtrl.showEditGallery" gallery="galleryItemCtrl.gallery"></edit-gallery>
<button ng-click="galleryItemCtrl.showEditGallery = !galleryItemCtrl.showEditGallery">EDIT</button>
<button ng-click="galleryItemCtrl.deleteGallery()">DELETE</button>
</li>
31 changes: 31 additions & 0 deletions app/component/gallery/gallery-item/gallery-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

require('./_gallery-item.scss');

module.exports = {
template: require('./gallery-item.html'),
controllerAs: 'galleryItemCtrl',
controller: ['$log', '$rootScope', 'galleryService', function($log, galleryService) {
$log.debug('Gallery Item Controller');
this.$onInit = () => {
this.showEditGallery = false;
};
}],
bindings: {
gallery: '<'
}
};

function GalleryItemController($log, $rootScope, galleryService) {
$log.debug('#GalleryItemController');

this.showEditGallery = false;

this.deleteGallery = () => {
galleryService.deleteGallery(this.gallery._id)
.then(
res => $log.log(`${res.status}, Successfully Deleted`),
err => $log.error(err)
);
};
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div>
<h3>{{ thumbnailContainerCtrl.gallery.name }}</h3>
<upload-pic gallery="thumbnailContainerCtrl.gallery"></upload-pic>

<div>
<thumbnail ng-repeat="item in thumbnailContainerCtrl.gallery.pics" pic="item" gallery="thumbnailContainerCtrl.gallery"></thumbnail>
</div>
</div>
11 changes: 11 additions & 0 deletions app/component/gallery/thumbnail-container/thumbnail-container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

// require('./_thumbnail-container.scss')

module.exports = {
template: require('./thumbnail-container.html'),
controllerAs: 'thumbnailContainerCtrl',
bindings: {
gallery: '<'
}
};
Empty file.
4 changes: 4 additions & 0 deletions app/component/gallery/thumbnail/thumbnail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
<img src="{{ thumbnailCtrl.pic.imageURI }}" alt="{{ thumbnailCtrl.pic.desc }}">
<button type="submit" ng-click="thumbnailCtrl.deletePic()">DELETE</button>
</div>
28 changes: 28 additions & 0 deletions app/component/gallery/thumbnail/thumbnail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

// require('./_thumbnail.scss');

module.exports = {
template: require('./thumbnail.html'),
controllerAs: 'thumbnailCtrl',
bindings: {
pic: '<',
gallery: '<'
},
controller: ['$log', 'picService', ThumbnailController],
};

function ThumbnailController($log, picService) {
this.$onInit = () => {
$log.debug('Thumbnail Controller');

this.deletePic = () => {
$log.debug('#thumbnailCtrl.deletePic()');
picService.deletePic(this.gallery, this.pic)
.then(
res => $log.log(`${res.status}, Picture Deleted`),
err => $log.error(err)
);
};
};
}
Empty file.
19 changes: 19 additions & 0 deletions app/component/gallery/upload-pic/upload-pic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<section>
<form
ng-submit="uploadPicCtrl.uploadPic()"
novalidate>

<fieldset>
<label for="name">NAME</label>
<input type="text" name="name" placeholder="name" ng-model="uploadPicCtrl.pic.name">
<label for="desc">DESCRIPTION</label>
<input type="text" name="desc" placeholder="desc" ng-model="uploadPicCtrl.pic.desc">
</fieldset>

<div>
<button ngf-select ng-model="uploadPicCtrl.pic.file">Choose File</button>
<button type="submit" name="upload picture">Upload Picture</button>

</div>
</form>
</section>
31 changes: 31 additions & 0 deletions app/component/gallery/upload-pic/upload-pic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

require('./_upload-pic.scss');

module.exports = {
template: require('./upload-pic.html'),
controllerAs: 'uploadPicCtrl',
bindings: {
gallery: '<'
},
controller: [
'$log', 'picService', function($log, picService) {
this.$onInit = () => {
$log.debug('uploadPicController');
this.pic = {};

this.uploadPic = () => {
picService.uploadPic(this.gallery, this.pic)
.then(
() => {
this.pic.name = null;
this.pic.name = null;
this.pic.file = null;
},
err => $log.error(err)
);
};
};
}
]
};
Empty file.
34 changes: 34 additions & 0 deletions app/component/landing/login/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<section class="login-form">
<form
name="loginForm"
ng-submit="loginCtrl.login()" novalidate>
<div
ng-class="{
'error': loginForm.username.$invalid,
'success': loginForm.username.$valid,
}">
<input
type="text"
name="username"
placeholder="username"
ng-minlength="4"
ng-model="loginCtrl.user.username" required>
</div>

<div
ng-class="{
'error': loginForm.password.$invalid && loginForm.$submitted,
'success': loginForm.password.$valid,
}">
<input
type="password"
name="password"
ng-disabled="loginForm.username.$invalid"
placeholder="password"
ng-minlength="3"
ng-model="loginCtrl.user.password" required>
</div>

<button class="btn-std">Sign In</button>
</form>
</section>
31 changes: 31 additions & 0 deletions app/component/landing/login/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

module.exports = {
template: require('./login.html'),
controllerAs: 'loginCtrl',
controller: [
'$log',
'$location',
'$window',
'authService',
function($log, $location, $window, authService) {
this.$onInit = () => {
$log.debug('LoginController');
if(!$window.localStorage.token) {
authService.getToken()
.then(
() => $location.url('/home'),
() => $location.url('/signup')
);
}

this.login = function() {
$log.log('loginCtrl.login()');

authService.login(this.user)
.then(() => $location.url('/home'));
};
};
}
]
};
Empty file.
34 changes: 34 additions & 0 deletions app/component/landing/signup/signup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<section class="signup">
<h2>{{ signupCtrl.title }}</h2>
<form
class="signup-form"
ng-submit="signupCtrl.signup(signupCtrl.user)"
novalidate
>

<input class="input-std"
type="text"
placeholder="name"
ng-minlength="4"
ng-model="signupCtrl.user.username"
required>

<input
class="input-std"
type="text"
placeholder="email"
ng-model="signupCtrl.user.email"
required>

<input
class="input-std"
type="text"
placeholder="password"
ng-minlength="3"
ng-model="signupCtrl.user.password"
required>

<input type="submit" value="Sign Up">

</form>
</section>
26 changes: 26 additions & 0 deletions app/component/landing/signup/signup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

module.exports = {
template: require('./signup.html'),
controllerAs: 'signupCtrl',
controller: ['$log', '$location', '$window', 'authService', function($log, $location, $window, authService) {
this.$onInit = () => {
$log.debug('SignupController');
if(!$window.localStorage.token) {
authService.getToken()
.then(
() => $location.url('/home'),
() => $location.url('/signup')
);
}
this.title = 'This here is the sign up page';

this.signup = function(user) {
$log.debug('signupCtrl.signup()');

authService.signup(user)
.then(() => $location.url('/home'));
};
};
}]
};
Empty file.
Loading