diff --git a/rd_ui/app/scripts/app.js b/rd_ui/app/scripts/app.js index 83d9fafa..11f2ab5a 100644 --- a/rd_ui/app/scripts/app.js +++ b/rd_ui/app/scripts/app.js @@ -90,6 +90,10 @@ angular.module('redash', [ templateUrl: '/views/index.html', controller: 'IndexCtrl' }); + $routeProvider.when('/personal', { + templateUrl: '/views/personal.html', + controller: 'PersonalIndexCtrl' + }); $routeProvider.otherwise({ redirectTo: '/' }); diff --git a/rd_ui/app/scripts/controllers/controllers.js b/rd_ui/app/scripts/controllers/controllers.js index a16c012b..d2ca5b6c 100644 --- a/rd_ui/app/scripts/controllers/controllers.js +++ b/rd_ui/app/scripts/controllers/controllers.js @@ -192,7 +192,7 @@ $(window).click(function () { notifications.getPermissions(); }); - } + }; var IndexCtrl = function ($scope, Events, Dashboard) { Events.record(currentUser, "view", "page", "homepage"); @@ -206,11 +206,29 @@ }); } } - } + }; + + var PersonalIndexCtrl = function ($scope, Events, Dashboard, Query) { + Events.record(currentUser, "view", "page", "homepage"); + $scope.$parent.pageTitle = "Home"; + + $scope.recentQueries = Query.recent(); + $scope.recentDashboards = Dashboard.recent(); + + $scope.archiveDashboard = function (dashboard) { + if (confirm('Are you sure you want to delete "' + dashboard.name + '" dashboard?')) { + Events.record(currentUser, "archive", "dashboard", dashboard.id); + dashboard.$delete(function () { + $scope.$parent.reloadDashboards(); + }); + } + } + }; angular.module('redash.controllers', []) .controller('QueriesCtrl', ['$scope', '$http', '$location', '$filter', 'Query', QueriesCtrl]) .controller('IndexCtrl', ['$scope', 'Events', 'Dashboard', IndexCtrl]) + .controller('PersonalIndexCtrl', ['$scope', 'Events', 'Dashboard', 'Query', PersonalIndexCtrl]) .controller('MainCtrl', ['$scope', '$location', 'Dashboard', 'notifications', MainCtrl]) .controller('QuerySearchCtrl', ['$scope', '$location', '$filter', 'Events', 'Query', QuerySearchCtrl]); })(); diff --git a/rd_ui/app/scripts/services/dashboards.js b/rd_ui/app/scripts/services/dashboards.js index 2b515572..6da28c63 100644 --- a/rd_ui/app/scripts/services/dashboards.js +++ b/rd_ui/app/scripts/services/dashboards.js @@ -1,6 +1,12 @@ (function () { var Dashboard = function($resource) { - var resource = $resource('/api/dashboards/:slug', {slug: '@slug'}); + var resource = $resource('/api/dashboards/:slug', {slug: '@slug'}, { + recent: { + method: 'get', + isArray: true, + url: "/api/dashboards/recent" + }}); + resource.prototype.canEdit = function() { return currentUser.hasPermission('admin') || currentUser.canEdit(this); } diff --git a/rd_ui/app/scripts/services/resources.js b/rd_ui/app/scripts/services/resources.js index 08ad8c68..fae28acf 100644 --- a/rd_ui/app/scripts/services/resources.js +++ b/rd_ui/app/scripts/services/resources.js @@ -377,7 +377,18 @@ }; var Query = function ($resource, QueryResult, DataSource) { - var Query = $resource('/api/queries/:id', {id: '@id'}, {search: {method: 'get', isArray: true, url: "/api/queries/search"}}); + var Query = $resource('/api/queries/:id', {id: '@id'}, + { + search: { + method: 'get', + isArray: true, + url: "/api/queries/search" + }, + recent: { + method: 'get', + isArray: true, + url: "/api/queries/recent" + }}); Query.newQuery = function () { return new Query({ diff --git a/rd_ui/app/views/personal.html b/rd_ui/app/views/personal.html new file mode 100644 index 00000000..834f2cd7 --- /dev/null +++ b/rd_ui/app/views/personal.html @@ -0,0 +1,28 @@ +