duplicate presentation from json file

  • 1
  • Problem
  • Updated 2 years ago
  • Not a Problem
Archived and Closed

This conversation is no longer open for comments or replies and is no longer visible to community members.

Good morning
For projects to the museum, I have the need to duplicate presentations by a service account to the account of production.
I created a site that downloads the presentation as json file locally and it seems correct. The problem comes when I try to import the json file and create the slideshow in your production using API Missing pieces.

The original presentation is http://rva.risevision.com/#/PRESENTAT...
while the presentation imported https://rva.risevision.com/#/PRESENTA...

You have an idea as to why? if you need I can post the json file.
Thanks
Marco
Photo of marco Cordini

marco Cordini

  • 110 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb
Hi Marco,

I'm getting a 404 error for both of those previews. Can you try linking them again?
Photo of marco Cordini

marco Cordini

  • 110 Points 100 badge 2x thumb
Photo of Robb

Robb, Official Rep

  • 76,676 Points 50k badge 2x thumb
Marco,

I don't think we could help in this capacity as we don't know what tool you are using to duplicate and import the JSON,

Would it be easier to copy the entire Presentation HTML as a text or HTML file, and then create it in the new Company that way?
Photo of marco Cordini

marco Cordini

  • 110 Points 100 badge 2x thumb
Hi Rob,
I have a function created by me using this code:

