Initial COmmit WIP

This commit is contained in:
Julius Haertl
2016-06-05 15:07:47 +02:00
commit e10fe82afb
55 changed files with 6366 additions and 0 deletions

3
js/.bowerrc Normal file
View File

@@ -0,0 +1,3 @@
{
"directory": "vendor"
}

78
js/app/App.js Normal file
View File

@@ -0,0 +1,78 @@
var app = angular.module('Deck', ['ngRoute', 'ngSanitize', 'ui.router', 'as.sortable']);
app.config(function ($provide, $routeProvider, $interpolateProvider, $httpProvider, $urlRouterProvider, $stateProvider) {
'use strict';
$httpProvider.defaults.headers.common.requesttoken = oc_requesttoken;
$urlRouterProvider.otherwise("/");
$stateProvider
.state('list', {
url: "/",
templateUrl: "/boardlist.mainView.html",
controller: 'ListController',
})
.state('board', {
url: "/board/:boardId",
templateUrl: "/board.html",
controller: 'BoardController'
})
.state('board.card', {
url: "/card/:cardId",
views: {
"sidebarView": {
templateUrl: "/card.sidebarView.html",
controller: 'CardController'
}
}
})
.state('board.settings', {})
.state('board.sharing', {});
});
// OwnCloud Click Handling
// https://doc.owncloud.org/server/8.0/developer_manual/app/css.html
app.directive('appNavigationEntryUtils', function () {
'use strict';
return {
restrict: 'C',
link: function (scope, elm) {
var menu = elm.siblings('.app-navigation-entry-menu');
var button = $(elm)
.find('.app-navigation-entry-utils-menu-button button');
button.click(function () {
menu.toggleClass('open');
});
scope.$on('documentClicked', function (scope, event) {
if (event.target !== button[0]) {
menu.removeClass('open');
}
});
}
};
});
app.directive('autofocusOnInsert', function () {
'use strict';
return function (scope, elm) {
elm.focus();
};
});
app.run(function ($document, $rootScope, $transitions) {
'use strict';
$document.click(function (event) {
$rootScope.$broadcast('documentClicked', event);
});
$transitions.onEnter({to: 'board.card'}, function ($state, $transition$) {
$rootScope.sidebar.show = true;
});
$transitions.onEnter({to: 'board'}, function ($state) {
$rootScope.sidebar.show = false;
});
$transitions.onExit({from: 'board.card'}, function ($state) {
$rootScope.sidebar.show = false;
});
});

27
js/bower.json Normal file
View File

