multiple exts, sync adapter register

This commit is contained in:
Mo Bitar
2017-05-16 14:25:30 -05:00
parent 5ec4797d85
commit 62d22c93da
6 changed files with 60 additions and 23 deletions

View File

@@ -134,11 +134,7 @@ class Item {
return [];
}
isEncrypted() {
return this.encryptionEnabled() && this.content.substring(0, 3) === '001' ? true : false;
}
encryptionEnabled() {
return this.enc_item_key;
doNotEncrypt() {
return false;
}
}

View File

@@ -0,0 +1,32 @@
class SyncAdapter extends Item {
constructor(json_obj) {
super(json_obj);
}
mapContentToLocalProperties(contentObject) {
super.mapContentToLocalProperties(contentObject)
this.url = contentObject.url;
}
structureParams() {
var params = {
url: this.url,
};
_.merge(params, super.structureParams());
return params;
}
toJSON() {
return {uuid: this.uuid}
}
get content_type() {
return "SF|Extension";
}
doNotEncrypt() {
return true;
}
}

View File

@@ -27,14 +27,14 @@ class ItemParams {
__params() {
let encryptionVersion = "001";
var itemCopy = _.cloneDeep(this.item);
console.assert(!this.item.dummy, "Item is dummy, should not have gotten here.", this.item.dummy)
var params = {uuid: this.item.uuid, content_type: this.item.content_type, deleted: this.item.deleted, created_at: this.item.created_at};
if(this.keys) {
if(this.keys && !this.item.doNotEncrypt()) {
EncryptionHelper.encryptItem(itemCopy, this.keys, encryptionVersion);
params.content = itemCopy.content;
params.enc_item_key = itemCopy.enc_item_key;

View File

@@ -73,29 +73,37 @@ class GlobalExtensionsMenu {
$scope.submitInstallLink = function() {
var link = $scope.formData.installLink;
if(!link) {
var fullLink = $scope.formData.installLink;
if(!fullLink) {
return;
}
var completion = function() {
$scope.formData.installLink = "";
$scope.formData.successfullyInstalled = true;
}
var type = getParameterByName("type", link);
var links = fullLink.split(",");
for(var link of links) {
var type = getParameterByName("type", link);
if(type == "sf" || type == "sync") {
$scope.handleSyncAdapterLink(link, completion);
} else if(type == "editor") {
$scope.handleEditorLink(link, completion);
} else if(link.indexOf(".css") != -1 || type == "theme") {
$scope.handleThemeLink(link, completion);
} else {
$scope.handleActionLink(link, completion);
if(type == "sf") {
$scope.handleSyncAdapterLink(link, completion);
} else if(type == "editor") {
$scope.handleEditorLink(link, completion);
} else if(link.indexOf(".css") != -1 || type == "theme") {
$scope.handleThemeLink(link, completion);
} else {
$scope.handleActionLink(link, completion);
}
}
}
$scope.handleSyncAdapterLink = function(link, completion) {
var ext = new SyncAdapter({url: link});
ext.setDirty(true);
modelManager.addItem(ext);
syncManager.sync();
completion();
}