SAAS-1064: Publish action for library context menu
This commit is contained in:
parent
50996a081f
commit
ed33714340
5 changed files with 139 additions and 29 deletions
|
@ -1174,13 +1174,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
if (oItems.publish !== undefined) {
|
||||
if (data.ftype === "audioclip") {
|
||||
callback = function() {
|
||||
alert("TODO: Publish track with ID " + data.id);
|
||||
|
||||
/*
|
||||
$.get(oItems.publish.url, {format: "json"}, function(json){
|
||||
//AIRTIME.playlist.fileMdEdit(json);
|
||||
alert("derp");
|
||||
});*/
|
||||
AIRTIME.publish.publishTrack(data.id);
|
||||
};
|
||||
}
|
||||
oItems.publish.callback = callback;
|
||||
|
|
|
@ -1,32 +1,39 @@
|
|||
var endpoint = 'rest/podcast/';
|
||||
|
||||
var podcastApp = angular.module('podcast', [])
|
||||
.controller('RestController', function($scope, $http, podcast) {
|
||||
$scope.podcast = podcast;
|
||||
AIRTIME.tabs.setActiveTabName($scope.podcast.title);
|
||||
|
||||
$scope.savePodcast = function() {
|
||||
$http.put(endpoint + $scope.podcast.id, { csrf_token: jQuery("#csrf").val(), podcast: $scope.podcast })
|
||||
.success(function() {
|
||||
// TODO
|
||||
});
|
||||
};
|
||||
|
||||
$scope.discard = function() {
|
||||
AIRTIME.tabs.getActiveTab().close();
|
||||
$scope.podcast = {};
|
||||
};
|
||||
});
|
||||
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
var mod;
|
||||
|
||||
|
||||
if (AIRTIME.podcast === undefined) {
|
||||
AIRTIME.podcast = {};
|
||||
}
|
||||
|
||||
mod = AIRTIME.podcast;
|
||||
|
||||
var endpoint = 'rest/podcast/';
|
||||
|
||||
//AngularJS app
|
||||
var podcastApp = angular.module('podcast', [])
|
||||
.controller('RestController', function($scope, $http, podcast) {
|
||||
|
||||
//We take a podcast object in as a parameter rather fetching the podcast by ID here because
|
||||
//when you're creating a new podcast, we already have the object from the result of the POST. We're saving
|
||||
//a roundtrip by not fetching it again here.
|
||||
$scope.podcast = podcast;
|
||||
AIRTIME.tabs.setActiveTabName($scope.podcast.title);
|
||||
|
||||
$scope.savePodcast = function() {
|
||||
$http.put(endpoint + $scope.podcast.id, { csrf_token: jQuery("#csrf").val(), podcast: $scope.podcast })
|
||||
.success(function() {
|
||||
// TODO
|
||||
});
|
||||
};
|
||||
|
||||
$scope.discard = function() {
|
||||
AIRTIME.tabs.getActiveTab().close();
|
||||
$scope.podcast = {};
|
||||
};
|
||||
});
|
||||
|
||||
function _bulkAction(method, callback) {
|
||||
var selected = $("#podcast_table").find(".selected"),
|
||||
ids = [];
|
||||
|
|
101
airtime_mvc/public/js/airtime/library/publish.js
Normal file
101
airtime_mvc/public/js/airtime/library/publish.js
Normal file
|
@ -0,0 +1,101 @@
|
|||
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
var mod;
|
||||
|
||||
if (AIRTIME.publish === undefined) {
|
||||
AIRTIME.publish = {};
|
||||
}
|
||||
|
||||
mod = AIRTIME.publish;
|
||||
|
||||
var endpoint = 'rest/media/';
|
||||
var dialogUrl = 'library/publish-dialog';
|
||||
var PUBLISH_APP_NAME = 'publish';
|
||||
|
||||
|
||||
//AngularJS app
|
||||
var publishApp = angular.module(PUBLISH_APP_NAME, [])
|
||||
.controller('RestController', function($scope, $http, mediaId) {
|
||||
|
||||
$http.get(endpoint + mediaId, { csrf_token: jQuery("#csrf").val() })
|
||||
.success(function(json) {
|
||||
console.log(json);
|
||||
$scope.media = json;
|
||||
AIRTIME.tabs.setActiveTabName($scope.media.track_title);
|
||||
});
|
||||
|
||||
$scope.save = function() {
|
||||
$http.put(endpoint + $scope.media.id, { csrf_token: jQuery("#csrf").val(), media: $scope.media })
|
||||
.success(function() {
|
||||
// TODO
|
||||
});
|
||||
};
|
||||
|
||||
$scope.discard = function() {
|
||||
AIRTIME.tabs.getActiveTab().close();
|
||||
$scope.media = {};
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
var selected = $("#podcast_table").find(".selected"),
|
||||
ids = [];
|
||||
var selectedData = AIRTIME.library.podcastTableWidget.getSelectedRows();
|
||||
selectedData.forEach(function(el) {
|
||||
ids.push(el.id);
|
||||
});*/
|
||||
|
||||
function _bootstrapAngularApp(mediaId) {
|
||||
publishApp.value('mediaId', mediaId);
|
||||
var wrapper = AIRTIME.tabs.getActiveTab().contents.find(".editor_pane_wrapper");
|
||||
wrapper.attr("ng-controller", "RestController");
|
||||
angular.bootstrap(wrapper.get(0), [PUBLISH_APP_NAME]);
|
||||
}
|
||||
|
||||
mod.publishSelectedTracks = function() {
|
||||
/*
|
||||
_bulkAction("GET", function(json) {
|
||||
json.forEach(function(el) {
|
||||
var uid = AIRTIME.library.MediaTypeStringEnum.FILE+"_"+el.id;
|
||||
var mediaId = el.id;
|
||||
|
||||
$http.get(dialogUrl, { csrf_token: jQuery("#csrf").val() })
|
||||
.success(function(json) {
|
||||
|
||||
AIRTIME.tabs.openTab(json, uid, null);
|
||||
_bootstrapAngularApp(mediaId);
|
||||
});
|
||||
});
|
||||
});*/
|
||||
|
||||
};
|
||||
|
||||
mod.publishTrack = function(mediaId) {
|
||||
|
||||
jQuery.get(dialogUrl, { csrf_token: jQuery("#csrf").val() })
|
||||
.success(function(html) {
|
||||
|
||||
var jsonWrapper = {'html' : html}; //Silly wrapper to make the openTab function happy
|
||||
AIRTIME.tabs.openTab(jsonWrapper, mediaId);
|
||||
_bootstrapAngularApp(mediaId);
|
||||
});
|
||||
|
||||
/*
|
||||
_bulkAction("GET", function(json) {
|
||||
json.forEach(function(el) {
|
||||
var uid = AIRTIME.library.MediaTypeStringEnum.FILE+"_"+el.id;
|
||||
|
||||
$http.get(dialogUrl, { csrf_token: jQuery("#csrf").val() })
|
||||
.success(function(json) {
|
||||
|
||||
AIRTIME.tabs.openTab(json, uid, null);
|
||||
_bootstrapAngularApp(el.media);
|
||||
});
|
||||
});
|
||||
});*/
|
||||
};
|
||||
|
||||
|
||||
return AIRTIME;
|
||||
}(AIRTIME || {}));
|
Loading…
Add table
Add a link
Reference in a new issue