(js) Fix dependency injections
This commit is contained in:
parent
874e393948
commit
618d3d9cc0
|
@ -9,7 +9,7 @@
|
|||
xmlns:label="OGo:label"
|
||||
className="UIxPageFrame"
|
||||
title="title"
|
||||
const:jsFiles="Preferences.app.js, Common.js, Mailer.js, Preferences.js">
|
||||
const:jsFiles="Preferences.app.js, Common.js, Mailer.js, Contacts.js, Preferences.js">
|
||||
|
||||
<main class="view md-layout-fill" ui-view="preferences" layout="row"
|
||||
ng-controller="navController"><!-- preferences --> </main>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* JavaScript for SOGoContacts */
|
||||
/* JavaScript for Authentication */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
@ -23,8 +23,13 @@
|
|||
})
|
||||
|
||||
// TODO: convert to a Factory recipe?
|
||||
.provider('Authentication', function(passwordPolicyConfig) {
|
||||
this.readCookie = function(name) {
|
||||
.provider('Authentication', Authentication);
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
function Authentication() {
|
||||
function readCookie(name) {
|
||||
var foundCookie, prefix, pairs, i, currentPair, start;
|
||||
foundCookie = null;
|
||||
prefix = name + '=';
|
||||
|
@ -41,11 +46,11 @@
|
|||
}
|
||||
|
||||
return foundCookie;
|
||||
};
|
||||
}
|
||||
|
||||
this.readLoginCookie = function() {
|
||||
function readLoginCookie() {
|
||||
var loginValues = null,
|
||||
cookie = this.readCookie('0xHIGHFLYxSOGo'),
|
||||
cookie = readCookie('0xHIGHFLYxSOGo'),
|
||||
value;
|
||||
if (cookie && cookie.length > 8) {
|
||||
value = decodeURIComponent(cookie.substr(8));
|
||||
|
@ -53,9 +58,9 @@
|
|||
}
|
||||
|
||||
return loginValues;
|
||||
};
|
||||
}
|
||||
|
||||
this.redirectUrl = function(username, domain) {
|
||||
function redirectUrl(username, domain) {
|
||||
var userName, address, baseAddress, altBaseAddress, parts, hostpart, protocol, newAddress;
|
||||
|
||||
userName = username;
|
||||
|
@ -81,22 +86,16 @@
|
|||
newAddress = baseAddress;
|
||||
}
|
||||
|
||||
// if (/theme=mobile/.test(window.location.search)) {
|
||||
// newAddress = baseAddress + '/Contacts' + '?theme=mobile';
|
||||
// }
|
||||
// else {
|
||||
// newAddress = baseAddress + '/Contacts';
|
||||
// }
|
||||
|
||||
return newAddress;
|
||||
};
|
||||
}
|
||||
|
||||
this.$get = ['$q', '$http', function($q, $http) {
|
||||
this.$get = getService;
|
||||
|
||||
getService.$inject = ['$q', '$http', 'passwordPolicyConfig']
|
||||
function getService($q, $http, passwordPolicyConfig) {
|
||||
var _this = this, service;
|
||||
|
||||
service = {
|
||||
// login: function(username, password, domain, language, rememberLogin) {
|
||||
// var d = $q.defer();
|
||||
login: function(data) {
|
||||
var d = $q.defer(),
|
||||
username = data.username,
|
||||
|
@ -125,7 +124,7 @@
|
|||
}
|
||||
}).success(function(data, status) {
|
||||
// Make sure browser's cookies are enabled
|
||||
var loginCookie = _this.readLoginCookie();
|
||||
var loginCookie = readLoginCookie();
|
||||
if (!loginCookie) {
|
||||
d.reject(l('cookiesNotEnabled'));
|
||||
}
|
||||
|
@ -140,11 +139,11 @@
|
|||
//showPasswordDialog('expiration', createPasswordExpirationDialog, data['expire']);
|
||||
}
|
||||
else {
|
||||
d.resolve(_this.redirectUrl(username, domain));
|
||||
d.resolve(redirectUrl(username, domain));
|
||||
}
|
||||
}
|
||||
else {
|
||||
d.resolve(_this.redirectUrl(username, domain));
|
||||
d.resolve(redirectUrl(username, domain));
|
||||
}
|
||||
}
|
||||
}).error(function(data, status) {
|
||||
|
@ -213,7 +212,7 @@
|
|||
}
|
||||
};
|
||||
return service;
|
||||
}];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo.Common', ['ngMaterial', 'RecursionHelper'])
|
||||
angular.module('SOGo.Common', ['ngMaterial'])
|
||||
// md break-points values are hard-coded in angular-material/src/core/util/constant.js
|
||||
// $mdMedia has a built-in support for those values but can also evaluate others
|
||||
// For some reasons, angular-material's break-points don't match the specs
|
||||
|
|
|
@ -28,6 +28,11 @@
|
|||
controllerAs: 'vm',
|
||||
link: link
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
sgSubscribeDialogController.$inject = ['$mdDialog'];
|
||||
function sgSubscribeDialogController($mdDialog) {
|
||||
var vm = this;
|
||||
|
@ -35,16 +40,16 @@
|
|||
$mdDialog.show({
|
||||
templateUrl: '../Contacts/UIxContactsUserFolders',
|
||||
clickOutsideToClose: true,
|
||||
//scope: vm,
|
||||
//preserveScope: true,
|
||||
locals: {
|
||||
folderType: vm.folderType,
|
||||
onFolderSelect: vm.onFolderSelect
|
||||
//User: User
|
||||
},
|
||||
controller: sgSubscribeController,
|
||||
controllerAs: 'vm'
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
|
@ -79,13 +84,12 @@
|
|||
onFolderSelect({folderData: folder});
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function link(scope, element, attrs, controller) {
|
||||
var inputEl = element.find('input');
|
||||
element.on('click', controller.showDialog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
angular
|
||||
.module('SOGo.Common')
|
||||
|
|
|
@ -37,9 +37,7 @@
|
|||
}
|
||||
},
|
||||
resolve: {
|
||||
stateAddressbooks: ['AddressBook', function(AddressBook) {
|
||||
return AddressBook.$findAll(window.contactFolders);
|
||||
}]
|
||||
stateAddressbooks: stateAddressbooks
|
||||
}
|
||||
})
|
||||
.state('app.addressbook', {
|
||||
|
@ -51,9 +49,7 @@
|
|||
}
|
||||
},
|
||||
resolve: {
|
||||
stateAddressbook: ['$stateParams', 'AddressBook', function($stateParams, AddressBook) {
|
||||
return AddressBook.$find($stateParams.addressbookId);
|
||||
}]
|
||||
stateAddressbook: stateAddressbook
|
||||
}
|
||||
})
|
||||
.state('app.addressbook.new', {
|
||||
|
@ -65,11 +61,7 @@
|
|||
}
|
||||
},
|
||||
resolve: {
|
||||
stateCard: ['$stateParams', 'stateAddressbook', 'Card', function($stateParams, stateAddressbook, Card) {
|
||||
var tag = 'v' + $stateParams.contactType,
|
||||
card = new Card({ pid: $stateParams.addressbookId, tag: tag });
|
||||
return card;
|
||||
}]
|
||||
stateCard: stateNewCard
|
||||
}
|
||||
})
|
||||
.state('app.addressbook.card', {
|
||||
|
@ -81,9 +73,7 @@
|
|||
}
|
||||
},
|
||||
resolve: {
|
||||
stateCard: ['$stateParams', 'stateAddressbook', function($stateParams, stateAddressbook) {
|
||||
return stateAddressbook.$getCard($stateParams.cardId);
|
||||
}]
|
||||
stateCard: stateCard
|
||||
}
|
||||
})
|
||||
.state('app.addressbook.card.view', {
|
||||
|
@ -109,4 +99,38 @@
|
|||
$urlRouterProvider.otherwise('/addressbooks/personal');
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateAddressbooks.$inject = ['AddressBook'];
|
||||
function stateAddressbooks(AddressBook) {
|
||||
return AddressBook.$findAll(window.contactFolders);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateAddressbook.$inject = ['$stateParams', 'AddressBook'];
|
||||
function stateAddressbook($stateParams, AddressBook) {
|
||||
return AddressBook.$find($stateParams.addressbookId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateNewCard.$inject = ['$stateParams', 'stateAddressbook', 'Card'];
|
||||
function stateNewCard($stateParams, stateAddressbook, Card) {
|
||||
var tag = 'v' + $stateParams.contactType,
|
||||
card = new Card({ pid: $stateParams.addressbookId, tag: tag });
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateCard.$inject = ['$stateParams', 'stateAddressbook'];
|
||||
function stateCard($stateParams, stateAddressbook) {
|
||||
return stateAddressbook.$getCard($stateParams.cardId);
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
@ -37,18 +37,7 @@
|
|||
}
|
||||
},
|
||||
resolve: {
|
||||
stateAccounts: ['$q', 'Account', function($q, Account) {
|
||||
var accounts = Account.$findAll(mailAccounts);
|
||||
var promises = [];
|
||||
// Fetch list of mailboxes for each account
|
||||
angular.forEach(accounts, function(account, i) {
|
||||
var mailboxes = account.$getMailboxes();
|
||||
promises.push(mailboxes.then(function(objects) {
|
||||
return account;
|
||||
}));
|
||||
});
|
||||
return $q.all(promises);
|
||||
}]
|
||||
stateAccounts: stateAccounts
|
||||
}
|
||||
})
|
||||
.state('mail.account', {
|
||||
|
@ -60,11 +49,7 @@
|
|||
}
|
||||
},
|
||||
resolve: {
|
||||
stateAccount: ['$stateParams', 'stateAccounts', function($stateParams, stateAccounts) {
|
||||
return _.find(stateAccounts, function(account) {
|
||||
return account.id == $stateParams.accountId;
|
||||
});
|
||||
}]
|
||||
stateAccount: stateAccount
|
||||
}
|
||||
})
|
||||
.state('mail.account.mailbox', {
|
||||
|
@ -76,27 +61,8 @@
|
|||
}
|
||||
},
|
||||
resolve: {
|
||||
stateMailbox: ['$stateParams', 'stateAccount', 'decodeUriFilter', function($stateParams, stateAccount, decodeUriFilter) {
|
||||
var mailboxId = decodeUriFilter($stateParams.mailboxId);
|
||||
// Recursive find function
|
||||
var _find = function(mailboxes) {
|
||||
var mailbox = _.find(mailboxes, function(o) {
|
||||
return o.path == mailboxId;
|
||||
});
|
||||
if (!mailbox) {
|
||||
angular.forEach(mailboxes, function(o) {
|
||||
if (!mailbox && o.children && o.children.length > 0) {
|
||||
mailbox = _find(o.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
return mailbox;
|
||||
};
|
||||
return _find(stateAccount.$mailboxes);
|
||||
}],
|
||||
stateMessages: ['stateMailbox', function(stateMailbox) {
|
||||
return stateMailbox.$filter();
|
||||
}]
|
||||
stateMailbox: stateMailbox,
|
||||
stateMessages: stateMessages
|
||||
}
|
||||
})
|
||||
.state('mail.account.mailbox.message', {
|
||||
|
@ -108,17 +74,7 @@
|
|||
}
|
||||
},
|
||||
resolve: {
|
||||
stateMessage: ['encodeUriFilter', '$stateParams', '$state', 'stateMailbox', 'stateMessages', function(encodeUriFilter, $stateParams, $state, stateMailbox, stateMessages) {
|
||||
var message = _.find(stateMessages, function(messageObject) {
|
||||
return messageObject.uid == $stateParams.messageId;
|
||||
});
|
||||
|
||||
if (message)
|
||||
return message.$reload();
|
||||
else
|
||||
// Message not found
|
||||
$state.go('mail.account.mailbox', { accountId: stateMailbox.$account.id, mailboxId: encodeUriFilter(stateMailbox.path) });
|
||||
}]
|
||||
stateMessage: stateMessage
|
||||
}
|
||||
})
|
||||
.state('mail.account.mailbox.message.edit', {
|
||||
|
@ -130,9 +86,7 @@
|
|||
}
|
||||
},
|
||||
resolve: {
|
||||
stateContent: ['stateMessage', function(stateMessage) {
|
||||
return stateMessage.$editableContent();
|
||||
}]
|
||||
stateContent: stateContent
|
||||
}
|
||||
})
|
||||
.state('mail.account.mailbox.message.action', {
|
||||
|
@ -172,6 +126,88 @@
|
|||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateAccounts.$inject = ['$q', 'Account'];
|
||||
function stateAccounts($q, Account) {
|
||||
var accounts = Account.$findAll(mailAccounts);
|
||||
var promises = [];
|
||||
// Fetch list of mailboxes for each account
|
||||
angular.forEach(accounts, function(account, i) {
|
||||
var mailboxes = account.$getMailboxes();
|
||||
promises.push(mailboxes.then(function(objects) {
|
||||
return account;
|
||||
}));
|
||||
});
|
||||
return $q.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateAccount.$inject = ['$stateParams', 'stateAccounts'];
|
||||
function stateAccount($stateParams, stateAccounts) {
|
||||
return _.find(stateAccounts, function(account) {
|
||||
return account.id == $stateParams.accountId;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateMailbox.$inject = ['$stateParams', 'stateAccount', 'decodeUriFilter'];
|
||||
function stateMailbox($stateParams, stateAccount, decodeUriFilter) {
|
||||
var mailboxId = decodeUriFilter($stateParams.mailboxId);
|
||||
// Recursive find function
|
||||
var _find = function(mailboxes) {
|
||||
var mailbox = _.find(mailboxes, function(o) {
|
||||
return o.path == mailboxId;
|
||||
});
|
||||
if (!mailbox) {
|
||||
angular.forEach(mailboxes, function(o) {
|
||||
if (!mailbox && o.children && o.children.length > 0) {
|
||||
mailbox = _find(o.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
return mailbox;
|
||||
};
|
||||
return _find(stateAccount.$mailboxes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateMessages.$inject = ['stateMailbox'];
|
||||
function stateMessages(stateMailbox) {
|
||||
return stateMailbox.$filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateMessage.$inject = ['encodeUriFilter', '$stateParams', '$state', 'stateMailbox', 'stateMessages'];
|
||||
function stateMessage(encodeUriFilter, $stateParams, $state, stateMailbox, stateMessages) {
|
||||
var message = _.find(stateMessages, function(messageObject) {
|
||||
return messageObject.uid == $stateParams.messageId;
|
||||
});
|
||||
|
||||
if (message)
|
||||
return message.$reload();
|
||||
else
|
||||
// Message not found
|
||||
$state.go('mail.account.mailbox', { accountId: stateMailbox.$account.id, mailboxId: encodeUriFilter(stateMailbox.path) } );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateContent.$inject = ['stateMessage'];
|
||||
function stateContent(stateMessage) {
|
||||
return stateMessage.$editableContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
angular.extend(_this.defaults, data);
|
||||
});
|
||||
});
|
||||
|
||||
Preferences.$$resource.fetch("jsonSettings").then(function(data) {
|
||||
Preferences.$timeout(function() {
|
||||
|
||||
|
@ -82,7 +83,7 @@
|
|||
* @memberof Preferences.prototype
|
||||
* @desc Save the preferences to the server.
|
||||
*/
|
||||
/*Preferences.prototype.$save = function() {
|
||||
Preferences.prototype.$save = function() {
|
||||
var _this = this;
|
||||
console.debug("save in model...");
|
||||
|
||||
|
@ -94,7 +95,7 @@
|
|||
//_this.$shadowData = _this.$omit(true);
|
||||
return data;
|
||||
});
|
||||
};*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $omit
|
||||
|
@ -103,7 +104,7 @@
|
|||
* @param {Boolean} [deep] - make a deep copy if true
|
||||
* @return an object literal copy of the Preferences instance
|
||||
*/
|
||||
/*Preferences.prototype.$omit = function(deep) {
|
||||
Preferences.prototype.$omit = function(deep) {
|
||||
var preferences = {};
|
||||
angular.forEach(this, function(value, key) {
|
||||
if (key != 'constructor' && key[0] != '$') {
|
||||
|
@ -139,6 +140,6 @@
|
|||
}
|
||||
|
||||
return preferences;
|
||||
};*/
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue