Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trello final #382

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ local.properties
# PDT-specific
.buildpath

# sbteclipse plugin
# sbteclipse plugin
.target

# TeXlipse plugin
Expand Down Expand Up @@ -141,3 +141,8 @@ build/Release

# Destination folder
/www/

.idea

.idea/workspace.xml

34 changes: 26 additions & 8 deletions src/js/controllers/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ angular.module('Teem')
redirectTo: function(params) {
return '/teems/' + params.id + '?tab=' + params.tab;
}
})
.when('/trello/get/',{
controller: 'TrelloGetController',
template: '<h1>Redirecting ....</h1>'
})
.when('/trello/auth',{
template: '<h1>Redirecting to trello</h1>',
controller: 'TrelloAuthController'
});
}])
.controller('FetchProject', [
Expand Down Expand Up @@ -255,7 +263,7 @@ angular.module('Teem')
$scope.pad.editing = false;
});

$scope.$on('$routeChangeStart', function(event, next, current) {
$scope.$on('$routeChangeStart', function(event, next, current) {
if (current.params.tab !== undefined && $scope.project!== undefined) {
$scope.project.setTimestampAccess(current.params.tab);
}
Expand All @@ -281,12 +289,12 @@ angular.module('Teem')

var lastChange = $scope.project.lastChange(section);
var lastAccess;
if ($scope.project.getTimestampAccess() &&
$scope.project.getTimestampAccess()[section]) {
lastAccess = new Date(($scope.project.getTimestampAccess()[section]).last);
} else {
lastAccess = new Date(0);
}
if ($scope.project.getTimestampAccess() &&
$scope.project.getTimestampAccess()[section]) {
lastAccess = new Date(($scope.project.getTimestampAccess()[section]).last);
} else {
lastAccess = new Date(0);
}
return lastChange > lastAccess;
};

Expand Down Expand Up @@ -361,7 +369,7 @@ angular.module('Teem')
url
}).then(function (response) {
angular.forEach(response.data.geonames, function(v) {
v.value = {
v.value = {
id: v.geonameId.toString(),
latitide: v.lat,
longitude: v.lng,
Expand Down Expand Up @@ -422,6 +430,16 @@ angular.module('Teem')
};

}])
.controller('TrelloGetController', ['$location','ProjectsSvc','SessionSvc', function($location,ProjectsSvc,SessionSvc){
let token = $location.hash().split('=')[1];
localStorage.setItem('trelloTeemToken',token);
SessionSvc.onLoad(function(){
ProjectsSvc.updateTrello();
});
}])
.controller('TrelloAuthController',['trelloSvc',function(trelloSvc){
trelloSvc.getToken();
}])
.directive(
'hideTabs',
function (SharedState, $timeout) {
Expand Down
224 changes: 196 additions & 28 deletions src/js/directives/pad.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,119 @@ angular.module('Teem')
$scope.editingDefault = attrs.editingDefault;
},
controller: [
'SessionSvc', '$rootScope', '$scope', '$route', '$location',
'$timeout', 'SharedState', 'needWidget', '$element',
function(SessionSvc, $rootScope, $scope, $route, $location,
$timeout, SharedState, needWidget, $element) {

var buttons = ['text_fields', 'format_bold', 'format_italic', 'format_strikethrough',
'format_align_left', 'format_align_center', 'format_align_right',
'format_list_bulleted', 'format_list_numbered'];

var annotationMap = {
'text_fields': 'paragraph/header=h3',
'format_bold': 'style/fontWeight=bold',
'format_italic': 'style/fontStyle=italic',
'format_strikethrough': 'style/textDecoration=line-through',
'format_align_left': 'paragraph/textAlign=left',
'format_align_center': 'paragraph/textAlign=center',
'format_align_right': 'paragraph/textAlign=right',
'format_list_bulleted': 'paragraph/listStyleType=unordered',
'format_list_numbered': 'paragraph/listStyleType=decimal'
};

var annotations = {};

function imgWidget(parentElement, before, state) {
state = state || before;

if (!(state in $scope.project.attachments) || !$scope.project.attachments[state].file) {
'SessionSvc', '$rootScope', '$scope', '$route', '$location',
'$timeout', 'SharedState', 'needWidget', '$element','linkPreview',
function(SessionSvc, $rootScope, $scope, $route, $location,
$timeout, SharedState, needWidget, $element, linkPreview) {

var buttons = ['text_fields', 'format_bold', 'format_italic', 'format_strikethrough',
'format_align_left', 'format_align_center', 'format_align_right',
'format_list_bulleted', 'format_list_numbered'];

var annotationMap = {
'text_fields': 'paragraph/header=h3',
'format_bold': 'style/fontWeight=bold',
'format_italic': 'style/fontStyle=italic',
'format_strikethrough': 'style/textDecoration=line-through',
'format_align_left': 'paragraph/textAlign=left',
'format_align_center': 'paragraph/textAlign=center',
'format_align_right': 'paragraph/textAlign=right',
'format_list_bulleted': 'paragraph/listStyleType=unordered',
'format_list_numbered': 'paragraph/listStyleType=decimal'
};

var annotations = {};

function openLinkPopover(event,range){
if(!styleAppended){
let pStyle = document.createElement('style');
pStyle.innerHTML = `
#popover{
width: 330px;
height: 270px;
margin: 0 5px;
border-radius: 6px;
}
div.popover-link-image{
width: 330px;
height: 190px;
margin: 5px auto;
}
div.popover-link-description{
width: 320px;
height: auto;
max-height: 40px;
margin: 0 auto;
overflow: auto;
word-wrap: break-all;
}
.popover-link-title{
word-wrap: break-all;
text-overflow: ellpsis;
overflow: hidden;
white-space: nowrap;
}
.popover-link-address{
color: #000;
margin-left: 5px;
overflow: auto;
word-wrap: break-all;
text-overflow: ellipsis;
white-space: nowrap;
}
.popover-link-title{
margin-left: 5px;
}
#popover-container:after{
content: "";
position: absolute;
bottom: -25px;
left: 175px;
border-style: solid;
visibility: hidden;
width: 0;
z-index: 1;
}
#popover-container:before{
content: "";
position: absolute;
top: -11px;
left: -1px;
border-style: solid;
border-width: 0 10px 10px;
border-color: #F1F1F1 transparent;
display: block;
width: 0;
z-index: 0;
}`;
document.body.appendChild(pStyle);
styleAppended = true;
}
timer = $timeout(() => {
event.stopPropagation();
let div = document.createElement('div');
let btn = event.target;
console.dir(btn.offsetHeight);
let inHTML = `
<style>
.pos-r{
position relative;
margin: 150px 0;
}
</style>
<div class="pos-r">
<div class="spinner-container">
<svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
</div>
</div>
`;
linkPreview.getMetaData(btn.href)
.then((meta) => {
console.log(meta);
if(!meta){
div.style.display = 'none';
return;
}

Expand All @@ -54,7 +140,89 @@ angular.module('Teem')
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
</div>
</div>`;
<div class="popover-link-description">${urlDescription}</div>
<div class="popover-link-address">${btn.href}</div>
</div>`;
}
else if(urlDescription && !urlImage){
div.style.height = '110px';
inHTML = `<div id="popover">
<div class="popover-link-title"></div>
<div class="popover-link-description">${urlDescription}</div>
<div class="popover-link-address">${btn.href}</div>
</div>`;
}
else{
if(!urlTitle){
div.style.height = '110px';
inHTML = `<div id="popover" align="center">
<div class="popover-link-description">No Description provided ...</div>
<div class="popover-link-address">${btn.href}</div>
</div>`;
}
div.style.height = '110px';
inHTML = `<div id="popover" align="center">
<div class="popover-link-title">${urlTitle}</div>
<div class="popover-link-description">No Description provided ...</div>
<div class="popover-link-address">${btn.href}</div>
</div>`;
}
div.innerHTML = inHTML;
})
.catch((err) => {
console.log(err);
});
let clientRect = range.node.nextSibling ?
range.node.nextSibling.getBoundingClientRect() :
range.node.parentElement.getBoundingClientRect();
div.innerHTML = inHTML;
div.style.width = '345px';
div.style.height = '300px';
div.style.position = 'absolute';
div.style.border = '1px solid #F0F0F0';
div.style.top = clientRect.top + 35 + 'px';
div.style.left = clientRect.left + 'px';
div.style.zIndex = 3;
div.style.backgroundColor = '#F2F2F2';
div.style.paddingTop = '5px';
div.id = 'popover-container';
document.body.appendChild(div);
},700);
}

function closeLinkPopover(delay){
if(timer){
$timeout.cancel(timer);
timer = null;
$timeout(() => {
if(document.getElementById('popover-container')){
document.body.removeChild(document.getElementById('popover-container'));
}
}, delay);
}
}

function imgWidget(parentElement, before, state) {
state = state || before;

if (!(state in $scope.project.attachments) || !$scope.project.attachments[state].file) {
return;
}

// cannot use spinner template directly here
parentElement.innerHTML = `
<div class="pos-r">
<div class="spinner-container">
<svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
</div>
</div>`;

$scope.project.attachments[state].file.getUrl().then(url => {
parentElement.innerHTML = `<img src="${url}">`;
});
}

$scope.project.attachments[state].file.getUrl().then(url => {
parentElement.innerHTML = `<img src="${url}">`;
Expand Down
4 changes: 3 additions & 1 deletion src/js/services/pad/need-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ angular.module('Teem')
editor.deleteText(selection);
}

need = scope.project.addNeed(need);
need = scope.project.addNeedWithoutTrello(need);
//FIXME Doesn't work with the Trello integration, for now the ones created in pad cannot be added to Trello
// need = scope.project.addNeed(need);


// To generate need added event after all the info is available
Expand Down
Loading