forked from saurabh/orbit4-5
Update import announcement and archive
This commit is contained in:
parent
5a88f5dd47
commit
264e61df15
|
@ -85,6 +85,8 @@ class Admin::ImportController < OrbitAdminController
|
||||||
if archive_file.nil?
|
if archive_file.nil?
|
||||||
archive_file = ArchiveFile.new
|
archive_file = ArchiveFile.new
|
||||||
archive_file.rss2_sn = file['Sn']
|
archive_file.rss2_sn = file['Sn']
|
||||||
|
else
|
||||||
|
archive_file.archive_file_multiples.destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
archive_file.title_translations = file['title']
|
archive_file.title_translations = file['title']
|
||||||
|
@ -122,6 +124,9 @@ class Admin::ImportController < OrbitAdminController
|
||||||
if bulletin.nil?
|
if bulletin.nil?
|
||||||
bulletin = Bulletin.new
|
bulletin = Bulletin.new
|
||||||
bulletin.rss2_sn = news['Sn']
|
bulletin.rss2_sn = news['Sn']
|
||||||
|
else
|
||||||
|
bulletin.bulletin_links.destroy_all
|
||||||
|
bulletin.bulletin_files.destroy_all
|
||||||
end
|
end
|
||||||
bulletin.update_user = current_user
|
bulletin.update_user = current_user
|
||||||
bulletin.title_translations = news['Title']
|
bulletin.title_translations = news['Title']
|
||||||
|
|
|
@ -148,7 +148,7 @@
|
||||||
<div id="links-module" class="module" onclick="importModule('links')">
|
<div id="links-module" class="module" onclick="importModule('links')">
|
||||||
<div class="lead muted">
|
<div class="lead muted">
|
||||||
<i class="icons-link"></i><br/>
|
<i class="icons-link"></i><br/>
|
||||||
<%= t("web_link.web_link") %>
|
<%= t("web_resource") %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var url;
|
var url;
|
||||||
var categories=null;
|
var categories=null;
|
||||||
var dataList=null;
|
var dataList=Array();
|
||||||
var module;
|
var module;
|
||||||
var progress = 0;
|
var progress = 0;
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@
|
||||||
|
|
||||||
var importModule = function(m){
|
var importModule = function(m){
|
||||||
module = m;
|
module = m;
|
||||||
dataList=null;
|
dataList=Array();
|
||||||
categories=null;
|
categories=null;
|
||||||
|
|
||||||
$('#import-progress i').attr('class', $('#'+m+'-module i').attr('class')+' module-icon');
|
$('#import-progress i').attr('class', $('#'+m+'-module i').attr('class')+' module-icon');
|
||||||
|
@ -379,69 +379,82 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var getModuleCategories= function(){
|
var getModuleCategories= function(){
|
||||||
$("#import-progress .bar").css('width','0%');
|
|
||||||
$("#import-progress-text").html("Importing Categories<br/><br/>");
|
$("#import-progress-text").html("Importing Categories<br/><br/>");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
url: '<%= admin_import_module_categories_path %>',
|
url: '<%= admin_import_module_categories_path %>',
|
||||||
data: {module: module, url: url+'?module='+module+'&type=categories'},
|
data: {module: module, url: url+'?module='+module+'&type=categories'}
|
||||||
success: function(data){
|
}).done(function(data){
|
||||||
$("#import-progress .bar").css('width','100%');
|
$("#import-progress-text").html("Done<br/><br/>");
|
||||||
$("#import-progress-text").html("Done<br/><br/>");
|
categories = data;
|
||||||
categories = data;
|
getModuleDataList();
|
||||||
getModuleDataList();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var getModuleDataList = function(){
|
var getModuleDataList = function(){
|
||||||
$("#import-progress .bar").css('width','0%');
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
url: '<%= admin_import_module_data_list_path %>',
|
url: '<%= admin_import_module_data_list_path %>',
|
||||||
data: {module: module, url: url+'?module='+module+'&type=dataList'},
|
data: {module: module, url: url+'?module='+module+'&type=dataList'}
|
||||||
success: function(data){
|
}).done(function(data){
|
||||||
dataList = data;
|
for(Sn in data){
|
||||||
importModuleDatas();
|
dataList.push({'Sn':Sn, 'category':data[Sn]});
|
||||||
}
|
}
|
||||||
|
importModuleDatas();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var importModuleDatas = function(){
|
var importModuleDatas = function(){
|
||||||
$("#import-progress .bar").css('width','0%');
|
progress = 0;
|
||||||
$("#import-progress-text").html("Start import...<br/><br/>");
|
$("#import-progress-text").html("Start import...<br/><br/>");
|
||||||
|
|
||||||
if(dataList!=null && categories!=null){
|
if(dataList!=null && categories!=null){
|
||||||
$.each(dataList, function(key, val){
|
importModuleData();
|
||||||
$.ajax({
|
|
||||||
type: 'GET',
|
|
||||||
dataType: 'json',
|
|
||||||
async: true,
|
|
||||||
url: '<%= admin_import_module_data_path %>?&category='+categories[val]['id'],
|
|
||||||
data: {module: module, url: url+'?module='+module+'&type=data&Sn='+key},
|
|
||||||
success: function(data){
|
|
||||||
progress++;
|
|
||||||
percentage = parseInt((progress/Object.keys(dataList).length)*100)+'%';
|
|
||||||
$("#import-progress .bar").css('width',percentage);
|
|
||||||
$("#import-progress-text").html(progress+' / '+Object.keys(dataList).length+'<br/>'+percentage);
|
|
||||||
if(percentage=="100%"){
|
|
||||||
$("#import-progress").delay(1000).fadeOut(300,function(){
|
|
||||||
$("#import-head").fadeIn(0);
|
|
||||||
$("#import-modules").fadeIn(300);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}else{
|
}else{
|
||||||
setTimeout("importModuleDatas()", 3000);
|
setTimeout("importModuleDatas()", 3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var importModuleData = function(){
|
||||||
|
if(progress>=dataList.length) return;
|
||||||
|
|
||||||
|
var data = dataList[progress];
|
||||||
|
var category_id = categories[data['category']]['id'];
|
||||||
|
var Sn = data['Sn'];
|
||||||
|
|
||||||
|
percentage = parseInt((progress/dataList.length)*100)+'%';
|
||||||
|
$("#import-progress-text").html(progress+' / '+dataList.length+'<br/>'+percentage);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'json',
|
||||||
|
url: '<%= admin_import_module_data_path %>',
|
||||||
|
data: {
|
||||||
|
module: module,
|
||||||
|
url: url+'?module='+module+'&type=data&Sn='+Sn,
|
||||||
|
type: 'data',
|
||||||
|
category: category_id
|
||||||
|
}
|
||||||
|
}).done(function(data){
|
||||||
|
progress++;
|
||||||
|
percentage = parseInt((progress/dataList.length)*100)+'%';
|
||||||
|
$("#import-progress .bar").css('width',percentage);
|
||||||
|
$("#import-progress-text").html(progress+' / '+dataList.length+'<br/>'+percentage);
|
||||||
|
|
||||||
|
if(percentage=="100%"){
|
||||||
|
$("#import-progress").delay(1000).fadeOut(300,function(){
|
||||||
|
$("#import-head").fadeIn(0);
|
||||||
|
$("#import-modules").fadeIn(300);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
importModuleData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var checkSiteUrl = function(){
|
var checkSiteUrl = function(){
|
||||||
url = $(".import-url").val();
|
url = $(".import-url").val();
|
||||||
url = (url[url.length-1]=='/') ? url+'export/' : url+'/export/';
|
url = (url[url.length-1]=='/') ? url+'export/' : url+'/export/';
|
||||||
|
|
Loading…
Reference in New Issue