Skip to content

Commit

Permalink
fixed bugs, #48 #46 #47 #49 #50
Browse files Browse the repository at this point in the history
  • Loading branch information
maggiolo00 authored and maggiolo00 committed Mar 15, 2014
1 parent 21d4e5a commit e74a1ea
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 27 deletions.
29 changes: 19 additions & 10 deletions app/scripts/controllers/database-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',
dbTime = new Object;
localStorageService.add("Timeline", dbTime);
}

$scope.timeline = dbTime[Database.getName()];
if (!$scope.timeline) {
$scope.timeline = new Array;
Expand Down Expand Up @@ -60,14 +61,6 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',

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

};


$scope.query = function () {
Spinner.start();
Expand Down Expand Up @@ -153,10 +146,22 @@ dbModule.controller("BrowseController", ['$scope', '$routeParams', '$location',
}

}]);
dbModule.controller("QueryController", ['$scope', '$routeParams', '$filter', '$location', 'Database', 'CommandApi', 'localStorageService', 'Spinner', 'ngTableParams', 'scroller', function ($scope, $routeParams, $filter, $location, Database, CommandApi, localStorageService, Spinner, ngTableParams, scroller) {
dbModule.controller("QueryController", ['$scope', '$routeParams', '$filter', '$location', 'Database', 'CommandApi', 'localStorageService', 'Spinner', 'ngTableParams', 'scroller','$ojson', function ($scope, $routeParams, $filter, $location, Database, CommandApi, localStorageService, Spinner, ngTableParams, scroller,$ojson) {


var data = $scope.item.resultTotal;

$scope.viewerOptions = {
lineWrapping: true,
lineNumbers: true,
readOnly: true,
mode: 'javascript',
onLoad : function(_cm){
$scope.item.cm = _cm;
$scope.item.cm.setValue($ojson.format($scope.item.rawData));
}

};
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 10 // count per page
Expand Down Expand Up @@ -205,8 +210,12 @@ dbModule.controller("QueryController", ['$scope', '$routeParams', '$filter', '$l
}
$scope.changeQuery = function () {
$scope.queryText = $scope.item.query;
$scope.cm.setValue($scope.queryText);
scroller.scrollTo(0, 0, 2000);
$scope.cm.focus();

$scope.cm.setValue($scope.queryText);
$scope.cm.setCursor($scope.cm.lineCount());

}

}]);
Expand Down
4 changes: 3 additions & 1 deletion app/scripts/controllers/function-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat

if ($scope.functions.length > 0 && $scope.functionToExecute != undefined) {
var index = $scope.functionsrid.indexOf($scope.functionToExecute['name']);
$scope.showInConsoleAfterSave($scope.functions[index]);
if (index != -1)
$scope.showInConsoleAfterSave($scope.functions[index]);
}
}
});
Expand Down Expand Up @@ -239,6 +240,7 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
});

}
$scope.createNewFunction();
}])
;