@@ -0,0 +1,27 @@
{
"name": "ownCloud Deck",
"version": "0.0.1",
"dependencies": {
"angular": "~1.5.*",
"angular-route": "~1.5.*",
"angular-mocks": "~1.5.*",
"angular-sanitize": "~1.5.*",
"angular-animate": "~1.5.*",
"angular-ui-bootstrap": "~1.*.*",
"ng-sortable": "~1.*.*",
"jquery": "~2.*",
"momentjs": "~2.11.*",
"es6-shim": "~0.*",
"js-url": "~2.*",
"masonry": "~4.0.0"
},
"license": "AGPL-3.0",
"private": true,
"ignore": [
"'**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

View File

@@ -0,0 +1,7 @@
app.controller('AppController', function ($scope, $location, $http, $route, $log, $rootScope, $stateParams) {
$rootScope.sidebar = {
show: false
};
$scope.sidebar = $rootScope.sidebar;
});

View File

@@ -0,0 +1,146 @@
app.controller('BoardController', function ($rootScope, $scope, $location, $http, $route, $stateParams, boardFactory, stackFactory, StackService) {
$scope.sidebar = $rootScope.sidebar;
$scope.newCard = {};
$scope.stackservice = StackService;
$scope.id = $stateParams.boardId;
$scope.status = {
'active': true,
'icon': 'loading',
'title': 'Bitte warten',
'text': 'Es dauert noch einen kleinen Moment'
};
$scope.setStatus = function($icon, $title, $text='') {
$scope.status.active = true;
$scope.status.icon = $icon;
$scope.status.title = $title;
$scope.status.text = $text;
}
$scope.unsetStatus = function() {
$scope.status = {
'active': false
}
}
$scope.getBoard = function() {
boardFactory.getBoard($scope.id)
.then(function (response) {
$scope.board = response.data;
$scope.unsetStatus();
}, function (error) {
$scope.setStatus('error','Unable to load board data', error);
});
}
$scope.getStacks = function() {
stackFactory.getStacks($scope.id)
.then(function (response) {
$scope.stacks = response.data;
$scope.unsetStatus();
}, function (error) {
$scope.setStatus('error','Unable to load board data', error);
});
}
$scope.createStack = function () {
$scope.newStack.boardId = $scope.id;
stackFactory.createStack($scope.newStack)
.then(function (response) {
$scope.stacks.push(response.data);
$scope.newStack = {};
$scope.status.addStack=false;
}, function(error) {
$scope.status.createBoard = 'Unable to insert board: ' + error.message;
});
};
$scope.rgblight = function (hex) {
var result = /^([A-Fa-f\d]{2})([A-Fa-f\d]{2})([A-Fa-f\d]{2})$/i.exec(hex);
var color = result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
if(result !== null) {
var rgba = "rgba(" + color.r + "," + color.g + "," + color.b + ",0.7)";
return rgba;
} else {
return "#"+hex;
}
};
// settings for card sorting
$scope.sortOptions = {
itemMoved: function (event) {
event.source.itemScope.modelValue.status = event.dest.sortableScope.$parent.column;
console.log(event.dest.sortableScope.$parent);
},
orderChanged: function (event) {
},
scrollableContainer: '#board',
containerPositioning: 'relative',
containment: '#board',
// auto scroll on drag
dragMove: function (itemPosition, containment, eventObj) {
if (eventObj) {
var container = $("#board");
var offset = container.offset();
targetX = eventObj.pageX - (offset.left || container.scrollLeft());
targetY = eventObj.pageY - (offset.top || container.scrollTop());
if (targetX < offset.left) {
container.scrollLeft(container.scrollLeft() - 50);
} else if (targetX > container.width()) {
container.scrollLeft(container.scrollLeft() + 50);
}
if (targetY < offset.top) {
container.scrollTop(container.scrollTop() - 50);
} else if (targetY > container.height()) {
container.scrollTop(container.scrollTop() + 50);
}
}
}
};
$scope.sortStackOptions = {
itemMoved: function (event) {
event.source.itemScope.modelValue.status = event.dest.sortableScope.$parent.column;
console.log(event.dest.sortableScope.$parent);
},
orderChanged: function (event) {
},
scrollableContainer: '#board',
containerPositioning: 'relative',
containment: '#board',
// auto scroll on drag
dragMove: function (itemPosition, containment, eventObj) {
if (eventObj) {
var container = $("#board");
var offset = container.offset();
targetX = eventObj.pageX - (offset.left || container.scrollLeft());
targetY = eventObj.pageY - (offset.top || container.scrollTop());
if (targetX < offset.left) {
container.scrollLeft(container.scrollLeft() - 50);
} else if (targetX > container.width()) {
container.scrollLeft(container.scrollLeft() + 50);
}
if (targetY < offset.top) {
container.scrollTop(container.scrollTop() - 50);
} else if (targetY > container.height()) {
container.scrollTop(container.scrollTop() + 50);
}
}
}
};
$scope.getBoard();
$scope.getStacks();
});

View File

@@ -0,0 +1,23 @@
app.controller('CardController', function ($scope, $rootScope, $routeParams, $location, $stateParams) {
$scope.sidebar = $rootScope.sidebar;
$scope.location = $location;
$scope.card = {'id': 1, 'title': 'We should implement all the useful things, that a kanban like project managemnt system needs for having success', 'description': 'Non et quibusdam officiis expedita excepturi. Tenetur ea et dignissimos qui. Rerum quis commodi aperiam amet dolorum suscipit asperiores. Enim dolorem ea nisi voluptate. \
Consequatur enim iste dolore autem est unde voluptatum. Aut sit et iure. Suscipit deserunt nisi repellat in officiis alias. Nihil beatae ea ut laudantium at.\
Doloribus nihil ipsa consequatur laudantium qui enim eveniet quo. Voluptatum tenetur sunt quis sint aliquam et molestias. Quae voluptatem tempora qui eaque qui esse possimus magni. Animi dolorem maiores iste.\
Totam ut tempora officiis ipsam dolorem modi. Dolores hic aut itaque. Earum in est voluptas voluptatum. Cumque pariatur qui omnis placeat. Eius sed sunt corrupti dolorem quo.'};
$scope.cardId = $stateParams.cardId;
console.log($stateParams);
/*var menu = $('#app-content');
menu.click(function(event){
$scope.location.path('/board/'+$scope.boardId);
$scope.$apply();
});*/
});

View File

@@ -0,0 +1,64 @@
app.controller('ListController', function ($scope, $location, boardFactory, StackService) {
$scope.boards = null;
$scope.newBoard = {};
$scope.status = {};
$scope.colors = ['31CC7C', '317CCC', 'FF7A66', 'F1DB50', '7C31CC', 'CC317C', '3A3B3D', 'CACBCD'];
$scope.stackservice = StackService;
$scope.getBoards = function() {
boardFactory.getBoards()
.then(function (response) {
$scope.boards = response.data;
for (var i = 0; i < $scope.boards.length; i++) {
$scope.boards[i].status = {
'edit': false,
}
}
}, function (error) {
$scope.status.getBoards = 'Unable to load customer data: ' + error.message;
});
}
$scope.createBoard = function () {
boardFactory.createBoard($scope.newBoard)
.then(function (response) {
$scope.boards.push(response.data);
$scope.newBoard = {};
$scope.status.addBoard=false;
}, function(error) {
$scope.status.createBoard = 'Unable to insert board: ' + error.message;
});
};
$scope.updateBoard = function(board) {
boardFactory.updateBoard(board)
.then(function (response) {
board = response.data;
}, function(error) {
$scope.status.createBoard = 'Unable to insert board: ' + error.message;
});
board.status.edit = false;
$scope.$apply();
};
$scope.selectColor = function(color) {
$scope.newBoard.color = color;
};
$scope.deleteBoard = function (index) {
var board = $scope.boards[index];
boardFactory.deleteBoard(board.id)
.then(function (response) {
$scope.status.deleteBoard = 'Deleted Board';
$scope.boards.splice( index, 1 );
}, function(error) {
$scope.status.deleteBoard = 'Unable to insert board: ' + error.message;
});
};
$scope.getBoards();
});

31
js/script.js Normal file
View File

@@ -0,0 +1,31 @@
/**
* ownCloud - deck
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Julius Härtl <jus@bitgrid.net>
* @copyright Julius Härtl 2016
*/
(function ($, OC) {
$(document).ready(function () {
$('#hello').click(function () {
alert('Hello from your script file');
});
$('#echo').click(function () {
var url = OC.generateUrl('/apps/deck/echo');
var data = {
echo: $('#echo-content').val()
};
$.post(url, data).success(function (response) {
$('#echo-result').text(response.echo);
});
});
});
})(jQuery, OC);

31
js/service/apiservice.js Normal file
View File

@@ -0,0 +1,31 @@
app.factory('ApiService', function($http){
var ApiService = function(http, BASEURL,endpoint) {
this.endpoint = endpoint;
this.baseUrl = OC.generateUrl('/apps/deck/' + endpoint);
this.http = http;
this.hashMap = {};
this.values = [];
};
ApiService.prototype.getAll = function(){
return $http.get(baseUrl);
}
ApiService.prototype.getOne = function (id) {
return $http.get(baseUrl + '/' + id);
};
ApiService.prototype.create = function (entity) {
return $http.post(baseUrl, entity);
};
ApiService.prototype.update = function (entity) {
return $http.put(baseUrl, entity)
};
ApiService.prototype.delete = function (id) {
return $http.delete(baseUrl + '/' + id);
};
return ApiService;
});

View File

@@ -0,0 +1,27 @@
app.factory('boardFactory', function($http, stackFactory){
var service = {};
var baseUrl = OC.generateUrl('/apps/deck/boards');
service.getBoards = function(){
return $http.get(baseUrl);
}
service.getBoard = function (id) {
board = $http.get(baseUrl + '/' + id);
return board;
};
service.createBoard = function (board) {
return $http.post(baseUrl, board);
};
service.updateBoard = function (board) {
return $http.put(baseUrl, board)
};
service.deleteBoard = function (id) {
return $http.delete(baseUrl + '/' + id);
};
return service;
});

View File

@@ -0,0 +1,78 @@
app.factory('ApiService', function($http){
var ApiService = function(http, endpoint) {
this.endpoint = endpoint;
this.baseUrl = OC.generateUrl('/apps/deck/' + endpoint);
this.http = http;
this.hashMap = {};
this.values = [];
this.once = null;
};
ApiService.prototype.getAll = function(){
return $http.get(this.baseUrl);
}
ApiService.prototype.getOne = function (id) {
self = this;
$http.get(this.baseUrl + '/' + id).then(function (response) {
self.once = response.data;
return response.data;
}, function (error) {
});
return this.once;
};
ApiService.prototype.create = function (entity) {
return $http.post(this.baseUrl, entity);
};
ApiService.prototype.update = function (entity) {
return $http.put(this.baseUrl, entity)
};
ApiService.prototype.delete = function (id) {
return $http.delete(this.baseUrl + '/' + id);
};
return ApiService;
});
app.factory('stackFactory', function($http){
var service = {};
var baseUrl = OC.generateUrl('/apps/deck/stacks');
service.getStacks = function(boardId){
return $http.get(baseUrl + '/' + boardId);
}
service.getStack = function (id) {
return $http.get(baseUrl + '/' + id);
};
service.createStack = function (stack) {
return $http.post(baseUrl, stack);
};
service.updateStack = function (stack) {
return $http.put(baseUrl, stack)
};
service.deleteStack = function (id) {
return $http.delete(baseUrl + '/' + id);
};
return service;
});
app.factory('StackService', function(ApiService, $http){
var StackService = function($http, ep) {
ApiService.call(this, $http, ep);
};
StackService.prototype = ApiService.prototype;
StackService.prototype.getAll = function(boardId) {
return $http.get(this.baseUrl + '/' + boardId);
}
service = new StackService($http, 'stacks')
return service;
});