Add support for the Hipchat room notification API
This commit is contained in:
parent
35bd28a77e
commit
32ea1d194f
7 changed files with 156 additions and 3 deletions
|
@ -513,6 +513,41 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
|||
$provide.factory('StringBuilderService', ['$sce', 'UtilService', function($sce, UtilService) {
|
||||
var stringBuilderService = {};
|
||||
|
||||
stringBuilderService.buildUrl = function(value_or_func, metadata) {
|
||||
var url = value_or_func;
|
||||
if (typeof url != 'string') {
|
||||
url = url(metadata);
|
||||
}
|
||||
|
||||
// Find the variables to be replaced.
|
||||
var varNames = [];
|
||||
for (var i = 0; i < url.length; ++i) {
|
||||
var c = url[i];
|
||||
if (c == '{') {
|
||||
for (var j = i + 1; j < url.length; ++j) {
|
||||
var d = url[j];
|
||||
if (d == '}') {
|
||||
varNames.push(url.substring(i + 1, j));
|
||||
i = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replace all variables found.
|
||||
for (var i = 0; i < varNames.length; ++i) {
|
||||
var varName = varNames[i];
|
||||
if (!metadata[varName]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
url = url.replace('{' + varName + '}', metadata[varName]);
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
stringBuilderService.buildString = function(value_or_func, metadata) {
|
||||
var fieldIcons = {
|
||||
'username': 'user',
|
||||
|
@ -1089,6 +1124,23 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
|||
'help_url': 'https://www.flowdock.com/account/tokens'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'hipchat',
|
||||
'title': 'HipChat Room Notification',
|
||||
'icon': 'hipchat-icon',
|
||||
'fields': [
|
||||
{
|
||||
'name': 'room_id',
|
||||
'type': 'string',
|
||||
'title': 'Room ID #'
|
||||
},
|
||||
{
|
||||
'name': 'notification_token',
|
||||
'type': 'string',
|
||||
'title': 'Notification Token'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -4830,7 +4882,7 @@ quayApp.directive('createExternalNotificationDialog', function () {
|
|||
'counter': '=counter',
|
||||
'notificationCreated': '¬ificationCreated'
|
||||
},
|
||||
controller: function($scope, $element, ExternalNotificationData, ApiService, $timeout) {
|
||||
controller: function($scope, $element, ExternalNotificationData, ApiService, $timeout, StringBuilderService) {
|
||||
$scope.currentEvent = null;
|
||||
$scope.currentMethod = null;
|
||||
$scope.status = '';
|
||||
|
@ -4930,6 +4982,15 @@ quayApp.directive('createExternalNotificationDialog', function () {
|
|||
}, 1000);
|
||||
};
|
||||
|
||||
$scope.getHelpUrl = function(field, config) {
|
||||
var helpUrl = field['help_url'];
|
||||
if (!helpUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return StringBuilderService.buildUrl(helpUrl, config);
|
||||
};
|
||||
|
||||
$scope.$watch('counter', function(counter) {
|
||||
if (counter) {
|
||||
$scope.clearCounter++;
|
||||
|
|
Reference in a new issue