1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +02:00

Merge pull request #249 from documize/section-pdf-files

PDF section type + section level attachments
This commit is contained in:
Harvey Kandola 2019-04-19 13:48:59 +01:00 committed by GitHub
commit 10c57a0ae1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
444 changed files with 46291 additions and 840 deletions

View file

@ -13,9 +13,9 @@ All you need to provide is PostgreSQL, Microsoft SQL Server or any MySQL variant
## Latest Release
[Community Edition: v2.3.2](https://github.com/documize/community/releases)
[Community Edition: v2.4.0](https://github.com/documize/community/releases)
[Enterprise Edition: v2.3.2](https://www.documize.com/downloads)
[Enterprise Edition: v2.4.0](https://www.documize.com/downloads)
> *We provide frequent product updates for both cloud and self-hosted customers.*
>

View file

@ -0,0 +1,4 @@
/* Community Edition */
-- Support per section attachments
ALTER TABLE dmz_doc_attachment ADD COLUMN `c_sectionid` VARCHAR(20) NOT NULL DEFAULT '' COLLATE utf8_bin AFTER `c_docid`;

View file

@ -15,7 +15,7 @@ CREATE TABLE dmz_space_label (
CREATE INDEX idx_space_label_1 ON dmz_space_label (id);
CREATE INDEX idx_space_label_2 ON dmz_space_label (c_orgid);
-- Space table upgrade to support labelling, icon and summary stats
-- Space table upgrade to support label, icon and summary stats
ALTER TABLE dmz_space ADD COLUMN c_desc VARCHAR(200) NOT NULL DEFAULT '';
ALTER TABLE dmz_space ADD COLUMN c_labelid VARCHAR(20) NOT NULL DEFAULT '' COLLATE ucs_basic;
ALTER TABLE dmz_space ADD COLUMN c_icon VARCHAR(20) NOT NULL DEFAULT '';

View file

@ -0,0 +1,4 @@
/* Community Edition */
-- Support per section attachments
ALTER TABLE dmz_doc_attachment ADD COLUMN c_sectionid VARCHAR(20) NOT NULL DEFAULT '' COLLATE ucs_basic;

View file

@ -0,0 +1,4 @@
/* Community Edition */
-- Support per section attachments
ALTER TABLE dmz_doc_attachment ADD c_sectionid NVARCHAR(20) COLLATE Latin1_General_CS_AS NOT NULL DEFAULT '';

View file

@ -217,7 +217,6 @@ func (h *Handler) Get(w http.ResponseWriter, r *http.Request) {
response.WriteServerError(w, method, err)
return
}
if len(a) == 0 {
a = []attachment.Attachment{}
}
@ -299,6 +298,9 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
return
}
// File can be associated with a section as well.
sectionID := request.Query(r, "page")
if !permission.CanChangeDocument(ctx, *h.Store, documentID) {
response.WriteForbiddenError(w)
return
@ -336,6 +338,7 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
a.FileID = random[0:9]
a.Filename = filename.Filename
a.Data = b.Bytes()
a.SectionID = sectionID
ctx.Transaction, err = h.Runtime.Db.Beginx()
if err != nil {

View file

@ -13,6 +13,7 @@ package attachment
import (
"database/sql"
"fmt"
"strings"
"time"
@ -36,8 +37,8 @@ func (s Store) Add(ctx domain.RequestContext, a attachment.Attachment) (err erro
bits := strings.Split(a.Filename, ".")
a.Extension = bits[len(bits)-1]
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_doc_attachment (c_refid, c_orgid, c_docid, c_job, c_fileid, c_filename, c_data, c_extension, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),
a.RefID, a.OrgID, a.DocumentID, a.Job, a.FileID, a.Filename, a.Data, a.Extension, a.Created, a.Revised)
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_doc_attachment (c_refid, c_orgid, c_docid, c_sectionid, c_job, c_fileid, c_filename, c_data, c_extension, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),
a.RefID, a.OrgID, a.DocumentID, a.SectionID, a.Job, a.FileID, a.Filename, a.Data, a.Extension, a.Created, a.Revised)
if err != nil {
err = errors.Wrap(err, "execute insert attachment")
@ -50,7 +51,7 @@ func (s Store) Add(ctx domain.RequestContext, a attachment.Attachment) (err erro
func (s Store) GetAttachment(ctx domain.RequestContext, orgID, attachmentID string) (a attachment.Attachment, err error) {
err = s.Runtime.Db.Get(&a, s.Bind(`
SELECT id, c_refid AS refid,
c_orgid AS orgid, c_docid AS documentid, c_job AS job, c_fileid AS fileid,
c_orgid AS orgid, c_docid AS documentid, c_sectionid AS sectionid, c_job AS job, c_fileid AS fileid,
c_filename AS filename, c_data AS data, c_extension AS extension,
c_created AS created, c_revised AS revised
FROM dmz_doc_attachment
@ -68,7 +69,7 @@ func (s Store) GetAttachment(ctx domain.RequestContext, orgID, attachmentID stri
func (s Store) GetAttachments(ctx domain.RequestContext, docID string) (a []attachment.Attachment, err error) {
err = s.Runtime.Db.Select(&a, s.Bind(`
SELECT id, c_refid AS refid,
c_orgid AS orgid, c_docid AS documentid, c_job AS job, c_fileid AS fileid,
c_orgid AS orgid, c_docid AS documentid, c_sectionid AS sectionid, c_job AS job, c_fileid AS fileid,
c_filename AS filename, c_extension AS extension,
c_created AS created, c_revised AS revised
FROM dmz_doc_attachment
@ -88,11 +89,36 @@ func (s Store) GetAttachments(ctx domain.RequestContext, docID string) (a []atta
return
}
// GetSectionAttachments returns a slice containing the attachment records
// with file data for specified document section.
func (s Store) GetSectionAttachments(ctx domain.RequestContext, sectionID string) (a []attachment.Attachment, err error) {
err = s.Runtime.Db.Select(&a, s.Bind(`
SELECT id, c_refid AS refid,
c_orgid AS orgid, c_docid AS documentid, c_sectionid AS sectionid, c_job AS job, c_fileid AS fileid,
c_filename AS filename, c_data AS data, c_extension AS extension,
c_created AS created, c_revised AS revised
FROM dmz_doc_attachment
WHERE c_orgid=? AND c_sectionid=?
ORDER BY c_filename`),
ctx.OrgID, sectionID)
if err == sql.ErrNoRows {
err = nil
a = []attachment.Attachment{}
}
if err != nil {
err = errors.Wrap(err, "execute select section attachments")
return
}
return
}
// GetAttachmentsWithData returns a slice containing the attachment records (including their data) for document docID, ordered by filename.
func (s Store) GetAttachmentsWithData(ctx domain.RequestContext, docID string) (a []attachment.Attachment, err error) {
err = s.Runtime.Db.Select(&a, s.Bind(`
SELECT id, c_refid AS refid,
c_orgid AS orgid, c_docid AS documentid, c_job AS job, c_fileid AS fileid,
c_orgid AS orgid, c_docid AS documentid, c_sectionid AS sectionid, c_job AS job, c_fileid AS fileid,
c_filename AS filename, c_data AS data, c_extension AS extension,
c_created AS created, c_revised AS revised
FROM dmz_doc_attachment
@ -116,3 +142,11 @@ func (s Store) GetAttachmentsWithData(ctx domain.RequestContext, docID string) (
func (s Store) Delete(ctx domain.RequestContext, id string) (rows int64, err error) {
return s.DeleteConstrained(ctx.Transaction, "dmz_doc_attachment", ctx.OrgID, id)
}
// DeleteSection removes all attachments agasinst a section.
func (s Store) DeleteSection(ctx domain.RequestContext, sectionID string) (rows int64, err error) {
rows, err = s.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM dmz_doc_attachment WHERE c_orgid='%s' AND c_sectionid='%s'",
ctx.OrgID, sectionID))
return
}

View file

@ -30,6 +30,7 @@ import (
indexer "github.com/documize/community/domain/search"
"github.com/documize/community/domain/store"
"github.com/documize/community/model/activity"
"github.com/documize/community/model/attachment"
"github.com/documize/community/model/audit"
"github.com/documize/community/model/doc"
"github.com/documize/community/model/link"
@ -661,6 +662,17 @@ func (h *Handler) FetchDocumentData(w http.ResponseWriter, r *http.Request) {
}
}
// Attachments.
a, err := h.Store.Attachment.GetAttachments(ctx, id)
if err != nil && err != sql.ErrNoRows {
h.Runtime.Log.Error("get attachment", err)
response.WriteServerError(w, method, err)
return
}
if len(a) == 0 {
a = []attachment.Attachment{}
}
// Prepare response.
data := BulkDocumentData{}
data.Document = document
@ -669,6 +681,7 @@ func (h *Handler) FetchDocumentData(w http.ResponseWriter, r *http.Request) {
data.Links = l
data.Spaces = sp
data.Versions = v
data.Attachments = a
ctx.Transaction, err = h.Runtime.Db.Beginx()
if err != nil {
@ -700,12 +713,13 @@ func (h *Handler) FetchDocumentData(w http.ResponseWriter, r *http.Request) {
// BulkDocumentData represents all data associated for a single document.
// Used by FetchDocumentData() bulk data load call.
type BulkDocumentData struct {
Document doc.Document `json:"document"`
Permissions pm.Record `json:"permissions"`
Roles pm.DocumentRecord `json:"roles"`
Spaces []space.Space `json:"folders"`
Links []link.Link `json:"links"`
Versions []doc.Version `json:"versions"`
Document doc.Document `json:"document"`
Permissions pm.Record `json:"permissions"`
Roles pm.DocumentRecord `json:"roles"`
Spaces []space.Space `json:"folders"`
Links []link.Link `json:"links"`
Versions []doc.Version `json:"versions"`
Attachments []attachment.Attachment `json:"attachments"`
}
// Export returns content as self-enclosed HTML file.

View file

@ -22,6 +22,7 @@ import (
"github.com/documize/community/core/env"
"github.com/documize/community/core/request"
"github.com/documize/community/core/response"
"github.com/documize/community/core/secrets"
"github.com/documize/community/core/streamutil"
"github.com/documize/community/core/uniqueid"
"github.com/documize/community/domain"
@ -599,6 +600,8 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
h.Store.Page.DeletePageRevisions(ctx, pageID)
h.Store.Attachment.DeleteSection(ctx, pageID)
// Update doc revised.
h.Store.Document.UpdateRevised(ctx, doc.RefID)
@ -700,6 +703,8 @@ func (h *Handler) DeletePages(w http.ResponseWriter, r *http.Request) {
h.Store.Page.DeletePageRevisions(ctx, page.SectionID)
h.Store.Attachment.DeleteSection(ctx, page.SectionID)
// Draft actions are not logged
if doc.Lifecycle == workflow.LifecycleLive {
h.Store.Activity.RecordUserActivity(ctx, activity.UserActivity{
@ -977,7 +982,27 @@ func (h *Handler) Copy(w http.ResponseWriter, r *http.Request) {
h.Store.Block.IncrementUsage(ctx, model.Page.TemplateID)
}
// Log t actions are not logged
// Copy section attachments.
at, err := h.Store.Attachment.GetSectionAttachments(ctx, pageID)
if err != nil {
h.Runtime.Log.Error(method, err)
}
for i := range at {
at[i].DocumentID = targetID
at[i].SectionID = newPageID
at[i].RefID = uniqueid.Generate()
random := secrets.GenerateSalt()
at[i].FileID = random[0:9]
err1 := h.Store.Attachment.Add(ctx, at[i])
if err1 != nil {
ctx.Transaction.Rollback()
response.WriteServerError(w, method, err1)
h.Runtime.Log.Error(method, err1)
return
}
}
if doc.Lifecycle == workflow.LifecycleLive {
h.Store.Activity.RecordUserActivity(ctx, activity.UserActivity{
SpaceID: doc.SpaceID,

View file

@ -0,0 +1,55 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
package pdfjs
import (
"net/http"
"github.com/documize/community/core/env"
"github.com/documize/community/domain/section/provider"
"github.com/documize/community/domain/store"
)
// Provider represents PDF viewer
type Provider struct {
Runtime *env.Runtime
Store *store.Store
}
// Meta describes us.
func (*Provider) Meta() provider.TypeMeta {
section := provider.TypeMeta{}
section.ID = "d54b0b89-6a91-460b-885d-95518b3dfdca"
section.Title = "PDF Viewer"
section.Description = "View PDF file"
section.ContentType = "pdf"
section.PageType = "section"
section.Order = 9995
return section
}
// Command stub.
func (*Provider) Command(ctx *provider.Context, w http.ResponseWriter, r *http.Request) {
provider.WriteEmpty(w)
}
// Render just sends back HMTL as-is.
func (*Provider) Render(ctx *provider.Context, config, data string) string {
return config
}
// Refresh just sends back data as-is.
func (*Provider) Refresh(ctx *provider.Context, config, data string) string {
return config
}

View file

@ -22,6 +22,7 @@ import (
"github.com/documize/community/domain/section/jira"
"github.com/documize/community/domain/section/markdown"
"github.com/documize/community/domain/section/papertrail"
"github.com/documize/community/domain/section/pdfjs"
"github.com/documize/community/domain/section/plantuml"
"github.com/documize/community/domain/section/provider"
"github.com/documize/community/domain/section/table"
@ -46,6 +47,7 @@ func Register(rt *env.Runtime, s *store.Store) {
provider.Register("airtable", &airtable.Provider{Runtime: rt, Store: s})
provider.Register("plantuml", &plantuml.Provider{Runtime: rt, Store: s})
provider.Register("flowchart", &flowchart.Provider{Runtime: rt, Store: s})
provider.Register("pdf", &pdfjs.Provider{Runtime: rt, Store: s})
p := provider.List()
rt.Log.Info(fmt.Sprintf("Extensions: registered %d section types", len(p)))

View file

@ -207,8 +207,10 @@ type AttachmentStorer interface {
Add(ctx domain.RequestContext, a attachment.Attachment) (err error)
GetAttachment(ctx domain.RequestContext, orgID, attachmentID string) (a attachment.Attachment, err error)
GetAttachments(ctx domain.RequestContext, docID string) (a []attachment.Attachment, err error)
GetSectionAttachments(ctx domain.RequestContext, sectionID string) (a []attachment.Attachment, err error)
GetAttachmentsWithData(ctx domain.RequestContext, docID string) (a []attachment.Attachment, err error)
Delete(ctx domain.RequestContext, id string) (rows int64, err error)
DeleteSection(ctx domain.RequestContext, id string) (rows int64, err error)
}
// LinkStorer defines required methods for persisting content links

View file

@ -40,9 +40,9 @@ func main() {
// product details
rt.Product = domain.Product{}
rt.Product.Major = "2"
rt.Product.Minor = "3"
rt.Product.Patch = "2"
rt.Product.Revision = "190416125622"
rt.Product.Minor = "4"
rt.Product.Patch = "0"
rt.Product.Revision = "190419131243"
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
rt.Product.Edition = domain.CommunityEdition
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,108 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import Modals from '../../mixins/modal';
import Notifier from '../../mixins/notifier';
import Component from '@ember/component';
export default Component.extend(Modals, Notifier, {
appMeta: service(),
session: service(),
editMode: false,
downloadQuery: '',
uploadId: computed('page', function () {
let page = this.get('page');
return `page-uploader-${page.id}`;
}),
uploadLabel: 'Upload Attachments',
uploaderReady: false,
didReceiveAttrs() {
this._super(...arguments);
// For authenticated users we send server auth token.
let qry = '';
if (this.get('session.hasSecureToken')) {
qry = '?secure=' + this.get('session.secureToken');
} else if (this.get('session.authenticated')) {
qry = '?token=' + this.get('session.authToken');
}
this.set('downloadQuery', qry);
},
didRender() {
this._super(...arguments);
// We don't setup uploader if not edit mode.
if (!this.get('editMode') || this.get('uploaderReady')) {
return;
}
let self = this;
let documentId = this.get('document.id');
let pageId = this.get('page.id');
let url = this.get('appMeta.endpoint');
let uploadUrl = `${url}/documents/${documentId}/attachments?page=${pageId}`;
let uploadId = this.get('uploadId');
// Handle upload clicks on button and anything inside that button.
let sel = ['#' + uploadId, '#' + uploadId + ' > div'];
for (var i=0; i < 2; i++) {
let dzone = new Dropzone(sel[i], {
headers: {
'Authorization': 'Bearer ' + self.get('session.authToken')
},
url: uploadUrl,
method: "post",
paramName: 'attachment',
clickable: true,
maxFilesize: 250,
parallelUploads: 5,
uploadMultiple: false,
addRemoveLinks: false,
autoProcessQueue: true,
init: function () {
this.on("success", function (/*file, response*/ ) {
});
this.on("queuecomplete", function () {
self.notifySuccess('Uploaded file');
self.get('onAttachmentUpload')();
});
this.on("addedfile", function ( /*file*/ ) {
});
this.on("error", function (error, msg) {
self.notifyError(msg);
self.notifyError(error);
});
}
});
dzone.on("complete", function (file) {
dzone.removeFile(file);
});
}
this.set('uploaderReady', true);
},
actions: {
onDelete(attachment) {
this.notifySuccess('File deleted');
this.get('onAttachmentDelete')(attachment.id);
}
}
});

View file

@ -46,7 +46,6 @@ export default Component.extend(Modals, Notifier, {
let url = this.get('appMeta.endpoint');
let uploadUrl = `${url}/documents/${documentId}/attachments`;
// Handle upload clicks on button and anything inside that button.
let sel = ['#upload-document-files ', '#upload-document-files > div'];
for (var i=0; i < 2; i++) {
@ -58,7 +57,7 @@ export default Component.extend(Modals, Notifier, {
method: "post",
paramName: 'attachment',
clickable: true,
maxFilesize: 50,
maxFilesize: 250,
parallelUploads: 5,
uploadMultiple: false,
addRemoveLinks: false,

View file

@ -12,10 +12,11 @@
import $ from 'jquery';
import { empty } from '@ember/object/computed';
import { computed } from '@ember/object';
import ModalMixin from '../../mixins/modal';
import Modals from '../../mixins/modal';
import Notifier from '../../mixins/notifier';
import Component from '@ember/component';
export default Component.extend(ModalMixin, {
export default Component.extend(Modals, Notifier, {
busy: false,
mousetrap: null,
showLinkModal: false,

View file

@ -0,0 +1,100 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import { computed } from '@ember/object';
import Component from '@ember/component';
export default Component.extend({
isDirty: false,
pageBody: '',
editorId: computed('page', function () {
let page = this.get('page');
return `pdf-editor-${page.id}`;
}),
pdfOption: null,
pdfName: '',
init() {
this._super(...arguments);
this.pdfOption = {};
},
didReceiveAttrs() {
let pdfOption = {};
try {
pdfOption = JSON.parse(this.get('meta.config'));
} catch (e) {} // eslint-disable-line no-empty
if (_.isEmpty(pdfOption)) {
pdfOption = {
height: 600,
sidebar: 'none', // none, bookmarks, thumbs
startPage: 1,
fileId: ''
};
}
this.set('pdfOption', pdfOption);
this.setPDF();
},
didUpdateAttrs() {
this._super(...arguments);
this.setPDF();
},
setPDF() {
let files = this.get('attachments');
this.set('pdfName', '');
this.set('pdfOption.fileId', '');
if (!_.isArray(files)) return;
for (let i=0; i < files.length; i++) {
if (_.endsWith(files[i].get('extension'), 'pdf') &&
files[i].get('pageId') === this.get('page.id')) {
this.set('pdfName', files[i].get('filename'));
this.set('pdfOption.fileId', files[i].get('id'));
break;
}
}
},
actions: {
onSetSidebar(e) {
this.set('pdfOption.sidebar', e);
},
isDirty() {
return this.get('isDirty');
},
onCancel() {
let cb = this.get('onCancel');
cb();
},
onAction(title) {
let config = this.get('pdfOption');
let page = this.get('page');
let meta = this.get('meta');
page.set('title', title);
page.set('body', JSON.stringify(config));
meta.set('config', JSON.stringify(config));
meta.set('rawBody', JSON.stringify(config));
let cb = this.get('onAction');
cb(page, meta);
}
}
});

View file

@ -0,0 +1,80 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import { inject as service } from '@ember/service';
import Component from '@ember/component';
export default Component.extend({
appMeta: service(),
session: service(),
// PDF URL is calculated
pdfUrl: '',
// https://github.com/mozilla/pdf.js/wiki/Viewer-options
viewHeight: 700,
startPage: 1,
pageMode: 'none', // none, bookmarks, thumbs
didReceiveAttrs() {
this._super(...arguments);
if (this.get('isDestroyed') || this.get('isDestroying')) {
return;
}
let pdfOption = {};
try {
pdfOption = JSON.parse(this.get('page.body'));
} catch (e) {} // eslint-disable-line no-empty
if (_.isEmpty(pdfOption)) {
pdfOption = {
height: 600,
sidebar: 'none', // none, bookmarks, thumbs
startPage: 1,
};
}
this.set('pdfOption', pdfOption);
let endpoint = this.get('appMeta.endpoint');
let orgId = this.get('appMeta.orgId');
let fileId = this.get('pdfOption.fileId');
if (_.isEmpty(fileId)) {
return;
}
// For authenticated users we send server auth token.
let qry = '';
if (this.get('session.hasSecureToken')) {
qry = '?secure=' + this.get('session.secureToken');
} else if (this.get('session.authenticated')) {
qry = '?token=' + this.get('session.authToken');
}
this.set('pdfUrl', encodeURIComponent(`${endpoint}/public/attachment/${orgId}/${fileId}${qry}`));
},
didInsertElement() {
this._super(...arguments);
if (this.get('isDestroyed') || this.get('isDestroying')) {
return;
}
},
willDestroyElement() {
this._super(...arguments);
}
});

View file

@ -15,6 +15,7 @@ import attr from 'ember-data/attr';
export default Model.extend({
documentId: attr('string'),
pageId: attr('string'),
extension: attr('string'),
fileId: attr('string'),
filename: attr('string'),

View file

@ -36,7 +36,7 @@ export default Model.extend({
}),
tocIndent: computed('level', function () {
return (this.get('level') - 1) * 20;
return (this.get('level') - 1) * 10;
}),
tocIndentCss: computed('tocIndent', function () {

View file

@ -222,6 +222,20 @@ export default Controller.extend(Notifier, {
this.get('router').transitionTo('document.settings', {queryParams: {tab: 'general'}});
},
onAttachmentUpload() {
this.get('documentService').getAttachments(this.get('document.id')).then((files) => {
this.set('attachments', files);
});
},
onAttachmentDelete(attachmentId) {
this.get('documentService').deleteAttachment(this.get('document.id'), attachmentId).then(() => {
this.get('documentService').getAttachments(this.get('document.id')).then((files) => {
this.set('attachments', files);
});
});
},
refresh(reloadPage) {
return new EmberPromise((resolve) => {
this.get('documentService').fetchDocumentData(this.get('document.id')).then((data) => {
@ -232,6 +246,7 @@ export default Controller.extend(Notifier, {
this.set('roles', data.roles);
this.set('links', data.links);
this.set('versions', data.versions);
this.set('attachments', data.attachments);
this.get('documentService').fetchPages(this.get('document.id'), this.get('session.user.id')).then((data) => {
this.set('pages', data);
@ -243,7 +258,7 @@ export default Controller.extend(Notifier, {
if (reloadPage) {
window.location.reload();
} else {
resolve();
resolve();
}
});
});

View file

@ -50,7 +50,8 @@ export default Route.extend(AuthenticatedRouteMixin, {
permissions: this.modelFor('document').permissions,
roles: this.modelFor('document').roles,
blocks: this.modelFor('document').blocks,
versions: this.modelFor('document').versions
versions: this.modelFor('document').versions,
attachments: this.modelFor('document').attachments
});
},
@ -67,6 +68,7 @@ export default Route.extend(AuthenticatedRouteMixin, {
controller.set('roles', model.roles);
controller.set('blocks', model.blocks);
controller.set('versions', model.versions);
controller.set('attachments', model.attachments);
},
activate: function () {

View file

@ -121,6 +121,7 @@
sections=sections
document=document
permissions=permissions
attachments=attachments
currentPageId=currentPageId
refresh=(action "refresh")
onSavePage=(action "onSavePage")
@ -130,5 +131,7 @@
onInsertSection=(action "onInsertSection")
onSavePageAsBlock=(action "onSavePageAsBlock")
onPageLevelChange=(action "onPageLevelChange")
onPageSequenceChange=(action "onPageSequenceChange")}}
onPageSequenceChange=(action "onPageSequenceChange")
onAttachmentUpload=(action "onAttachmentUpload")
onAttachmentDelete=(action "onAttachmentDelete")}}
{{/layout/master-content}}

View file

@ -33,6 +33,7 @@ export default Route.extend(AuthenticatedRouteMixin, {
this.set('roles', data.roles);
this.set('links', data.links);
this.set('versions', data.versions);
this.set('attachments', data.attachments);
resolve();
});
});
@ -47,6 +48,7 @@ export default Route.extend(AuthenticatedRouteMixin, {
roles: this.get('roles'),
links: this.get('links'),
versions: this.get('versions'),
attachments: this.get('attachments'),
sections: this.get('sectionService').getAll(),
blocks: this.get('sectionService').getSpaceBlocks(this.get('folder.id'))
});

View file

@ -43,5 +43,19 @@ export default Controller.extend({
{ queryParams: { currentPageId: page.get('id')}});
});
},
onAttachmentUpload() {
this.get('documentService').getAttachments(this.get('model.document.id')).then((files) => {
this.set('model.attachments', files);
});
},
onAttachmentDelete(attachmentId) {
this.get('documentService').deleteAttachment(this.get('model.document.id'), attachmentId).then(() => {
this.get('documentService').getAttachments(this.get('model.document.id')).then((files) => {
this.set('attachments', files);
});
});
},
}
});

View file

@ -11,8 +11,8 @@
import { hash } from 'rsvp';
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import Route from '@ember/routing/route';
export default Route.extend(AuthenticatedRouteMixin, {
documentService: service('document'),
@ -27,6 +27,7 @@ export default Route.extend(AuthenticatedRouteMixin, {
permissions: this.get('folderService').get('permissions'),
links: this.modelFor('document').links,
sections: this.modelFor('document').sections,
attachments: this.modelFor('document').attachments,
page: this.get('documentService').getPage(this.modelFor('document').document.get('id'), params.page_id),
meta: this.get('documentService').getPageMeta(this.modelFor('document').document.get('id'), params.page_id)
});

View file

@ -9,6 +9,17 @@
{{/layout/master-sidebar}}
{{#layout/master-content}}
{{document/document-editor document=model.document folder=model.folder page=model.page meta=model.meta
{{document/document-editor
document=model.document
folder=model.folder
page=model.page
meta=model.meta
attachments=model.attachments
onCancel=(action "onCancel") onAction=(action "onAction")}}
{{document/section-attachment uploadLabel="Upload Attachments"
editMode=true page=model.page document=model.document
files=model.attachments
onAttachmentUpload=(action "onAttachmentUpload")
onAttachmentDelete=(action "onAttachmentDelete")}}
{{/layout/master-content}}

View file

@ -397,6 +397,7 @@ export default Service.extend({
folder: {},
links: [],
versions: [],
attachments: [],
};
let doc = this.get('store').normalize('document', response.document);
@ -414,6 +415,11 @@ export default Service.extend({
return this.get('store').push(data);
});
let attachments = response.attachments.map((obj) => {
let data = this.get('store').normalize('attachment', obj);
return this.get('store').push(data);
});
data.document = doc;
data.permissions = perms;
data.roles = roles;
@ -421,6 +427,7 @@ export default Service.extend({
data.folder = folders.findBy('id', doc.get('spaceId'));
data.links = response.links;
data.versions = response.versions;
data.attachments = attachments;
return data;
}).catch((error) => {

View file

@ -4,6 +4,7 @@
@import "github.scss";
@import "jira.scss";
@import "markdown.scss";
@import "pdfjs.scss";
@import "plantuml.scss";
@import "papertrail.scss";
@import "table.scss";

File diff suppressed because it is too large Load diff

View file

@ -40,3 +40,40 @@
}
}
}
.dz-preview, .dz-processing {
display: none !important;
}
.section-attachments {
margin: 1.5rem 0 0 0;
padding: 0;
> .file {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
font-size: 1rem;
position: relative;
> a {
display: inline-block;
font-size: 1rem;
vertical-align: text-top;
margin-right: 10px;
width: 90%;
@extend .text-truncate;
color: map-get($green-shades, 800);
&:hover {
color: map-get($green-shades, 900);
}
}
> .menu {
position: absolute;
right: -10px;
top: 0;
}
}
}

View file

@ -1 +1,7 @@
{{component editorType document=document folder=folder page=page meta=meta onCancel=(action "onCancel") onAction=(action "onAction")}}
{{component editorType
document=document
folder=folder
page=page
meta=meta
attachments=attachments
onCancel=(action "onCancel") onAction=(action "onAction")}}

View file

@ -6,6 +6,7 @@
folder=folder
page=editPage
meta=editMeta
attachments=attachments
onCancel=(action "onCancelEdit")
onAction=(action "onSavePage")}}
</div>
@ -35,4 +36,9 @@
{{section/base-renderer page=page}}
</div>
{{/if}}
{{document/section-attachment uploadLabel="Upload Attachments"
editMode=editMode page=page document=document files=attachments
onAttachmentUpload=(action onAttachmentUpload)
onAttachmentDelete=(action onAttachmentDelete)}}
</div>

View file

@ -0,0 +1,39 @@
{{#if editMode}}
{{ui/ui-spacer size=200}}
{{ui/ui-button color=constants.Color.Gray label=uploadLabel id=uploadId}}
{{/if}}
<ul class="section-attachments">
{{#each files key="id" as |file|}}
{{#if (eq file.pageId page.id)}}
<li class="file">
<a href="{{appMeta.endpoint}}/public/attachment/{{appMeta.orgId}}/{{file.id}}{{downloadQuery}}">
{{file.filename}}
</a>
{{#if editMode}}
<div class="menu">
{{#ui/ui-toolbar dark=false light=false raised=false large=false bordered=false}}
{{#ui/ui-toolbar-icon icon=constants.Icon.Delete color=constants.Color.Red}}
{{#attach-popover class="ember-attacher-popper" hideOn="escapekey, clickout" showOn="click" isShown=false}}
<div class="form">
<p>Are you sure you want to delete this file?</p>
{{ui/ui-spacer size=100}}
{{ui/ui-button
light=false
label=constants.Label.Delete
color=constants.Color.Red
onClick=(action "onDelete" file)}}
</div>
{{/attach-popover}}
{{/ui/ui-toolbar-icon}}
{{/ui/ui-toolbar}}
</div>
{{/if}}
</li>
{{/if}}
{{/each}}
</ul>
{{#ui/ui-dialog title="Delete Attachment" confirmCaption="Delete" buttonColor=constants.Color.Red show=showDialog onAction=(action "onDelete")}}
<p>Are you sure you want to delete this attachment?</p>
{{/ui/ui-dialog}}

View file

@ -11,31 +11,32 @@
<div class="document-sidebar-attachment">
<ul class="files">
{{#each files key="id" as |file|}}
<li class="file">
<a href="{{appMeta.endpoint}}/public/attachment/{{appMeta.orgId}}/{{file.id}}{{downloadQuery}}">
{{file.filename}}
</a>
{{#if canEdit}}
<div class="menu">
{{#ui/ui-toolbar dark=false light=false raised=false large=false bordered=false}}
{{#ui/ui-toolbar-icon icon=constants.Icon.Delete color=constants.Color.Red}}
{{#attach-popover class="ember-attacher-popper" hideOn="escapekey, clickout" showOn="click" isShown=false}}
<div class="form">
<p>Are you sure you want to delete this file?</p>
{{ui/ui-spacer size=100}}
{{ui/ui-button
light=false
label=constants.Label.Delete
color=constants.Color.Red
onClick=(action "onDelete" file)}}
</div>
{{/attach-popover}}
{{/ui/ui-toolbar-icon}}
{{/ui/ui-toolbar}}
</div>
{{/if}}
</li>
{{#if (eq file.pageId '')}}
<li class="file">
<a href="{{appMeta.endpoint}}/public/attachment/{{appMeta.orgId}}/{{file.id}}{{downloadQuery}}">
{{file.filename}}
</a>
{{#if canEdit}}
<div class="menu">
{{#ui/ui-toolbar dark=false light=false raised=false large=false bordered=false}}
{{#ui/ui-toolbar-icon icon=constants.Icon.Delete color=constants.Color.Red}}
{{#attach-popover class="ember-attacher-popper" hideOn="escapekey, clickout" showOn="click" isShown=false}}
<div class="form">
<p>Are you sure you want to delete this file?</p>
{{ui/ui-spacer size=100}}
{{ui/ui-button
light=false
label=constants.Label.Delete
color=constants.Color.Red
onClick=(action "onDelete" file)}}
</div>
{{/attach-popover}}
{{/ui/ui-toolbar-icon}}
{{/ui/ui-toolbar}}
</div>
{{/if}}
</li>
{{/if}}
{{/each}}
</ul>
</div>

View file

@ -12,13 +12,16 @@
document=document
pending=item.pending
permissions=permissions
attachments=attachments
refresh=(action refresh)
onAttachmentUpload=(action onAttachmentUpload)
onAttachmentDelete=(action onAttachmentDelete)
onSavePage=(action "onSavePage")
onCopyPage=(action "onCopyPage")
onMovePage=(action "onMovePage")
onDeletePage=(action "onDeletePage")
onSavePageAsBlock=(action "onSavePageAsBlock")
onPageLevelChange=(action onPageLevelChange)
onPageLevelChange=(action onPageLevelChange)
onPageSequenceChange=(action onPageSequenceChange)
onShowSectionWizard=(action "onShowSectionWizard")}}
{{/each}}

View file

@ -0,0 +1,37 @@
{{#section/base-editor-inline document=document folder=folder page=page tip="Select PDF to render" isDirty=(action "isDirty") onCancel=(action "onCancel") onAction=(action "onAction")}}
<div class="form-group">
<label for="new-space-name">PDF</label>
{{input type="text" class="form-control mousetrap" placeholder="click upload button below" value=pdfName readonly=true}}
<small class="form-text text-muted">First PDF uploaded will be used</small>
</div>
<div class="form-group">
<label for="new-space-name">Preview Height</label>
{{input type="number" class="form-control mousetrap" placeholder="e.g. 700" value=pdfOption.height}}
<small class="form-text text-muted">How tall is the PDF preview?</small>
</div>
<div class="form-group">
<label for="new-space-name">Start Page</label>
{{input type="number" class="form-control mousetrap" placeholder="e.g. 1" value=pdfOption.startPage}}
<small class="form-text text-muted">The first page to display</small>
</div>
<div class="form-group">
<label for="new-space-name">Sidebar</label>
<select onchange={{action "onSetSidebar" value="target.value"}} class="form-control">
<option value="none" selected={{is-equal pdfOption.sidebar 'none'}}>
None
</option>
<option value="bookmarks" selected={{is-equal pdfOption.sidebar 'bookmarks'}}>
Bookmarks
</option>
<option value="thumbs" selected={{is-equal pdfOption.sidebar 'thumbs'}}>
Thumbnails
</option>
</select>
<small class="form-text text-muted">Optionally, set sidebar content</small>
</div>
{{/section/base-editor-inline}}

View file

@ -0,0 +1,7 @@
<div class="non-printable">
<iframe frameborder="0" onmousewheel=""
width="100%"
height={{pdfOption.height}}
src="/pdfjs/web/viewer.html?file={{pdfUrl}}#zoom=page-width&page={{pdfOption.startPage}}&pagemode={{pdfOption.sidebar}}">
</iframe>
</div>

View file

@ -17,20 +17,20 @@ module.exports = function (defaults) {
fingerprintAssetMap: true,
prepend: '/',
extensions: ['js', 'css'],
exclude: ['tinymce/**', 'codemirror/**', 'prism/**']
exclude: ['tinymce/**', 'codemirror/**', 'prism/**', 'pdfjs/**']
},
minifyJS: {
enabled: !isDevelopment,
options: {
exclude: ['tinymce/**', 'codemirror/**', 'prism/**']
exclude: ['tinymce/**', 'codemirror/**', 'prism/**', 'pdfjs/**']
}
},
minifyCSS: {
enabled: !isDevelopment,
options: {
exclude: ['tinymce/**', 'codemirror/**', 'prism/**']
exclude: ['tinymce/**', 'codemirror/**', 'prism/**', 'pdfjs/**']
}
},

View file

@ -1,6 +1,6 @@
{
"name": "documize",
"version": "2.3.2",
"version": "2.4.0",
"description": "The Document IDE",
"repository": "",
"license": "AGPL",
@ -61,6 +61,7 @@
"nan": "git+https://github.com/nodejs/nan.git",
"node-sass": "^4.11.0",
"npm": "^6.7.0",
"pdfjs-dist": "^2.0.943",
"popper.js": "^1.14.7"
}
}

177
gui/public/pdfjs/LICENSE Normal file
View file

@ -0,0 +1,177 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,3 @@
àRCopyright 1990-2009 Adobe Systems Incorporated.
All rights reserved.
See ./LICENSEáCNS2-H

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more