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();
}

View File

@@ -55,15 +55,15 @@
%span{"ng-if" => "syncStatus.total > 0"} {{syncStatus.current}}/{{syncStatus.total}}
%p.bold.mt-10.red.block{"ng-if" => "syncStatus.error"} Error syncing: {{syncStatus.error.message}}
%a.block.mt-15{"href" => "{{dashboardURL()}}", "target" => "_blank"} → Standard File Dashboard
%a.block.mt-15{"href" => "{{dashboardURL()}}", "target" => "_blank"} Data Dashboard
%a.block.mt-5{"ng-click" => "showCredentials = !showCredentials"} Show Credentials
%section.gray-bg.mt-10.medium-padding{"ng-if" => "showCredentials"}
%label.block
Encryption key:
.wrap.normal.mt-1 {{encryptionKey()}}
.wrap.normal.mt-1.selectable {{encryptionKey()}}
%label.block.mt-5.mb-0
Server password:
.wrap.normal.mt-1 {{serverPassword() ? serverPassword() : 'Not available. Sign out then sign back in to compute.'}}
.wrap.normal.mt-1.selectable {{serverPassword() ? serverPassword() : 'Not available. Sign out then sign back in to compute.'}}
%a.block.mt-5{"ng-click" => "newPasswordData.changePassword = !newPasswordData.changePassword"} Change Password
%section.gray-bg.mt-10.medium-padding{"ng-if" => "newPasswordData.changePassword"}

View File

@@ -104,5 +104,6 @@
%h2.blue Install
%p.faded Enter an install link
%form.mt-10.mb-10
%input.form-control{:autofocus => 'autofocus', :name => 'url', :required => true,
%input.form-control{:autofocus => 'autofocus', :name => 'url', :required => true, :autocomplete => "off",
:type => 'url', 'ng-model' => 'formData.installLink', "ng-keyup" => "$event.keyCode == 13 && submitInstallLink();"}
%p.blue{"ng-if" => "formData.successfullyInstalled"} Successfully installed extension.