Skip to content

Commit

Permalink
fixed Issue #34
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Dec 20, 2013
1 parent d68bf6c commit 3c8e327
Show file tree
Hide file tree
Showing 12 changed files with 895 additions and 27 deletions.
4 changes: 3 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<link rel="stylesheet" href="components/bootstrap/docs/assets/css/bootstrap.css">
<link rel="stylesheet" href="components/bootstrap/docs/assets/css/docs.css">
<link rel="stylesheet" href="components/bootstrap-datepicker/css/datepicker.css"/>
<link rel="stylesheet" href="components/ng-grid/ng-grid.min.css"/>
<link rel="stylesheet" href="components/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css"/>
<link rel="stylesheet" href="styles/main.css">

Expand Down Expand Up @@ -81,7 +82,8 @@
<script src="components/angular-strap/dist/angular-strap.js"></script>
<script src="components/bootstrap/docs/assets/js/bootstrap.js"></script>
<script src="components/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="components/angular-localstorage/angular-local-storage.js"></script>
<script type="text/javascript" src="components/angular-local-storage/angular-local-storage.min.js"></script>
<script type="text/javascript" src="components/ng-grid/ng-grid-2.0.7.min.js"></script>
<script type="text/javascript" src="components/codemirror/lib/codemirror.js"></script>
<script type="text/javascript" src="components/codemirror/mode/javascript/javascript.js"></script>
<script type="text/javascript" src="components/codemirror/mode/sql/sql.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 = '/';
10 changes: 10 additions & 0 deletions app/scripts/api.js.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

<<<<<<< Updated upstream
//
//var API = '/api/';
var API = '../';
=======

var API = '/api/';
//var API = '/';
>>>>>>> Stashed changes
3 changes: 2 additions & 1 deletion app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var deps = ['header.controller',
'LocalStorageModule',
'filters',
'rendering',
'schema.controller'];
'schema.controller',
'ngGrid'];


