diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | gulpfile.js | 13 | ||||
-rw-r--r-- | js/components/addressBook/addressBook_controller.js | 3 | ||||
-rw-r--r-- | js/components/addressBook/addressBook_directive.js | 13 | ||||
-rw-r--r-- | js/components/addressBookList/addressBookList_controller.js | 9 | ||||
-rw-r--r-- | js/components/addressBookList/addressBookList_directive.js | 9 | ||||
-rw-r--r-- | js/components/contact/contact_controller.js | 6 | ||||
-rw-r--r-- | js/components/contact/contact_directive.js | 11 | ||||
-rw-r--r-- | js/components/contactList/contactList_controller.js | 3 | ||||
-rw-r--r-- | js/components/contactList/contactList_directive.js | 12 | ||||
-rw-r--r-- | js/main.js | 86 | ||||
-rw-r--r-- | js/public/script.js | 153 | ||||
-rw-r--r-- | js/script.js | 164 | ||||
-rw-r--r-- | package.json | 24 | ||||
-rw-r--r-- | templates/main.php | 2 |
15 files changed, 344 insertions, 165 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..cc9e994a --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,13 @@ +var gulp = require('gulp'), + concat = require('gulp-concat'), + notify = require('gulp-notify'); + +gulp.task('scripts', function() { + return gulp.src([ + 'js/main.js', + 'js/components/**/*.js' + ]) + .pipe(concat('script.js')) + .pipe(gulp.dest('js/public')) + .pipe(notify({message: 'Scripts task complete'})); +}); diff --git a/js/components/addressBook/addressBook_controller.js b/js/components/addressBook/addressBook_controller.js new file mode 100644 index 00000000..66fb8380 --- /dev/null +++ b/js/components/addressBook/addressBook_controller.js @@ -0,0 +1,3 @@ +app.controller('addressbookCtrl', function() { + var ctrl = this; +});
\ No newline at end of file diff --git a/js/components/addressBook/addressBook_directive.js b/js/components/addressBook/addressBook_directive.js new file mode 100644 index 00000000..030edfe5 --- /dev/null +++ b/js/components/addressBook/addressBook_directive.js @@ -0,0 +1,13 @@ +app.directive('addressbook', function() { + return { + restrict: 'E', + scope: {}, + controller: 'addressbookCtrl', + controllerAs: 'ctrl', + bindToController: { + addressBook: "=data" + }, + templateUrl: OC.linkTo('contactsrework', 'templates/addressBook.html') + + } +});
\ No newline at end of file diff --git a/js/components/addressBookList/addressBookList_controller.js b/js/components/addressBookList/addressBookList_controller.js new file mode 100644 index 00000000..0d0fce5b --- /dev/null +++ b/js/components/addressBookList/addressBookList_controller.js @@ -0,0 +1,9 @@ +app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', function(scope, AddressBookService) { + var ctrl = this; + + AddressBookService.then(function(addressBooks) { + scope.$apply(function() { + ctrl.addressBooks = addressBooks; + }); + }); +}]);
\ No newline at end of file diff --git a/js/components/addressBookList/addressBookList_directive.js b/js/components/addressBookList/addressBookList_directive.js new file mode 100644 index 00000000..a887ff07 --- /dev/null +++ b/js/components/addressBookList/addressBookList_directive.js @@ -0,0 +1,9 @@ +app.directive('addressbooklist', function() { + return { + scope: {}, + controller: 'addressbooklistCtrl', + controllerAs: 'ctrl', + bindToController: {}, + templateUrl: OC.linkTo('contactsrework', 'templates/addressBookList.html') + } +});
\ No newline at end of file diff --git a/js/components/contact/contact_controller.js b/js/components/contact/contact_controller.js new file mode 100644 index 00000000..2fffd08c --- /dev/null +++ b/js/components/contact/contact_controller.js @@ -0,0 +1,6 @@ +app.controller('contactCtrl', ['$filter', function($filter) { + var ctrl = this; + + console.log($filter('vCard2JSON')(ctrl.data.addressData)); + +}]);
\ No newline at end of file diff --git a/js/components/contact/contact_directive.js b/js/components/contact/contact_directive.js new file mode 100644 index 00000000..d0abc556 --- /dev/null +++ b/js/components/contact/contact_directive.js @@ -0,0 +1,11 @@ +app.directive('contact', function() { + return { + scope: {}, + controller: 'contactCtrl', + controllerAs: 'ctrl', + bindToController: { + data: '=' + }, + templateUrl: OC.linkTo('contactsrework', 'templates/contact.html') + } +});
\ No newline at end of file diff --git a/js/components/contactList/contactList_controller.js b/js/components/contactList/contactList_controller.js new file mode 100644 index 00000000..c64b5ecd --- /dev/null +++ b/js/components/contactList/contactList_controller.js @@ -0,0 +1,3 @@ +app.controller('contactlistCtrl', function() { + var ctrl = this; +});
\ No newline at end of file diff --git a/js/components/contactList/contactList_directive.js b/js/components/contactList/contactList_directive.js new file mode 100644 index 00000000..68cda6a0 --- /dev/null +++ b/js/components/contactList/contactList_directive.js @@ -0,0 +1,12 @@ +app.directive('contactlist', function() { + return { + priority: 1, + scope: {}, + controller: 'contactlistCtrl', + controllerAs: 'ctrl', + bindToController: { + addressbook: '=' + }, + templateUrl: OC.linkTo('contactsrework', 'templates/contactList.html') + }; +});
\ No newline at end of file diff --git a/js/main.js b/js/main.js new file mode 100644 index 00000000..0cb8f6fe --- /dev/null +++ b/js/main.js @@ -0,0 +1,86 @@ +/** + * ownCloud - contactsrework + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Hendrik Leppelsack <hendrik@leppelsack.de> + * @copyright Hendrik Leppelsack 2015 + */ + +var app = angular.module('contactsApp', ['ui.router']); + +app.run(function($rootScope) { + $rootScope.addressBooks = []; +}); + +app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){ + $urlRouterProvider.otherwise('/'); + + $stateProvider + .state('home', { + url: '/', + template: '<div>Home</div>' + }) + .state('contactlist',{ + url: '/:addressBookId', + template: '<contactlist data-addressbook="addressBook"></contactlist>', + resolve: { + addressBook: function(AddressBookService, DavClient, $stateParams) { + return AddressBookService.then(function (addressBooks) { + var addressBook = addressBooks.filter(function (element) { + return element.displayName === $stateParams.addressBookId; + })[0]; + return DavClient.syncAddressBook(addressBook, {accept: 'application/vCard+json'}); + }).then(function (addressBook) { + return addressBook; + }); + } + }, + controller: function($scope, addressBook) { + $scope.addressBook = addressBook; + } + }) +}]); + +app.service('DavClient', function() { + var xhr = new dav.transport.Basic( + new dav.Credentials() + ); + return new dav.Client(xhr); +}); + +app.service('DavService', ['DavClient', function(client) { + return client.createAccount({ + server: OC.linkToRemoteBase('carddav'), + accountType: 'carddav' + }); +}]); + +app.service('AddressBookService', ['DavService', function(DavService){ + return DavService.then(function(account) { + return account.addressBooks; + }); +}]); + +app.filter('JSON2vCard', function() { + return vCard.generate; +}); + +app.filter('vCard2JSON', function() { + return function(input, prop) { + var result = vCard.parse(input); + if(prop === undefined) { + return result; + } + if(result[prop] === undefined) { + return undefined; + } + result = result[prop][0]; + if(result.value instanceof Array) { + return result.value.join(' '); + } else { + return result.value; + } + } +}); diff --git a/js/public/script.js b/js/public/script.js new file mode 100644 index 00000000..cdc19f4a --- /dev/null +++ b/js/public/script.js @@ -0,0 +1,153 @@ +/** + * ownCloud - contactsrework + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Hendrik Leppelsack <hendrik@leppelsack.de> + * @copyright Hendrik Leppelsack 2015 + */ + +var app = angular.module('contactsApp', ['ui.router']); + +app.run(function($rootScope) { + $rootScope.addressBooks = []; +}); + +app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){ + $urlRouterProvider.otherwise('/'); + + $stateProvider + .state('home', { + url: '/', + template: '<div>Home</div>' + }) + .state('contactlist',{ + url: '/:addressBookId', + template: '<contactlist data-addressbook="addressBook"></contactlist>', + resolve: { + addressBook: function(AddressBookService, DavClient, $stateParams) { + return AddressBookService.then(function (addressBooks) { + var addressBook = addressBooks.filter(function (element) { + return element.displayName === $stateParams.addressBookId; + })[0]; + return DavClient.syncAddressBook(addressBook, {accept: 'application/vCard+json'}); + }).then(function (addressBook) { + return addressBook; + }); + } + }, + controller: function($scope, addressBook) { + $scope.addressBook = addressBook; + } + }) +}]); + +app.service('DavClient', function() { + var xhr = new dav.transport.Basic( + new dav.Credentials() + ); + return new dav.Client(xhr); +}); + +app.service('DavService', ['DavClient', function(client) { + return client.createAccount({ + server: OC.linkToRemoteBase('carddav'), + accountType: 'carddav' + }); +}]); + +app.service('AddressBookService', ['DavService', function(DavService){ + return DavService.then(function(account) { + return account.addressBooks; + }); +}]); + +app.filter('JSON2vCard', function() { + return vCard.generate; +}); + +app.filter('vCard2JSON', function() { + return function(input, prop) { + var result = vCard.parse(input); + if(prop === undefined) { + return result; + } + if(result[prop] === undefined) { + return undefined; + } + result = result[prop][0]; + if(result.value instanceof Array) { + return result.value.join(' '); + } else { + return result.value; + } + } +}); + +app.controller('addressbookCtrl', function() { + var ctrl = this; +}); +app.directive('addressbook', function() { + return { + restrict: 'E', + scope: {}, + controller: 'addressbookCtrl', + controllerAs: 'ctrl', + bindToController: { + addressBook: "=data" + }, + templateUrl: OC.linkTo('contactsrework', 'templates/addressBook.html') + + } +}); +app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', function(scope, AddressBookService) { + var ctrl = this; + + AddressBookService.then(function(addressBooks) { + scope.$apply(function() { + ctrl.addressBooks = addressBooks; + }); + }); +}]); +app.directive('addressbooklist', function() { + return { + scope: {}, + controller: 'addressbooklistCtrl', + controllerAs: 'ctrl', + bindToController: {}, + templateUrl: OC.linkTo('contactsrework', 'templates/addressBookList.html') + } +}); +app.controller('contactCtrl', ['$filter', function($filter) { + var ctrl = this; + + console.log($filter('vCard2JSON')(ctrl.data.addressData)); + +}]); +app.directive('contact', function() { + return { + scope: {}, + controller: 'contactCtrl', + controllerAs: 'ctrl', + bindToController: { + data: '=' + }, + templateUrl: OC.linkTo('contactsrework', 'templates/contact.html') + } +}); +app.controller('contactlistCtrl', function() { + var ctrl = this; +}); +app.directive('contactlist', function() { + return { + priority: 1, + scope: {}, + controller: 'contactlistCtrl', + controllerAs: 'ctrl', + bindToController: { + addressbook: '=' + }, + templateUrl: OC.linkTo('contactsrework', 'templates/contactList.html') + }; +});
\ No newline at end of file diff --git a/js/script.js b/js/script.js deleted file mode 100644 index 122c442c..00000000 --- a/js/script.js +++ /dev/null @@ -1,164 +0,0 @@ -/** - * ownCloud - contactsrework - * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. - * - * @author Hendrik Leppelsack <hendrik@leppelsack.de> - * @copyright Hendrik Leppelsack 2015 - */ - -(function (OC, angular, $, vCard) { - - var app = angular.module('contactsApp', ['ui.router']); - - app.run(function($rootScope) { - $rootScope.addressBooks = []; - }); - - app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){ - $urlRouterProvider.otherwise('/'); - - $stateProvider - .state('home', { - url: '/', - template: '<div>Home</div>' - }) - .state('contactlist',{ - url: '/:addressBookId', - template: '<contactlist data-addressbook="addressBook"></contactlist>', - resolve: { - addressBook: function(AddressBookService, DavClient, $stateParams) { - return AddressBookService.then(function (addressBooks) { - var addressBook = addressBooks.filter(function (element) { - return element.displayName === $stateParams.addressBookId; - })[0]; - return DavClient.syncAddressBook(addressBook, {accept: 'application/vCard+json'}); - }).then(function (addressBook) { - return addressBook; - }); - } - }, - controller: function($scope, addressBook) { - $scope.addressBook = addressBook; - } - }) - }]); - - app.service('DavClient', function() { - var xhr = new dav.transport.Basic( - new dav.Credentials() - ); - return new dav.Client(xhr); - }); - - app.service('DavService', ['DavClient', function(client) { - return client.createAccount({ - server: OC.linkToRemoteBase('carddav'), - accountType: 'carddav' - }); - }]); - - app.service('AddressBookService', ['DavService', function(DavService){ - return DavService.then(function(account) { - return account.addressBooks; - }); - }]); - - app.directive('addressbooklist', function() { - return { - scope: {}, - controller: 'addressbooklistCtrl', - controllerAs: 'ctrl', - bindToController: {}, - templateUrl: OC.linkTo('contactsrework', 'templates/addressBookList.html') - } - }); - - app.directive('addressbook', function() { - return { - restrict: 'E', - scope: {}, - controller: 'addressbookCtrl', - controllerAs: 'ctrl', - bindToController: { - addressBook: "=data" - }, - templateUrl: OC.linkTo('contactsrework', 'templates/addressBook.html') - - } - }); - - app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', function(scope, AddressBookService) { - var ctrl = this; - - AddressBookService.then(function(addressBooks) { - scope.$apply(function() { - ctrl.addressBooks = addressBooks; - }); - }); - }]); - - app.controller('addressbookCtrl', function() { - var ctrl = this; - }); - - app.directive('contactlist', function() { - return { - priority: 1, - scope: {}, - controller: 'contactlistCtrl', - controllerAs: 'ctrl', - bindToController: { - addressbook: '=' - }, - templateUrl: OC.linkTo('contactsrework', 'templates/contactList.html') - }; - }); - - app.controller('contactlistCtrl', function() { - var ctrl = this; - }); - - app.directive('contact', function() { - return { - scope: {}, - controller: 'contactCtrl', - controllerAs: 'ctrl', - bindToController: { - data: '=' - }, - templateUrl: OC.linkTo('contactsrework', 'templates/contact.html') - } - }); - - app.controller('contactCtrl', ['$filter', function($filter) { - var ctrl = this; - - console.log($filter('vCard2JSON')(ctrl.data.addressData)); - - }]); - - app.filter('JSON2vCard', function() { - return vCard.generate; - }); - - app.filter('vCard2JSON', function() { - return function(input, prop) { - var result = vCard.parse(input); - if(prop === undefined) { - return result; - } - if(result[prop] === undefined) { - return undefined; - } - result = result[prop][0]; - if(result.value instanceof Array) { - return result.value.join(' '); - } else { - return result.value; - } - } - }); - -})(OC, angular, jQuery, vCard); diff --git a/package.json b/package.json new file mode 100644 index 00000000..c0f0b373 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "contactsrework", + "version": "0.1.0", + "description": "Place this app in **owncloud/apps/**", + "author": { + "name": "Hendrik Leppelsack", + "email": "hendrik@leppelsack.de" + }, + "private": true, + "repository": { + "type": "git", + "url": "git+https://github.com/Henni/contactsrework.git" + }, + "license": "AGPL-3.0", + "bugs": { + "url": "https://github.com/Henni/contactsrework/issues" + }, + "homepage": "https://github.com/Henni/contactsrework#readme", + "devDependencies": { + "gulp": "^3.9.0", + "gulp-concat": "^2.6.0", + "gulp-notify": "^2.2.0" + } +} diff --git a/templates/main.php b/templates/main.php index 28fdc947..fb4ecebf 100644 --- a/templates/main.php +++ b/templates/main.php @@ -3,7 +3,7 @@ script('contactsrework', 'vendor/angular/angular'); script('contactsrework', 'vendor/angular-ui-router/release/angular-ui-router'); script('contactsrework', 'vendor/dav/dav'); script('contactsrework', 'vendor/vcard/src/vcard'); -script('contactsrework', 'script'); +script('contactsrework', 'public/script'); style('contactsrework', 'style'); ?> |