Skip to content

Commit

Permalink
implemented #80
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Sep 2, 2014
1 parent d26efc6 commit 5f75b41
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
11 changes: 8 additions & 3 deletions app/scripts/controllers/header-controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
angular.module('header.controller', ['database.services']).controller("HeaderController", ['$scope', '$routeParams', '$http', '$location', '$modal', '$q', 'Database', 'Aside', function ($scope, $routeParams, $http, $location, $modal, $q, Database, Aside) {
angular.module('header.controller', ['database.services']).controller("HeaderController", ['$scope', '$rootScope', '$routeParams', '$http', '$location', '$modal', '$q', 'Database', 'Aside', function ($scope, $rootScope, $routeParams, $http, $location, $modal, $q, Database, Aside)
{
$scope.database = Database;
$scope.selectedMenu = null;
$scope.menus = [];
Expand Down Expand Up @@ -47,7 +48,6 @@ angular.module('header.controller', ['database.services']).controller("HeaderCon
return menu == $scope.selectedMenu ? 'active' : '';
}
$scope.$on('$routeChangeSuccess', function (scope, next, current) {
//$scope.refreshMetadata();
$scope.setSelected();
});
$scope.refreshMetadata = function () {
Expand All @@ -68,11 +68,16 @@ angular.module('header.controller', ['database.services']).controller("HeaderCon
$scope.manageServer = function () {
$location.path("/server");
}
$rootScope.$on('request:logout', function () {
$scope.logout()
})
$scope.logout = function () {
Database.disconnect(function () {
$scope.menus = [];
$location.path("/");
});
}

}]);
}
])
;
3 changes: 2 additions & 1 deletion app/scripts/controllers/login-controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var login = angular.module('login.controller', ['database.services']);
login.controller("LoginController", ['$scope', '$routeParams', '$location', '$modal', '$q', 'Database', 'DatabaseApi', 'Notification', '$http', function ($scope, $routeParams, $location, $modal, $q, Database, DatabaseApi, Notification, $http) {
login.controller("LoginController", ['$scope','$rootScope', '$routeParams', '$location', '$modal', '$q', 'Database', 'DatabaseApi', 'Notification', '$http', function ($scope,$rootScope, $routeParams, $location, $modal, $q, Database, DatabaseApi, Notification, $http) {

$scope.server = "http://localhost:2480"

Expand Down Expand Up @@ -84,6 +84,7 @@ login.controller("LoginController", ['$scope', '$routeParams', '$location', '$mo

}

$rootScope.$broadcast("request:logout");
$scope.deleteDb = function () {
var modalScope = $scope.$new(true);
modalScope.name = $scope.database;
Expand Down
11 changes: 11 additions & 0 deletions app/scripts/services/database-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,13 @@ database.factory('Database', function (DatabaseApi, localStorageService) {
getPropertyTableFromResults: function (results) {
var self = this;
var headers = new Array;
var temp = false;
results.forEach(function (element, index, array) {
var tmp = Object.keys(element);
if (headers.length == 0) {
if (element["@rid"] && element["@rid"].startsWith('#-')) {
temp = true;
}
headers = headers.concat(tmp);
} else {
var tmp2 = tmp.filter(function (element, index, array) {
Expand All @@ -453,6 +457,13 @@ database.factory('Database', function (DatabaseApi, localStorageService) {
var all = headers.filter(function (element, index, array) {
return self.exclude.indexOf(element) == -1;
});
if (temp) {
if (all.indexOf("@rid") != -1)
all.splice(all.indexOf("@rid"), 1)
if (all.indexOf("@version") != -1)
all.splice(all.indexOf("@version"), 1)

}
return all;
}

Expand Down

0 comments on commit 5f75b41

Please sign in to comment.