SAAS-1083 - work on publish dialog
This commit is contained in:
parent
05f51a9a2d
commit
e97aa199bd
8 changed files with 198 additions and 41 deletions
|
@ -21,7 +21,7 @@ var AIRTIME = (function (AIRTIME) {
|
|||
tab.setName($scope.podcast.title);
|
||||
$scope.csrf = jQuery("#csrf").val();
|
||||
tab.contents.find("table").attr("id", "podcast_episodes_" + podcast.id);
|
||||
var episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(podcast.episodes, tab);
|
||||
var episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(podcast, tab);
|
||||
|
||||
// Override the switchTo function to reload the table when the tab is focused.
|
||||
// Should help to reduce the number of cases where the frontend doesn't match the state
|
||||
|
@ -162,7 +162,7 @@ var AIRTIME = (function (AIRTIME) {
|
|||
}
|
||||
};
|
||||
|
||||
mod.initPodcastEpisodeDatatable = function(episodes, tab) {
|
||||
mod.initPodcastEpisodeDatatable = function(podcast, tab) {
|
||||
var aoColumns = [
|
||||
/* GUID */ { "sTitle" : "" , "mDataProp" : "guid" , "sClass" : "podcast_episodes_guid" , "bVisible" : false },
|
||||
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "title" , "sClass" : "podcast_episodes_title" , "sWidth" : "170px" },
|
||||
|
@ -194,7 +194,7 @@ var AIRTIME = (function (AIRTIME) {
|
|||
// as json. Doing this caches all the episode data on the front-end,
|
||||
// which means we also don't need to go back to the server for pagination
|
||||
'sAjaxSource' : null,
|
||||
'aaData' : episodes,
|
||||
'aaData' : podcast.episodes,
|
||||
"oColVis": {
|
||||
"sAlign": "right",
|
||||
"aiExclude": [0, 1],
|
||||
|
|
|
@ -15,34 +15,51 @@ var AIRTIME = (function (AIRTIME) {
|
|||
|
||||
//AngularJS app
|
||||
var publishApp = angular.module(PUBLISH_APP_NAME, [])
|
||||
.controller('RestController', function($scope, $http, mediaId, tab) {
|
||||
.controller('RestController', function ($scope, $http, mediaId, tab) {
|
||||
$scope.publishSources = {};
|
||||
|
||||
$http.get(endpoint + mediaId, { csrf_token: jQuery("#csrf").val() })
|
||||
.success(function(json) {
|
||||
console.log(json);
|
||||
$scope.media = json;
|
||||
tab.setName($scope.media.track_title);
|
||||
});
|
||||
function init () {
|
||||
$http.get(endpoint + mediaId, { csrf_token: jQuery("#csrf").val() })
|
||||
.success(function (json) {
|
||||
console.log(json);
|
||||
$scope.media = json;
|
||||
tab.setName($scope.media.track_title);
|
||||
});
|
||||
|
||||
// TODO: implement GET request to endpoint that returns source information
|
||||
// ie. SoundCloud connection + publish status
|
||||
// Get an object containing all sources, their translated labels,
|
||||
// and their publication state for the file with the given ID
|
||||
$http.get(endpoint + mediaId + '/publish-sources', { csrf_token: jQuery("#csrf").val() })
|
||||
.success(function (json) {
|
||||
$scope.sources = json;
|
||||
// Store the data (whether each source should be published to when publish is clicked)
|
||||
// in a separate array so we don't overwrite the labels
|
||||
$scope.publishData = {};
|
||||
jQuery.each($scope.sources.toPublish, function (k, v) {
|
||||
$scope.publishData[k] = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$scope.publish = function() {
|
||||
var sources = {};
|
||||
$.each($scope.publishSources, function(k, v) {
|
||||
if (v) sources[k] = 'publish'; // Tentative TODO: decide on a robust implementation
|
||||
});
|
||||
$http.put(endpoint + $scope.media.id + '/publish', { csrf_token: jQuery("#csrf").val(), sources: sources })
|
||||
.success(function() {
|
||||
// TODO
|
||||
$scope.publish = function () {
|
||||
$http.put(endpoint + mediaId + '/publish',
|
||||
{
|
||||
csrf_token: jQuery("#csrf").val(),
|
||||
sources: $scope.publishData
|
||||
}).success(function () {
|
||||
init();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.discard = function() {
|
||||
$scope.remove = function (source) {
|
||||
// TODO
|
||||
};
|
||||
|
||||
$scope.discard = function () {
|
||||
tab.close();
|
||||
$scope.media = {};
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue