Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Feb 8, 2014
2 parents 336a3da + 8229738 commit 017b52f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 150 deletions.
4 changes: 2 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +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/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 @@ -83,7 +83,7 @@
<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-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/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
134 changes: 0 additions & 134 deletions app/index.html.orig

This file was deleted.

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


var App = angular.module('OrientDBStudioApp', deps);
Expand Down
40 changes: 30 additions & 10 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', 'Spinner', function ($scope, $routeParams, $location, Database, CommandApi, FunctionApi, DocumentApi, $modal, $q, $route, Spinner) {
schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$location', 'Database', 'CommandApi', 'FunctionApi', 'DocumentApi', '$modal', '$q', '$route', 'Spinner', 'Notification', function ($scope, $routeParams, $location, Database, CommandApi, FunctionApi, DocumentApi, $modal, $q, $route, Spinner, Notification) {

$scope.database = Database;
$scope.listClasses = $scope.database.listClasses();
Expand Down Expand Up @@ -36,7 +36,7 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
$scope.getListFunction = function () {
$scope.functions = new Array;
$scope.functionsrid = new Array;
CommandApi.queryText({database: $routeParams.database, language: 'sql', verbose: false, text: sqlText, limit: $scope.limit, shallow: true}, function (data) {
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) {
$scope.functions.push(data.result[i]);
Expand All @@ -45,7 +45,7 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat

if ($scope.functions.length > 0 && $scope.functionToExecute != undefined) {
var index = $scope.functionsrid.indexOf($scope.functionToExecute['name']);
$scope.showInConsole($scope.functions[index]);
$scope.showInConsoleAfterSave($scope.functions[index]);
}
}
});
Expand Down Expand Up @@ -81,11 +81,18 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
}
}
$scope.addParam = function () {


if ($scope.functionToExecute['parameters'] == undefined) {
$scope.functionToExecute['parameters'] = new Array;
}


var app = JSON.parse(JSON.stringify($scope.parametersToExecute));

$scope.functionToExecute['parameters'].push('');
$scope.inParams = $scope.functionToExecute['parameters'];

$scope.$watch('inParams.length', function (data) {
if (data) {
$scope.parametersToExecute = new Array(data);
Expand All @@ -94,13 +101,17 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat

$scope.parametersToExecute = null;
}
});
var i;
for (i in app) {
$scope.parametersToExecute[i] = app[i];
}

$scope.functionToExecute['parameters'].push('');

});
}
$scope.
executeFunction = function () {

$scope.resultExecute = '';

if ($scope.functionToExecute != undefined) {
var functionNamee = $scope.nameFunction;
Expand Down Expand Up @@ -140,21 +151,25 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
}

//when click on a function in list of functions
$scope.showInConsole = function (selectedFunction) {

$scope.showInConsoleAfterSave = function (selectedFunction) {
$scope.consoleValue = selectedFunction['code'];
$scope.nameFunction = selectedFunction['name'];
$scope.selectedLanguage = selectedFunction['language'];
$scope.functionToExecute = selectedFunction;
$scope.inParams = $scope.functionToExecute['parameters'];
$scope.parametersToExecute = new Array;
}

$scope.showInConsole = function (selectedFunction) {

$scope.showInConsoleAfterSave(selectedFunction);
$scope.parametersToExecute = new Array;

$scope.$watch('inParams.length', function (data) {
if (data) {
$scope.parametersToExecute = new Array(data);
}
else {

$scope.parametersToExecute = null;
}
});
Expand All @@ -163,7 +178,7 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat
$scope.isNewFunction = false;
}

$scope.modificataLang = function (lang) {
$scope.modifiedLanguage = function (lang) {
$scope.functionToExecute['language'] = lang;
}
$scope.createNewFunction = function () {
Expand All @@ -174,17 +189,22 @@ schemaModule.controller("FunctionController", ['$scope', '$routeParams', '$locat

}
$scope.saveFunction = function () {
$scope.resultExecute = '';
if ($scope.functionToExecute['language'] != undefined && $scope.functionToExecute['name'] != undefined && $scope.functionToExecute['name'] != '') {
if ($scope.isNewFunction == true) {
DocumentApi.createDocument($scope.database.getName(), $scope.functionToExecute['@rid'], $scope.functionToExecute, function (data) {
$scope.getListFunction();
var message = 'Function saved successfully. Server returns ' + JSON.stringify(data);
Notification.push({content: message });
}
);

}
else {
DocumentApi.updateDocument($scope.database.getName(), $scope.functionToExecute['@rid'], $scope.functionToExecute, function (data) {
$scope.getListFunction();
var message = 'Function saved successfully. Server returns ' + JSON.stringify(data);
Notification.push({content: message });
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/services/database-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ database.factory('FunctionApi', function ($http, $resource, Notification) {
var records = data.result ? data.result.length : "";
if (verbose) {
var noti = "Query executed in " + time + " sec. Returned " + records + " record(s)";
// Notification.push({content: noti});
Notification.push({content: noti});
}
callback(data);
}).error(function (data) {
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 @@ -42,7 +42,7 @@
Name : <input type="text" required ng-model="functionToExecute['name']">
Language:
<select ng-options="lang for lang in languages" ng-model="selectedLanguage"
ng-change="modificataLang(selectedLanguage)">
ng-change="modifiedLanguage(selectedLanguage)">

</select>
Idempotent: <input type="checkbox" ng-model="functionToExecute['idempotent']">
Expand Down

0 comments on commit 017b52f

Please sign in to comment.