9 changes: 5 additions & 4 deletions app/scripts/controllers/schema-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ schemaModule.controller("ClassEditController", ['$scope', '$routeParams', '$loca
$scope.modificati = undefined;
$scope.limit = 20;
$scope.queries = new Array;
$scope.classClickedHeaders = ['Name', 'Type', 'Linked_Type', 'Linked_Class', 'Mandatory', 'Read_Only', 'Not_Null', 'Min', 'Max','Collate', '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 All @@ -123,6 +123,7 @@ schemaModule.controller("ClassEditController", ['$scope', '$routeParams', '$loca
var sql = 'DROP CLASS ' + nameClass;

CommandApi.queryText({database: $routeParams.database, language: 'sql', text: sql, limit: $scope.limit}, function (data) {
Database.setMetadata(null);
$location.path("/database/" + $scope.database.getName() + "/schema");

});
Expand All @@ -145,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.collateTypes = ['Case Insensitive', 'default'];
$scope.modificato = function (result, prop) {
var key = result['name'];
if ($scope.modificati[result['name']] == undefined) {
Expand Down Expand Up @@ -215,8 +216,8 @@ 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';
if (newValue == 'Case Insensitive')
newValue = 'ci';
var sql = 'ALTER PROPERTY ' + clazz + '.' + keyName + ' ' + prop + ' ' + newValue;
CommandApi.queryText({database: $routeParams.database, language: 'sql', text: sql, limit: $scope.limit}, function (data) {
if (data) {
Expand Down
89 changes: 89 additions & 0 deletions app/scripts/widgets/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,92 @@ Widget.directive('collaterender', function () {
}
};
});
Widget.provider("$ojson", function () {

var $jsonProvider = {

$get: function ($q, $modal, $rootScope) {

var $ojson = {};

$ojson.repeat = function (s, count) {
return new Array(count + 1).join(s);
}

$ojson.formatJson = function (json, indentChars) {
var i = 0,
il = 0,
tab = (typeof indentChars !== "undefined") ? indentChars : " ",
newJson = "",
indentLevel = 0,
inString = false,
currentChar = null;

for (i = 0, il = json.length; i < il; i += 1) {
currentChar = json.charAt(i);

switch (currentChar) {
case '{':
case '[':
if (!inString) {
newJson += currentChar + "\r\n" + this.repeat(tab, indentLevel + 1);
indentLevel += 1;
} else {
newJson += currentChar;
}
break;
case '}':
case ']':
if (!inString) {
indentLevel -= 1;
newJson += "\r\n" + this.repeat(tab, indentLevel) + currentChar;
} else {
newJson += currentChar;
}
break;
case ',':
if (!inString) {
newJson += ",\r\n" + this.repeat(tab, indentLevel);
} else {
newJson += currentChar;
}
break;
case ':':
if (!inString) {
newJson += ": ";
} else {
newJson += currentChar;
}
break;
case ' ':
case "\n":
case "\t":
if (inString) {
newJson += currentChar;
}
break;
case '"':
if (i > 0 && json.charAt(i - 1) !== '\\') {
inString = !inString;
}
newJson += currentChar;
break;
default:
newJson += currentChar;
break;
}
}
return newJson;
}
$ojson.format = function (text) {
return this.formatJson(text);
}


return $ojson;
}
}


return $jsonProvider;
});
4 changes: 3 additions & 1 deletion app/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ body div.container-studio {
min-height: 50px;
max-height: 300px;
}

.jsonView .CodeMirror {
height: 200px !important;
}
.CodeMirror-scroll {
/*overflow-y: hidden;*/
/*overflow-x: auto;*/
Expand Down
9 changes: 5 additions & 4 deletions app/views/database/browseConfig.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
ng-options="q for q in contentType"></select>
<label>Limit</label>
<input type="text" class="input-medium" ng-model="limit"/>
<label>Keep Limit</label>

<label class="checkbox">
<input type="checkbox" class="input-medium" ng-model="shallow"/> Shallow collection
</label>
<label> Keep result set in history</label>
<input type="text" class="input-medium" ng-model="keepLimit"/>
<label>Shallow collection</label>
<input type="checkbox" class="input-medium pull-right" ng-model="shallow"/>
<br>
<!--<div style="margin-top: 5px;">-->
<!--<label>History</label>-->
<!--<select ng-model="queryText" ng-options="q for q in queries"></select>-->
Expand Down
2 changes: 1 addition & 1 deletion app/views/database/functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<tr>

<td>
<a href="javascript:void(0)" class="btn btn-success"
<a href="javascript:void(0)" class="btn btn-success" ng-disabled="!nameFunction"
ng-click="executeFunction()">
<i
class="icon-white icon-ok"></i>
Expand Down
12 changes: 6 additions & 6 deletions app/views/database/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ <h5><a href="javascript:void(0)" ng-click="changeQuery()" bs-tooltip="item.query
<!--<textarea jsontext ui-codemirror="viewerOptions" ng-model="rawData"></textarea>-->
<!--</div>-->
<!--</div>-->
<div ng-hide="table">
<div ng-hide="table" class="jsonView">
<div class="row-fluid">
<textarea ng-model='rawData' style="width: 100%; height: 100px;"></textarea>
<textarea jsontext ui-codemirror="viewerOptions" ng-model="item.rawData" style="width: 100%; height: 100px;"></textarea>
</div>
</div>
</div>
Expand All @@ -43,13 +43,13 @@ <h5><a href="javascript:void(0)" ng-click="changeQuery()" bs-tooltip="item.query

</div>
<div class="span2">
<ul class="nav nav-pills" ng-show="item.headers">
<ul class="nav nav-pills pull-right" ng-show="item.headers">
<li ng-class="{active : table }">
<a href="javascript:void(0)" ng-click="table = true">Table</a>
</li>
<li>
<a href="javascript:void(0)">Graph</a>
</li>
<!--<li>-->
<!--<a href="javascript:void(0)">Graph</a>-->
<!--</li>-->
<li ng-class="{active : !table }">
<a href="javascript:void(0)" ng-click="table = false">Raw</a>
</li>
Expand Down

0 comments on commit e74a1ea

Please sign in to comment.