Added Google Viewer Integration (Preview Microsoft Word, Excel and PowerPoint files)

This commit is contained in:
RainLoop Team 2014-10-31 00:09:53 +04:00
parent 1638b55411
commit 139f412b6a
15 changed files with 254 additions and 42 deletions

View file

@ -117,6 +117,22 @@
return true;
};
AbstractApp.prototype.googlePreviewSupportedCache = null;
/**
* @return {boolean}
*/
AbstractApp.prototype.googlePreviewSupported = function ()
{
if (null === this.googlePreviewSupportedCache)
{
this.googlePreviewSupportedCache = !!Settings.settingsGet('AllowGoogleSocial') &&
!!Settings.settingsGet('AllowGoogleSocialPreview');
}
return this.googlePreviewSupportedCache;
};
/**
* @param {string} sTitle
*/

View file

@ -65,6 +65,15 @@
return this.sServer + '/Raw/' + this.sSubQuery + this.sSpecSuffix + '/ViewAsPlain/' + sDownload;
};
/**
* @param {string} sDownload
* @return {string}
*/
Links.prototype.attachmentFramed = function (sDownload)
{
return this.sServer + '/Raw' + this.sSubQuery + this.sSpecSuffix + '/FramedView/' + sDownload;
};
/**
* @return {string}
*/

View file

@ -1093,10 +1093,19 @@
oData.googleEnable = ko.observable(false);
oData.googleEnable.auth = ko.observable(false);
oData.googleEnable.drive = ko.observable(false);
oData.googleEnable.preview = ko.observable(false);
oData.googleClientID = ko.observable('');
oData.googleClientSecret = ko.observable('');
oData.googleApiKey = ko.observable('');
oData.googleEnable.requireClientSettings = ko.computed(function () {
return oData.googleEnable() && (oData.googleEnable.auth() || oData.googleEnable.drive());
});
oData.googleEnable.requireApiKey = ko.computed(function () {
return oData.googleEnable() && oData.googleEnable.drive();
});
oData.dropboxEnable = ko.observable(false);
oData.dropboxApiKey = ko.observable('');

View file

@ -27,7 +27,7 @@
this.value = oParams.value || '';
this.size = oParams.size || 0;
this.label = oParams.label || '';
this.enable = oParams.enable || true;
this.enable = Utils.isUnd(oParams.enable) ? true : oParams.enable;
this.trigger = oParams.trigger && oParams.trigger.subscribe ? oParams.trigger : null;
this.placeholder = oParams.placeholder || '';

View file

@ -34,6 +34,7 @@
this.folder = '';
this.uid = '';
this.mimeIndex = '';
this.framed = false;
}
_.extend(AttachmentModel.prototype, AbstractModel.prototype);
@ -62,6 +63,7 @@
AttachmentModel.prototype.folder = '';
AttachmentModel.prototype.uid = '';
AttachmentModel.prototype.mimeIndex = '';
AttachmentModel.prototype.framed = false;
/**
* @param {AjaxJsonAttachment} oJsonAttachment
@ -83,6 +85,7 @@
this.folder = oJsonAttachment.Folder;
this.uid = oJsonAttachment.Uid;
this.mimeIndex = oJsonAttachment.MimeIndex;
this.framed = !!oJsonAttachment.Framed;
this.friendlySize = Utils.friendlySize(this.estimatedSize);
this.cidWithOutTags = this.cid.replace(/^<+/, '').replace(/>+$/, '');
@ -120,6 +123,15 @@
return Globals.bAllowPdfPreview && 'application/pdf' === this.mimeType;
};
/**
* @return {boolean}
*/
AttachmentModel.prototype.isFramed = function ()
{
return this.framed && (Globals.__APP__ && Globals.__APP__.googlePreviewSupported()) &&
!this.isPdf() && !this.isText() && !this.isImage();
};
/**
* @return {string}
*/
@ -136,6 +148,14 @@
return Links.attachmentPreview(this.download);
};
/**
* @return {string}
*/
AttachmentModel.prototype.linkFramed = function ()
{
return Links.attachmentFramed(this.download);
};
/**
* @return {string}
*/

View file

@ -49,7 +49,7 @@
'AdminSettingsSecurity', 'Security', 'security');
kn.addSettingsViewModel(require('Settings/Admin/Social'),
'AdminSettingsSocial', 'Social', 'social');
'AdminSettingsSocial', 'Integrations', 'integrations');
kn.addSettingsViewModel(require('Settings/Admin/Plugins'),
'AdminSettingsPlugins', 'Plugins', 'plugins');

View file

@ -128,6 +128,12 @@
});
});
self.googleEnable.preview.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'GoogleEnablePreview': bValue ? '1' : '0'
});
});
self.googleClientID.subscribe(function (sValue) {
Remote.saveAdminConfig(f5, {
'GoogleClientID': Utils.trim(sValue)

View file

@ -82,6 +82,7 @@
this.googleEnable(!!Settings.settingsGet('AllowGoogleSocial'));
this.googleEnable.auth(!!Settings.settingsGet('AllowGoogleSocialAuth'));
this.googleEnable.drive(!!Settings.settingsGet('AllowGoogleSocialDrive'));
this.googleEnable.preview(!!Settings.settingsGet('AllowGoogleSocialPreview'));
this.googleClientID(Settings.settingsGet('GoogleClientID'));
this.googleClientSecret(Settings.settingsGet('GoogleClientSecret'));
this.googleApiKey(Settings.settingsGet('GoogleApiKey'));