diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000000..11320e1181b --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,118 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "base" + + # The url from where the 'config.vm.box' box will be fetched if it + # doesn't already exist on the user's system. + # config.vm.box_url = "http://domain.com/path/to/above.box" + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network :forwarded_port, guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network :private_network, ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network :public_network + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider :virtualbox do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file base.pp in the manifests_path directory. + # + # An example Puppet manifest to provision the message of the day: + # + # # group { "puppet": + # # ensure => "present", + # # } + # # + # # File { owner => 0, group => 0, mode => 0644 } + # # + # # file { '/etc/motd': + # # content => "Welcome to your Vagrant-built virtual machine! + # # Managed by Puppet.\n" + # # } + # + # config.vm.provision :puppet do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "site.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision :chef_solo do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { :mysql_password => "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision :chef_client do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end diff --git a/lib/javascript/tools.js b/lib/javascript/tools.js index 450363357e9..e833a68d451 100644 --- a/lib/javascript/tools.js +++ b/lib/javascript/tools.js @@ -50,10 +50,10 @@ function showPlaylistDialog(e, item_type, item_ids) { width: 300, height: 100, autoOpen: false, - position: { - my: 'left+10 top', - of: e - }, + position: { + my: 'left+10 top', + of: e + }, open: function () { closeplaylist = 1; $(document).bind('click', overlayclickclose); @@ -115,10 +115,10 @@ function showBroadcastsDialog(e) { width: 150, height: 70, autoOpen: false, - position: { - my: 'left-180 top', - of: e - }, + position: { + my: 'left-180 top', + of: e + }, open: function () { closebroadcasts = 1; $(document).bind('click', broverlayclickclose); @@ -172,10 +172,10 @@ function showShareDialog(e, object_type, object_id) { width: 200, height: 90, autoOpen: false, - position: { - my: 'left+10 top', - of: e - }, + position: { + my: 'left+10 top', + of: e + }, open: function () { closeshare = 1; $(document).bind('click', shoverlayclickclose); @@ -198,10 +198,10 @@ function showShareDialog(e, object_type, object_id) { } function shoverlayclickclose(e) { - if (closeshare) { - $('#sharedialog').dialog('close'); - } - closeshare = 1; + if (closeshare) { + $('#sharedialog').dialog('close'); + } + closeshare = 1; } function handleShareAction(url) { @@ -241,7 +241,7 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro }); return; } - parent.editLabelChoices = new Array(); + parent.editLabelChoices = new Array(); if (label_choices == undefined && label_choices != '') { // Load tag map $.ajax(jsAjaxServer + '/ajax.server.php?page=tag&action=get_labels', { @@ -259,8 +259,8 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro for (i = 0; i < splitted.length; ++i) { parent.editTagChoices.push($.trim(splitted[i])); } - splitted = label_choices.split(','); - for (i = 0; i < splitted.length; ++i) { + splitted = label_choices.split(','); + for (i = 0; i < splitted.length; ++i) { parent.editLabelChoices.push($.trim(splitted[i])); } @@ -323,7 +323,7 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro availableTags: parent.editTagChoices }); } - if ($('#edit_labels').length > 0) { + if ($('#edit_labels').length > 0) { $('#edit_labels').tagit({ allowSpaces: true, singleField: true, @@ -350,9 +350,9 @@ $(window).resize(function() { function check_inline_song_edit(type, song) { var source = '#' + type + '_select_' + song; if ($(source + ' option:selected').val() == -1) { - $(source).fadeOut(600, function() { - $(this).replaceWith(''); - }); + $(source).fadeOut(600, function() { + $(this).replaceWith(''); + }); } } @@ -361,7 +361,7 @@ function check_inline_song_edit(type, song) { /*********************/ function sortPlaylistRender() { - var eles = $("tbody[id^='sortableplaylist_']"); + var eles = $("tbody[id^='sortableplaylist_']"); if (eles != null) { var len = eles.length; for (var i = 0; i < len; i++) { @@ -374,7 +374,7 @@ function sortPlaylistRender() { } $(document).ready(function () { - sortPlaylistRender(); + sortPlaylistRender(); }); function submitNewItemsOrder(itemId, tableid, rowPrefix, updateUrl, refreshAction) { @@ -384,12 +384,12 @@ function submitNewItemsOrder(itemId, tableid, rowPrefix, updateUrl, refreshActio var table = document.getElementById(tableid); var rowLength = table.rows.length; - var offset = 0; + var offset = 0; var finalOrder = ''; - if ($('#' + tableid).attr('data-offset')) { - offset = $('#' + tableid).attr('data-offset'); - } + if ($('#' + tableid).attr('data-offset')) { + offset = $('#' + tableid).attr('data-offset'); + } for (var i = 0; i < rowLength; ++i) { var row = table.rows[i]; @@ -450,3 +450,216 @@ function show_selected_license_link(license_select) { window.open(link); } } + + +var currentEditId = 0; +//var currentRadioDJId = 0; +function loadUtilsData(formId, path, id) { + + var utilsURL = '//utils.gradio.local/admin/checkupload/path/t?id=' + id +'&path='; + currentEditId = id; + + //$(formId).load(utilsURL + path); + + + var promise = $.ajax({ + url: utilsURL + path, + dataType: "json" + }); + + promise.done(function(response) { + console.debug(response); + //$(formId).prepend(data); + + var tableHTML = ` +
| + | Relevance | +ID | +Tune | +Duration | +Bitrate | +Size | +Action | +
|---|
Oh no, something went wrong!
'); + }); +} + +function mergeDBS(songId, radioDJId) { + + var utilsURL = '//utils.gradio.local/admin/checkupload/merge/t?ampache_song_id=' + songId +'&song_id=' + radioDJId; + + var promise = $.ajax({ + url: utilsURL, + dataType: "json" + }); + + promise.done(function(response) { + console.debug(response); + $('.edit_dialog_content').prepend('Merged!
'); + }); + + promise.fail(function() { + $('.edit_dialog_content').prepend('Oh no, something went wrong!
'); + }); +} + +function showToRadioDBDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_row_prefix) { + var parent = this; + parent.editFormId = 'form#' + edit_form_id; + parent.contentUrl = jsAjaxServer + '/edit.server.php?action=show_edit_object&id=' + edit_id + '&type=' + edit_type; + parent.saveUrl = jsAjaxServer + '/edit.server.php?action=edit_object&id=' + edit_id + '&type=' + edit_type; + parent.editDialogId = ''; + parent.refreshRowPrefix = refresh_row_prefix; + parent.editType = edit_type; + parent.editId = edit_id; + + // Convert choices string ("tag0,tag1,tag2,...") to choices array + parent.editTagChoices = new Array(); + if (tag_choices == undefined && tag_choices != '') { + // Load tag map + $.ajax(jsAjaxServer + '/ajax.server.php?page=tag&action=get_tag_map', { + success: function(data) { + tag_choices = $(data).find('content').text(); + if (tag_choices != '') { + showToRadioDBDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_row_prefix); + } + }, type: 'post', dataType: 'xml' + }); + return; + } + parent.editLabelChoices = new Array(); + if (label_choices == undefined && label_choices != '') { + // Load tag map + $.ajax(jsAjaxServer + '/ajax.server.php?page=tag&action=get_labels', { + success: function(data) { + label_choices = $(data).find('content').text(); + if (label_choices != '') { + showToRadioDBDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_row_prefix); + } + }, type: 'post', dataType: 'xml' + }); + return; + } + var splitted = tag_choices.split(','); + var i; + for (i = 0; i < splitted.length; ++i) { + parent.editTagChoices.push($.trim(splitted[i])); + } + splitted = label_choices.split(','); + for (i = 0; i < splitted.length; ++i) { + parent.editLabelChoices.push($.trim(splitted[i])); + } + + parent.dialog_buttons = {}; + this.dialog_buttons[jsSaveTitle] = function () { + $.ajax({ + url: parent.saveUrl, + type: 'POST', + data: $(parent.editFormId).serializeArray(), + success: function (resp) { + $('#editdialog').dialog('close'); + + if (parent.refreshRowPrefix != '') { + var new_id = $.trim(resp.lastChild.textContent); + + // resp should contain the new identifier, otherwise we take the same as the edited item + if (new_id == '') { + new_id = parent.editId; + } + + var url = jsAjaxServer + '/edit.server.php?action=refresh_updated&type=' + parent.editType + '&id=' + new_id; + // Reload only table + $('#' + parent.refreshRowPrefix + parent.editId).load(url, function() { + // Update the current row identifier with new id + $('#' + parent.refreshRowPrefix + parent.editId).attr('id', parent.refreshRowPrefix + new_id); + }); + } else { + var reloadp = window.location; + var hash = window.location.hash.substring(1); + if (hash && hash.indexOf('.php') > -1) { + reloadp = jsWebPath + '/' + hash; + } + loadContentPage(reloadp); + } + }, + error: function(resp) { + $('#editdialog').dialog('close'); + } + }); + } + this.dialog_buttons[jsCancelTitle] = function() { + $('#editdialog').dialog('close'); + } + + $(parent.editDialogId).dialog({ + title: edit_title, + modal: true, + dialogClass: 'editdialogstyle', + resizable: false, + width: 1400, + autoOpen: false, + show: { effect: 'fade', duration: 400 }, + open: function () { + $(this).load(parent.contentUrl, function() { + if ($('#edit_tags').length > 0) { + $('#edit_tags').tagit({ + allowSpaces: true, + singleField: true, + singleFieldDelimiter: ',', + availableTags: parent.editTagChoices + }); + } + if ($('#edit_labels').length > 0) { + $('#edit_labels').tagit({ + allowSpaces: true, + singleField: true, + singleFieldDelimiter: ',', + availableTags: parent.editLabelChoices + }); + } + }); + }, + close: function (e) { + $(this).empty(); + $(this).dialog('destroy'); + }, + buttons: dialog_buttons + }); + + setTimeout(function(){ + //console.debug( $(parent.editFormId).data("path") ); + loadUtilsData(parent.editFormId, $(parent.editFormId).data("path"), edit_id); + }, 1000); + $('#editdialog').dialog('open'); + +} diff --git a/templates/header.inc.php b/templates/header.inc.php index 78a9109e684..e5ebb5c2b4b 100644 --- a/templates/header.inc.php +++ b/templates/header.inc.php @@ -44,9 +44,9 @@ - -