Skip to content

working on the delete, had issues setting up the other parts #5

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 1 commit 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
3 changes: 3 additions & 0 deletions caylab/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
2 changes: 2 additions & 0 deletions caylab/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
node_modules
8 changes: 8 additions & 0 deletions caylab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Angular Basic CRUD
* Create a login page
* Create a signup page
* Create a gallery creation page
* Create a method to edit galleries
* Create a method to delete galleries
* Create a controller for your home that will allow for galleries to be generated on the fly, and then displays them visibly.
* create a readme.
Empty file.
27 changes: 27 additions & 0 deletions caylab/app/component/gallery/create-gallery/create-gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<section>
<form name="createGalleryForm"
ng-submit="createGalleryCtrl.createGallery()">

<fieldset>
<label for="name">Gallery Name</label>
<input
type="text"
name="name"
placeholder="name"
ng-model="createGalleryCtrl.gallery.name"
required>
</fieldset>

<fieldset>
<label for="description">Gallery Description</label>
<input
type="text"
name="description"
placeholder="description"
ng-model="createGalleryCtrl.gallery.desc"
required>
</fieldset>

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

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

module.exports = {
template: require('./create-gallery.html'),
controllerAs: 'createGalleryCtrl',
controller: [
'$log',
'galleryService',
function($log, galleryService){
this.$onInit = () => {
$log.debug('#createGalleryCtrl')
this.gallery = {}

return this.createGallery = () => {
return galleryService.createGallery(this.gallery)//the frontend ui is going to assign a new gallery when we fillout the form on submit
.then(() => {
let res = this.gallery
this.gallery.name = null
this.gallery.desc = null
return res
})
.catch(err => $log.error(err))
}
}
}
]
}
Empty file.
18 changes: 18 additions & 0 deletions caylab/app/component/gallery/edit-gallery/edit-gallery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<section>
<form
name="editGalleryForm"
ng-submit="editGalleryCtrl.updateGallery()"
novalidate>

<fieldset>
<label for="name">name</label>
<input name="name" type="text" ng-model="editGalleryCtrl.gallery.name">
</fieldset>
<fieldset>
<label for="desc">desc</label>
<input type="text" name="desc" ng-model="editGalleryCtrl.gallery.desc">
</fieldset>
<button ng-click="editGalleryCtrl.deleteGallery()">delete</button>
<button type="submit" name="submit">update</button>
</form>
</section>
35 changes: 35 additions & 0 deletions caylab/app/component/gallery/edit-gallery/edit-gallery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'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('successful gallery update'),
err => $log.error(err)
)
}

this.deleteGallery = () => {
galleryService.deleteGallery(this.gallery._id, this.gallery)
.then(
() => $log.log('successful gallery deletion'),
err => $log.error(err)
)
}

}
}
]
}
Empty file.
Empty file.
13 changes: 13 additions & 0 deletions caylab/app/component/gallery/edit-pic/edit-pic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

module.exports = {
template: require('./edit-pic.html'),
controllerAs: 'editPicCtrl',
bindings: {
gallery: '<',
pics: '<'
},
controller: [
'$log'
]
}
Empty file.
14 changes: 14 additions & 0 deletions caylab/app/component/gallery/gallery-item/gallery-item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<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>

</li>
17 changes: 17 additions & 0 deletions caylab/app/component/gallery/gallery-item/gallery-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

module.exports = {
template: require('./gallery-item.html'),
controllerAs: 'galleryItemCtrl',
controller: [
'$log',
'galleryService',
function($log, galleryService){
$log.debug('Gallery item in Controller')

this.showEditGallery = false
}],
bindings: {
gallery: '<'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="">
<h3>{{thumbnailContainerCtrl.gallery.name}}</h3>
<upload-pic
gallery="thumbnailContainerCtrl.gallery"></upload-pic>
<div>
<thumbnail
ng-repeat="picture in thumbnailContainerCtrl.gallery.pics"
pic="picture"
gallery="thumbnailContainerCtrl.gallery">
</thumbnail>
<!-- <button
ng-click="thumbnailContainerCtrl.deletePic()"
pic="thumbnailContainerCtrl.gallery.pic"
gallery="thumbnailContainerCtrl.gallery">delete</button> -->
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict'

//scss require

module.exports = {
template: require('./thumbnail-container.html'),
controllerAs: 'thumbnailContainerCtrl',
bindings: {
gallery: '<'
}
// controller: [
// '$log',
// 'picService',
// function($log, picService){
// this.$onInit = () => {
// $log.debug('edit pic controller')
//
// this.editPic = () => {
//
// }
//
// this.deletePic = () => {
// console.log('selected gallery: ', this.gallery)
// console.log('selected picture: ', this.pic);
// picService.deletePic(this.gallery._id, this.pic._id)
// .then(
// () => $log.log('successful pic deletion'),
// err => $log.error(err)
// )
// }
//
// }
// }
// ]
// }
}
Empty file.
3 changes: 3 additions & 0 deletions caylab/app/component/gallery/thumbnail/thumbnail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
<img ng-src="{{thumbnailCtrl.pic.imageURI}}" alt="{{thumbnailCtrl.pic.desc}}">
</div>
10 changes: 10 additions & 0 deletions caylab/app/component/gallery/thumbnail/thumbnail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'

module.exports = {
template: require('./thumbnail.html'),
controllerAs: 'thumbnailCtrl',
bindings: {
pic: '<',
gallery: '<'
}
}
Empty file.
21 changes: 21 additions & 0 deletions caylab/app/component/gallery/upload-pic/upload-pic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<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="description" ng-model="uploadPicCtrl.pic.desc">
</fieldset>

<div>
<button ngf-select ng-model="uploadPicCtrl.pic.file">
choose file..
</button>
<button type="submit" name="upload">upload file</button>
</div>

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

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

this.pic = {}
this.uploadPic = () => {
picService.uploadPic(this.gallery, this.pic)
.then(
() => {
this.pic.name = null
this.pic.desc = null
this.pic.file = null
},
err => $log.error(err)
)
}
}
}
]
}
Empty file.
28 changes: 28 additions & 0 deletions caylab/app/component/landing/login/login-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'

//require('./_login.scss')

module.exports = {
template: require('./login.html'),
controllerAs: 'loginCtrl',
controller: [
'$log',
'$location',
'authService',
function($log, $location, authService){
this.$onInit = () => {
$log.debug('#loginCtrl')

authService.getToken()
.then(() => $location.url('/home'))

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

authService.login(this.user)
.then(() => $location.url('/home'))
}
}
}
]
}
38 changes: 38 additions & 0 deletions caylab/app/component/landing/login/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<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>
<input type="text" placeholder="email">
</div>

<div
ng-class="{
'error': loginForm.password.$invalid && loginForm.$submitted,
'success': loginForm.password.$valid,
}">

<input
type="password"
name="password"
ng-minlength="3"
ng-model="loginCtrl.user.password"
required>
</div>

<button type="btn-std" ng-submit="navbarCtrl.hideButtons = false">sign in</button>
</form>
</section>
Empty file.
30 changes: 30 additions & 0 deletions caylab/app/component/landing/signup/signup-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict'

//require('./_signup.scss')

module.exports = {
template: require('./signup.html'),
controllerAs: 'signupCtrl',
controller: [
'$log',
'$location',
'$window',
'authService',
function($log, $location, $window, authService){
this.$onInit = () => {
$log.debug('#signupCtrl')
authService.getToken()
.then(() => $location.url('/home'))

this.title = 'Welcome to the signup page@!@#!@'

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

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