Skip to content
Snippets Groups Projects
Commit 9e82da24 authored by Kyle Doherty's avatar Kyle Doherty
Browse files

Merge branch 'activity_feed' of github.com:metabase/metabase-init into activity_feed

parents a1756a25 7a8a802b
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,6 @@ var Card = angular.module('metabase.card', [
'metabase.filters',
'metabase.directives',
'metabase.services',
'metabase.aceeditor.directives',
'metabase.card.services',
'metabase.card.controllers',
'metabase.card.directives'
......
......@@ -96,6 +96,8 @@
}
.bg-gold { background-color: var(--gold-color); }
.bg-purple { background-color: var(--purple-color); }
.bg-green { background-color: var(--green-color); }
/* alt */
.bg-alt { background-color: var(--alt-color); }
......
'use strict';
/*global ace*/
import { Provider } from 'react-redux';
import { DevTools, DebugPanel } from 'redux-devtools/lib/react';
......@@ -223,76 +221,12 @@ NavbarDirectives.directive('mbProfileLink', [function () {
return {
restrict: 'A',
template: '<div mb-react-component="ProfileLink"></div>',
controller: function ($scope) {
controller: ['$scope', function ($scope) {
$scope.ProfileLink = ProfileLink;
},
}],
scope: {
context: '=',
user: '='
},
};
}]);
var MetabaseACEEditorDirectives = angular.module('metabase.aceeditor.directives', ['ui.ace']);
MetabaseACEEditorDirectives.directive('mbAceSqlEditor', function() {
function controller($scope, Metabase) {
$scope.aceLoaded = function(aceEditor) {
if ($scope.onLoad) {
var fn = $scope.onLoad();
if (fn) fn(aceEditor);
}
var aceLanguageTools = ace.require('ace/ext/language_tools');
aceEditor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
});
aceLanguageTools.addCompleter({
getCompletions: function(editor, session, pos, prefix, callback) {
if (prefix.lengh === 0 || !$scope.database) {
console.log("$scope.database is not set, unable to perform autocompletions for ACE Editor :'(");
callback(null, []);
return;
}
Metabase.db_autocomplete_suggestions({
dbId: $scope.database,
prefix: prefix
}, function(results) {
// transform results of the API call into what ACE expects
var js_results = results.map(function(result) {
return {
name: result[0],
value: result[0],
meta: result[1]
};
});
callback(null, js_results);
}, function(error) {
console.log(error);
callback(null, []);
});
}
});
// focus the editor on load to allow faster editing of query
aceEditor.focus();
};
}
return {
restrict: 'E',
templateUrl: '/app/components/editor/editor.html',
controller: ['$scope', 'Metabase', controller],
scope: {
sql: '=', // the text of the editor itself
database: '=', // int ID of DB to use for autocompletion
onLoad: '&onload' // optional callback of the form fn(aceEditor) in case we need a reference to it (e.g. so we can aceEditor.focus())
}
};
});
......@@ -18,7 +18,7 @@ export default class Activity extends Component {
super();
this.state = { error: null, userColors: {} };
this.colorClasses = ['bg-brand', 'bg-gold', 'bg-error', 'bg-gold', 'bg-gold', 'bg-gold'];
this.colorClasses = ['bg-brand', 'bg-purple', 'bg-error', 'bg-green', 'bg-gold', 'bg-grey-2'];
this.styles = {
modelLink: {
......@@ -47,7 +47,7 @@ export default class Activity extends Component {
const colors = [1,2,3,4,5];
const maxColorUsed = (_.isEmpty(userColors)) ? 0 : _.max(_.values(userColors));
var currColor = (maxColorUsed && maxColorUsed < 5) ? maxColorUsed : 0;
var currColor = (maxColorUsed && maxColorUsed < colors.length) ? maxColorUsed : 0;
for (var item of activity) {
if (!(item.user_id in userColors)) {
......@@ -243,8 +243,8 @@ export default class Activity extends Component {
<div className="full flex flex-column">
<div className="">
{ activity.length === 0 ?
<div className="flex flex-column layout-centered">
<span className="QuestionCircle">?</span>
<div className="flex flex-column layout-centered mt4">
<span className="QuestionCircle">!</span>
<div className="text-normal mt3 mb1">Hmmm, looks like nothing has happened yet.</div>
<div className="text-normal text-grey-2">Save a question and get this baby going!</div>
</div>
......
......@@ -34,13 +34,20 @@ export default class RecentViews extends Component {
<span className="pl1">Recents</span>
</div>
<div className="bordered rounded bg-white">
<ul className="px3 py1">
{recentViews.map(item =>
<li key={item.id} className="py1">
<a className="link text-dark" href={Urls.modelToUrl(item.model, item.model_id)}>{item.model_object.name}</a>
</li>
)}
</ul>
{recentViews.length > 0 ?
<ul className="px3 py1">
{recentViews.map(item =>
<li key={item.id} className="py1">
<a className="link text-dark ml1" href={Urls.modelToUrl(item.model, item.model_id)}>{item.model_object.name}</a>
</li>
)}
</ul>
:
<div className="flex flex-column layout-centered text-normal text-grey-2">
<span className="QuestionCircle mt4">!</span>
<p className="p3 text-centered text-grey-4">You haven't looked at any Dashboards or Questions recently?</p>
</div>
}
</div>
</div>
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment