diff --git a/README.md b/README.md index f598919..5627f46 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This mashup provide both export the app to json and import the json file. * measures * snapshots * bookmarks -* ***variables ( in the next release )*** +* variables * app properties - like name, thumbnail, description etc. * load script * fields @@ -57,6 +57,13 @@ After the restore process is finished the app will be saved to preserve the chan * press the "Restore" button and wait for the process to finish. After the process is done the result table will be populated with more detail about the objects that were processed. * That's it! If you have the app already open just refresh the browser tabs where this app is open. +#### Change log +v0.9.0 (03/01/2016) + * add - "variables" support + * update - qsocks to v2.1.5 + * update - serializeapp to v1.0.3 + * fix - no need to refresh the page to switch the apps + Please report and issues in the [Github issue tracker](https://github.com/countnazgul/QS-backup-and-restore-app/issues) ![Screenshot](https://raw.githubusercontent.com/countnazgul/QS-backup-and-restore-app/master/images/backup_and_restore.png) diff --git a/backup-and-restore.html b/backup-and-restore.html index aa75f0c..fa609e5 100644 --- a/backup-and-restore.html +++ b/backup-and-restore.html @@ -11,6 +11,7 @@ + diff --git a/backup-and-restore.js b/backup-and-restore.js index c6e8575..84d7e87 100644 --- a/backup-and-restore.js +++ b/backup-and-restore.js @@ -67,6 +67,7 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, case "measures": case "snapshots": case "bookmarks": + case "variables": for (var i = 0; i < backupContent[name].length; i++) { backupInfos.push({ info: backupContent[name][i].qInfo, @@ -100,7 +101,6 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, if (present == true) { status.forUpdate.push(d) } else { - if (appInfos.qInfos[i].qType != 'folder' && appInfos.qInfos[i].qType != 'internet' && appInfos.qInfos[i].qType != 'ODBC' && appInfos.qInfos[i].qType != 'OLEDB') { status.forDelete.push(appInfos.qInfos[i]) } @@ -134,7 +134,7 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, function deleteObjects() { return Promise.all(status.forDelete.map(function(d) { - //console.log('deleted123') + //console.log(d.qType) if (d.qType === 'measure') { return main.app.destroyMeasure(d.qId).then(function() { return importData.push([d.qType, '', d.qId, 'delete']); @@ -142,15 +142,15 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, } else if (d.qType === 'dimension') { return main.app.destroyDimension(d.qId).then(function() { return importData.push([d.qType, '', d.qId, 'delete']); - });; + }); } else if (d.qType === 'snapshot' || d.qType === 'bookmark') { return main.app.destoryBookmark(d.qId).then(function() { return importData.push([d.qType, '', d.qId, 'delete']); - });; + }); } else if (d.qType === 'variable') { return main.app.destroyVariableById(d.qId).then(function() { return importData.push([d.qType, '', d.qId, 'delete']); - });; + }); } else { return main.app.destroyObject(d.qId).then(function() { return importData.push([d.qType, '', d.qId, 'delete']); @@ -169,6 +169,10 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, return main.app.createDimension(d.data).then(function(msg) { return importData.push(['dimension', d.data.qMetaDef.title, d.info.qId, 'create']); }) + } else if (d.info.qType === 'variable') { + return main.app.createVariableEx(d.data).then(function(msg) { + return importData.push(['variable', d.data.qName, d.info.qId, 'create']); + }) } else if (d.info.qType === 'snapshot' || d.info.qType === 'bookmark') { return main.app.createBookmark(d.data).then(function(msg) { var snapTitle; @@ -203,6 +207,24 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, return importData.push(['dimension', d.data.qMetaDef.title, d.info.qId, 'modify']); }); }) + } else if (d.info.qType === 'variable') { + // qDef = JSON.stringify(d.data.qDefinition); + // qName = JSON.stringify(d.data.qName); + // var patches = [{ + // "qOp": "replace", + // "qPath": "/qDefinition", + // "qValue": qDef + // },{ + // "qOp": "replace", + // "qPath": "/qName", + // "qValue": qName + // }]; + + return main.app.getVariableById(d.info.qId).then(function(obj) { + return obj.setProperties(d.data).then(function(msg) { + return importData.push(['variable', d.data.qName, d.info.qId, 'modify']); + }); + }) } else if (d.info.qType === 'snapshot' || d.info.qType === 'bookmark') { return main.app.getBookmark(d.info.qId).then(function(obj) { return obj.setProperties(d.data).then(function(msg) { @@ -266,6 +288,31 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, }) } + function getVariables(app) { + + return app.createSessionObject({ + qVariableListDef: { + qType: 'variable', + qShowReserved: false, + qShowConfig: false, + qData: { + info: '/qDimInfos' + }, + qMeta: {} + }, + qInfo: { qId: "VariableList", qType: "VariableList" } + }).then(function (list) { + return list.getLayout().then(function (layout) { + return Promise.all(layout.qVariableList.qItems.map(function (d) { + return app.getVariableById(d.qInfo.qId).then(function (variable) { + return variable.getProperties().then(function(properties) { return properties; }); + }); + })); + }); + }); + + }; + $("#open").on("click", function() { $('#openDoc').css('visibility', 'hidden'); $('#loadingImg').css('display', 'inline-block'); @@ -289,6 +336,7 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, .then(function(info) { appInfos = info; + //console.log(JSON.stringify(appInfos)) main.app.getConnections().then(function(connections) { for (var i = 0; i < connections.length; i++) { appInfos.qInfos.push({ @@ -297,6 +345,18 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, }) } + getVariables(main.app).then(function(variables) { + // console.log(variables) + + for (var i = 0; i < variables.length; i++) { + appInfos.qInfos.push({ + qId: variables[i].qInfo.qId, + qType: variables[i].qInfo.qType + }) + } + + }) + $('#json').prop('disabled', false); $('#loadingImg').css('display', 'none'); $('#openDoc').css('visibility', 'visible'); @@ -350,12 +410,13 @@ require(['jquery', 'qsocks', 'serializeApp', 'dataTables'], function($, qsocks, insertObjects(), updateObjects(), setScript(), - setAppProperties(), - main.app.doSave() + setAppProperties() ]) .then(function(results) { + main.app.doSave().then(function(results) { GenerateTable() }); + }); }) diff --git a/backup-and-restore.qext b/backup-and-restore.qext index dba6129..6387f82 100644 --- a/backup-and-restore.qext +++ b/backup-and-restore.qext @@ -1,7 +1,7 @@ { "type": "mashup", "name": "Backup and Restore", - "version": "0.8.2", + "version": "0.9.0", "description": "Bachup and restore QS app", "preview": "images/preview.png", "homepage": "https://github.com/countnazgul/QS-backup-and-restore-app", diff --git a/backup-and-restore.zip b/backup-and-restore.zip index 8e47589..4bce863 100644 Binary files a/backup-and-restore.zip and b/backup-and-restore.zip differ