Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support creating a new simple column
- Loading branch information
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| 'use strict'; | ||
|
|
||
| /** | ||
| * @ngdoc function | ||
| * @name groongaAdminApp.controller:ColumnNewController | ||
| * @description | ||
| * # ColumnNewController | ||
| * Controller of the groongaAdminApp | ||
| */ | ||
| angular.module('groongaAdminApp') | ||
| .controller('ColumnNewController', [ | ||
| '$scope', '$routeParams', '$location', '$http', 'schemaLoader', | ||
| function ($scope, $routeParams, $location, $http, schemaLoader) { | ||
| var schema; | ||
| var client = new GroongaClient($http); | ||
|
|
||
| function initialize() { | ||
| $scope.table = { | ||
| name: $routeParams.table | ||
| }; | ||
| $scope.availableTypes = { | ||
| scalar: { | ||
| label: 'Scalar', | ||
| flag: 'COLUMN_SCALAR' | ||
| }, | ||
| vector: { | ||
| label: 'Vector', | ||
| flag: 'COLUMN_VECTOR' | ||
| }, | ||
| index: { | ||
| label: 'Index', | ||
| flag: 'COLUMN_INDEX' | ||
| } | ||
| }; | ||
| $scope.column = { | ||
| type: $scope.availableTypes.scalar, | ||
| sources: [] | ||
| }; | ||
| $scope.submit = submit; | ||
| } | ||
|
|
||
| function submit() { | ||
| var parameters = { | ||
| table: $scope.table.name, | ||
| name: $scope.column.name, | ||
| flags: [$scope.column.type.flag].join('|'), | ||
| type: $scope.column.valueType, | ||
| source: $scope.column.sources.join(',') | ||
| }; | ||
| var request = client.execute('column_create', parameters); | ||
| request.success(function(response) { | ||
| if (response.isCreated()) { | ||
| schemaLoader().reload(); | ||
| $location.url('/tables/' + parameters.table + | ||
| '/columns/' + parameters.name); | ||
| } else { | ||
| var errorMessage = response.errorMessage(); | ||
| $scope.message = 'Failed to create the column: ' + errorMessage; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| initialize(); | ||
| schemaLoader() | ||
| .then(function(_schema) { | ||
| schema = _schema; | ||
| }); | ||
| }]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <div class="container-fluid" ng-controller="ColumnNewController"> | ||
| <ol class="breadcrumb"> | ||
| <li><a href="#/">Top</a></li> | ||
| <li><a href="#/tables/">Tables</a></li> | ||
| <li><a href="#/tables/{{table.name}}">{{table.name}}</a></li> | ||
| </ol> | ||
|
|
||
| <div class="content"> | ||
| <div class="alert alert-warning" ng-show="message.length > 0"> | ||
| <p>{{message}}</p> | ||
| </div> | ||
|
|
||
| <h2>{{table.name}}: Create a new column</h2> | ||
| <form name="tableForm" class="table-form" ng-submit="submit()"> | ||
| <div class="form-group"> | ||
| <label for="table" class="control-label">Table</label> | ||
| <input id="table" | ||
| name="table" | ||
| type="text" | ||
| class="form-control" | ||
| ng-model="table.name" | ||
| disabled="true" | ||
| required> | ||
| </div> | ||
| <div class="form-group" | ||
| ng-class="{'has-error': tableForm.name.$invalid}"> | ||
| <label for="name" class="control-label">Name</label> | ||
| <input id="name" | ||
| name="name" | ||
| type="text" | ||
| class="form-control" | ||
| ng-model="column.name" | ||
| required> | ||
| </div> | ||
| <div class="form-group" | ||
| ng-class="{'has-error': tableForm.type.$invalid}"> | ||
| <label for="type" class="control-label">Type</label> | ||
| <select id="type" | ||
| name="type" | ||
| type="select" | ||
| class="form-control" | ||
| ng-model="column.type" | ||
| ng-options="type.label for (name, type) in availableTypes"> | ||
| </select> | ||
| </div> | ||
| <div class="form-group" | ||
| ng-class="{'has-error': tableForm.keyType.$invalid}"> | ||
| <label for="value-type" class="control-label">Value type</label> | ||
| <input id="value-type" | ||
| name="valueType" | ||
| type="text" | ||
| class="form-control" | ||
| ng-model="column.valueType"> | ||
| </div> | ||
| <div class="form-group"> | ||
| <div class="form-button"> | ||
| <button type="submit">Submit</button> | ||
| </div> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </div> |