mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Inital work on Twitter notifications
This commit is contained in:
parent
e05365a669
commit
2fbf7a4114
22 changed files with 683 additions and 18 deletions
13
src/UI/Content/oauthLand.html
Normal file
13
src/UI/Content/oauthLand.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>oauth landing page</title>
|
||||
<script><!--
|
||||
window.opener.onCompleteOauth(window.location.search, function() { window.close(); });
|
||||
--></script>
|
||||
</head>
|
||||
<body>
|
||||
Shouldn't see this
|
||||
</body>
|
||||
</html>
|
7
src/UI/Form/ActionTemplate.hbs
Normal file
7
src/UI/Form/ActionTemplate.hbs
Normal file
|
@ -0,0 +1,7 @@
|
|||
<div class="form-group {{#if advanced}}advanced-setting{{/if}}">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
|
||||
<div class="col-sm-5">
|
||||
<button class="form-control x-path {{name}}" data-value="{{value}}">{{label}}</button>
|
||||
</div>
|
||||
</div>
|
|
@ -29,6 +29,10 @@ var _fieldBuilder = function(field) {
|
|||
return _templateRenderer.call(field, 'Form/SelectTemplate');
|
||||
}
|
||||
|
||||
if (field.type === 'hidden') {
|
||||
return _templateRenderer.call(field, 'Form/HiddenTemplate');
|
||||
}
|
||||
|
||||
if (field.type === 'path') {
|
||||
return _templateRenderer.call(field, 'Form/PathTemplate');
|
||||
}
|
||||
|
@ -37,6 +41,11 @@ var _fieldBuilder = function(field) {
|
|||
return _templateRenderer.call(field, 'Form/TagTemplate');
|
||||
}
|
||||
|
||||
if (field.type === 'action') {
|
||||
return _templateRenderer.call(field, 'Form/ActionTemplate');
|
||||
}
|
||||
|
||||
|
||||
return _templateRenderer.call(field, 'Form/TextboxTemplate');
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1 @@
|
|||
<div class="form-group hidden">
|
||||
<label class="col-sm-3 control-label">{{label}}</label>
|
||||
|
||||
<div class="col-sm-5">
|
||||
<input type="text" name="fields.{{order}}.value" validation-name="{{name}}" spellcheck="false" class="form-control"/>
|
||||
</div>
|
||||
{{> FormHelpPartial}}
|
||||
</div>
|
||||
<input type="hidden" name="fields.{{order}}.value" validation-name="{{name}}" spellcheck="false"/>
|
|
@ -13,8 +13,11 @@ var view = Marionette.ItemView.extend({
|
|||
template : 'Settings/Notifications/Edit/NotificationEditViewTemplate',
|
||||
|
||||
ui : {
|
||||
onDownloadToggle : '.x-on-download',
|
||||
onUpgradeSection : '.x-on-upgrade',
|
||||
onDownloadToggle : '.x-on-download',
|
||||
onUpgradeSection : '.x-on-upgrade',
|
||||
tags : '.x-tags',
|
||||
indicator : '.x-indicator',
|
||||
authorizedNotificationButton : '.AuthorizeNotification'
|
||||
tags : '.x-tags',
|
||||
modalBody : '.modal-body',
|
||||
formTag : '.x-form-tag',
|
||||
|
@ -23,7 +26,8 @@ var view = Marionette.ItemView.extend({
|
|||
|
||||
events : {
|
||||
'click .x-back' : '_back',
|
||||
'change .x-on-download' : '_onDownloadChanged'
|
||||
'change .x-on-download' : '_onDownloadChanged',
|
||||
'click .AuthorizeNotification' : '_onAuthorizeNotification'
|
||||
},
|
||||
|
||||
_deleteView : DeleteView,
|
||||
|
@ -81,7 +85,15 @@ var view = Marionette.ItemView.extend({
|
|||
} else {
|
||||
this.ui.onUpgradeSection.hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_onAuthorizeNotification : function(e) {
|
||||
var self = this;
|
||||
self.ui.indicator.show();
|
||||
this.model.connectData(this.ui.authorizedNotificationButton.data('value')).always(function(newValues) {
|
||||
self.ui.indicator.hide();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
AsModelBoundView.call(view);
|
||||
|
|
|
@ -3,6 +3,66 @@ var DeepModel = require('backbone.deepmodel');
|
|||
var Messenger = require('../Shared/Messenger');
|
||||
|
||||
module.exports = DeepModel.extend({
|
||||
connectData : function(action) {
|
||||
var self = this;
|
||||
|
||||
this.trigger('connect:sync');
|
||||
|
||||
var promise = $.Deferred();
|
||||
|
||||
var callAction = function(action) {
|
||||
var params = {};
|
||||
params.url = self.collection.url + '/connectData/' + action;
|
||||
params.contentType = 'application/json';
|
||||
params.data = JSON.stringify(self.toJSON());
|
||||
params.type = 'POST';
|
||||
params.isValidatedCall = true;
|
||||
|
||||
$.ajax(params).fail(promise.reject).success(function(response) {
|
||||
if (response.action)
|
||||
{
|
||||
|
||||
if (response.action === "openwindow")
|
||||
{
|
||||
var connectResponseWindow = window.open(response.url);
|
||||
var selfWindow = window;
|
||||
selfWindow.onCompleteOauth = function(query, callback) {
|
||||
delete selfWindow.onCompleteOauth;
|
||||
if (response.nextStep) { callAction(response.nextStep + query); }
|
||||
else { promise.resolve(response); }
|
||||
callback();
|
||||
};
|
||||
return;
|
||||
}
|
||||
else if (response.action === "updatefields")
|
||||
{
|
||||
Object.keys(response.fields).forEach(function(field) {
|
||||
self.set(field, response.fields[field]);
|
||||
self.attributes.fields.forEach(function(fieldDef) {
|
||||
if (fieldDef.name === field) { fieldDef.value = response.fields[field]; }
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
if (response.nextStep) { callAction(response.nextStep); }
|
||||
else { promise.resolve(response); }
|
||||
});
|
||||
};
|
||||
|
||||
callAction(action);
|
||||
|
||||
Messenger.monitor({
|
||||
promise : promise,
|
||||
successMessage : 'Connecting for \'{0}\' completed'.format(this.get('name')),
|
||||
errorMessage : 'Connecting for \'{0}\' failed'.format(this.get('name'))
|
||||
});
|
||||
|
||||
promise.fail(function(response) {
|
||||
self.trigger('connect:failed', response);
|
||||
});
|
||||
|
||||
return promise;
|
||||
},
|
||||
test : function() {
|
||||
var self = this;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue