Skip to content

Commit

Permalink
commit for issue #32 and #31
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolazzara committed Nov 29, 2013
1 parent 3cad0ab commit 7c6b258
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 47 deletions.
Binary file modified app/img/spinner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
<div ng-include src="'views/header.html'"></div>
</div>

<div ng-controller="SpinnerController">
<div ng-include src="'views/spinner.html'"></div>
<div id="spinner-container" class="">
<div id="spinner">
</div>
</div>


<!-- Add your site or application content here -->
<div class="container-fluid container-studio">
<!--<div class="row-fluid">
Expand All @@ -66,8 +66,6 @@
</div>




<!-- <script type="text/javascript" src="components/select2/select2.js"></script>
<script type="text/javascript" src="components/angular-ui-select2/src/select2.js"></script> -->
<!-- build:js scripts/scripts.js -->
Expand All @@ -93,7 +91,8 @@
<script src="components/angular-ui-bootstrap-bower/ui-bootstrap.js"></script>
<script src="components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.js"></script>
<!--<script type="text/javascript" src="components/nnnick-chartjs/Chart.js"></script>-->
<script type="text/javascript" src="components/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"
src="components/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>


<script src="scripts/api.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

//
//var API = '/api/';
var API = '../';
var API = '/api/';
//var API = '../';
22 changes: 16 additions & 6 deletions app/scripts/controllers/database-controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var dbModule = angular.module('database.controller', ['database.services']);
dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', 'Spinner', 'localStorageService', function ($scope, $routeParams, $location, Database, CommandApi, Spinner, localStorageService) {
dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', 'localStorageService', 'Spinner', function ($scope, $routeParams, $location, Database, CommandApi, localStorageService, Spinner) {

