forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.js
43 lines (39 loc) · 1.17 KB
/
schema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
app.controller('SchemaCtrl', function($scope, $http, $mdDialog,
actions, keyspaces) {
$scope.refreshData = function() {
$scope.keyspaces = keyspaces.query();
};
$scope.refreshData();
$scope.schemaChange = {Keyspace: '', SQL: ''};
$scope.keyspaceSelector = {
searchText: '',
items: function() {
var searchText = this.searchText;
if (!searchText) return $scope.keyspaces;
return $scope.keyspaces.filter(function(item) {
return item.indexOf(searchText) != -1;
});
}
};
$scope.submitSchema = function(ev) {
var action = {
title: 'Apply Schema',
confirm: 'This will execute the provided SQL on all shards in the keyspace.'
};
actions.applyFunc(ev, action, function() {
var result = {$resolved: false};
$http.post('../api/schema/apply', $scope.schemaChange)
.success(function(data) {
result.$resolved = true;
result.Output = data;
result.Error = false;
})
.error(function(data) {
result.$resolved = true;
result.Output = data;
result.Error = true;
});
return result;
});
};
});