Navigation Menu

Skip to content

Commit

Permalink
column show: support removing the column
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 3, 2015
1 parent 345db08 commit 9a48e4e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
28 changes: 26 additions & 2 deletions app/scripts/controllers/column-show-controller.js
Expand Up @@ -9,9 +9,10 @@
*/
angular.module('groongaAdminApp')
.controller('ColumnShowController', [
'$scope', '$routeParams', '$filter', 'schemaLoader',
function ($scope, $routeParams, $filter, schemaLoader) {
'$scope', '$routeParams', '$location', '$http', 'schemaLoader',
function ($scope, $routeParams, $location, $http, schemaLoader) {
var schema;
var client = new GroongaClient($http);

function initialize() {
$scope.column = {
Expand All @@ -20,6 +21,29 @@ angular.module('groongaAdminApp')
name: $routeParams.table
}
};
$scope.remove = remove;
}

function remove() {
if (!window.confirm('Really remove the column?')) {
return;
}

var parameters = {
table: $scope.column.table.name,
name: $scope.column.name
};
var request = client.execute('column_remove', parameters);
request.success(function(response) {
console.log(response);
if (response.isRemoved()) {
schemaLoader().reload();
$location.url('/tables/' + $scope.column.table.name + '/');
} else {
var errorMessage = response.errorMessage();
$scope.message = 'Failed to remove the column: ' + errorMessage;
}
});
}

initialize();
Expand Down
20 changes: 19 additions & 1 deletion app/views/columns/show.html
Expand Up @@ -10,7 +10,25 @@
</li>
</ol>

<div class="content">
<div class="sidebar">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">Actions</h2>
</div>
<div class="panel-body">
<ul class="list-group">
<li class="list-group-item">
<button type="button" ng-click="remove()">
<span class="glyphicon glyphicon-remove"></span>
Remove
</button>
</li>
</ul>
</div>
</div>
</div>

<div class="main-content">
<div class="alert alert-warning" ng-show="message.length &gt; 0">
<p>{{message}}</p>
</div>
Expand Down

0 comments on commit 9a48e4e

Please sign in to comment.