Skip to content

Commit

Permalink
BI-866: Distapy user's queries and dashboards on edit user page
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinkwiatkowski committed Sep 7, 2015
1 parent 167ec89 commit 138b391
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 71 deletions.
46 changes: 34 additions & 12 deletions rd_ui/app/scripts/controllers/admin_controllers.js
@@ -1,4 +1,11 @@
(function() {
var dateFormatter = function(date) {
value = moment(date);
if (!value) return "-";
return value.format("DD/MM/YY HH:mm");
}


var AdminStatusCtrl = function($scope, Events, $http, $timeout) {
Events.record(currentUser, "view", "page", "admin/status");
$scope.$parent.pageTitle = "System Status";
Expand Down Expand Up @@ -118,10 +125,37 @@

// tables
$scope.groups = groups;

user.queries().$promise.then(function(result){
$scope.queries = result;
});

user.dashboards().$promise.then(function(result){
$scope.dashboards = result;
})

})
}
}

$scope.queryColumns = [
{label: "Name", map: "name"},
{label: "Created At", map: "created_at", formatFunction: dateFormatter},
{label: "Actions", cellTemplateUrl: "/views/admin_user_form_query_actions_cell.html"}
];
$scope.dashboardColumns = [
{label: "Name", map: "name"},
{label: "Created At", map: "created_at", formatFunction: dateFormatter},
{label: "Actions", cellTemplateUrl: "/views/admin_user_form_dashboard_actions_cell.html"}
];

$scope.tableConfig = {
isPaginationEnabled: true,
itemsByPage: 50,
maxSize: 8,
isGlobalSearchActivated: false
}

var groups = new Groups();
groups.get().$promise.then(function(result) {

Expand Down Expand Up @@ -225,12 +259,6 @@
admin_users: false
};

var dateFormatter = function(date) {
value = moment(date);
if (!value) return "-";
return value.format("DD/MM/YY HH:mm");
}

var permissionsFormatter = function(permissions) {
value = permissions.join(', ');
if (!value) return "-";
Expand Down Expand Up @@ -514,12 +542,6 @@
$location.path("/");
}

var dateFormatter = function(date) {
value = moment(date);
if (!value) return "-";
return value.format("DD/MM/YY HH:mm");
}

var permissionsFormatter = function(permissions) {
value = permissions.join(', ');
if (!value) return "-";
Expand Down
8 changes: 7 additions & 1 deletion rd_ui/app/scripts/services/resources.js
Expand Up @@ -449,6 +449,12 @@
User.new = function (data) {
return new User(data);
};
User.prototype.queries = function(){
return $resource('/api/users/:id/queries', {id: '@id'}).query({id: this.id});
}
User.prototype.dashboards = function(){
return $resource('/api/users/:id/dashboards', {id: '@id'}).query({id: this.id});
}
return User;
}

Expand Down Expand Up @@ -481,7 +487,7 @@
.factory('Group', ['$resource', Group])
.factory('Users', ['$resource', Users])
.factory('User', ['$resource', User])
.factory('Widget', ['$resource', 'Query', Widget])
.factory('Widget', ['$resource', 'Query', Widget])
.factory('Table', ['$resource', Table]);

})();
16 changes: 14 additions & 2 deletions rd_ui/app/views/admin_user_form.html
Expand Up @@ -2,7 +2,7 @@
<div class="container">
<h1>Edit User<br /><br /></h1>

<form ng-submit="submit()" class="form-horizontal" role="form" id="userAddForm" novalidate ng-controller="AdminUserFormCtrl">
<form ng-submit="submit()" class="form-horizontal" role="form" id="userAddForm" novalidate>
<div class="form-group">
<label for="inputName1" class="col-sm-2 control-label">Name</label>
<div style="padding-top:7px;" class="col-sm-4">
Expand Down Expand Up @@ -33,5 +33,17 @@ <h1>Edit User<br /><br /></h1>
<input class="form-control" id="inputName3" placeholder="Email" type="hidden" ng-model="email" name="text">
</form>

<div class="row">
<div class="col-lg-6">
<h2>{{name}}'s queries</h2>
<smart-table rows="queries" columns="queryColumns" config="tableConfig" class="table table-condensed table-hover"></smart-table>
</div>
<div class="col-lg-6">
<h2>{{name}}'s dashboards</h2>
<smart-table rows="dashboards" columns="dashboardColumns" config="tableConfig" class="table table-condensed table-hover"></smart-table>
</div>
</div>



</div>
</div>
@@ -0,0 +1 @@
<a ng-href="/dashboard/{{dataRow.name}}">View</a>
1 change: 1 addition & 0 deletions rd_ui/app/views/admin_user_form_query_actions_cell.html
@@ -0,0 +1 @@
<a ng-href="/queries/{{dataRow.id}}">View</a>

0 comments on commit 138b391

Please sign in to comment.