var App = angular.module('OrientDBStudioApp', deps);
Expand Down
4 changes: 3 additions & 1 deletion app/scripts/controllers/database-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',
$scope.countPageOptions = [10, 20, 50, 100, 500, 1000, 2000, 5000];
$scope.table = true;
$scope.contentType = ['JSON', 'CSV'];
$scope.shallow = true;
$scope.selectedContentType = $scope.contentType[0];
$scope.editorOptions = {
lineWrapping: true,
Expand Down Expand Up @@ -57,7 +58,8 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',
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) {

CommandApi.queryText({database: $routeParams.database, contentType: conttype, language: $scope.language, text: $scope.queryText, limit: $scope.limit, shallow: $scope.shallow}, function (data) {

if (data.result) {

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

$scope.database = Database;
$scope.limit = 20;

Database.setWiki("https://github.com/orientechnologies/orientdb-studio/wiki/Query");
if (localStorageService.get("Queries") == null) {
localStorageService.add("Queries", new Array);
}
$scope.queries = localStorageService.get("Queries");
$scope.language = 'sql';
$scope.countPage = 10;
$scope.countPageOptions = [10, 20, 50, 100, 500, 1000, 2000, 5000];
$scope.table = true;
$scope.contentType = ['JSON', 'CSV'];
$scope.shallow = true;
$scope.selectedContentType = $scope.contentType[0];
$scope.editorOptions = {
lineWrapping: true,
lineNumbers: true,
readOnly: false,
theme: 'ambiance',
mode: 'text/x-sql',
metadata: Database,
extraKeys: {
"Ctrl-Enter": function (instance) {
$scope.$apply(function () {
$scope.query();
});

},
"Ctrl-Space": "autocomplete"

}
};
$scope.viewerOptions = {
lineWrapping: true,
lineNumbers: true,
readOnly: true,
mode: 'javascript'

};
$scope.gridOptions = { data: 'myData' };

$scope.myData = [
{'@rid': "PROVA", name: "Moroni", age: 50},
{name: "Tiancum", age: 43},
{name: "Jacob", age: 27},
{name: "Nephi", age: 29},
{name: "Enos", age: 34}
];

$scope.query = function () {


Spinner.start();
$scope.queryText = $scope.queryText.trim();
$scope.queryText = $scope.queryText.replace(/\n/g, " ");
if ($scope.queryText.startsWith('g.')) {
$scope.language = 'gremlin';
}
if ($scope.queryText.startsWith('#')) {
$location.path('/database/' + $routeParams.database + '/browse/edit/' + $scope.queryText.replace('#', ''));
}

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, shallow: $scope.shallow}, function (data) {

if (data.result) {

$scope.headers = Database.getPropertyTableFromResults(data.result);
if ($scope.headers.length == 00) {
$scope.alerts = new Array;
$scope.alerts.push({content: "No records found."});
}
$scope.rawData = JSON.stringify(data);
$scope.resultTotal = data.result;
$scope.results = data.result.slice(0, $scope.countPage);
$scope.currentPage = 1;
$scope.numberOfPage = new Array(Math.ceil(data.result.length / $scope.countPage));
<<<<<<< Updated upstream
Spinner.stopSpinner();
}
if ($scope.queries.indexOf($scope.queryText) != -1) {
var idx = $scope.queries.indexOf($scope.queryText);
$scope.queries.splice(idx, 1);

}
localStorageService.add("Queries", $scope.queries);
$scope.queries.unshift($scope.queryText);
=======
if ($scope.queries.indexOf($scope.queryText) != -1) {
var idx = $scope.queries.indexOf($scope.queryText);
$scope.queries.splice(idx, 1);

}
$scope.queries.unshift($scope.queryText);
localStorageService.add("Queries", $scope.queries);
}
>>>>>>> Stashed changes
Spinner.stopSpinner();
}, function (data) {
Spinner.stopSpinner();
$scope.headers = undefined;
$scope.resultTotal = undefined;
$scope.results = undefined;
});

}

$scope.clear = function () {
$scope.queries = new Array;
localStorageService.add("Queries", $scope.queries);
}
$scope.switchPage = function (index) {
if (index != $scope.currentPage) {
$scope.currentPage = index;
$scope.results = $scope.resultTotal.slice(
(index - 1) * $scope.countPage,
index * $scope.countPage
);
}
}
$scope.previous = function () {
if ($scope.currentPage > 1) {
$scope.switchPage($scope.currentPage - 1);
}
}
$scope.next = function () {

if ($scope.currentPage < $scope.numberOfPage.length) {
$scope.switchPage($scope.currentPage + 1);
}
}
$scope.$watch("countPage", function (data) {
if ($scope.resultTotal) {
$scope.results = $scope.resultTotal.slice(0, $scope.countPage);
$scope.currentPage = 1;
$scope.numberOfPage = new Array(Math.ceil($scope.resultTotal.length / $scope.countPage));
}
});
$scope.openRecord = function (doc) {
$location.path("/database/" + $scope.database.getName() + "/browse/edit/" + doc["@rid"].replace('#', ''));
}

if ($routeParams.query) {
$scope.queryText = $routeParams.query;
$scope.query();
}
}]);

4 changes: 2 additions & 2 deletions app/scripts/services/database-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,9 @@ database.factory('CommandApi', function ($http, $resource, Notification, Spinner
var startTime = new Date().getTime();
var limit = params.limit || 20;
var verbose = params.verbose != undefined ? params.verbose : true;
var shallow = params.shallow != undefined ? '' : ',shallow';
var shallow = params.shallow ? ',shallow' : '';
var contentType = params.contentType || 'application/json';
// rid,type,version,class,attribSameRow,indent:2,dateAsLong,shalow,graph
//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';


Expand Down
Loading

0 comments on commit 3c8e327

Please sign in to comment.