Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#16] added attachment #22

Merged
merged 11 commits into from
Sep 27, 2017
Merged

[#16] added attachment #22

merged 11 commits into from
Sep 27, 2017

Conversation

nirojdyola
Copy link
Contributor

No description provided.

Copy link
Member

@paulbert paulbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the specific comments, the issue referenced specifically said we would address the attachments at a later time.

Please, if what you are working on doesn't match the issue create a new issue so the rest of the team can see what you are working on.

Also, I think we'll need to discuss how we will manage attachments:

  • Are we going to continue with the zip file solution for HTML resources or would another method be better?
  • Can we make any changes to the data structure to improve performance?

@@ -35,5 +35,9 @@
li:last-child a {
border:none;
}

Copy link
Member

@paulbert paulbert Sep 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the change on the following lines. It is not related to creating the add resources component.


onChange(event) {
var files = event.target.files;
this.upload_files.push(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are only supporting one file upload with the function as written, so there is no need to save this as an array. It just complicates the code below with constant [0]

var filename = this.upload_files[0].name;
var defaultOpts = {headers:headers,withCredentials:true};

this.couchService.post('/resources',{}).then(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it not work to post a resource with an attachment?

If possible, we should refactor this to only have one HTTP request.

@@ -7,7 +7,7 @@ import { Router } from '@angular/router';
selector:'main-navigation',
template: `
<ul>
<li *ngFor="let comp of components"><a [routerLink]="'/' + comp.link">{{comp.name.toUpperCase()}}</a></li>
<li *ngFor="let comp of components"><a routerLinkActive="active-link" [routerLink]="'/' + comp.link">{{comp.name.toUpperCase()}}</a></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this change. It is not related to creating the add resources component.



//For Attachment files
saveAttachment(db:string,data:any,content_type:any): Promise<any> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an exact copy of the put method on the service. It is not necessary to add this, you can just use the put method.

In general, please do not add another method to the CouchService service. It is meant to be a quick wrapper for the basic HTTP requests to CouchDB.

Copy link
Member

@paulbert paulbert Sep 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see the slight difference with the content_type parameter. Rather than mostly copy the put method, the opts parameter for the put method can be used to overwrite the header.

<div>
{{message}}
<ol>
<li *ngFor="let attachment of attachments">{{_.keys(attachment.doc._attachments)[0]}}</li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the only place you are using Underscore. The resource list won't be listing out attachments, so I don't think we need to add an entire library for this one function that we will be removing in the future.

@@ -24,7 +24,8 @@
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/underscore/underscore-min.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the other comment. I don't think we need to add Underscore at this time.

@paulbert
Copy link
Member

paulbert commented Sep 7, 2017

To make sure this keeps moving in the right direction, I went ahead and did some work on this today.

  • I added a resource view component which uses HTML5 tags for rendering audio, video, and PDFs. This way we can see how these browser players work with Angular.
  • Adding a resource is now done in one step, a PUT request with the file attachment included as a Base64 string within the JSON.
  • I added a basic file type dropdown to the resource add page which is used to tell the resource view component which player to use.
  • This means we no longer need the saveAttachments method. I'll reiterate that the methods on the CouchService all allow for changing the headers of the HTTP request. If you need to modify the headers you do not need to add a new function.
  • Also fully removed Underscore (it was still in the cli.json file and the package.json)
  • Removed the resources.scss. If we don't have custom css, no need for the file. We can always add it later.

I think that covers it.

@nirojdyola
Copy link
Contributor Author

@paulbert I think we need to define the type of audio and video . Since , html5 doesn't support all type of audio and video.

@paulbert
Copy link
Member

Merging this so we can continue working on resources, but I'll create an issue so we can continue the discussion about video & audio support for HTML5

@paulbert paulbert merged commit 78fc187 into master Sep 27, 2017
@lmmrssa lmmrssa deleted the 16-Resources branch November 7, 2017 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants