Browse Source

add ngtouch to angular app, remove all backbone deps and models code

dev/WO-783
Tankred Hase 10 years ago
parent
commit
1259d0c160
  1. 1
      src/js/app-config.js
  2. 4
      src/js/app.js
  3. 27
      src/js/model/account-model.js
  4. 27
      src/js/model/email-model.js
  5. 21
      src/js/model/folder-model.js
  6. 23
      src/js/model/privatekey-model.js
  7. 22
      src/js/model/publickey-model.js
  8. 21
      src/require-config.js
  9. 10
      test/test-data.js
  10. 10
      test/unit/crypto-test.js
  11. 4
      test/unit/devicestorage-dao-test.js
  12. 10
      test/unit/email-dao-test.js

1
src/js/app-config.js

@ -5,7 +5,6 @@ define([], function() { @@ -5,7 +5,6 @@ define([], function() {
* Create the application namespace
*/
var app = {
model: {},
util: {}
};

4
src/js/app.js

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
// hey Angular, we're bootstrapping manually!
window.name = 'NG_DEFER_BOOTSTRAP!';
require(['angular', 'js/controller/message-list', 'angularRoute', 'js/app-config'], function(angular, MessageListCtrl) {
require(['angular', 'js/controller/message-list', 'angularRoute', 'angularTouch', 'js/app-config'], function(angular, MessageListCtrl) {
'use strict';
var app = angular.module('mail', ['ngRoute']);
var app = angular.module('mail', ['ngRoute', 'ngTouch']);
app.config(function($routeProvider) {
$routeProvider.when('/', {
templateUrl: 'tpl/message-list.html',

27
src/js/model/account-model.js

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
define(['backbone', 'js/app-config', 'js/model/folder-model'], function(Backbone, app) {
'use strict';
app.model.Account = Backbone.Model.extend({
defaults: {
emailAddress: null,
symKeySize: null,
symIvSize: null,
ssymKeySize: null,
folders: null
},
initialize: function() {
this.set('folders', new app.model.FolderCollection());
}
});
app.model.AccountCollection = Backbone.Collection.extend({
model: app.model.Account
});
return app.model.Account;
});

27
src/js/model/email-model.js

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
define(['backbone', 'js/app-config'], function(Backbone, app) {
'use strict';
app.model.Email = Backbone.Model.extend({
defaults: {
id: null,
from: null,
to: [],
cc: [],
bcc: [],
subject: null,
body: null,
sentDate: null
},
initialize: function() {}
});
app.model.EmailCollection = Backbone.Collection.extend({
model: app.model.Email
});
});

21
src/js/model/folder-model.js

@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
define(['backbone', 'js/app-config'], function(Backbone, app) {
'use strict';
app.model.Folder = Backbone.Model.extend({
defaults: {
name: null,
items: null
},
initialize: function() {}
});
app.model.FolderCollection = Backbone.Collection.extend({
model: app.model.Folder
});
});

23
src/js/model/privatekey-model.js

@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
define(['backbone', 'js/app-config'], function(Backbone, app) {
'use strict';
app.model.PrivateKey = Backbone.Model.extend({
defaults: {
_id: null,
userId: null,
encryptedKey: null,
iv: null
},
initialize: function() {}
});
app.model.PrivateKeyCollection = Backbone.Collection.extend({
model: app.model.PrivateKey
});
});

22
src/js/model/publickey-model.js

@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
define(['backbone', 'js/app-config'], function(Backbone, app) {
'use strict';
app.model.PublicKey = Backbone.Model.extend({
defaults: {
_id: null,
userId: null,
publicKey: null
},
initialize: function() {}
});
app.model.PublicKeyCollection = Backbone.Collection.extend({
model: app.model.PublicKey
});
});

21
src/require-config.js

@ -8,9 +8,7 @@ @@ -8,9 +8,7 @@
test: '../../test',
cryptoLib: '../js/crypto',
jquery: 'jquery-1.8.2.min',
jquerymobile: 'jquery.mobile-1.2.0.min',
underscore: 'underscore-1.4.4.min',
backbone: 'backbone-1.0.0.min',
lawnchair: 'lawnchair/lawnchair-git',
lawnchairSQL: 'lawnchair/lawnchair-adapter-webkit-sqlite-git',
lawnchairIDB: 'lawnchair/lawnchair-adapter-indexed-db-git',
@ -18,7 +16,8 @@ @@ -18,7 +16,8 @@
ImapClient: 'imap-client-browserified',
SmtpClient: 'smtp-client-browserified',
angular: 'angular/angular.min',
angularRoute: 'angular/angular-route.min'
angularRoute: 'angular/angular-route.min',
angularTouch: 'angular/angular-touch.min'
},
shim: {
angular: {
@ -28,6 +27,10 @@ @@ -28,6 +27,10 @@
exports: 'angular',
deps: ['angular']
},
angularTouch: {
exports: 'angular',
deps: ['angular']
},
lawnchair: {
exports: 'Lawnchair'
},
@ -37,20 +40,10 @@ @@ -37,20 +40,10 @@
lawnchairIDB: {
deps: ['lawnchair', 'lawnchairSQL']
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
underscore: {
exports: '_'
},
jquerymobile: {
deps: ['jquery', 'js/jqm-config']
}
},
priority: [
"angular"
]
}
});
}());

10
test/test-data.js

@ -1,24 +1,24 @@ @@ -1,24 +1,24 @@
define(['cryptoLib/util', 'js/app-config', 'js/model/email-model'], function(util, app) {
define(['cryptoLib/util', 'js/app-config'], function(util) {
'use strict';
var self = {};
self.getEmailCollection = function(size) {
// create test data
var i, mail, collection = new app.model.EmailCollection(),
var i, mail, collection = [],
bigAssString = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet,';
for (i = 0; i < size; i++) {
mail = new app.model.Email({
mail = {
id: i + '',
from: 'john@from.com',
to: ['jack@to.com'],
subject: 'Important stuff ' + i,
sentDate: (1971 + i) + '-03-13 18:17:53',
body: bigAssString
});
};
collection.add(mail);
collection.push(mail);
}
return collection;

10
test/unit/crypto-test.js

@ -58,10 +58,7 @@ define(['js/crypto/crypto', 'cryptoLib/util', 'test/test-data'], function(crypto @@ -58,10 +58,7 @@ define(['js/crypto/crypto', 'cryptoLib/util', 'test/test-data'], function(crypto
asyncTest("AES/HMAC encrypt batch (Async/Worker)", 2, function() {
// generate test data
var collection;
collection = testData.getEmailCollection(10);
cryptoTest.symlist = collection.toJSON();
cryptoTest.symlist = testData.getEmailCollection(10);
crypto.symEncryptList(cryptoTest.symlist, function(err, result) {
ok(!err && result.key && result.list && result.list[0].hmac, 'Encrypt list for user');
@ -89,10 +86,7 @@ define(['js/crypto/crypto', 'cryptoLib/util', 'test/test-data'], function(crypto @@ -89,10 +86,7 @@ define(['js/crypto/crypto', 'cryptoLib/util', 'test/test-data'], function(crypto
asyncTest("AES/RSA encrypt batch for User (Async/Worker)", 2, function() {
// generate test data
var collection;
collection = testData.getEmailCollection(10);
cryptoTest.list = collection.toJSON();
cryptoTest.list = testData.getEmailCollection(10);
var receiverPubkeys = [cryptoTest.generatedKeypair.publicKey];

4
test/unit/devicestorage-dao-test.js

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
define(['underscore', 'cryptoLib/util', 'js/crypto/crypto', 'js/dao/lawnchair-dao',
'js/dao/devicestorage-dao', 'test/test-data'
'js/dao/devicestorage-dao', 'test/test-data'
], function(_, util, crypto, jsonDao, storage, testData) {
'use strict';
@ -19,7 +19,7 @@ define(['underscore', 'cryptoLib/util', 'js/crypto/crypto', 'js/dao/lawnchair-da @@ -19,7 +19,7 @@ define(['underscore', 'cryptoLib/util', 'js/crypto/crypto', 'js/dao/lawnchair-da
ok(storage, 'DeviceStorageDAO');
// generate test data
devicestorageTest.list = testData.getEmailCollection(100).toJSON();
devicestorageTest.list = testData.getEmailCollection(100);
// init crypto
crypto.init({

10
test/unit/email-dao-test.js

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
'js/crypto/crypto', 'js/dao/devicestorage-dao', 'test/test-data', 'js/app-config'
'js/crypto/crypto', 'js/dao/devicestorage-dao', 'test/test-data', 'js/app-config'
], function(EmailDAO, KeychainDAO, jsonDao, crypto, storage, testData, app) {
'use strict';
@ -60,13 +60,13 @@ define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao', @@ -60,13 +60,13 @@ define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
var receiverPubkeys = [keypair.publicKey];
crypto.encryptListForUser(emaildaoTest.list.toJSON(), receiverPubkeys, function(err, encryptedList) {
crypto.encryptListForUser(emaildaoTest.list, receiverPubkeys, function(err, encryptedList) {
ok(!err);
equal(encryptedList.length, emaildaoTest.list.length, 'Encrypt list');
// add sent date to encrypted items
for (var i = 0; i < encryptedList.length; i++) {
encryptedList[i].sentDate = emaildaoTest.list.at(i).get('sentDate');
encryptedList[i].sentDate = emaildaoTest.list[i].sentDate;
}
// set encrypted test list as return value for cloud storage stub
@ -87,7 +87,7 @@ define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao', @@ -87,7 +87,7 @@ define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
emaildaoTest.emailDao.listItems('inbox', 0, emaildaoTest.list.length, function(err, gotten) {
ok(!err);
var reference = emaildaoTest.list.toJSON();
var reference = emaildaoTest.list;
deepEqual(gotten, reference, 'Compare collection');
@ -96,7 +96,7 @@ define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao', @@ -96,7 +96,7 @@ define(['js/dao/email-dao', 'js/dao/keychain-dao', 'js/dao/lawnchair-dao',
});
asyncTest("Get item", 1, function() {
var item = emaildaoTest.list.toJSON()[0];
var item = emaildaoTest.list[0];
var mail = emaildaoTest.emailDao.getItem('inbox', item.id);
deepEqual(mail, item, 'Item correct');
start();

Loading…
Cancel
Save