Skip to content

Commit

Permalink
added page crud
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniespratley committed Dec 4, 2014
1 parent f8cd965 commit 0b06037
Show file tree
Hide file tree
Showing 11 changed files with 329 additions and 272 deletions.
8 changes: 6 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var proxyConfig = {
}
};

var LIVERELOAD_PORT = 35729;
var LIVERELOAD_PORT = 35728;
var SERVER_PORT = 9000;
//var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
Expand Down Expand Up @@ -72,7 +72,11 @@ module.exports = function (grunt) {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: ['<%= yeoman.app %>/{,**/}*.html', '.tmp/styles/{,*/}*.css', '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'],
files: [
'<%= yeoman.app %>/{,**/}*.html',
'.tmp/styles/{,*/}*.css',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
],
tasks: ['ngtemplates']
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ app = angular.module('angularCmsApp', [
'mgcrea.ngStrap'
#'cms.Templates'
])
.config ($routeProvider) ->
.config ($routeProvider) ->
#Resolve routes
routeResolver =
# I will cause a 1 second delay
delay: ($q, $timeout) ->
delay = $q.defer()
$timeout delay.resolve, 1000
delay.promise

#Router Config
$routeProvider
.when '/',
Expand Down
20 changes: 19 additions & 1 deletion app/scripts/controllers/pages.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
'use strict'

angular.module('angularCmsApp')
.controller 'PagesCtrl', ($scope) ->
.controller 'PagesCtrl', ($scope, DataService) ->
$scope.awesomeThings = [
'HTML5 Boilerplate'
'AngularJS'
'Karma'
]
$scope.page = {}
#Select user
$scope.selectPage = (p) ->
$scope.page = p

#Get users
$scope.getPages = () ->
DataService.fetch('pages').then((res) ->
$scope.pages = res.data
)

#Add user to database
$scope.save = (p) ->
DataService.save('pages', p).then((data) ->
$scope.getPages()
$scope.page = {}
console.log(data)
)
25 changes: 13 additions & 12 deletions app/scripts/controllers/users.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ angular.module('angularCmsApp').controller('UsersCtrl', ($scope, DataService) ->
'AngularJS'
'Karma'
]
$scope.user =

$scope.user =
username: null
email: null
password: null
role: null
created: new Date()
modified: new Date()
metadata:
metadata:
avatar: ''
name: null
aboue: null

#Hold the users
$scope.users = []

#Holds the user groups
$scope.groups = ['Admin', 'Member', 'Public']

$scope.getGroups = () ->
DataService.fetch('groups').then((data) ->
$scope.groups = data
DataService.fetch('groups').then((res) ->
$scope.groups = res.data
console.log(data)
)

Expand All @@ -36,8 +36,8 @@ angular.module('angularCmsApp').controller('UsersCtrl', ($scope, DataService) ->

#Get users
$scope.getUsers = () ->
DataService.fetch('users').then((data) ->
$scope.users = data
DataService.fetch('users').then((res) ->
$scope.users = res.data
$scope.getGroups() unless $scope.groups
)

Expand All @@ -46,7 +46,7 @@ angular.module('angularCmsApp').controller('UsersCtrl', ($scope, DataService) ->
ask = confirm "Delete #{user.email}?"

if ask
DataService.destroy('users', user).then((data) ->
DataService.destroy('users', user).then((res) ->
$scope.users.pop(index)
$scope.getUsers()
)
Expand All @@ -55,9 +55,10 @@ angular.module('angularCmsApp').controller('UsersCtrl', ($scope, DataService) ->
$scope.addUser = (user) ->
DataService.save('users', user).then((data) ->
$scope.getUsers()
#$scope.users.push(user) unless user._id
$scope.users.push(user) unless user._id
$scope.user = {}
console.log(data)
$('#user-modal').modal('hide')
)

)
2 changes: 1 addition & 1 deletion app/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ html {
}

.cms-sidebar.closed .well {
width: 45px;
width: 62px;

}

Expand Down
7 changes: 6 additions & 1 deletion app/views/_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
Version {{App.version}}
</p>
</div>
</div>
</div>

<hr/>

<pre>{{App.config}}</pre>
<pre>{{App.session}}</pre>
92 changes: 52 additions & 40 deletions app/views/pages.html
Original file line number Diff line number Diff line change
@@ -1,47 +1,59 @@

<div class="page-container">
<div class="row">
<ol class="breadcrumb">
<li>
<a href="#">Home</a>
</li>
<li class="active">Add Page</li>
</ol>
<!-- Nav tabs --><br></div>
<div class="row">
<div class="col-sm-8">
<input type="text" class="form-control" placeholder="Enter title here">
<div class="">
<cms-header title="Pages" icon="folder-open"></cms-header>
<button class="btn" ng-click="getPages()">Refresh</button>
<section>
<div class="row">
<div class="col-md-12">
<ol class="breadcrumb">
<li>
<a href="#">Home</a>
</li>
<li class="active">Add Page</li>
</ol>
<table class="table table-condensed table-hover table-striped clearfix">
<thead>
<tr>
<th>#</th>
<th>Page</th>
<th>Body</th>
<th>Status</th>

<span class="help-block">
<strong>Permlink:</strong> http://jonniespratley.me/?page_id=83
</span>

<div class="btn-group">
<a class="btn btn-default btn-xs" href="#">h1</a>
<a class="btn btn-default btn-xs" href="#">h2</a>
<a class="btn btn-default btn-xs" href="#">h3</a>
</div>
</tr>
</thead>
<tbody>

<textarea class="form-control" rows="3"></textarea>
</div>
<div class="col-sm-4">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Publish</strong>
</div>
<div class="panel-body">
<ul>
<tr ng-repeat="page in pages" ng-click="selectPage(page)">
<td>{{page._id}}</td>
<td>{{page.title}}</td>
<td>{{page.body}}</td>
<td><span class="label label-default">{{page.publish}}</span></td>
<td>{{page.visibility}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<div class="row">
<div class="col-sm-8">
<input type="text" class="form-control" placeholder="Enter title here" ng-model="page.title">
<span class="help-block">
<strong>Permlink:</strong> http://{{App.baseurl}}/?page_id={{page.slug}}
</span>
<div class="btn-group"></div>
<textarea class="form-control" rows="5" ng-model="page.body"></textarea>
</div>
<div class="col-sm-4">
<ul>
<li>Status: Published</li>
<li>Visibility: Public</li>
</ul>
</div>
<div class="panel-footer clearfix">
<a href="#">Move to trash</a>
<button class="btn btn-primary pull-right">Publish</button>
</div>
</div>
</div>
</div>
</div>
<!--/span-->
<!--/row-->
<button href="#" class="btn btn-danger btn-block btn-xs" ng-click="remove(post)">Move to trash</button>
<button class="btn pull-right btn-primary btn-block" ng-click="save(page)">Save</button>
</div>
</div>
</div>
<!--/span-->
<!--/row-->
Loading

0 comments on commit 0b06037

Please sign in to comment.