Skip to content
This repository has been archived by the owner on Oct 11, 2021. It is now read-only.

Commit

Permalink
Version 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoStahl committed Oct 10, 2015
1 parent 476ae13 commit 03367ab
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 67 deletions.
4 changes: 2 additions & 2 deletions src/css/style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/* Chrome Extension*/
body {
min-width:400px;
min-width:600px;
}

.task {
Expand Down
139 changes: 92 additions & 47 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,95 +64,113 @@ angular.module('Kanboard')
});
})
.run(function($rootScope, $location, $route, dataFactory, navigation) {

//check if settings are availiable
var settings = dataFactory.getSettings();
if (settings === null) {
//create settings in local storage
settings = new Object();
}
if (!("rememberLastPage" in settings)) {
//rememberLastPage missing
settings.rememberLastPage = false;
}
dataFactory.setSettings(settings);

$rootScope.$watch(function() {
return $location.path();
},
function(a) {
// url changed
var settings = dataFactory.getSettings();
if (a != '/lasturl') {
settings.lastVisitedUrl = settings.currentUrl;
settings.currentUrl = a;
dataFactory.setSettings(settings);
} else {
if (settings.rememberLastPage) {
navigation.url(settings.currentUrl);
}
if (a === '/lasturl' && settings.rememberLastPage) {
navigation.back();
}
});

//fix https://github.com/angular/angular.js/issues/1699
var original = $location.path;
$location.path = function (path, reload) {
if (reload === false) {
var lastRoute = $route.current;
var un = $rootScope.$on('$locationChangeSuccess', function () {
$route.current = lastRoute;
un();
});
}

return original.apply($location, [path]);
};
$location.path = function(path, reload) {
if (reload === false) {
var lastRoute = $route.current;
var un = $rootScope.$on('$locationChangeSuccess', function() {
$route.current = lastRoute;
un();
});
}

return original.apply($location, [path]);
};
})
.factory('navigation', ['$location', 'dataFactory', function($location, dataFactory) {
return {
home: function() {
console.log("Navigation: home/projectlist");
$location.path('/projectlist').replace();
this.go_with_history('/projectlist');
return;
},
settings: function() {
console.log("Navigation: settings");
$location.path('/settings').replace();
this.go_with_history('/settings');
return;
},
settings_endpoint: function(api_id) {
console.log("Navigation: settings_endpoint");
if (api_id >= 0) {
$location.path('/settings/endpoint/' + api_id);
this.go_with_history('/settings/endpoint/' + api_id);
}
else {
$location.path('/settings/endpoint');
this.go_with_history('/settings/endpoint');
}
$location.replace();
return;
},
task: function(api_id, task_id) {
console.log("Navigation: task");
$location.path('/' + api_id + '/task/show/' + task_id).replace();
this.go_with_history('/' + api_id + '/task/show/' + task_id);
return;
},
board: function(api_id, board_id, column_id, reload) {
console.log("Navigation: board");
if(!column_id){
column_id = 0;
if (!column_id) {
column_id = 0;
}
$location.path('/' + api_id + '/board/show/' + board_id + '/' + column_id, reload).replace();
this.go_with_history('/' + api_id + '/board/show/' + board_id + '/' + column_id, reload);
return;
},
url: function(url) {
console.log("Navigation: url => " + url);
$location.path(url).replace();
this.go_with_history(url);
return;
},
extern_url: function(url) {
extern_url: function(url) {
console.log("Navigation: url => " + url);
window.open(url,"_blank")
window.open(url, "_blank");
return;
},
back: function(){
var settings = dataFactory.getSettings();
this.url(settings.lastVisitedUrl);
//window.history.back();
back: function() {
var history = dataFactory.getHistory();
var url = $location.path();
while (url === $location.path()) {
url = history.pop();
}
dataFactory.setHistory(history);
$location.path(url).replace();
return;
},
board_activity: function(api_id, board_id) {
console.log("Navigation: board activity");
$location.path('/' + api_id + '/board/activity/' + board_id).replace();
this.go_with_history('/' + api_id + '/board/activity/' + board_id);
return;
},
board_overdue: function(api_id, board_id) {
console.log("Navigation: board overdue");
$location.path('/' + api_id + '/board/overdue/' + board_id).replace();
this.go_with_history('/' + api_id + '/board/overdue/' + board_id);
return;
},
go_with_history: function(url, reload) {
var history = dataFactory.getHistory();
history.push(url);
dataFactory.setHistory(history);
$location.path(url, reload).replace();
return;
}
}
Expand All @@ -170,13 +188,17 @@ angular.module('Kanboard')
"i": "0",
"name": "Kanboard.net Demopage",
"token": "da2776e2c7ca07b2b1169099550aa4a197024f2f7aac21212682240acc3f",
"url": "http://demo.kanboard.net/jsonrpc.php"
"url": "http://demo.kanboard.net/jsonrpc.php",
"user": "jsonrpc"
}];
}
else {
items = JSON.parse(items);
for (var i = 0; i < items.length; i++) {
items[i].id = i;
if (items[i].user === undefined || items[i].user == "") {
items[i].user = "jsonrpc";
}
}
}

Expand All @@ -198,14 +220,36 @@ angular.module('Kanboard')
return localStorage.setItem("settings", JSON.stringify(settings));
};

dataFactory.getHistory = function() {
var history = {};
history = localStorage.getItem("history");
if (history === null) {
history = new Array();
}
else {
history = JSON.parse(history);
}
if (history.length <= 1) {
history.push("/projectlist");
}
return history;
};

dataFactory.setHistory = function(history) {
while (history.length > 50) {
history.shift();
}
return localStorage.setItem("history", JSON.stringify(history));
};

dataFactory.getBaseUrl = function(api_id) {
var api_config = this.getEndpoints()[api_id - 1];
return api_config.url;
};

dataFactory.createConfig = function(api_id) {
var api_config = this.getEndpoints()[api_id - 1];
var auth = $base64.encode('jsonrpc' + ':' + api_config.token);
var auth = $base64.encode(api_config.user + ':' + api_config.token);
var config = {
headers: {
'Authorization': 'Basic ' + auth
Expand All @@ -215,7 +259,13 @@ angular.module('Kanboard')
};

dataFactory.getProjects = function(api_id) {
var request = '{"jsonrpc": "2.0", "method": "getAllProjects", "id": ' + api_id + '}';
var api_config = this.getEndpoints()[api_id - 1];
if (api_config.user == 'jsonrpc') {
var request = '{"jsonrpc": "2.0", "method": "getAllProjects", "id": ' + api_id + '}';
}
else {
var request = '{"jsonrpc": "2.0", "method": "getMyProjectsList", "id": ' + api_id + '}';
}
return $http.post(this.getBaseUrl(api_id) + '?getAllProjects', request, this.createConfig(api_id));
};

Expand All @@ -229,11 +279,6 @@ angular.module('Kanboard')
return $http.post(this.getBaseUrl(api_id) + '?getProjectById', request, this.createConfig(api_id));
};

dataFactory.getProjectActivity = function(api_id, projectid) {
var request = '{"jsonrpc": "2.0", "method": "getProjectActivity", "id": ' + api_id + ',"params": { "project_id": ' + projectid + ' }}';
return $http.post(this.getBaseUrl(api_id) + '?getProjectActivity', request, this.createConfig(api_id));
};

dataFactory.getTaskById = function(api_id, taskid) {
var request = '{"jsonrpc": "2.0", "method": "getTask", "id": ' + api_id + ',"params": { "task_id": ' + taskid + ' }}';
return $http.post(this.getBaseUrl(api_id) + '?getTask', request, this.createConfig(api_id));
Expand All @@ -243,7 +288,7 @@ angular.module('Kanboard')
var request = '{"jsonrpc": "2.0", "method": "getOverdueTasks", "id": ' + api_id + '}';
return $http.post(this.getBaseUrl(api_id) + '?getOverdueTasks', request, this.createConfig(api_id));
};

dataFactory.getProjectActivity = function(api_id, project_id) {
var request = '{"jsonrpc": "2.0", "method": "getProjectActivity", "id": ' + api_id + ',"params": { "project_id": ' + project_id + ' }}';
return $http.post(this.getBaseUrl(api_id) + '?getProjectActivity', request, this.createConfig(api_id));
Expand Down
4 changes: 4 additions & 0 deletions src/js/controllers/SettingsEndpointCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ angular.module('KanboardCtrl')
$scope.endpoint = items[api_id];
$scope.edit = true;
} else {
$scope.endpoint = new Object();
$scope.edit = false;
}

$scope.endpoint.user = "jsonrpc";

$scope.save = function() {
$scope.endpoint.user = "jsonrpc";
if ($scope.endpoint.id >= 0) {
items = dataFactory.getEndpoints();
items[$scope.endpoint.id] = $scope.endpoint;
Expand Down
2 changes: 2 additions & 0 deletions src/js/controllers/ShowBoardCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ angular.module('KanboardCtrl')
.success(function(request) {
project = request.result;
$scope.project = project;
console.log("Before " + $scope.selectedIndex);
if($routeParams.columnId > 0){
$scope.selectedIndex = $routeParams.columnId;
console.log("In " + $scope.selectedIndex);
}
})
.error(function(error) {
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_chrome_extension_name__",
"description": "__MSG_chrome_extension_description__",
"version": "0.1.1",
"version": "0.1.2",
"author": "Timo Litzbarski",
"default_locale": "en",
"browser_action": {
Expand Down
5 changes: 3 additions & 2 deletions src/translation/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"add": "hinzufügen",
"name": "Name",
"url": "URL",
"token": "Token",
"token": "Passwort/Token",
"save": "Speichern",
"cancel": "Abbrechen",
"no_task_in_column": "Keine Aufgaben in Spalte:",
Expand All @@ -18,5 +18,6 @@
"no_overdue_in": "Keine überfälligen Aufgaben in",
"overdue": "Überfällig",
"activities": "Aktivitäten",
"Remember last page on close and reopen on startup.": "Bei Start der App, die zuletzt besuchte Seite laden."
"Remember last page on close and reopen on startup.": "Bei Start der App, die zuletzt besuchte Seite laden.",
"user": "Benutzer"
}
5 changes: 3 additions & 2 deletions src/translation/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"add": "add",
"name": "Name",
"url": "URL",
"token": "Token",
"token": "Password/Token",
"save": "Save",
"cancel": "Cancel",
"no_task_in_column": "No tasks in column:",
Expand All @@ -18,5 +18,6 @@
"no_overdue_in": "no overdue tasks in",
"overdue": "Overdue",
"activities": "Activities",
"Remember last page on close and reopen on startup.": "Remember last page on close and reopen on startup."
"Remember last page on close and reopen on startup.": "Remember last page on close and reopen on startup.",
"user": "User"
}
4 changes: 1 addition & 3 deletions src/view/board_activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ <h1 class="md-title">{{ 'activities' | translate }}: {{project.name}}</h1>
</md-button>-->
</md-list-item>
<md-list>
</div>

<md-button ng-click="$navigation.back()">{{ 'back' | translate }}</md-button>
</div>
4 changes: 1 addition & 3 deletions src/view/board_overdue.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ <h1 class="md-title">{{ 'overdue' | translate }}: {{project.name}}</h1>
</div>

<span ng-repeat="task in tasks" ng-include="'view/task_box.html'">
</div>

<md-button ng-click="$navigation.back()">{{ 'back' | translate }}</md-button>
</div>
4 changes: 1 addition & 3 deletions src/view/board_show.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,4 @@ <h1 class="md-title">{{project.name}}</h1>

</md-tabs>
</md-content>
</div>

<md-button ng-click="$navigation.back()">{{ 'back' | translate }}</md-button>
</div>
3 changes: 3 additions & 0 deletions src/view/menu.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<md-button class="md-icon-button" ng-click="$navigation.back()">
<ng-md-icon icon="undo"></ng-md-icon>
</md-button>
<md-menu>
<md-button aria-label="Open interactions menu" class="md-icon-button" ng-click="$mdOpenMenu()">
<ng-md-icon icon="menu"></ng-md-icon>
Expand Down
4 changes: 4 additions & 0 deletions src/view/settings_endpoint.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ <h1 class="md-title">
<label>{{ 'url' | translate }}</label>
<input type="url" ng-model="endpoint.url" required>
</md-input-container>
<md-input-container flex>
<label>{{ 'user' | translate }}</label>
<input ng-model="endpoint.user" readonly required>
</md-input-container>
<md-input-container flex>
<label>{{ 'token' | translate }}</label>
<input ng-model="endpoint.token" required>
Expand Down
5 changes: 1 addition & 4 deletions src/view/task_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ <h1 class="md-title">{{task.title}}</h1>
<p>ID: {{task.id}}</p>

<p>Description:</p>
<blockquote>{{task.description}}</blockquote>


<a href="#/{{api_id}}/board/show/{{task.project_id}}"><md-button>Back</md-button></a>
<blockquote>{{task.description}}</blockquote>

0 comments on commit 03367ab

Please sign in to comment.