Skip to content

Commit

Permalink
implemented #121 #125
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Sep 11, 2014
1 parent 16933a8 commit 509b34f
Show file tree
Hide file tree
Showing 24 changed files with 314 additions and 239 deletions.
2 changes: 1 addition & 1 deletion app/scripts/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var API = (function () {
var m = window.location.pathname.match(/(.*\/)studio\/index.html/);
return m && m[1] ? m[1] : '/';
return m && m[1] ? m[1] : '/api/';
})();

var STUDIO_VERSION = "2.0-SNAPSHOT";
6 changes: 5 additions & 1 deletion app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ App.config(function ($routeProvider, $httpProvider, $translateProvider, $transla
});

});
App.run(function ($rootScope, $interval, DatabaseApi, Notification, Spinner) {
App.run(function ($rootScope, $interval, DatabaseApi, Notification, Spinner, $templateCache,Aside) {
$rootScope.$on('$routeChangeSuccess', function (event, currentRoute, oldRoute) {
switch (currentRoute.templateUrl) {
case 'views/login.html':
Expand All @@ -178,16 +178,20 @@ App.run(function ($rootScope, $interval, DatabaseApi, Notification, Spinner) {
NProgress.done();
});
$rootScope.$on("$routeChangeStart", function (event, next, current) {
Aside.destroy();
NProgress.start();
NProgress.set(0.2);
NProgress.set(0.4);

})

$interval(function () {
DatabaseApi.listDatabases().then(function (data) {
$rootScope.$broadcast("server:up");
}, function error(data) {
$rootScope.$broadcast("server:down");
})
}, 10000);

$templateCache.put('popover/popover.tpl.html', '<div class="popover"><div class="arrow"></div><h3 class="popover-title" ng-bind="title" ng-show="title"></h3><div class="popover-content" ng-bind-html="content"></div></div>');
})
14 changes: 11 additions & 3 deletions app/scripts/controllers/configuration-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,20 @@ configModule.controller("UMLController", ['$scope', '$routeParams', '$location',

}]);

configModule.controller("StructureController", ['$scope', '$routeParams', '$location', 'DatabaseApi', 'Database', function ($scope, $routeParams, $location, DatabaseApi, Database) {
configModule.controller("StructureController", ['$scope', '$routeParams', '$location', 'DatabaseApi', 'Database', 'ClusterAlterApi', "Notification", function ($scope, $routeParams, $location, DatabaseApi, Database, ClusterAlterApi, Notification) {

$scope.clusters = Database.getMetadata()['clusters'];
$scope.conflictStrategies = ['version', 'content', 'automerge']
$scope.dataSegments = Database.getMetadata()['dataSegments'];
$scope.txSegments = Database.getMetadata()['txSegment'];


$scope.changeStrategy = function (cluster) {

ClusterAlterApi.changeProperty(Database.getName(), { cluster: cluster.name, name: "conflictStrategy", value: cluster.conflictStrategy}).then(function () {
Notification.push({content: "Conflict strategy for cluster '" + cluster.name + "' changed in '" + cluster.conflictStrategy + "'."});
});
}
}]);
configModule.controller("DbConfigController", ['$scope', '$routeParams', '$location', 'DatabaseApi', 'Database', 'DatabaseAlterApi', 'Notification', '$q', function ($scope, $routeParams, $location, DatabaseApi, Database, DatabaseAlterApi, Notification, $q) {

Expand All @@ -189,12 +196,13 @@ configModule.controller("DbConfigController", ['$scope', '$routeParams', '$locat
$scope.properties.push({name: 'useLightweightEdges', value: 'false' });
}

$scope.canChange = ["clusterSelection", "minimumClusters", "localeCountry", "useLightweightEdges"];
$scope.changeTemplate = { clusterSelection: "views/database/config/clusterSelection.html", useLightweightEdges: "views/database/config/boolenaCustom.html"}
$scope.canChange = ["clusterSelection", "minimumClusters", "localeCountry", "useLightweightEdges", "conflictStrategy"];
$scope.changeTemplate = { clusterSelection: "views/database/config/clusterSelection.html", useLightweightEdges: "views/database/config/boolenaCustom.html", conflictStrategy: "views/database/config/conflictStrategy.html"}
$scope.dirty = [];
$scope.customDirty = [];
$scope.clusterStrategies = ['round-robin', "default", "balanced"];

$scope.conflictStrategies = ['version', 'content', 'automerge']
$scope.isDisabledVal = function (val) {
return $scope.canChange.indexOf(val.name) == -1
}
Expand Down
1 change: 1 addition & 0 deletions app/scripts/controllers/database-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',
{name: "bookmarks", title: "Bookmarks"}
];


Aside.show({scope: $scope, title: "Bookmarks", template: 'views/database/context/bookmarksAside.html', show: false});
$scope.item = {};
$scope.queries = [];
Expand Down
11 changes: 9 additions & 2 deletions app/scripts/controllers/function-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
$scope.getListFunction = function () {
$scope.functions = new Array;
$scope.functionsrid = new Array;
var deferred = $q.defer();
CommandApi.queryText({database: $routeParams.database, language: 'sql', verbose: false, text: sqlText, limit: $scope.limit, shallow: false}, function (data) {
if (data.result) {
for (i in data.result) {
Expand All @@ -68,16 +69,22 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
var index = $scope.functionsrid.indexOf($scope.functionToExecute['name']);
if (index != -1)
$scope.showInConsoleAfterSave($scope.functions[index]);
} else {
$scope.createNewFunction();
}
Aside.show({scope: $scope, title: "Functions", template: 'views/database/function/functionAside.html', show: true, absolute: false});
deferred.resolve();
}

});
return deferred.promise;

}
$scope.clearConsole = function () {
$scope.functionToExecute['code'] = '';
}
$scope.getListFunction();
$scope.getListFunction().then(function () {
Aside.show({scope: $scope, title: "Functions", template: 'views/database/function/functionAside.html', show: true, absolute: false});
});

$scope.removeParam = function (index) {
if ($scope.functionToExecute != undefined) {
Expand Down
7 changes: 3 additions & 4 deletions app/scripts/controllers/header-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ angular.module('header.controller', ['database.services']).controller("HeaderCon
var modalScope = $scope.$new(true);
modalScope.oVersion = Database.getMetadata()["server"].version;
modalScope.version = STUDIO_VERSION;
var modalPromise = $modal({template: 'views/server/about.html', persist: true, show: false, backdrop: 'static', scope: modalScope});
$q.when(modalPromise).then(function (modalEl) {
modalEl.modal('show');
});
var modalPromise = $modal({template: 'views/server/about.html', show: false, scope: modalScope});
modalPromise.$promise.then(modalPromise.show);

}
$scope.manageServer = function () {
$location.path("/server");
Expand Down
8 changes: 8 additions & 0 deletions app/scripts/services/aside-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ aside.factory('Aside', function ($rootScope) {
this.params.scope.$apply();
}
},
destroy: function () {
$rootScope.$broadcast("aside:close");
delete this.params.scope;
delete this.params.tpl;
delete this.params.title;
delete this.params.absolute;
delete this.params.cls;
},
hide: function () {
this.params.cls = "";
$rootScope.$broadcast("aside:close");
Expand Down
22 changes: 22 additions & 0 deletions app/scripts/services/database-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,3 +885,25 @@ database.factory('PropertyAlterApi', function ($http, $resource, $q) {
}
return resource
});
database.factory('ClusterAlterApi', function ($http, $resource, $q) {


var resource = $resource('');


resource.changeProperty = function (database, props) {

var deferred = $q.defer();
var text = API + 'command/' + database + '/sql/-/-1?format=rid,type,version,class,graph';
var query = "alter cluster {{cluster}} {{name}} {{value}}"
var queryText = S(query).template(props).s;
$http.post(text, queryText).success(function (data) {
deferred.resolve(data)
}).error(function (data) {
deferred.reject(data);
});
return deferred.promise;
}
return resource
});

1 change: 0 additions & 1 deletion app/scripts/widgets/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ Widget.directive('autofill', function ($timeout) {
require: 'ngModel',
link: function (scope, elem, attrs, ngModel) {
var origVal = elem.val();
console.log(origVal);
$timeout(function () {
var newVal = elem.val();
if (ngModel.$pristine && origVal !== newVal) {
Expand Down
30 changes: 30 additions & 0 deletions app/styles/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ text.vicon {

.btn {
border-radius: 0;
background-color: #acacad;
}

.btn-trasparent {
background-color: transparent;
}

#wrap {
Expand Down Expand Up @@ -650,4 +655,29 @@ div.users-ui div.container-fluid, div.role-ui div.container-fluid {

.ologin .fa-question-circle {
font-size: 24px;
}

.popover-md {
max-width: 400px;
}

.popover-lg {
max-width: 800px;
}

.popover.bottom-left .arrow:after {

}

.popover.bottom-left .arrow {
margin-left: -32px;
}

.popover-help .popover-content {
padding-left: 0;
padding-right: 0;
}

.query-info .btn-help {
font-size: 20px;
}
2 changes: 1 addition & 1 deletion app/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ ul.arrayrid > li {
.circle-interrupt {
position: fixed;
top: 55%;
left: 45.5%;
left: 45%;
opacity: 1;
z-index: 9999;
}
Expand Down
20 changes: 8 additions & 12 deletions app/views/database/bookmark.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@ <h3 class="popover-title" ng-bind-html="title" ng-show="title"></h3>

<div class="popover-content" ng-controller="BookmarkNewController">

<form class="form-horizontal" ng-if="viewTags">
<form ng-if="viewTags">
<div class="form-group">
<label class="col-sm-2 control-label">Name</label>

<div class="col-sm-10">
<input type="text" class="form-control" ng-model="bookmark.name"/>
</div>
<label class=" control-label">Name</label>
<input type="text" class="form-control" ng-model="bookmark.name"/>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Category</label>
<label class="control-label">Category</label>


<div class="col-sm-10">
<input type="hidden" ng-model="bookmark.tags" ui-select2="select2Options"
<input type="hidden" ng-model="bookmark.tags" ui-select2="select2Options"

data-placeholder="Pick a tag">
</input>
</div>
data-placeholder="Pick a tag">
</input>
</div>
<div class="form-actions">
<button type="button" class="btn btn-sm" ng-click="cancel();$hide()">Cancel</button>
Expand Down
46 changes: 30 additions & 16 deletions app/views/database/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,29 @@
<div class="container-fluid">
<div class="row vertical-align">
<div class="col-md-6 info">
<!--<a class="btn btn-trasparent btn-help"-->
<!--data-placement="bottom-left"-->
<!--data-title="Query help"-->
<!--data-trigger="hover"-->
<!--data-animation="am-flip-x"-->
<!--data-template="views/database/browseHelp.html"-->
<!--bs-popover>-->
<!--<i class="fa fa-question-circle fa-lg"></i>-->
<!--</a>-->
<div class="query-hint">
<b>Run:</b>
Ctrl/Cmd + Return
Ctrl + Return
<b>Undo:</b>
Ctrl/Cmd + Z
<b>Redo:</b>
Ctrl/Cmd + Shift + Z
<br>
<b class="clear-hint">
Search :</b>
Ctrl/Cmd + F
<b>
Toggle Comment:</b>
Ctrl/Cmd + /
<!--<b class="clear-hint">Hint:</b>-->
<!--You can select-->
</div>
Expand All @@ -65,15 +80,6 @@
<label>Limit</label>
<input type="text" class="form-control input-sm" ng-model="limit"/>
</div>
<!--<div class="form-group">-->
<!--<label> Keep result set in history</label>-->
<!--<input type="text" class="form-control input-sm" ng-model="keepLimit"/>-->
<!--</div>-->
<!--<div class="checkbox">-->
<!--<label>-->
<!--<input type="checkbox" class="" ng-model="shallow"/> Shallow collection-->
<!--</label>-->
<!--</div>-->
<div class="checkbox">
<label>
<input type="checkbox" class="" ng-model="hideSettings"/> Hide settings
Expand All @@ -96,23 +102,31 @@
</div>


<div class="row" ng-show="timeline.length >1">
<div class="col-md-6">
<form class="form-search search-history">
<div class="row">
<div class="col-md-6 col-xs-12">
<form class="form-search search-history" ng-show="timeline.length >1">
<div class="input-group">
<input type="text" class="input-xxlarge form-control search-query" ng-model="search.query"
placeholder="Search history">
<span class="input-group-btn">
<button type="submit" class="btn" ng-click="clear()">
<button type="submit" data-title="Clear history" data-placement="right" bs-tooltip class="btn"
ng-click="clear()">
<i class="fa fa-trash-o"></i>
</button>
</span>
</div>
</form>
</div>
<div class="col-md-6">
<div class="col-md-6 col-xs-12">

<!--<div class="btn-group pull-right">-->
<!--<button data-animation="am-fade-and-scale" data-placement="center" data-title="title"-->
<!--data-content="content" bs-modal class="btn">modal-->
<!--</button>-->
<!--</div>-->
<div class="btn-group pull-right">
<button class="btn" ng-click="toggleBookmarks()">
<button class="btn" data-title="Open bookmarks" data-placement="left" bs-tooltip
ng-click="toggleBookmarks()">
<i class="fa fa-star"></i>
</button>
</div>
Expand Down
23 changes: 23 additions & 0 deletions app/views/database/browseHelp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="popover popover-lg popover-help">
<div class="arrow"></div>
<div class="popover-content">

<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="query-hint">
<b>Run:</b>
Ctrl/Cmd + Return
<b>Undo:</b>
Ctrl/Cmd + Z
<b>Redo:</b>
Ctrl/Cmd + Shift + Z
<br>
<!--<b class="clear-hint">Hint:</b>-->
<!--You can select-->
</div>
</div>
</div>
</div>
</div>
</div>
3 changes: 3 additions & 0 deletions app/views/database/config/conflictStrategy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<select type="text" ng-options="opt for opt in conflictStrategies" ng-change="setDirty(val)" ng-model="val.value">

</select>
Loading

0 comments on commit 509b34f

Please sign in to comment.