Working telegram test

This commit is contained in:
Jason House
2020-08-15 11:22:41 +09:00
parent d3b10a7206
commit edc641b246
4 changed files with 15 additions and 30 deletions

View File

@@ -11,7 +11,7 @@
'use strict';
import {Payload} from '/js/modules/payload.min.js';
import {saveTelegramNotifications} from '/js/modules/telegram-notifications.min.js'
import {saveTelegramNotifications, testTelegramNotifications} from '/js/modules/telegram-notifications.min.js'
let plexSpinner, plexSaveSuccess, plexSaveError, plexTestSuccess, plexTestError, plexDeleteSuccess, plexDeleteError,
plexDuplicateError;
@@ -101,6 +101,7 @@ document.addEventListener('DOMContentLoaded', function () {
//Exposing function for onClick() from module
window.saveTelegram = saveTelegramNotifications;
window.testTelegram = testTelegramNotifications;
});
function testTmdbKey() {

File diff suppressed because one or more lines are too long

View File

@@ -10,38 +10,23 @@
import {getNotificationTypes} from '/js/modules/notification-types.min.js';
export function testTelegram() {
export async function testTelegramNotifications() {
'use strict';
getUserAsync('yourUsernameHere').then(data => console.log(data));
$.ajax({
type: "PUT",
url: `/configuration/test/plex/${machineIdentifier}`,
dataType: "json",
success: function (result) {
hideAllAlertsAndSpinners();
if (result && result.success) {
plexTestSuccess.show();
} else {
plexTestError.show();
}
}, error: function () {
hideAllAlertsAndSpinners();
plexTestError.show();
}
});
}
async function testTelegramNotifications() {
let response = await fetch('/notifications/test/0', {
method: 'put',
});
let data = await response.json()
return data;
if (response.ok) {
//Good
} else {
//Show errors
}
}
export async function saveTelegramNotifications() {
'use strict';
const body = {};
body.botId = document.getElementById('telegramBotId').value;
body.chatId = document.getElementById('telegramChatId').value;
@@ -60,12 +45,11 @@ export async function saveTelegramNotifications() {
},
body: JSON.stringify(body)
});
let data = await response.json()
if (response.ok) {
//Good
} else {
//Show errors
}
let data = await response.json()
return data;
}

View File

@@ -388,10 +388,10 @@
</select>
</div>
<div class="form-group">
<a class="btn btn-info" href="javascript:void(0)" id="testTelegram" onclick="testTelegram();"
type="button">Test</a>
<a class="btn btn-primary" href="javascript:void(0)" id="saveTelegram" onclick="saveTelegram();"
type="button">Save</a>
<a class="btn btn-info" href="javascript:void(0)" id="testTelegram" onclick="testTelegram();"
type="button">Test</a>
</div>
</form>
<hr class="thin">