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

Attachments in compose and reply #23

Closed
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
258e5a0
Merge remote-tracking branch 'e2email-org/master'
KamilaHasanbega Jun 24, 2016
bf409ca
Merge remote-tracking branch 'e2email-org/master'
KamilaHasanbega Jun 27, 2016
70904c4
Adding introductory pages
KamilaHasanbega Jul 12, 2016
fee5805
fixed the identation and comments issues
Jul 13, 2016
f62b388
Fixed the lint for the files and changed the css.
Jul 14, 2016
6a7d37d
Merge remote-tracking branch 'e2email-org/master'
KamilaHasanbega Jul 15, 2016
c2bce03
Authorization and design
KamilaHasanbega Jul 19, 2016
4b7ea4f
fixed the formatting for the authorization page commit
Jul 19, 2016
396dc4e
fixed according to the comments
Aug 8, 2016
d32c9e5
fixed the karma tests for secretcode input
Aug 8, 2016
0fc3788
Corrected linter and fixed getEmailAddress method
Aug 9, 2016
8e443e6
made possible encryption and sending of attachments
Aug 10, 2016
927c798
merged files with master
Aug 15, 2016
49b23b7
changed css
Aug 15, 2016
3d173ea
Added the file-upload directive
Aug 15, 2016
cce3d60
Merge branch 'master' of https://github.com/e2email-org/e2email
Aug 17, 2016
5eef612
changed messages page to support reply with attachments and it's tests
Aug 17, 2016
163687c
fixed merge conflicts
Aug 17, 2016
b94d025
Delete fileupload-directive.js
KamilaHasanbega Aug 17, 2016
2e78137
fixed css
Aug 17, 2016
7aaddd2
fixed css
Aug 17, 2016
c238259
fixed css
Aug 17, 2016
167b8b1
The file did not belong to this branch Merge branch 'show-attachments…
Aug 17, 2016
b66dce2
Merge branch 'show-attachments' of https://github.com/KamilaHasanbega…
Aug 17, 2016
75bbc71
removing not needed css
Aug 17, 2016
e8e9031
fixing merging details
Aug 17, 2016
4048749
added the typedef according to comments
Aug 17, 2016
48ed7a8
added the typedef according to comments
Aug 17, 2016
9de1f24
added more descriptions
Aug 17, 2016
f6ae85e
fixed styling according to comments
Aug 17, 2016
ca5350b
fixed the hovering-over-cursor bug
Aug 17, 2016
76e22aa
made the attach button responsive
Aug 18, 2016
3dcec24
changed linting
Aug 18, 2016
d48ad79
fixed typos and fixed the download tags
Aug 22, 2016
2071b8a
fixed linting
Aug 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chrome/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ body {
h1.wizard-title {
font-family: inherit;
font-weight: 300;
padding-top: 30%;
text-color: #777;
}

Expand Down
39 changes: 36 additions & 3 deletions chrome/pages/messages/messages-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ e2email.pages.messages.MessagesCtrl = function(
/**
* Contains the state related to any replies by the user
* for this thread.
* @type {!{baseTitle: string, showText: boolean, content: ?string}}
* @type {!{baseTitle: string, showText: boolean, content: ?string, attachments: Array<Object>}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make a @typedef of the attachments and make attachments and `Array<...Attachment>' ? The mail model file would be a good fit for this new typedef.

*/
this.reply = {
'baseTitle': 'reply',
'content': null,
'showText': false
'showText': false,
'attachments': []
};

// Run an async task to fetch/decrypt messages in this thread
Expand All @@ -95,6 +96,36 @@ MessagesCtrl.prototype.cancelReply = function(opt_event) {
this.reply['baseTitle'] = 'reply';
this.reply['content'] = null;
this.reply['showText'] = false;
this.reply['attachments'] = [];
};


/**
Copy link
Contributor

Choose a reason for hiding this comment

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

The function description is missing, same below.

* @param {string} name of the file
Copy link
Contributor

Choose a reason for hiding this comment

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

'name of the file' => "The name of the file.", same for other parameters.

* @param {string} type of the file
* @param {string} contents of the file in a string format
* @param {number} size of the file
* @export
*/
MessagesCtrl.prototype.onFileUpload = function(name, type, contents, size) {
var obj = {
'filename': name,
'type': type,
'encoding': 'base64',
'content': contents,
'size': size
};
this.reply.attachments.push(obj);
};


/**
* @export
*/
MessagesCtrl.prototype.removeObj = function() {
if (this.reply.attachments != []) {
this.reply.attachments.pop();
}
};


Expand All @@ -109,6 +140,7 @@ MessagesCtrl.prototype.onReply = function() {
this.reply['showText'] = true;
this.reply['baseTitle'] = 'send';
this.reply['content'] = null;
this.reply['attachments'] = [];
setTimeout(function() {
document.querySelector('textarea').focus();
document.querySelector('#replyButton').scrollIntoView();
Expand All @@ -117,7 +149,8 @@ MessagesCtrl.prototype.onReply = function() {
var messageLength = this.reply['content'].length;
this.gmailService_.encryptAndSendMail(
this.thread.to, this.threadId_, this.thread.messageId,
this.thread.subject, this.reply['content']).then(goog.bind(function() {
this.thread.subject, this.reply['content'], this.reply['attachments']).
then(goog.bind(function() {
return this.gmailService_.refreshThread(this.threadId_);
}, this)).then(goog.bind(this.cancelReply, this));
}
Expand Down
41 changes: 38 additions & 3 deletions chrome/pages/messages/messages-controller_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@ goog.require('e2email.pages.messages.MessagesCtrl');

describe('MessagesCtrl', function() {
var q, controller, messagesController, scope, location;
var mockGmailService;
var mockGmailService, mockWindowService, mockTranslateService;
var TEST_EMAIL = 'mail@example.com';
var TEST_SUBJECT = 'test subject';
var TEST_THREAD_ID = 'test-thread-id';
var TEST_MESSAGE_ID = 'test-message-id';
var TEST_CONTENT = 'test content';
var TEST_FILENAME = 'dull';
var TEST_TYPE = 'dull';
var TEST_ENCODING = 'base64';
var TEST_CONTENT_ATTACHMENT = 'dull';
var TEST_SIZE = 12;
var TEST_ATTACHMENTS = [{'filename': TEST_FILENAME, 'type': TEST_TYPE,
'encoding': TEST_ENCODING, 'content': TEST_CONTENT_ATTACHMENT,
'size': TEST_SIZE}];

var TEST_THREAD = {
'to': [TEST_EMAIL],
'messageId': TEST_MESSAGE_ID,
Expand All @@ -45,6 +54,14 @@ describe('MessagesCtrl', function() {
controller = $controller;
location = $location;

mockWindowService = {
open: function(url, name, options) {
},
document: {
title: 'not set'
}
};

mockGmailService = {
refresh: function(force, progress) {
return q.when(undefined);
Expand All @@ -57,10 +74,11 @@ describe('MessagesCtrl', function() {
}
},
encryptAndSendMail: function(
recipients, threadId, messageId, subject, content) {
recipients, threadId, messageId, subject, content, attachments) {
if ((recipients.length === 1) && (recipients[0] === TEST_EMAIL) &&
(threadId == TEST_THREAD_ID) && (messageId === TEST_MESSAGE_ID) &&
(subject === TEST_SUBJECT) && (content === TEST_CONTENT)) {
(subject === TEST_SUBJECT) && (content === TEST_CONTENT) &&
(attachments === TEST_ATTACHMENTS)) {
return q.when(undefined);
} else {
return q.reject('bad parameters');
Expand Down Expand Up @@ -113,6 +131,7 @@ describe('MessagesCtrl', function() {

messagesController.reply['showText'] = true;
messagesController.reply['content'] = TEST_CONTENT;
messagesController.reply['attachments'] = TEST_ATTACHMENTS;
messagesController.onReply();
// Resolve promises.
scope.$digest();
Expand All @@ -124,5 +143,21 @@ describe('MessagesCtrl', function() {
expect(messagesController.reply['showText']).toBe(false);
});

it('should create an object with the properties and add it to attachments',
function() {
messagesController = controller(
'MessagesCtrl as messagesCtrl', {
$scope: scope,
$location: location,
$window: mockWindowService,
gmailService: mockGmailService,
$routeParams: { 'threadId': TEST_THREAD_ID }
});
messagesController.onFileUpload(TEST_FILENAME, TEST_TYPE,
TEST_CONTENT_ATTACHMENT, TEST_SIZE);

// Verify attachments to have been updated.
expect(messagesController.reply['attachments']).
toEqual(TEST_ATTACHMENTS);
});
});
20 changes: 19 additions & 1 deletion chrome/pages/messages/messages.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
margin-bottom: 1em;
}

.email-detail-from {
.email-detail-from {
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a selector with no definitions, please remove.


}

Expand All @@ -25,6 +25,7 @@
.email-subject {
font-family: Roboto;
color: #505050;
text-align: left !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

text-align: left is probably not needed here and in .email-text-content

}

.email-mime-entry {
Expand All @@ -34,6 +35,7 @@

.email-text-content {
white-space: pre-line;
text-align: left !important;
}

.email-image-content {
Expand All @@ -49,3 +51,19 @@
border: 1px solid rgba(0,0,0,0.25);
white-space: pre-line;
}

.single-attachment-received {
background-color: #f5f5f5;
border: 1px solid #dcdcdc;
font-weight: bold;
font-size: 13px;
margin: 0 7px 6px;
color: #1155CC !important;
overflow-y: hidden;
text-align: left;
padding: 2px 6px;
max-width: 448px;
width: 80%;
height: 23px;
margin-bottom: -5px;
}
23 changes: 14 additions & 9 deletions chrome/pages/messages/messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="container">
<div class="row">
<div class="col-xs-12">
<button ng-click="messagesCtrl.showThreads()" class="btn btn-primary btn-focus col-xs-3">
<button ng-click="messagesCtrl.showThreads()" class="btn btn-primary btn-focus col-xs-3 sidebtnlarge">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
{{'inbox' | translate}}
</button>
Expand Down Expand Up @@ -38,22 +38,27 @@ <h4 class="col-xs-12 page-header email-subject selectable">{{messagesCtrl.thread
</div>
<div class="row email-mime-entry" ng-repeat="mime in mail.mimeContent" ng-show="mail.mimeContent">
<img class="fade-show email-image-content" ng-src="{{mime.content}}" ng-if="mime.type=='image'">
<div class="email-text-content col-xs-12" ng-if="mime.type=='text'">{{mime.content}}
</div>
<div class="col-xs-12" ng-if="mime.type=='unsupported'">
<div class="col-xs-12 email-unsupported-content text-warning">{{mime.content}}</div>
</div>
<div class="email-text-content col-xs-12" ng-if="mime.type=='text'">{{mime.content}}</div>
<div class="col-xs-12 single-attachment-received" ng-if="mime.url"> <a href="{{mime.url}}" download>{{mime.filename}}</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

The download attribute can have a value https://developers.google.com/web/updates/2011/08/Downloading-resources-in-HTML5-a-download : Please use the download="{{mime.filename}}"

<div class="email-error-content text-danger col-xs-12" ng-if="mime.type=='error'">{{mime.content}}</div>
</div>
</li>
</ul>

<form class="email-detail-reply-form fade-show" ng-show="messagesCtrl.thread.mails[messagesCtrl.thread.mails.length-1].mimeContent && !messagesCtrl.thread.mails[messagesCtrl.thread.mails.length-1].hasErrors" ng-submit="messagesCtrl.onReply()">
<textarea ng-show="messagesCtrl.reply.showText" class="form-control fade-show" placeholder="{{'typeReplyPlaceholder' | translate}}" ng-model="messagesCtrl.reply.content" rows="10"></textarea>
<div id="textareaSpace" ng-show="messagesCtrl.reply.showText">
<textarea id="textareaElement" class="form-control fade-show" placeholder="{{'typeReplyPlaceholder' | translate}}" ng-model="messagesCtrl.reply.content" rows="10"></textarea>
<div id="attachmentRepeat">
<div ng-repeat="x in messagesCtrl.reply.attachments" class="single-attachment"><span style="margin: 0px; padding:0px;overflow-y: hidden; width:60%;">{{ x.filename | limitTo: 20 }}{{x.filename.length > 20 ? '...' : ''}} </span> <span style="width:30%; overflow-y:hidden;"> {{' (' + x.size/1000 +
Copy link
Contributor

Choose a reason for hiding this comment

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

Move the inline style rules to some CSS class.

' K)'}}</span> <span style="width:10%;">
<button ng-click="threadsCtrl.removeObj()" class="removeAttachment"> x </button> </span></div>
</div>
</div>
<div class="row email-detail-reply-form-button-row">
<div class="col-xs-12">
<button id="replyButton" type="submit" class="col-xs-3 btn btn-primary btn-focus pull-right">{{messagesCtrl.reply.baseTitle | translate}}</button>
<button style="margin-top: 1em;" ng-click="messagesCtrl.cancelReply($event)" ng-show="messagesCtrl.reply.showText" class="btn btn-link btn-focus pull-right fade-show">{{'cancel' | translate}}</button>
<button id="replyButton" type="submit" class="col-xs-3 btn btn-primary btn-focus pull-right sidebtn">{{messagesCtrl.reply.baseTitle | translate}}</button>
<button style="margin-top: 1em;" ng-click="messagesCtrl.cancelReply($event)" ng-show="messagesCtrl.reply.showText" class="btn btn-link btn-focus pull-right fade-show sidebtn">{{'cancel' | translate}}</button>
<img src="assets/img/attach2.png" class="attach-img" ng-show="messagesCtrl.reply.showText" as-upload="messagesCtrl.onFileUpload(name, type, contents, size)"/>
</div>
</div>
</form>
Expand Down
1 change: 0 additions & 1 deletion chrome/pages/recover/recover.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ <h1 class="wizard-title text-center"><b>{{'recoverScreenTitle' | translate}}</b>
</div>
<div class="col-xs-12 row">
<button id="6" ng-disabled="theform.thecode.$error.pattern || theform.thecode.$error.required || recoverCtrl.status" class="btn btn-primary btn-focus" data-ng-click="recoverCtrl.unlock()">{{'recover' | translate}}</button>

</div>
</form>

Expand Down
2 changes: 0 additions & 2 deletions chrome/pages/reset/reset.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ <h1 class="wizard-title text-center"><b>{{'resetTitle' | translate}}</b></h1>
<div class="col-xs-12 lead text-center">{{'resetHelp' | translate}}</div>
<div class="col-xs-12 lead text-danger text-center">{{'resetWarning' | translate}}</div>
</div>

<div class="reset-row row">
<div class="col-xs-6">
<button class="btn btn-primary btn-focus reset-btn" ng-disabled="resetCtrl.inProgress" data-ng-click="resetCtrl.cancel()">{{'cancel' | translate}}</button>
Expand All @@ -16,4 +15,3 @@ <h1 class="wizard-title text-center"><b>{{'resetTitle' | translate}}</b></h1>
<button class="btn btn-link btn-focus" ng-disabled="resetCtrl.inProgress" data-ng-click="resetCtrl.goAhead()"><span class="text-danger">{{'resetAnywayLink' | translate}}</span></button>
</div>
</div>
</div>