Updated interfacing with ng-table module. Will propagate changes to campaigns soon.

Updated footer copyright year
Cleaned up tables in templates
pull/24/head
Jordan 2014-02-10 01:15:36 -06:00
parent b471a886e3
commit d72bc4b7df
6 changed files with 39 additions and 28 deletions

View File

@ -190,7 +190,7 @@ func API_Groups_Id(w http.ResponseWriter, r *http.Request) {
}
writeJSON(w, gj)
case r.Method == "DELETE":
err := db.DeleteGroup(id)
err := db.DeleteGroup(id, ctx.Get(r, "user_id").(int64))
if checkError(err, w, "Error creating JSON response") {
return
}

View File

@ -207,6 +207,6 @@ func PostGroup(g *models.Group, uid int64) error {
return nil
}
func DeleteGroup(id int64) error {
func DeleteGroup(id int64, uid int64) error {
return nil
}

View File

@ -104,4 +104,8 @@
.remove-row {
float:right;
cursor:pointer;
}
.pagination {
margin:0px;
}

View File

@ -24,10 +24,25 @@ app.controller('CampaignCtrl', function($scope, CampaignService) {
})
});
app.controller('GroupCtrl', function($scope, GroupService) {
GroupService.query(function(groups) {
$scope.groups = groups
})
app.controller('GroupCtrl', function($scope, GroupService, ngTableParams) {
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 10, // count per page
sorting: {
name: 'asc' // initial sorting
}
}, {
total: 0, // length of data
getData: function($defer, params) {
GroupService.query(function(groups) {
$scope.groups = groups
params.total(groups.length)
$defer.resolve(groups.slice((params.page() - 1) * params.count(), params.page() * params.count()));
})
}
});
$scope.editGroup = function(group) {
if (group === 'new') {
@ -61,8 +76,7 @@ app.controller('GroupCtrl', function($scope, GroupService) {
newGroup.$save(function() {
$scope.groups.push(newGroup);
});
}
else {
} else {
newGroup.$update()
}
}

View File

@ -30,7 +30,7 @@
<div class="container">
<hr>
<footer>
<p>&copy; Jordan (<a href="https://github.com/jordan-wright">jordan-wright</a>) 2013</p>
<p>&copy; Jordan (<a href="https://github.com/jordan-wright">jordan-wright</a>) 2014</p>
</footer>
</div>
<!-- Placed at the end of the document so the pages load faster -->

View File

@ -25,18 +25,11 @@
</div>
&nbsp;
<div class="row">
<table ng-table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th class="col-sm-1">Name</th>
<th class="col-sm-2">Members</th>
<th class="col-sm-1">Modified Date</th>
</tr>
</thead>
<table ng-table="tableParams" class="table table-hover table-striped table-bordered">
<tbody>
<tr ng-repeat="group in groups" class="editable-row">
<td>{{group.name}}</td>
<td>
<tr ng-repeat="group in $data" class="editable-row">
<td data-title="'Name'" class="col-sm-1">{{group.name}}</td>
<td data-title="'Members'" class="col-sm-2">
<span ng-repeat="target in group.targets">
{{target.email}}{{$last ? '' : ', '}}
</span>
@ -56,14 +49,14 @@
</ul>
</div>
</td>
<td>{{group.modified_date | date:'medium'}}</td>
<td data-title="'Modified Date'" class="col-sm-1">{{group.modified_date | date:'medium'}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- New Campaign Modal -->
<div class="modal" id="newGroupModal" tabindex="-1" role="dialog" aria-labelledby="groupModalLabel" aria-hidden="true" >
<div class="modal" id="newGroupModal" tabindex="-1" role="dialog" aria-labelledby="groupModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -81,12 +74,12 @@
</div>
<label class="control-label" for="users">Users:</label>
<form ng:submit="addTarget()">
<div class="input-group">
<input type="email" class="form-control" placeholder="test@example.com" id="users" ng-model="newTarget.email" />
<span class="input-group-btn">
<button class="btn btn-primary"><i class="fa fa-plus"></i> Add</button>
</span>
</div>
<div class="input-group">
<input type="email" class="form-control" placeholder="test@example.com" id="users" ng-model="newTarget.email" />
<span class="input-group-btn">
<button class="btn btn-primary"><i class="fa fa-plus"></i> Add</button>
</span>
</div>
</form>
<br />
<table ng-table class="table table-hover table-striped table-condensed">