This repository has been archived by the owner on Oct 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
425 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
angular.module('Kanboard') | ||
|
||
.config(function($compileProvider) { | ||
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|file|chrome-extension):/); | ||
}) | ||
|
||
.config(function($translateProvider) { | ||
|
||
$translateProvider.registerAvailableLanguageKeys(['en', 'de'], { | ||
'en_US': 'en', | ||
'en_UK': 'en', | ||
'de_DE': 'de', | ||
'de_CH': 'de', | ||
'de_AT': 'de' | ||
}) | ||
.determinePreferredLanguage() | ||
.fallbackLanguage('en') | ||
.useStaticFilesLoader({ | ||
prefix: 'translation/', | ||
suffix: '.json' | ||
}); | ||
}) | ||
|
||
.config(function($routeProvider) { | ||
$routeProvider | ||
.when('/', { | ||
controller: 'ProjectListController', | ||
templateUrl: 'view/project_list.html' | ||
}) | ||
.when('/settings', { | ||
controller: 'SettingsController', | ||
templateUrl: 'view/settings.html' | ||
}) | ||
.when('/settings/endpoint', { | ||
controller: 'SettingsEndpointController', | ||
templateUrl: 'view/settings_endpoint.html' | ||
}) | ||
.when('/settings/endpoint/:api_id', { | ||
controller: 'SettingsEndpointController', | ||
templateUrl: 'view/settings_endpoint.html' | ||
}) | ||
.when('/:api_id/board/show/:projectId', { | ||
controller: 'ShowProjectController', | ||
templateUrl: 'view/board_show.html' | ||
}) | ||
.when('/:api_id/task/show/:taskId', { | ||
controller: 'ShowTaskController', | ||
templateUrl: 'view/task_details.html' | ||
}) | ||
.when('/:api_id/board/overdue/:projectId', { | ||
controller: 'ShowOverdueController', | ||
templateUrl: 'view/board_overdue.html' | ||
}) | ||
.otherwise({ | ||
redirectTo: '/' | ||
}); | ||
}) | ||
|
||
.factory('navigation', ['$location', function($location) { | ||
return { | ||
home: function() { | ||
$location.path('/'); | ||
$location.replace(); | ||
console.log("Navigation: home"); | ||
return; | ||
}, | ||
settings: function() { | ||
$location.path('/settings'); | ||
$location.replace(); | ||
console.log("Navigation: settings"); | ||
return; | ||
}, | ||
settings_endpoint: function(api_id) { | ||
if (api_id >= 0) { | ||
$location.path('/settings/endpoint/' + api_id); | ||
} | ||
else { | ||
$location.path('/settings/endpoint'); | ||
} | ||
$location.replace(); | ||
console.log("Navigation: settings_endpoint"); | ||
return; | ||
}, | ||
task: function(api_id, task_id) { | ||
$location.path('/' + api_id + '/task/show/' + task_id); | ||
$location.replace(); | ||
console.log("Navigation: task"); | ||
return; | ||
}, | ||
board: function(api_id, board_id) { | ||
$location.path('/' + api_id + '/board/show/' + board_id); | ||
$location.replace(); | ||
console.log("Navigation: board"); | ||
return; | ||
} | ||
} | ||
}]) | ||
|
||
.factory('dataFactory', ['$base64', '$http', function($base64, $http) { | ||
|
||
var dataFactory = {}; | ||
|
||
dataFactory.getEndpoints = function() { | ||
var items = localStorage.getItem("endpoints"); | ||
|
||
if (items === null) { | ||
items = [{ | ||
"i": "0", | ||
"name": "Kanboard.net Demopage", | ||
"token": "da2776e2c7ca07b2b1169099550aa4a197024f2f7aac21212682240acc3f", | ||
"url": "http://demo.kanboard.net/jsonrpc.php" | ||
}]; | ||
} | ||
else { | ||
items = JSON.parse(items); | ||
for (var i = 0; i < items.length; i++) { | ||
items[i].id = i; | ||
} | ||
} | ||
|
||
return items; | ||
}; | ||
|
||
dataFactory.setEndpoints = function(endpoints) { | ||
return localStorage.setItem("endpoints", JSON.stringify(endpoints)); | ||
}; | ||
|
||
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 config = { | ||
headers: { | ||
'Authorization': 'Basic ' + auth | ||
} | ||
}; | ||
return config; | ||
}; | ||
|
||
dataFactory.getProjects = function(api_id) { | ||
var request = '{"jsonrpc": "2.0", "method": "getAllProjects", "id": ' + api_id + '}'; | ||
return $http.post(this.getBaseUrl(api_id) + '?getAllProjects', request, this.createConfig(api_id)); | ||
}; | ||
|
||
dataFactory.getBoard = function(api_id, projectid) { | ||
var request = '{"jsonrpc": "2.0", "method": "getBoard", "id": ' + api_id + ',"params": { "project_id": ' + projectid + ' }}'; | ||
return $http.post(this.getBaseUrl(api_id) + '?getBoard', request, this.createConfig(api_id)); | ||
}; | ||
|
||
dataFactory.getProjectById = function(api_id, projectid) { | ||
var request = '{"jsonrpc": "2.0", "method": "getProjectById", "id": ' + api_id + ',"params": { "project_id": ' + projectid + ' }}'; | ||
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)); | ||
}; | ||
|
||
dataFactory.getOverdueTasks = function(api_id) { | ||
var request = '{"jsonrpc": "2.0", "method": "getOverdueTasks", "id": ' + api_id + '}'; | ||
return $http.post(this.getBaseUrl(api_id) + '?getOverdueTasks', request, this.createConfig(api_id)); | ||
}; | ||
|
||
return dataFactory; | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
angular.module('KanboardCtrl') | ||
.controller('ProjectListController', function($scope, navigation, dataFactory) { | ||
$scope.$navigation = navigation; | ||
var projectList = this; | ||
|
||
$scope.endpoints = dataFactory.getEndpoints(); | ||
|
||
for (var i = 0; i < $scope.endpoints.length; i++) { | ||
$scope.endpoints[i].id = i; | ||
var id = i + 1; | ||
var result; | ||
dataFactory.getProjects(id) | ||
.success(function(request) { | ||
result = request.result; | ||
$scope.endpoints[request.id - 1].projects = result; | ||
}) | ||
.error(function(error) { | ||
console.log(error); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
angular.module('KanboardCtrl') | ||
.controller('SettingsController', function($scope, navigation, dataFactory, $mdDialog, $mdToast) { | ||
$scope.$navigation = navigation; | ||
|
||
var items = dataFactory.getEndpoints(); | ||
$scope.endpoints = items; | ||
|
||
$scope.showDeleteConfirm = function(ev, endpoint) { | ||
var confirm = $mdDialog.confirm() | ||
.parent(angular.element(document.body)) | ||
.title('Would you like to delete your endpoint?') | ||
.content('Name: ' + endpoint.name) | ||
.ariaLabel('Delete') | ||
.ok('Yes') | ||
.cancel('No') | ||
.targetEvent(ev); | ||
|
||
$mdDialog.show(confirm).then(function() { | ||
|
||
//delete from storage | ||
var items_new = new Array(); | ||
for (var i = 0; i < items.length; i++) { | ||
if (i == endpoint.id) { | ||
//nothing | ||
} | ||
else { | ||
items_new.push(items[i]); | ||
} | ||
} | ||
dataFactory.setEndpoints(items_new); | ||
|
||
//refresh list | ||
$scope.endpoints = dataFactory.getEndpoints(); | ||
|
||
$mdToast.show( | ||
$mdToast.simple() | ||
.content('Deleted!') | ||
.hideDelay(3000) | ||
); | ||
}, function() { | ||
//$scope.alert = 'Nothing changed.'; | ||
}); | ||
}; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
angular.module('KanboardCtrl') | ||
.controller('SettingsEndpointController', function($routeParams, $scope, navigation, dataFactory) { | ||
$scope.$navigation = navigation; | ||
var items; | ||
|
||
if ($routeParams.api_id >= 0) { | ||
var api_id = parseInt($routeParams.api_id); | ||
items = dataFactory.getEndpoints(); | ||
$scope.endpoint = items[api_id]; | ||
$scope.edit = true; | ||
} else { | ||
$scope.edit = false; | ||
} | ||
|
||
$scope.save = function() { | ||
if ($scope.endpoint.id >= 0) { | ||
items = dataFactory.getEndpoints(); | ||
items[$scope.endpoint.id] = $scope.endpoint; | ||
dataFactory.setEndpoints(items); | ||
} | ||
else { | ||
items = dataFactory.getEndpoints(); | ||
items.push($scope.endpoint); | ||
dataFactory.setEndpoints(items); | ||
} | ||
navigation.settings(); | ||
}; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
angular.module('KanboardCtrl') | ||
.controller('ShowOverdueController', function($routeParams, $scope, navigation, dataFactory) { | ||
$scope.$navigation = navigation; | ||
var project_id = $routeParams.projectId; | ||
|
||
var api_id = parseInt($routeParams.api_id) + 1; | ||
$scope.api_id = $routeParams.api_id; | ||
var overdue; | ||
|
||
$scope.tasks = []; | ||
|
||
dataFactory.getOverdueTasks(api_id) | ||
.success(function(request) { | ||
overdue = request.result; | ||
for (var i = 0; i < overdue.length; i++) { | ||
if (overdue[i].project_id == project_id) { | ||
$scope.tasks.push(overdue[i]); | ||
} | ||
} | ||
}) | ||
.error(function(error) { | ||
console.log(error); | ||
}); | ||
|
||
dataFactory.getProjectById(api_id, project_id) | ||
.success(function(request) { | ||
var project = request.result; | ||
$scope.project_name = project.name; | ||
}) | ||
.error(function(error) { | ||
console.log(error); | ||
}); | ||
|
||
}); |
Oops, something went wrong.