Skip to content

Commit

Permalink
fixed some issues #56, #55, #46, #39, #12
Browse files Browse the repository at this point in the history
  • Loading branch information
maggiolo00 authored and maggiolo00 committed Mar 24, 2014
1 parent 6514e9e commit 32e5366
Show file tree
Hide file tree
Showing 16 changed files with 224 additions and 47 deletions.
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<script type="text/javascript" src="components/codemirror/mode/sql/sql.js"></script>
<script type="text/javascript" src="components/codemirror/addon/hint/show-hint.js"></script>
<script src="scripts/util/orientdb-hint.js"></script>
<script type="text/javascript" src="components/angular-ui-codemirror/ui-codemirror.js"></script>
<script type="text/javascript" src="scripts/widgets/patch/ui-codemirror.js"></script>
<script src="components/angular-ui-bootstrap-bower/ui-bootstrap.js"></script>
<script src="components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.js"></script>
<script src="components/angular-scroll/angular-scroll.min.js"></script>
Expand Down
10 changes: 10 additions & 0 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ App.config(function ($routeProvider) {
controller: 'ClassEditController',
resolve: DatabaseResolve
})
.when('/database/:database/schema/create/:clazz', {
templateUrl: 'views/database/createRecord.html',
controller: 'CreateController',
resolve: DatabaseResolve
}).
when('/database/:database/schema/editclass/:clazz', {
templateUrl: 'views/database/editclass.html',
controller: 'ClassEditController',
resolve: DatabaseResolve
})
.when('/database/:database/db', {
templateUrl: 'views/database/configuration.html',
controller: 'ConfigurationController',
Expand Down
18 changes: 17 additions & 1 deletion app/scripts/controllers/document-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ function BaseEditController($scope, $routeParams, $route, $location, $modal, $q,
if (type == 'INTEGER') {
$scope.doc[name] = 0;
}
console.log(type);
if (Database.getMappingFor(type)) {
if (types) {
types = types + ',' + name + '=' + Database.getMappingFor(type);
Expand Down Expand Up @@ -319,4 +320,19 @@ function BaseEditController($scope, $routeParams, $route, $location, $modal, $q,
$scope.create = function () {
$location.path('database/' + $scope.database + '/browse/create/' + $scope.doc['@class']);
}
}
}
DocController.controller("EmbeddedController", ['$scope', '$ojson', function ($scope, $ojson) {


$scope.viewerOptions = {
lineWrapping: true,
lineNumbers: true,
mode: 'javascript',
onLoad: function (_cm) {
$scope.vcm = _cm;
$scope.vcm.setValue(JSON.stringify($scope.doc[$scope.header]));
}

};

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

}
},
onLoad: function (_cm) {
$scope.vcm = _cm;
$scope.createNewFunction();
}
};
Database.setWiki("https://github.com/orientechnologies/orientdb-studio/wiki/Functions");
Expand Down Expand Up @@ -159,6 +163,8 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
$scope.selectedLanguage = selectedFunction['language'];
$scope.functionToExecute = selectedFunction;
$scope.inParams = $scope.functionToExecute['parameters'];
$scope.vcm.setValue($scope.consoleValue != null ? $scope.consoleValue : "");

}

$scope.showInConsole = function (selectedFunction) {
Expand Down Expand Up @@ -195,6 +201,7 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
if ($scope.isNewFunction == true) {
DocumentApi.createDocument($scope.database.getName(), $scope.functionToExecute['@rid'], $scope.functionToExecute, function (data) {
$scope.getListFunction();
$scope.isNewFunction = false;
var message = 'Function saved successfully. Server returns ' + JSON.stringify(data);
Notification.push({content: message });
}
Expand Down Expand Up @@ -240,7 +247,6 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
});

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

5 changes: 4 additions & 1 deletion app/scripts/controllers/header-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ angular.module('header.controller', ['database.services']).controller("HeaderCon
var find = $location.path().indexOf("/" + element.name.toLowerCase());
if (find != -1) {
$scope.selectedMenu = element;

if (!$scope.$$phase && !$scope.$root.$$phase) {
$scope.$apply();
}
return;
}

});
Expand Down
21 changes: 18 additions & 3 deletions app/scripts/controllers/schema-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ schemaModule.controller("SchemaController", ['$scope', '$routeParams', '$locatio
$scope.classClicked = clazz;
}
$scope.openClass = function (clazz) {
$location.path("/database/" + $scope.database.getName() + "/browse/editclass/" + clazz.name);
$location.path("/database/" + $scope.database.getName() + "/schema/editclass/" + clazz.name);
}
$scope.refreshWindow = function () {
$window.location.reload();
Expand Down Expand Up @@ -343,7 +343,7 @@ schemaModule.controller("IndexController", ['$scope', '$routeParams', '$location
$scope.prop2add.splice(index, 1)
}
var first = true;
$scope.nameIndexToShow = $scope.classInject + '_';
$scope.nameIndexToShow = $scope.classInject + '.';

for (entry in $scope.prop2add) {
if (first) {
Expand Down Expand Up @@ -526,7 +526,6 @@ schemaModule.controller("NewClassController", ['$scope', '$routeParams', '$locat
schemaModule.controller("IndexesController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', '$modal', '$q', '$route', function ($scope, $routeParams, $location, Database, CommandApi, $modal, $q, $route) {

$scope.indexes = Database.getMetadata()["indexes"];
console.log($scope.indexes);

$scope.rebuildIndex = function (indexName) {
var sql = 'REBUILD INDEX ' + indexName;
Expand All @@ -551,4 +550,20 @@ schemaModule.controller("IndexesController", ['$scope', '$routeParams', '$locati
}
});
}
$scope.getFields = function (definition) {
var fields = "";
if (definition) {
if (definition.indexDefinitions) {
fields += " [";
definition.indexDefinitions.forEach(function (elem, idx, array) {
if (idx > 0)fields += ","
fields += elem.field;
});
fields += "]";
} else {
fields += "[" + definition.field + "]";
}
}
return fields;
}
}]);
2 changes: 1 addition & 1 deletion app/scripts/services/database-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ database.factory('Database', function (DatabaseApi, localStorageService) {

listTypes: ['BINARY', 'BYTE', 'BOOLEAN', 'EMBEDDED', 'EMBEDDEDLIST', 'EMBEDDEDMAP', 'EMBEDDEDSET', 'DECIMAL', 'FLOAT', 'DATE', 'DATETIME', 'DOUBLE', 'INTEGER', 'LINK', 'LINKLIST', 'LINKMAP', 'LINKSET', 'LONG', 'SHORT', 'STRING'],

mapping: { 'BINARY': 'b', 'BYTE': 'b', 'DATE': 'a', 'DATETIME': 't', 'FLOAT': 'f', 'DECIMAL': 'c', 'LONG': 'l', 'DOUBLE': 'd', 'SHORT': 's', 'LINKSET': 'e'},
mapping: { 'BINARY': 'b', 'BYTE': 'b', 'DATE': 'a', 'DATETIME': 't', 'FLOAT': 'f', 'DECIMAL': 'c', 'LONG': 'l', 'DOUBLE': 'd', 'SHORT': 's', 'LINKSET': 'e', 'EMBEDDEDLIST': 'e', 'EMBEDDEDMAP': 'e', 'EMBEDDEDSET': 'e', 'EMBEDDED': 'e'},
getMetadata: function () {
/*if (current.metadata == null) {
var tmp = localStorageService.get("CurrentDB");
Expand Down
79 changes: 79 additions & 0 deletions app/scripts/widgets/patch/ui-codemirror.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use strict';
angular.module('ui.codemirror', []).constant('uiCodemirrorConfig', {}).directive('uiCodemirror', [
'uiCodemirrorConfig',
function (uiCodemirrorConfig) {
return {
restrict: 'EA',
require: '?ngModel',
priority: 1,
compile: function compile(tElement) {
if (angular.isUndefined(window.CodeMirror)) {
throw new Error('ui-codemirror need CodeMirror to work... (o rly?)');
}
var value = tElement.text();
var codeMirror = new window.CodeMirror(function (cm_el) {
angular.forEach(tElement.prop('attributes'), function (a) {
if (a.name === 'ui-codemirror') {
cm_el.setAttribute('ui-codemirror-opts', a.textContent);
} else {
cm_el.setAttribute(a.name, a.textContent);
}
});
if (tElement.parent().length <= 0) {
tElement.wrap('<div>');
}
tElement.replaceWith(cm_el);
}, { value: value });
return function postLink(scope, iElement, iAttrs, ngModel) {
var options, opts;
options = uiCodemirrorConfig.codemirror || {};
opts = angular.extend({}, options, scope.$eval(iAttrs.uiCodemirror), scope.$eval(iAttrs.uiCodemirrorOpts));
function updateOptions(newValues) {
for (var key in newValues) {
if (newValues.hasOwnProperty(key)) {
codeMirror.setOption(key, newValues[key]);
}
}
}
updateOptions(opts);
if (angular.isDefined(scope.$eval(iAttrs.uiCodemirror))) {
scope.$watch(iAttrs.uiCodemirror, updateOptions, true);
}
codeMirror.on('change', function (instance) {
var newValue = instance.getValue();
if (ngModel && newValue !== ngModel.$viewValue) {
ngModel.$setViewValue(newValue);
}
if (!scope.$$phase && !scope.$root.$$phase) {
scope.$apply();
}
});
if (ngModel) {
ngModel.$formatters.push(function (value) {
if (angular.isUndefined(value) || value === null) {
return '';
} else if (angular.isObject(value) || angular.isArray(value)) {
throw new Error('ui-codemirror cannot use an object or an array as a model');
}
return value;
});
ngModel.$render = function () {
var safeViewValue = ngModel.$viewValue || '';
codeMirror.setValue(safeViewValue);
};
}
if (iAttrs.uiRefresh) {
scope.$watch(iAttrs.uiRefresh, function (newVal, oldVal) {
if (newVal !== oldVal) {
codeMirror.refresh();
}
});
}
if (angular.isFunction(opts.onLoad)) {
opts.onLoad(codeMirror);
}
};
}
};
}
]);
12 changes: 1 addition & 11 deletions app/scripts/widgets/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ Widget.directive('ridrender', function (Database) {
i++;
}
});
html = html.replace(/,([^,]*)$/,'$1');
html = html.replace(/,([^,]*)$/, '$1');
html += "</ul>";
if (html != "" && i == value.length) {
element.html(html);
Expand All @@ -390,16 +390,6 @@ Widget.directive('ridrender', function (Database) {
}
};
});
Widget.directive("autofill", function () {
return {
require: "ngModel",
link: function (scope, element, attrs, ngModel) {
scope.$on("autofill:update", function() {
ngModel.$setViewValue(element.val());
});
}
}
});
Widget.directive('dtpicker', function () {


Expand Down
Loading

0 comments on commit 32e5366

Please sign in to comment.