mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
channelmapper
This commit is contained in:
parent
2e4591b9ae
commit
c750ba55b4
1 changed files with 83 additions and 36 deletions
|
@ -1,10 +1,15 @@
|
||||||
define(["dialogHelper", "loading", "connectionManager", "globalize", "actionsheet", "emby-input", "paper-icon-button-light", "emby-button", "listViewStyle", "material-icons", "formDialogStyle"], function(dialogHelper, loading, connectionManager, globalize, actionsheet) {
|
define(["dialogHelper", "loading", "connectionManager", "globalize", "actionsheet", "emby-input", "paper-icon-button-light", "emby-button", "listViewStyle", "material-icons", "formDialogStyle"], function (dialogHelper, loading, connectionManager, globalize, actionsheet) {
|
||||||
"use strict";
|
"use strict";
|
||||||
return function(options) {
|
|
||||||
|
return function (options) {
|
||||||
function parentWithClass(elem, className) {
|
function parentWithClass(elem, className) {
|
||||||
for (; !elem.classList || !elem.classList.contains(className);)
|
for (; !elem.classList || !elem.classList.contains(className);) {
|
||||||
if (!(elem = elem.parentNode)) return null;
|
if (!(elem = elem.parentNode)) {
|
||||||
return elem
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapChannel(button, channelId, providerChannelId) {
|
function mapChannel(button, channelId, providerChannelId) {
|
||||||
|
@ -19,33 +24,35 @@ define(["dialogHelper", "loading", "connectionManager", "globalize", "actionshee
|
||||||
providerChannelId: providerChannelId
|
providerChannelId: providerChannelId
|
||||||
},
|
},
|
||||||
dataType: "json"
|
dataType: "json"
|
||||||
}).then(function(mapping) {
|
}).then(function (mapping) {
|
||||||
var listItem = parentWithClass(button, "listItem");
|
var listItem = parentWithClass(button, "listItem");
|
||||||
button.setAttribute("data-providerid", mapping.ProviderChannelId), listItem.querySelector(".secondary").innerHTML = getMappingSecondaryName(mapping, currentMappingOptions.ProviderName), loading.hide()
|
button.setAttribute("data-providerid", mapping.ProviderChannelId);
|
||||||
})
|
listItem.querySelector(".secondary").innerHTML = getMappingSecondaryName(mapping, currentMappingOptions.ProviderName);
|
||||||
|
loading.hide();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChannelsElementClick(e) {
|
function onChannelsElementClick(e) {
|
||||||
var btnMap = parentWithClass(e.target, "btnMap");
|
var btnMap = parentWithClass(e.target, "btnMap");
|
||||||
|
|
||||||
if (btnMap) {
|
if (btnMap) {
|
||||||
var channelId = btnMap.getAttribute("data-id");
|
var channelId = btnMap.getAttribute("data-id");
|
||||||
var providerChannelId = btnMap.getAttribute("data-providerid");
|
var providerChannelId = btnMap.getAttribute("data-providerid");
|
||||||
var menuItems = currentMappingOptions.ProviderChannels.map(function(m) {
|
var menuItems = currentMappingOptions.ProviderChannels.map(function (m) {
|
||||||
return {
|
return {
|
||||||
name: m.Name,
|
name: m.Name,
|
||||||
id: m.Id,
|
id: m.Id,
|
||||||
selected: m.Id.toLowerCase() === providerChannelId.toLowerCase()
|
selected: m.Id.toLowerCase() === providerChannelId.toLowerCase()
|
||||||
}
|
};
|
||||||
}).sort(function (a, b) {
|
}).sort(function (a, b) {
|
||||||
return a.name.localeCompare(b.name);
|
return a.name.localeCompare(b.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
actionsheet.show({
|
actionsheet.show({
|
||||||
positionTo: btnMap,
|
positionTo: btnMap,
|
||||||
items: menuItems
|
items: menuItems
|
||||||
}).then(function(newChannelId) {
|
}).then(function (newChannelId) {
|
||||||
mapChannel(btnMap, channelId, newChannelId)
|
mapChannel(btnMap, channelId, newChannelId);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,47 +60,87 @@ define(["dialogHelper", "loading", "connectionManager", "globalize", "actionshee
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
var apiClient = connectionManager.getApiClient(serverId);
|
||||||
return apiClient.getJSON(apiClient.getUrl("LiveTv/ChannelMappingOptions", {
|
return apiClient.getJSON(apiClient.getUrl("LiveTv/ChannelMappingOptions", {
|
||||||
providerId: providerId
|
providerId: providerId
|
||||||
}))
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMappingSecondaryName(mapping, providerName) {
|
function getMappingSecondaryName(mapping, providerName) {
|
||||||
return (mapping.ProviderChannelName || "") + " - " + providerName
|
return (mapping.ProviderChannelName || "") + " - " + providerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTunerChannelHtml(channel, providerName) {
|
function getTunerChannelHtml(channel, providerName) {
|
||||||
var html = "";
|
var html = "";
|
||||||
return html += '<div class="listItem">', html += '<i class="md-icon listItemIcon">dvr</i>', html += '<div class="listItemBody two-line">', html += '<h3 class="listItemBodyText">', html += channel.Name, html += "</h3>", html += '<div class="secondary listItemBodyText">', channel.ProviderChannelName && (html += getMappingSecondaryName(channel, providerName)), html += "</div>", html += "</div>", html += '<button class="btnMap autoSize" is="paper-icon-button-light" type="button" data-id="' + channel.Id + '" data-providerid="' + channel.ProviderChannelId + '"><i class="md-icon">mode_edit</i></button>', html += "</div>"
|
html += '<div class="listItem">';
|
||||||
|
html += '<i class="md-icon listItemIcon">dvr</i>';
|
||||||
|
html += '<div class="listItemBody two-line">';
|
||||||
|
html += '<h3 class="listItemBodyText">';
|
||||||
|
html += channel.Name;
|
||||||
|
html += "</h3>";
|
||||||
|
html += '<div class="secondary listItemBodyText">';
|
||||||
|
|
||||||
|
if (channel.ProviderChannelName) {
|
||||||
|
html += getMappingSecondaryName(channel, providerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
html += "</div>";
|
||||||
|
html += "</div>";
|
||||||
|
html += '<button class="btnMap autoSize" is="paper-icon-button-light" type="button" data-id="' + channel.Id + '" data-providerid="' + channel.ProviderChannelId + '"><i class="md-icon">mode_edit</i></button>';
|
||||||
|
return html += "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEditorHtml() {
|
function getEditorHtml() {
|
||||||
var html = "";
|
var html = "";
|
||||||
return html += '<div class="formDialogContent">', html += '<div class="dialogContentInner dialog-content-centered">', html += '<form style="margin:auto;">', html += "<h1>" + globalize.translate("HeaderChannels") + "</h1>", html += '<div class="channels paperList">', html += "</div>", html += "</form>", html += "</div>", html += "</div>"
|
html += '<div class="formDialogContent">';
|
||||||
|
html += '<div class="dialogContentInner dialog-content-centered">';
|
||||||
|
html += '<form style="margin:auto;">';
|
||||||
|
html += "<h1>" + globalize.translate("HeaderChannels") + "</h1>";
|
||||||
|
html += '<div class="channels paperList">';
|
||||||
|
html += "</div>";
|
||||||
|
html += "</form>";
|
||||||
|
html += "</div>";
|
||||||
|
return html += "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function initEditor(dlg, options) {
|
function initEditor(dlg, options) {
|
||||||
getChannelMappingOptions(options.serverId, options.providerId).then(function(result) {
|
getChannelMappingOptions(options.serverId, options.providerId).then(function (result) {
|
||||||
currentMappingOptions = result;
|
currentMappingOptions = result;
|
||||||
var channelsElement = dlg.querySelector(".channels");
|
var channelsElement = dlg.querySelector(".channels");
|
||||||
channelsElement.innerHTML = result.TunerChannels.map(function(channel) {
|
channelsElement.innerHTML = result.TunerChannels.map(function (channel) {
|
||||||
return getTunerChannelHtml(channel, result.ProviderName)
|
return getTunerChannelHtml(channel, result.ProviderName);
|
||||||
}).join(""), channelsElement.addEventListener("click", onChannelsElementClick)
|
}).join("");
|
||||||
})
|
channelsElement.addEventListener("click", onChannelsElementClick);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
var currentMappingOptions, self = this;
|
|
||||||
self.show = function() {
|
var currentMappingOptions;
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
self.show = function () {
|
||||||
var dialogOptions = {
|
var dialogOptions = {
|
||||||
removeOnClose: !0
|
removeOnClose: true
|
||||||
};
|
};
|
||||||
dialogOptions.size = "small";
|
dialogOptions.size = "small";
|
||||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
var dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
dlg.classList.add("formDialog"), dlg.classList.add("ui-body-a"), dlg.classList.add("background-theme-a");
|
dlg.classList.add("formDialog");
|
||||||
var html = "",
|
dlg.classList.add("ui-body-a");
|
||||||
title = globalize.translate("MapChannels");
|
dlg.classList.add("background-theme-a");
|
||||||
return html += '<div class="formDialogHeader">', html += '<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><i class="md-icon"></i></button>', html += '<h3 class="formDialogHeaderTitle">', html += title, html += "</h3>", html += "</div>", html += getEditorHtml(), dlg.innerHTML = html, initEditor(dlg, options), dlg.querySelector(".btnCancel").addEventListener("click", function() {
|
var html = "";
|
||||||
dialogHelper.close(dlg)
|
var title = globalize.translate("MapChannels");
|
||||||
}), new Promise(function(resolve, reject) {
|
html += '<div class="formDialogHeader">';
|
||||||
dlg.addEventListener("close", resolve), dialogHelper.open(dlg)
|
html += '<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><i class="md-icon"></i></button>';
|
||||||
})
|
html += '<h3 class="formDialogHeaderTitle">';
|
||||||
}
|
html += title;
|
||||||
}
|
html += "</h3>";
|
||||||
|
html += "</div>";
|
||||||
|
html += getEditorHtml();
|
||||||
|
dlg.innerHTML = html;
|
||||||
|
initEditor(dlg, options);
|
||||||
|
dlg.querySelector(".btnCancel").addEventListener("click", function () {
|
||||||
|
dialogHelper.close(dlg);
|
||||||
|
});
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
dlg.addEventListener("close", resolve);
|
||||||
|
dialogHelper.open(dlg);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue