First page implemented (home)

This commit is contained in:
Arik Fraimovich 2016-10-30 16:20:09 +02:00
parent 4e0c9af18d
commit da790de60d
6 changed files with 85 additions and 11 deletions

View File

@ -4,17 +4,14 @@
<meta charset="UTF-8">
<title>Redash</title>
<link rel="stylesheet" href="./assets/css/superflat_redash.css">
<link rel="stylesheet" href="./assets/css/redash.css">
<link rel="icon" type="image/png" sizes="32x32" href="./assets/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="./assets/images/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="./assets/images/favicon-16x16.png">
</head>
<body ng-app="app">
<div class="container">
<section>
<app-header></app-header>
<div ng-view></div>
</div>
</section>
</body>
</html>

View File

@ -7,6 +7,9 @@ import ngResource from 'angular-resource';
import uiBootstrap from 'angular-ui-bootstrap';
import { each } from 'underscore';
import './assets/css/superflat_redash.css';
import './assets/css/redash.css';
import * as pages from './pages';
import * as components from './components';
import * as filters from './filters';

View File

@ -0,0 +1,35 @@
<div class="container">
<div class="tile m-t-10 m-b-5">
<div class="t-body p-5">
<a href="queries/new" ng-show="$ctrl.canCreateQuery" class="btn btn-default">New Query</a>
<button ng-show="$ctrl.canCreateDashboard" type="button" class="btn btn-default"
data-toggle="modal" href="#new_dashboard_dialog">New Dashboard
</button>
<a href="alerts/new" class="btn btn-default">New Alert</a>
</div>
</div>
<div class="tile">
<div class="t-body tb-padding">
<div class="row">
<div class="col-md-6">
<p class="f-500 m-b-20 c-black">Recent Dashboards</p>
<div class="list-group">
<a ng-href="dashboard/{{dashboard.slug}}" class="list-group-item" ng-repeat="dashboard in $ctrl.recentDashboards">
{{dashboard.name}}
</a>
</div>
</div>
<div class="col-md-6">
<p class="f-500 m-b-20 c-black">Recent Queries</p>
<div class="list-group">
<a ng-href="queries/{{query.id}}" class="list-group-item"
ng-repeat="query in $ctrl.recentQueries">{{query.name}}</a>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,13 +1,21 @@
class HomeController {
constructor(Dashboard) {
console.log(Dashboard.query());
}
import template from './home.html';
function HomeCtrl($scope, currentUser, Events, Dashboard, Query) {
Events.record(currentUser, 'view', 'page', 'personal_homepage');
// $scope.$parent.pageTitle = 'Home';
// todo: maybe this should come from some serivce as we have this logic elsewhere.
this.canCreateQuery = currentUser.hasPermission('create_query');
this.canCreateDashboard = currentUser.hasPermission('create_dashboard');
this.recentQueries = Query.recent();
this.recentDashboards = Dashboard.recent();
}
export default function (ngModule) {
ngModule.component('pageHome', {
template: '<div>Home {{1923 | durationHumanize}} </div>',
controller: HomeController,
template,
controller: HomeCtrl,
});
return {

View File

@ -0,0 +1,30 @@
import { debounce } from 'underscore';
function Events($http) {
this.events = [];
this.post = debounce(() => {
const events = this.events;
this.events = [];
$http.post('api/events', events);
}, 1000);
this.record = function record(user, action, objectType, objectId, additionalProperties) {
const event = {
user_id: user.id,
action,
object_type: objectType,
object_id: objectId,
timestamp: Date.now() / 1000.0,
};
Object.assign(event, additionalProperties);
this.events.push(event);
this.post();
};
}
export default function (ngModule) {
ngModule.service('Events', Events);
}

View File

@ -2,3 +2,4 @@ export { default as Dashboard } from './dashboard';
export { default as Widget } from './widget';
export { default as Query } from './query';
export { default as QueryResult } from './query_result';
export { default as Events } from './events';