getPresentation function (id) {
console.log ( 'getPresentation');
// Getting parameter values
var _id = id;
_fields var = "";

// Create a JavaScript object Which will be converted to JSON
var parameters = {};
if (_id) {
parameters [ 'id'] = _id;
}
if (_fields) {
parameters [ 'fields'] = _fields;
}

gapi.client.load (API_NAME, API_VER, function () {
var request = gapi.client.core.presentation.get (parameters);

request.execute (function (jsonResp, rawResp) {

var = presName jsonResp.item.name;

var blob = new Blob ([JSON.stringify (jsonResp)], {type: "application / json"})

var name = presName + ".json";

saveAs (blob, name, true);
});
}, ROOT);

That saves me the presentation in a json file

Then I created two other functions that read the json file and in theory should re-create the presentation under another person / company

loadFile function () {
var input, files, fr;

if (typeof window.FileReader! == 'function') {
alert ( "The File API is not supported on this browser yet.");
return;
}

input = document.getElementById ( 'fileinput');
if (! input) {
alert ( "Um, could not find the fileinput element.");
}
else if (! input.files) {
alert ( "This browser does not Seem to support the` files` property of inputs file. ");
}
else if (! input.files [0]) {
alert ( "Please select a before clicking 'Load' 'files);
}
else {
// For (var f input.files)
for (var i = 0, f, f = input.files [i]; i ++)
{

file = f; // input.files [f];

fr = new FileReader ();
fr.onload = receivedText;
fr.readAsText (input.files [i]);
}
document.getElementById ( 'fileinput'). value = "";
}
}

receivedText function (e) {
lines = e.target.result;
var = newArr JSON.parse (lines);
var = presName newArr.item.name;
var = presLayout JSON.stringify (newArr.item.layout);

var test = '{ "name": "' + presName + '", "layout":' + presLayout + '}';
addPresentation (test, document.getElementById ( 'listPresentation_companyId'). value);
}
addPresentation function (date, CompanyID) {
console.log ( 'addPresentation');
// Getting parameter values
var = _data JSON.parse (date);
var = _companyId CompanyID;
_fields var = "";

// Create a JavaScript object Which will be converted to JSON
var parameters = {};
if (_data) {
parameters [ 'date'] = _data;
}
if (_companyId) {
parameters [ 'CompanyID'] = _companyId;
}
if (_fields) {
parameters [ 'fields'] = _fields;
}

// Loading and calling the bees passing the parameter object
gapi.client.load (API_NAME, API_VER, function () {
var request = gapi.client.core.presentation.add (parameters);

request.execute (function (jsonResp, rawResp) {

});
}, ROOT);
}
If the page I have a widget text, the function can not create the page completely, as if in the text there was some character that creates some errors

However, if I do a copy / paste I have no problems.

Sorry for my poor english :)

Marco
Photo of marco Cordini

marco Cordini

  • 110 Points 100 badge 2x thumb
This is the json file .. if I can be useful ...

{"item":{"id":"481c8e91-b607-4007-a16f-d88fd6c7ceaa","companyId":"2cd34e96-9da4-41a3-a613-0b341f92c5df","name":"François de Chasseloup-Laubat","publish":0,"layout":"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html>\n\t<head>\n\t\t<script src="\\"\n\t\t<meta">http://digitalsignage.almapro.it/Mant... content="\\"text/html\" http-equiv="\\"content-type\" />\n\t\t<!--meta http-equiv=\"content-type\" content=\"text/html>; charset=UTF-8\"-->\n\t\t<title></title>\n\t\n\t</head>\n\n\t<!--body style=\"width:1080px;height:1920px; margin: 0; overflow: hidden;background:url('http://digitalsignage.almapro.it/Mant...') no-repeat left top;background-size:contain;\" -->\n\t<body style=\"width:100%;height:100%; margin: 0; overflow: hidden;background:url('http://digitalsignage.almapro.it/Mant...') no-repeat left top;background-size:contain;\">\n\t\t<div id="\\"testo\" placeholder="\\"true\" style="\\"width:898px;height:960px;left:184px;top:763px;z-index:3;position:absolute;\">\n\t<div id="\\"Titolo\" placeholder="\\"true\" style="\\"width:900px;height:102px;left:182px;top:647px;z-index:0;position:absolute;\">\n\t<div id="\\"qrcode\" placeholder="\\"true\" style="\\"width:145px;height:159px;left:276px;top:1736px;position:absolute;z-index:2;background:transparent;background-size:contain;\">\n\t\t<div id=\"Ascolta\" placeholder=\"true\" style=\"width:152px;height:152px;left:523px;top:1743px;position:absolute;background:url('http://digitalsignage.almapro.it/Mant...') no-repeat left top;background-size:contain;z-index:1;\" onclick=\"document.getElementById('a1').volume =0.5;document.getElementById('a2').play()\">\t\n\t<audio autoplay="\\"autoplay\" id="\\"a1\" loop="\\"loop\" mediagroup="\\"a11yvid\" preload="\\"metadata\">\n\t\t<source src="\\"http://digitalsignage.almapro.it/Mant...\" type="\\"audio/mp3\\"/">\n\t\n\t<audio id="\\"a2\" mediagroup="\\"a11yvid\" preload="\\"metadata\">\n\t\t<source src="\\"http://digitalsignage.almapro.it/Mant...\" type="\\"audio/mp3\\"/">\n\t\n\t\t<div class="\\"verticalmenu\" id="\\"verticalmenu\">\n\t\t<nav role="\\"navigation\">\n\t\t\t<ul class="\\"nav\">\n\t\t\t\n\t\t\n\t\t\t<div class="\\"stories\">\n\t\t\t\n\t\t\n \n<!-- No scripts after this point -->\n</html>\n","isTemplate":false,"isStoreProduct":false,"revisionStatus":1,"revisionStatusName":"Revised","creationDate":"2016-07-28T09:13:51.791Z","changedBy":"jtg107@gmail.com","changeDate":"2017-01-05T08:18:17.319Z"},"kind":"core#presentationItem","etag":"\"EX5m36NKoRALOdykVrY29S8SlMo/Zr2CG9eWOMCoYbL3Bk_gFCtgaSo\""}}
Photo of Robb

Robb, Official Rep

  • 76,676 Points 50k badge 2x thumb
Marco,

Unfortunately since this is custom code, I don't know if we can be of assistance. 

Would it be possible to copy the entire Presentation HTML as a text or HTML file, and then create it in the new Company that way?
Photo of marco Cordini

marco Cordini

  • 110 Points 100 badge 2x thumb
Hi Rob, sorry for delay.
I found the problem.
I did a couple of tests, and I saw a strange thing.
The widget text, if a font with a space in the name is used, use a single quote as indicatore.Esempio 'times new romans'. When I do the stringify jquery replace the single quote with "& quot" and makes the item no longer usable in the process of page creation.
By the time I solved by making a replace of "& quot" in the layout and in this way it works.
Thanks for your patience.
Marco
Photo of Robb

Robb, Official Rep

  • 76,676 Points 50k badge 2x thumb
Great find Marco, nice work!