mirror of
https://github.com/getredash/redash.git
synced 2025-12-25 01:03:20 -05:00
WIP
This commit is contained in:
@@ -126,13 +126,13 @@
|
||||
$scope.enabled = !clientConfig.mailSettingsMissing;
|
||||
|
||||
$scope.subscribers = AlertSubscription.query({alertId: $scope.alertId}, function(subscriptions) {
|
||||
$scope.subscribers = _.filter(subscriptions, function(subscription) { return typeof subscription.destination === "undefined"; });
|
||||
$scope.subscribers = _.filter(subscriptions, function(subscription) { return typeof subscription.destination === "undefined"; });
|
||||
});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
angular.module('redash.directives').directive('destinationSubscribers', ['AlertSubscription', 'Destination', 'growl', function (AlertSubscription, Destination, growl) {
|
||||
angular.module('redash.directives').directive('destinationSubscribers', ['$sce', 'AlertSubscription', 'Destination', 'growl', function ($sce, AlertSubscription, Destination, growl) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
@@ -143,15 +143,37 @@
|
||||
controller: function ($scope) {
|
||||
$scope.subscription = {};
|
||||
$scope.subscribers = [];
|
||||
$scope.destinations = Destination.query();
|
||||
$scope.destinations = [];
|
||||
|
||||
Destination.query(function(destinations) {
|
||||
$scope.destinations = destinations;
|
||||
destinations.unshift({name: currentUser.name + ' (Email)', icon: 'fa-envelope', type: 'user'});
|
||||
$scope.subscription.destination = destinations[0];
|
||||
});
|
||||
|
||||
$scope.destinationsDisplay = function(destination) {
|
||||
return '<i class="fa ' + destination.icon + '"></i> ' + destination.name
|
||||
if (destination.destination) {
|
||||
destination = destination;
|
||||
}
|
||||
|
||||
if (destination.user) {
|
||||
destination = {
|
||||
name: destination.user.name + ' (Email)',
|
||||
icon: 'fa-envelope',
|
||||
type: 'user'
|
||||
};
|
||||
}
|
||||
|
||||
if (!destination) {
|
||||
return '';
|
||||
}
|
||||
return $sce.trustAsHtml('<i class="fa ' + destination.icon + '"></i> ' + destination.name);
|
||||
};
|
||||
|
||||
$scope.subscribers = AlertSubscription.query({alertId: $scope.alertId}, function(subscriptions) {
|
||||
$scope.subscribers = _.filter(subscriptions, function(subscription) { return typeof subscription.destination !== "undefined"; });
|
||||
// $scope.subscribers = _.filter(subscriptions, function(subscription) { return typeof subscription.destination !== "undefined"; });
|
||||
});
|
||||
|
||||
$scope.saveSubscriber = function() {
|
||||
$scope.sub = new AlertSubscription({alert_id: $scope.alertId, destination_id: $scope.subscription.destination.id});
|
||||
$scope.sub.$save(function() {
|
||||
@@ -179,7 +201,7 @@
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
template: '<button class="btn btn-primary" ng-click="toggleSubscription()" ng-bind="message"></button>',
|
||||
template: '<button class="btn btn-default" ng-click="toggleSubscription()" ng-bind="message"></button>',
|
||||
controller: function ($scope) {
|
||||
var updateMessage = function() {
|
||||
if ($scope.subscription) {
|
||||
@@ -210,6 +232,7 @@
|
||||
$scope.subscription = new AlertSubscription({alert_id: $scope.alertId});
|
||||
$scope.subscription.$save(function() {
|
||||
$scope.subscribers.push($scope.subscription);
|
||||
console.log($scope.subscribers);
|
||||
updateMessage();
|
||||
}, function() {
|
||||
growl.addErrorMessage("Unsubscription failed.");
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
<div class="p-5">
|
||||
<div class="row">
|
||||
|
||||
<ui-select ng-model="subscription.destination" class="col-sm-10">
|
||||
<ui-select-match>{{$select.selected.name}}</ui-select-match>
|
||||
<ui-select-match><span ng-bind-html="destinationsDisplay($select.selected)"></span></ui-select-match>
|
||||
<ui-select-choices repeat="d in destinations">
|
||||
<span ng-bind-html=destinationsDisplay(d)></span>
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
<button class="btn btn-primary col-sm-2" ng-click="saveSubscriber()">Add</button>
|
||||
<button class="btn btn-default col-sm-2" ng-click="saveSubscriber()">Add</button>
|
||||
</div>
|
||||
|
||||
<div class="list-group">
|
||||
<label>Currently subscribed</label>
|
||||
<div class="list-group-item" ng-repeat="subscriber in subscribers">
|
||||
<span ng-bind-html=destinationsDisplay(subscriber.destination)></span>
|
||||
<button class="btn btn-xs btn-danger pull-right" ng-click="unsubscribe(subscriber)">Unsubscribe</button>
|
||||
<span ng-bind-html=destinationsDisplay(subscriber)></span>
|
||||
<button class="btn btn-xs btn-danger pull-right" ng-click="unsubscribe(subscriber)">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -62,13 +62,10 @@
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-4" ng-if="alert.id">
|
||||
<ul class="tab-nav">
|
||||
<li ng-class="{active: selectedTab == 'users'}"><a ng-click="selectedTab = 'users'">Subscribers</a></li>
|
||||
<li ng-class="{active: selectedTab == 'destinations'}"><a ng-click="selectedTab = 'destinations'">Notification Destinations</a></li>
|
||||
</ul>
|
||||
<strong>Notifications</strong>
|
||||
|
||||
<user-subscribers alert-id="alertId" ng-show="selectedTab == 'users'"></user-subscribers>
|
||||
<destination-subscribers alert-id="alertId" ng-show="selectedTab == 'destinations'"></destination-subscribers>
|
||||
<!--<user-subscribers alert-id="alertId"></user-subscribers>-->
|
||||
<destination-subscribers alert-id="alertId"></destination-subscribers>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="p-5">
|
||||
<div>
|
||||
<div class="p-b-10" ng-show="subscribers.length > 0">
|
||||
<img ng-src="{{s.user.gravatar_url}}" class="img-circle" alt="{{s.id}}" ng-repeat="s in subscribers"/>
|
||||
</div>
|
||||
<div class="p-t-20">
|
||||
<div>
|
||||
<subscribe-button alert-id="alertId" subscribers="subscribers"></subscribe-button>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<form name="dataSourceForm" ng-submit="saveChanges()">
|
||||
<form name="dataSourceForm">
|
||||
<div class="form-group">
|
||||
<label for="dataSourceName">Name</label>
|
||||
<input type="string" class="form-control" name="dataSourceName" ng-model="target.name" required>
|
||||
@@ -16,7 +16,7 @@
|
||||
base-sixty-four-input
|
||||
ng-if="input.type === 'file'">
|
||||
</div>
|
||||
<button class="btn btn-primary" ng-disabled="!dataSourceForm.$valid">Save</button>
|
||||
<button class="btn btn-primary" ng-disabled="!dataSourceForm.$valid" ng-click="saveChanges()">Save</button>
|
||||
<span ng-transclude>
|
||||
|
||||
</span>
|
||||
|
||||
@@ -5,8 +5,7 @@ from redash import settings
|
||||
from redash.destinations import *
|
||||
|
||||
|
||||
class Hipchat(BaseDestination):
|
||||
|
||||
class HipChat(BaseDestination):
|
||||
@classmethod
|
||||
def configuration_schema(cls):
|
||||
return {
|
||||
@@ -45,4 +44,4 @@ class Hipchat(BaseDestination):
|
||||
logging.exception("hipchat send ERROR.")
|
||||
|
||||
|
||||
register(Hipchat)
|
||||
register(HipChat)
|
||||
|
||||
@@ -6,7 +6,6 @@ from redash.destinations import *
|
||||
|
||||
|
||||
class Slack(BaseDestination):
|
||||
|
||||
@classmethod
|
||||
def configuration_schema(cls):
|
||||
return {
|
||||
@@ -14,7 +13,7 @@ class Slack(BaseDestination):
|
||||
'properties': {
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'title': 'Slack webhook URL'
|
||||
'title': 'Slack Webhook URL'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,11 @@ import logging
|
||||
import requests
|
||||
from requests.auth import HTTPBasicAuth
|
||||
|
||||
from redash import models, mail
|
||||
from redash.destinations import *
|
||||
from redash.utils import json_dumps
|
||||
|
||||
|
||||
class Webhook(BaseDestination):
|
||||
|
||||
@classmethod
|
||||
def configuration_schema(cls):
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user