1
0
Fork 0

more functionality added

This commit is contained in:
Paul V Moreau 2016-02-09 11:38:31 -06:00
parent 5803cfc798
commit 3cdbf12444
8 changed files with 61 additions and 24 deletions

View file

@ -40,7 +40,7 @@
<script src='js/module.js'></script>
<script src='js/directives/brewEntry.js'></script>
<script src='js/services/cauldronAPI.js'></script>
<script src='js/controllers/indexView.js'></script>
<script src='js/controllers/addEntry.js'></script>
<script src='js/controllers/IndexController.js'></script>
<script src='js/controllers/AddEntryController.js'></script>
</body>
</html>

View file

@ -1,23 +1,31 @@
angular.module('cauldron')
.controller('addEntry', ['cauldronAPI','$scope','$q', function(cauldronAPI, $scope, $q){
var tagsList = cauldronAPI.getTags();
var submitEntry = function(){
var newEntry = $scope.entryData;
newEntry.author = {
.controller('AddEntryController', ['cauldronAPI','$scope','$q','$location', function(cauldronAPI, $scope, $q, $location){
$scope.entryData ={
author: {
username: 'Megaman '+ Math.random(),
display_name: 'The_dude' + Math.random(),
email:'Mega' + Math.random() + '@fakemeail.com'
};
email:'Mega' + Math.random() + '@fakemeail.com',
},
title: 'this is the title for the entry page ' + Math.random(),
imageURL:'http://www.clipartbest.com/cliparts/9ip/eMR/9ipeMRo7T.png',
description:'DIS is da Monster!',
}
var tagsList = cauldronAPI.getTags();
$scope.submitEntry = function(){
var newEntry = $scope.entryData;
newEntry.version = '1.0';
newEntry.links = ['megaLinks.com', 'UltimateLink.org'];
var promise = cauldronAPI.addEntry(newEntry);
promise.then(function(response){
console.log('Entry Added, redirecting back to index');
$location.path( "/" );
},
function(response) {
console.log('something went wrong', response);
});
}
};
}]);

View file

@ -1,5 +1,5 @@
angular.module('cauldron')
.controller('indexView', ['cauldronAPI','$scope','$q', function(cauldronAPI, $scope, $q){
.controller('IndexController', ['cauldronAPI','$scope','$q', function(cauldronAPI, $scope, $q){
console.log('indexView controller checking in');
var setIndexEntries = function(){
@ -22,5 +22,17 @@ angular.module('cauldron')
function(response) {
console.log('something went wrong', response);
});
}
};
$scope.deleteEntry = function(id){
var promise = cauldronAPI.removeEntry(id);
promise.then(function(response){
console.log('Entry Deleted');
setIndexEntries();
},
function(response) {
console.log('deletion went wrong', response);
});
};
}]);

View file

@ -2,12 +2,12 @@ angular.module("cauldron", ['ngRoute'])
.config(['$routeProvider',
function($routeProvider){
$routeProvider.when('/',{
templateUrl:'/views/indexView.html',
controller:'indexView'
templateUrl:'/views/IndexView.html',
controller:'IndexController'
})
.when('/addEntry',{
templateUrl:'/views/addEntry.html',
controller:'addEntry'
templateUrl:'/views/AddEntryView.html',
controller:'AddEntryController'
})
.otherwise({
redirectTo: '/',

View file

@ -55,9 +55,23 @@ angular.module('cauldron')
});
};
var getTags = function(){
console.log('get the tags here');
}
var removeEntry = function(entryId){
return $http({
method: 'DELETE',
url: backendURL+'/brew/'+entryId,
}).then(function(response){
return response.data;
});
}
return {
connect: connect,
addEntry:addEntry,
getEntries:getEntries,
getTags:getTags,
removeEntry:removeEntry,
}
}]);

View file

@ -1,23 +1,23 @@
<form data-toggle="validator" role="form">
<div class="form-group">
<label for="entryData.title" class="control-label">Title: </label>
<input type="text" class="form-control" id="entryData.title" placeholder="Title" required>
<input type="text" class="form-control" id="entryData.title" ng-model="entryData.title" placeholder="Title" required>
</div>
<div class="form-group">
<label for="entryData.email" class="control-label">Email</label>
<input type="email" class="form-control" id="entryData.email" placeholder="Email" data-error="Bruh, that email address is invalid" required>
<input type="email" class="form-control" id="entryData.email" ng-model="entryData.author.email" placeholder="Email" data-error="Bruh, that email address is invalid" required>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="entryData.imageURL" class="control-label">Image URL</label>
<input type="url" class="form-control" id="entryData.imageURL" placeholder="Image URL">
<input type="url" class="form-control" id="entryData.imageURL" ng-model="entryData.imageURL" placeholder="Image URL">
<div class="help-block with-errors">We ain't goin' to host your shit</div>
</div>
<div class="form-group">
<label for="entryData.description" class="control-label">Description: </label>
<textarea class="form-control" rows ='5' id="entryData.description" placeholder="Description" required></textarea>
<textarea class="form-control" rows ='5' id="entryData.description" ng-model="entryData.description" placeholder="Description" required></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" data-disable='true'>Submit</button>
<button type="submit" class="btn btn-primary" data-disable='true' ng-click='submitEntry()'>Submit</button>
</div>
</form>

View file

@ -1,6 +1,6 @@
<div class="col-md-12 row brewIndexEntry panel panel-primary">
<div class="col-md-2">
<img src="https://cdn0.iconfinder.com/data/icons/monsters-and-creatures/512/monster-creature-avatar-alien-green-128.png" alt="" class='img-responsive'></img>
<img src='entryData.imageURL' alt="" class='img-responsive'></img>
</div>
<div class="col-md-10">
<div class="pull-right panel panel-warning">This Is the System</div>

View file

@ -1,4 +1,7 @@
<div class="mainContainer">
<button ng-click='addNew()'> Click here for adding</button>
<brew-entry ng-repeat='entry in indexEntries' brew='entry'></brew-entry>
<div ng-repeat='entry in indexEntries'>
<brew-entry brew='entry'></brew-entry>
<button class="pull-right panel" ng-click="deleteEntry(entry.id)">Delete Entry</div>
</div>
</div>