From 080341eb0aa499580a08c9646b2782b098b4c17d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 18 Feb 2016 17:07:34 +0100 Subject: [PATCH] Don't use wellknown if not needed - fixes #41 --- js/dav/dav.js | 2 +- js/dav/lib/accounts.js | 2 +- js/public/script.js | 95 +++++++++++++++++++------------------- js/services/dav_service.js | 3 +- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/js/dav/dav.js b/js/dav/dav.js index 628d0bc62..9e9445190 100644 --- a/js/dav/dav.js +++ b/js/dav/dav.js @@ -683,7 +683,7 @@ var serviceDiscovery = _co2['default'].wrap(regeneratorRuntime.mark(function cal uri = _url2['default'].format({ protocol: endpoint.protocol, host: endpoint.host, - pathname: '/.well-known/' + options.accountType + pathname: !options.useProvidedPath ? '/.well-known/' + options.accountType : endpoint.pathname }); req = request.basic({ method: 'GET' }); context$1$0.prev = 5; diff --git a/js/dav/lib/accounts.js b/js/dav/lib/accounts.js index dbeb67459..f471c5b61 100644 --- a/js/dav/lib/accounts.js +++ b/js/dav/lib/accounts.js @@ -30,7 +30,7 @@ let serviceDiscovery = co.wrap(function *(account, options) { let uri = url.format({ protocol: endpoint.protocol, host: endpoint.host, - pathname: `/.well-known/${options.accountType}` + pathname: (!options.useProvidedPath ? '/.well-known/' + options.accountType : endpoint.pathname) }); let req = request.basic({ method: 'GET' }); diff --git a/js/public/script.js b/js/public/script.js index 4e531260f..0dc74140d 100644 --- a/js/public/script.js +++ b/js/public/script.js @@ -18,6 +18,22 @@ app.config(['$routeProvider', function($routeProvider){ }]); +app.controller('addressbookCtrl', function() { + var ctrl = this; + console.log(this); +}); +app.directive('addressbook', function() { + return { + restrict: 'A', // has to be an attribute to work with core css + scope: {}, + controller: 'addressbookCtrl', + controllerAs: 'ctrl', + bindToController: { + addressBook: "=data" + }, + templateUrl: OC.linkTo('contactsrework', 'templates/addressBook.html') + }; +}); app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', 'SettingsService', function(scope, AddressBookService, SettingsService) { var ctrl = this; @@ -45,38 +61,54 @@ app.directive('addressbooklist', function() { }; }); -app.controller('addressbookCtrl', function() { +app.controller('contactCtrl', [function() { var ctrl = this; - console.log(this); -}); -app.directive('addressbook', function() { + + console.log("Contact: ",ctrl.contact); + +}]); + +app.directive('contact', function() { return { - restrict: 'A', // has to be an attribute to work with core css scope: {}, - controller: 'addressbookCtrl', + controller: 'contactCtrl', controllerAs: 'ctrl', bindToController: { - addressBook: "=data" + contact: '=data' }, - templateUrl: OC.linkTo('contactsrework', 'templates/addressBook.html') + templateUrl: OC.linkTo('contactsrework', 'templates/contact.html') }; }); -app.controller('contactCtrl', [function() { +app.controller('contactlistCtrl', ['$scope', 'ContactService', function($scope, ContactService) { var ctrl = this; - console.log("Contact: ",ctrl.contact); + ContactService.registerObserverCallback(function(contacts) { + $scope.$apply(function() { + ctrl.contacts = contacts; + }); + }); + + ContactService.getAll().then(function(contacts) { + $scope.$apply(function(){ + ctrl.contacts = contacts; + }); + }); + ctrl.createContact = function() { + ContactService.create(); + }; }]); -app.directive('contact', function() { +app.directive('contactlist', function() { return { + priority: 1, scope: {}, - controller: 'contactCtrl', + controller: 'contactlistCtrl', controllerAs: 'ctrl', bindToController: { - contact: '=data' + addressbook: '=adrbook' }, - templateUrl: OC.linkTo('contactsrework', 'templates/contact.html') + templateUrl: OC.linkTo('contactsrework', 'templates/contactList.html') }; }); app.controller('contactdetailsCtrl', ['ContactService', '$routeParams', '$scope', function(ContactService, $routeParams, $scope) { @@ -116,38 +148,6 @@ app.directive('contactdetails', function() { }; }); -app.controller('contactlistCtrl', ['$scope', 'ContactService', function($scope, ContactService) { - var ctrl = this; - - ContactService.registerObserverCallback(function(contacts) { - $scope.$apply(function() { - ctrl.contacts = contacts; - }); - }); - - ContactService.getAll().then(function(contacts) { - $scope.$apply(function(){ - ctrl.contacts = contacts; - }); - }); - - ctrl.createContact = function() { - ContactService.create(); - }; -}]); - -app.directive('contactlist', function() { - return { - priority: 1, - scope: {}, - controller: 'contactlistCtrl', - controllerAs: 'ctrl', - bindToController: { - addressbook: '=adrbook' - }, - templateUrl: OC.linkTo('contactsrework', 'templates/contactList.html') - }; -}); app.factory('AddressBook', function() { return function AddressBook(data) { @@ -468,7 +468,8 @@ app.service('DavClient', function() { app.service('DavService', ['DavClient', function(client) { return client.createAccount({ server: OC.linkToRemoteBase('dav/addressbooks'), - accountType: 'carddav' + accountType: 'carddav', + useProvidedPath: true }); }]); diff --git a/js/services/dav_service.js b/js/services/dav_service.js index 060658471..9981d377e 100644 --- a/js/services/dav_service.js +++ b/js/services/dav_service.js @@ -1,6 +1,7 @@ app.service('DavService', ['DavClient', function(client) { return client.createAccount({ server: OC.linkToRemoteBase('dav/addressbooks'), - accountType: 'carddav' + accountType: 'carddav', + useProvidedPath: true }); }]);