$scope.database = Database;
$scope.limit = 20;
Expand All @@ -11,8 +11,10 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',
$scope.queries = localStorageService.get("Queries");
$scope.language = 'sql';
$scope.countPage = 10;
$scope.countPageOptions = [10, 20, 50, 100];
$scope.countPageOptions = [10, 20, 50, 100, 500, 1000, 2000, 5000];
$scope.table = true;
$scope.contentType = ['JSON', 'CSV'];
$scope.selectedContentType = $scope.contentType[0];
$scope.editorOptions = {
lineWrapping: true,
lineNumbers: true,
Expand Down Expand Up @@ -41,7 +43,8 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',


$scope.query = function () {
Spinner.loading = true;
Spinner.start();

$scope.queryText = $scope.queryText.trim();
$scope.queryText = $scope.queryText.replace(/\n/g, " ");
if ($scope.queryText.startsWith('g.')) {
Expand All @@ -51,9 +54,13 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',
$location.path('/database/' + $routeParams.database + '/browse/edit/' + $scope.queryText.replace('#', ''));
}

CommandApi.queryText({database: $routeParams.database, language: $scope.language, text: $scope.queryText, limit: $scope.limit}, function (data) {
Spinner.loading = false;
var conttype;
if ($scope.selectedContentType == 'CSV')
conttype = 'text/csv';
CommandApi.queryText({database: $routeParams.database, contentType: conttype, language: $scope.language, text: $scope.queryText, limit: $scope.limit}, function (data) {

if (data.result) {

$scope.headers = Database.getPropertyTableFromResults(data.result);
if ($scope.headers.length == 00) {
$scope.alerts = new Array;
Expand All @@ -72,14 +79,17 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',
}
$scope.queries.unshift($scope.queryText);
localStorageService.add("Queries", $scope.queries);
Spinner.stopSpinner();
}
}, function (data) {
Spinner.stopSpinner();
$scope.headers = undefined;
$scope.resultTotal = undefined;
$scope.results = undefined;
Spinner.loading = false;
});

}

$scope.clear = function () {
$scope.queries = new Array;
localStorageService.add("Queries", $scope.queries);
Expand Down
9 changes: 7 additions & 2 deletions app/scripts/controllers/function-controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var schemaModule = angular.module('function.controller', ['database.services']);
schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', 'FunctionApi', 'DocumentApi', '$modal', '$q', '$route', function ($scope, $routeParams, $location, Database, CommandApi, FunctionApi, DocumentApi, $modal, $q, $route) {
schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', 'FunctionApi', 'DocumentApi', '$modal', '$q', '$route', 'Spinner', function ($scope, $routeParams, $location, Database, CommandApi, FunctionApi, DocumentApi, $modal, $q, $route, Spinner) {

$scope.database = Database;
$scope.listClasses = $scope.database.listClasses();
Expand Down Expand Up @@ -110,11 +110,16 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
for (i in $scope.parametersToExecute) {
buildedParams = buildedParams.concat($scope.parametersToExecute[i] + '/');
}

Spinner.start();
FunctionApi.executeFunction({database: $routeParams.database, functionName: $scope.nameFunction, parameters: buildedParams, limit: $scope.limit}, function (data) {
if (data.result) {
$scope.resultExecute = JSON.stringify(data.result);
Spinner.stopSpinner();
}
Spinner.stopSpinner();
}, function (error) {
$scope.resultExecute = error;
Spinner.stopSpinner();
});
}
}
Expand Down
25 changes: 17 additions & 8 deletions app/scripts/controllers/schema-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ schemaModule.controller("ClassEditController", ['$scope', '$routeParams', '$loca
$scope.modificati = undefined;
$scope.limit = 20;
$scope.queries = new Array;
$scope.classClickedHeaders = ['name', 'type', 'linkedType', 'linkedClass', 'mandatory', 'readonly', 'notNull', 'min', 'max', 'Actions'];
$scope.classClickedHeaders = ['Name', 'Type', 'Linked_Type', 'Linked_Class', 'Mandatory', 'Read_Only', 'Not_Null', 'Min', 'Max','Collate', 'Actions'];
$scope.property = null;
$scope.property = Database.listPropertiesForClass(clazz);
$scope.propertyNames = new Array;
Expand Down Expand Up @@ -146,7 +146,7 @@ schemaModule.controller("ClassEditController", ['$scope', '$routeParams', '$loca
$scope.queryText = ""
$scope.modificati = new Array;
$scope.listTypes = ['BINARY', 'BOOLEAN', 'EMBEDDED', 'EMBEDDEDLIST', 'EMBEDDEDMAP', 'EMBEDDEDSET', 'DECIMAL', 'FLOAT', 'DATE', 'DATETIME', 'DOUBLE', 'INTEGER', 'LINK', 'LINKLIST', 'LINKMAP', 'LINKSET', 'LONG', 'SHORT', 'STRING'];

$scope.collateTypes = ['Case Insensitive', 'default'];
$scope.modificato = function (result, prop) {
var key = result['name'];
if ($scope.modificati[result['name']] == undefined) {
Expand Down Expand Up @@ -216,8 +216,10 @@ schemaModule.controller("ClassEditController", ['$scope', '$routeParams', '$loca

var prop = arrayToUpdate[0];
var newValue = properties[result][prop] != '' ? properties[result][prop] : null;
if(newValue == 'Case Insensitive')
newValue = 'ci';
var sql = 'ALTER PROPERTY ' + clazz + '.' + keyName + ' ' + prop + ' ' + newValue;

console.log(sql);
CommandApi.queryText({database: $routeParams.database, language: 'sql', text: sql, limit: $scope.limit}, function (data) {
if (data) {
var index = arrayToUpdate.indexOf(prop);
Expand Down Expand Up @@ -313,7 +315,7 @@ schemaModule.controller("ClassEditController", ['$scope', '$routeParams', '$loca
});
}
}]);
schemaModule.controller("IndexController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', '$modal', '$q', function ($scope, $routeParams, $location, Database, CommandApi, $modal, $q) {
schemaModule.controller("IndexController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', '$modal', '$q', 'Spinner', function ($scope, $routeParams, $location, Database, CommandApi, $modal, $q, Spinner) {

$scope.listTypeIndex = [ 'DICTIONARY', 'FULLTEXT', 'UNIQUE', 'NOTUNIQUE', 'DICTIONARY_HASH_INDEX', 'FULLTEXT_HASH_INDEX', 'UNIQUE_HASH_INDEX', 'NOTUNIQUE_HASH_INDEX' ];
$scope.newIndex = {"name": "", "type": "", "fields": "" }
Expand All @@ -322,6 +324,7 @@ schemaModule.controller("IndexController", ['$scope', '$routeParams', '$location
$scope.nameIndexToShow = $scope.classInject + '.';
$scope.db.refreshMetadata($routeParams.database);
$scope.property = Database.listPropertiesForClass($scope.classInject);

$scope.propertyNames = new Array;

for (inn in $scope.property) {
Expand Down Expand Up @@ -375,18 +378,20 @@ schemaModule.controller("IndexController", ['$scope', '$routeParams', '$location
var sql = 'CREATE INDEX ' + $scope.nameIndexToShow + ' ON ' + $scope.classInject + ' ( ' + proppps + ' ) ' + $scope.newIndex['type'];
$scope.newIndex['name'] = $scope.nameIndexToShow;
$scope.newIndex['fields'] = proppps;

Spinner.startSpinnerPopup();
CommandApi.queryText({database: $routeParams.database, language: 'sql', text: sql, limit: $scope.limit}, function (data) {
$scope.hide();
$scope.parentScope.addIndexFromExt($scope.newIndex);
Spinner.stopSpinnerPopup();
}, function (error) {
$scope.testMsgClass = 'alert alert-error';
$scope.testMsg = error;
Spinner.stopSpinnerPopup();
});
}
}]);

schemaModule.controller("PropertyController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', '$modal', '$q', function ($scope, $routeParams, $location, Database, CommandApi, $modal, $q) {
schemaModule.controller("PropertyController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', '$modal', '$q', 'Spinner', function ($scope, $routeParams, $location, Database, CommandApi, $modal, $q, Spinner) {


$scope.property = {"name": "", "type": "", "linkedType": "", "linkedClass": "", "mandatory": "false", "readonly": "false", "notNull": "false", "min": null, "max": null}
Expand All @@ -404,12 +409,15 @@ schemaModule.controller("PropertyController", ['$scope', '$routeParams', '$locat
var linkedType = prop['linkedType'] != null ? prop['linkedType'] : '';
var linkedClass = prop['linkedClass'] != null ? prop['linkedClass'] : '';
var sql = 'CREATE PROPERTY ' + $scope.classInject + '.' + propName + ' ' + propType + ' ' + linkedType + ' ' + linkedClass;
console.log(sql);
Spinner.startSpinnerPopup();
CommandApi.queryText({database: $routeParams.database, language: 'sql', text: sql, limit: $scope.limit}, function (data) {

Spinner.stopSpinnerPopup();
}, function (error) {
Spinner.stopSpinnerPopup();
});

var i = 1;
Spinner.startSpinnerPopup();
for (entry in prop) {
var sql = 'ALTER PROPERTY ' + $scope.classInject + '.' + propName + ' ' + entry + ' ' + prop[entry];
CommandApi.queryText({database: $routeParams.database, language: 'sql', text: sql, limit: $scope.limit}, function (data) {
Expand All @@ -420,6 +428,7 @@ schemaModule.controller("PropertyController", ['$scope', '$routeParams', '$locat
$scope.parentScope.indexes = Database.listIndexesForClass(clazz);
$scope.parentScope.apply();
});
Spinner.startSpinnerPopup();
$scope.hide();
}
});
Expand Down
16 changes: 11 additions & 5 deletions app/scripts/services/database-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ database.factory('DatabaseApi', function ($http, $resource) {

var urlWiki = "https://github.com/orientechnologies/orientdb-studio/wiki/Functions";


var resource = $resource(API + 'database/:database');
resource.listDatabases = function (callback) {
$http.get(API + 'listDatabases').success(callback);
Expand All @@ -452,7 +451,6 @@ database.factory('DatabaseApi', function ($http, $resource) {
return urlWiki;
}


resource.connect = function (database, username, password, callback, error) {
$http.defaults.headers.common['Authorization'] = 'Basic ' + Base64.encode(username + ':' + password);
$http.get(API + 'connect/' + database).success(callback).error(error);
Expand Down Expand Up @@ -487,7 +485,7 @@ database.factory('DatabaseApi', function ($http, $resource) {
}
return resource;
});
database.factory('CommandApi', function ($http, $resource, Notification) {
database.factory('CommandApi', function ($http, $resource, Notification, Spinner) {

var resource = $resource(API + 'command/:database');

Expand All @@ -496,22 +494,30 @@ database.factory('CommandApi', function ($http, $resource, Notification) {
var limit = params.limit || 20;
var verbose = params.verbose != undefined ? params.verbose : true;
var shallow = params.shallow != undefined ? '' : ',shallow';
// var contentType = params.contentType || 'application/json';
//rid,type,version,class,attribSameRow,indent:2,dateAsLong,shalow,graph
var text = API + 'command/' + params.database + "/" + params.language + "/-/" + limit + '?format=rid,type,version' + shallow + ',class,graph';


if (params.text) {
var query = params.text.trim();
// var config = {headers: "Content-Type: " + contentType};
$http.post(text, query).success(function (data) {

var time = ((new Date().getTime() - startTime) / 1000);
var records = data.result ? data.result.length : "";

if (verbose) {
var noti = "Query executed in " + time + " sec. Returned " + records + " record(s)";
Notification.push({content: noti});
}
if (data != undefined)
if (data != undefined) {
callback(data);
else
}
else {
callback('ok');
}

}).error(function (data) {
Notification.push({content: data});
if (error) error(data);
Expand Down
48 changes: 44 additions & 4 deletions app/scripts/services/spinner-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,50 @@

var spinner = angular.module('spinner.services', []);

spinner.factory('Spinner',function(){

var spinner = {
loading : false
spinner.factory('Spinner', function () {
var spinnerOpts = {
lines: 9, // The number of lines to draw
length: 7, // The length of each line
width: 7, // The line thickness
radius: 19, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: [
'rgb(0,0,0)',
'rgb(255,102,0)'
], // #rgb or #rrggbb or array of colors
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: 'auto', // Top position relative to parent in px
left: 'auto' // Left position relative to parent in px
};
var spinner = new Spinner(spinnerOpts);
// $(document).ready(function () {
// var target = document.getElementById('spinner');
// spinner.spin(target);
// spinner.stop();
// })
spinner.start = function () {
var target = document.getElementById('spinner');
spinner.spin(target);
$("#spinner-container").addClass('spinner-start')
}
spinner.stopSpinner = function () {
spinner.stop();
$("#spinner-container").removeClass('spinner-start');

}
spinner.startSpinnerPopup = function () {
var target = document.getElementById('spinner-popup');
spinner.spin(target);
}
spinner.stopSpinnerPopup = function () {
spinner.stop();
}
return spinner;
});
18 changes: 16 additions & 2 deletions app/scripts/widgets/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,29 @@ Widget.directive('dtpicker', function () {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attr,ngModel) {
link: function (scope, element, attr, ngModel) {

element.datetimepicker({
format: 'dd/MM/yyyy hh:mm:ss',
language: 'en'
});
element.on('changeDate', function(e) {
element.on('changeDate', function (e) {
ngModel.$setViewValue(e.date);
});
}
};
});
Widget.directive('collaterender', function () {


return {
restrict: 'A',
link: function (scope, element, attr, ngModel) {

var value = scope.result['collate'];
if (value == 'ci') {
scope.result['collate'] = 'Case Insensitive';
}
}
};
});
Loading

0 comments on commit 7c6b258

Please sign in to comment.