Commit 20eed09d authored by chickahoona's avatar chickahoona

on the way to group shares

parent a84ada81
......@@ -9,6 +9,8 @@ stages:
- deploy
unittests:
except:
- schedules
stage: test
image: ubuntu:16.04
script:
......@@ -21,6 +23,8 @@ unittests:
- karma start ./unittests/karma-chrome-headless.conf.js
linter:
except:
- schedules
stage: test
image: ubuntu:16.04
script:
......@@ -31,6 +35,8 @@ linter:
docker-image:
except:
- schedules
stage: build
image: ubuntu:16.04
services:
......@@ -46,6 +52,8 @@ docker-image:
- docker push $CONTAINER_TEST_IMAGE
firefox-extension:
except:
- schedules
stage: build
image: ubuntu:16.04
script:
......@@ -62,6 +70,8 @@ firefox-extension:
- ./*
chrome-extension:
except:
- schedules
stage: build
image: ubuntu:16.04
script:
......@@ -78,6 +88,8 @@ chrome-extension:
- ./*
webclient:
except:
- schedules
stage: build
image: ubuntu:16.04
script:
......@@ -94,6 +106,8 @@ webclient:
- ./*
job-release-docker:
except:
- schedules
stage: release
image: docker:git
services:
......@@ -108,6 +122,8 @@ job-release-docker:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
job-deploy:
except:
- schedules
stage: deploy
image: docker:git
services:
......@@ -121,6 +137,8 @@ job-deploy:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
job-deploy-chrome:
except:
- schedules
stage: deploy
image: ubuntu:16.04
script:
......@@ -134,6 +152,8 @@ job-deploy-chrome:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
job-deploy-firefox:
except:
- schedules
stage: deploy
image: ubuntu:16.04
script:
......@@ -145,3 +165,14 @@ job-deploy-firefox:
url: https://addons.mozilla.org/de/firefox/addon/psono-pw-password-manager/
only:
- /^v[0-9]*\.[0-9]*\.[0-9]*$/
scheduled-linter:
only:
- schedules
stage: test
image: ubuntu:16.04
script:
- sh ./var/build-ubuntu.sh
- cat ./build/firefox/manifest.json
- addons-linter --help
- addons-linter ./build/firefox
# PSONO Client - Password Manager
Master: [![Code Climate](https://codeclimate.com/github/psono/psono-client/badges/gpa.svg)](https://codeclimate.com/github/psono/psono-client) [![build status](https://images.microbadger.com/badges/image/psono/psono-client.svg)](https://hub.docker.com/r/psono/psono-client/) [![build status](https://gitlab.com/psono/psono-client/badges/master/build.svg)](https://gitlab.com/psono/psono-client/commits/master) [![coverage report](https://gitlab.com/psono/psono-client/badges/master/coverage.svg)](https://gitlab.com/psono/psono-client/commits/master)
Master: [![build status](https://gitlab.com/psono/psono-client/badges/master/build.svg)](https://gitlab.com/psono/psono-client/commits/master) [![coverage report](https://gitlab.com/psono/psono-client/badges/master/coverage.svg)](https://gitlab.com/psono/psono-client/commits/master) [![Code Climate](https://codeclimate.com/github/psono/psono-client/badges/gpa.svg)](https://codeclimate.com/github/psono/psono-client) [![build status](https://images.microbadger.com/badges/image/psono/psono-client.svg)](https://hub.docker.com/r/psono/psono-client/) [![build status](https://img.shields.io/docker/pulls/psono/psono-client.svg)](https://hub.docker.com/r/psono/psono-client/)
Develop: [![build status](https://gitlab.com/psono/psono-client/badges/develop/build.svg)](https://gitlab.com/psono/psono-client/commits/develop) [![coverage report](https://gitlab.com/psono/psono-client/badges/develop/coverage.svg)](https://gitlab.com/psono/psono-client/commits/develop)
......
......@@ -159,6 +159,7 @@ var build = function(build_path, type) {
"src/common/data/js/controller/modal/EditEntryCtrl.js",
"src/common/data/js/controller/modal/EditFolderCtrl.js",
"src/common/data/js/controller/modal/NewFolderCtrl.js",
"src/common/data/js/controller/modal/DeleteVerifyCtrl.js",
"src/common/data/js/controller/modal/NewGroupCtrl.js",
"src/common/data/js/controller/modal/EditGroupCtrl.js",
"src/common/data/js/controller/modal/ShareEditEntryCtrl.js",
......
......@@ -161,6 +161,7 @@
<script src="js/controller/modal/EditEntryCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/EditFolderCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/NewFolderCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/DeleteVerifyCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/NewGroupCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/EditGroupCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/ShareEditEntryCtrl.js" type="application/javascript"></script>
......
......@@ -83,6 +83,7 @@
<script src="js/controller/modal/EditEntryCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/EditFolderCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/NewFolderCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/DeleteVerifyCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/NewGroupCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/EditGroupCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/ShareEditEntryCtrl.js" type="application/javascript"></script>
......
......@@ -25,12 +25,12 @@ body {
.progress {
margin-bottom: 0; }
.tree-container {
.panel-body {
position: relative; }
.tree-container .widget-searchform {
.panel-body .widget-searchform {
position: absolute;
right: -13px;
top: -52px; }
right: 2px;
top: -36px; }
.note {
font-style: italic; }
......
......@@ -309,6 +309,7 @@
<script src="js/controller/modal/EditEntryCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/EditFolderCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/NewFolderCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/DeleteVerifyCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/NewGroupCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/EditGroupCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/ShareEditEntryCtrl.js" type="application/javascript"></script>
......
......@@ -372,6 +372,7 @@
<script src="js/controller/modal/EditEntryCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/EditFolderCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/NewFolderCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/DeleteVerifyCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/NewGroupCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/EditGroupCtrl.js" type="application/javascript"></script>
<script src="js/controller/modal/ShareEditEntryCtrl.js" type="application/javascript"></script>
......
......@@ -31,17 +31,10 @@
$scope.openNewFolder = openNewFolder;
$scope.openNewItem = openNewItem;
$scope.tosearchTreeFilter = $routeParams.default_search;
$scope.structure = { data: {}} ;
$scope.options = {
/**
* Returns the default value for the search if it exists
* @returns {*}
*/
getDefaultSearch: function() {
return $routeParams.default_search;
},
/**
* Triggered once someone selects a node
*
......@@ -196,9 +189,31 @@
.then(function(data) {
$scope.structure.data = data;
$scope.structure.loaded = true;
managerDatastorePassword.modifyTreeForSearch($scope.tosearchTreeFilter, undefined, $scope.structure.data);
});
var update_datastore = function(value) {
$scope.structure.data = value;
managerDatastorePassword.modifyTreeForSearch($scope.tosearchTreeFilter, $scope.structure.data);
};
managerDatastorePassword.register('save_datastore_content', update_datastore);
$scope.$on('$destroy', function() {
managerDatastorePassword.unregister('save_datastore_content', update_datastore);
})
}
$scope.$watch('tosearchTreeFilter', function(newValue, oldValue) {
managerDatastorePassword.modifyTreeForSearch(newValue, oldValue, $scope.structure.data);
});
/**
* clears the input field for the tree search
*/
$scope.clearSearchTreeForm = function () {
$scope.tosearchTreeFilter = '';
};
function contextMenuOnShow(div_id) {
dropDownMenuWatcher.on_open(div_id);
contextMenusOpen++;
......
......@@ -8,17 +8,20 @@
* @requires $interval
* @requires $uibModal
* @requires psonocli.managerGroups
* @requires psonocli.managerDatastorePassword
* @requires psonocli.helper
*
* @description
* Controller for the Group view
*/
angular.module('psonocli').controller('GroupsCtrl', ["$scope", "$interval", "$uibModal", "managerGroups", "helper",
function ($scope, $interval, $uibModal, managerGroups, helper) {
angular.module('psonocli').controller('GroupsCtrl', ["$scope", "$interval", "$uibModal", "managerGroups", "managerDatastorePassword", "helper",
function ($scope, $interval, $uibModal, managerGroups, managerDatastorePassword, helper) {
$scope.create_group = create_group;
$scope.edit_group = edit_group;
$scope.delete_group = delete_group;
$scope.accept_group = accept_group;
$scope.decline_group = decline_group;
activate();
......@@ -73,29 +76,64 @@
* @description
* Opens the modal for editing a group
*
* @param {Object} group The group to edit
* @param {uuid} group_id The id of the group to edit
* @param {string} size The size of the modal to open
*/
function edit_group(group, size) {
function edit_group(group_id, size) {
var modalInstance = $uibModal.open({
templateUrl: 'view/modal-edit-group.html',
controller: 'ModalEditGroupCtrl',
size: size,
resolve: {
group: function () {
return group;
group_id: function () {
return group_id;
}
}
});
modalInstance.result.then(function (group) {
// TODO: Trigger Save of group and update table
modalInstance.result.then(function (new_group_name) {
if (typeof(new_group_name) === 'undefined') {
return;
}
var onSuccess = function(){
for (var i = 0; i < $scope.groups.length; i++) {
if ($scope.groups[i].group_id !== group_id) {
continue;
}
$scope.groups[i].name = new_group_name;
}
};
var onError = function() {
//pass
};
managerGroups.update_group(group_id, new_group_name)
.then(onSuccess, onError);
}, function () {
// cancel triggered
});
}
/**
* @ngdoc
* @name psonocli.controller:ShareCtrl#remove_item_from_pending_list
* @methodOf psonocli.controller:ShareCtrl
*
* @description
* Helper function to remove a specified item from the pending shares list
*
* @param group_id
*/
var remove_group_from_pending_list = function (group_id) {
helper.remove_from_array($scope.groups, group_id, function(group, group_id) {
return group.group_id === group_id;
});
};
/**
* @ngdoc
* @name psonocli.controller:GroupsCtrl#delete_group
......@@ -104,19 +142,143 @@
* @description
* Deletes a given group
*
* @param {Object} group The group to delete
* @param {uuid} group_id The id of the group to delete
*/
function delete_group(group_id) {
var modalInstance = $uibModal.open({
templateUrl: 'view/modal-delete-verify.html',
controller: 'ModalDeleteVerifyCtrl',
resolve: {
title: function () {
return 'Delete Group';
},
description: function () {
return 'You are about to delete the group. All shares will be lost. Are you sure?';
}
}
});
modalInstance.result.then(function () {
// User clicked the yes button
var onSuccess = function(data){
remove_group_from_pending_list(group_id);
};
var onError = function() {
//pass
};
managerGroups.delete_group(group_id)
.then(onSuccess, onError);
}, function () {
// cancel triggered
});
}
/**
* @ngdoc
* @name psonocli.controller:GroupsCtrl#accept_group
* @methodOf psonocli.controller:GroupsCtrl
*
* @description
* Accepts a given membership request
*
* @param {uuid} group The group to accept
*/
function delete_group(group) {
function accept_group(group) {
var modalInstance = $uibModal.open({
templateUrl: 'view/modal-accept-share.html',
controller: 'ModalAcceptShareCtrl',
resolve: {
title: function () {
return 'Accept Group';
},
item: function () {
return {
'share_right_read': true
};
},
user: function () {
return {
'user_id': group.user_id,
'user_username': group.user_username
};
}
}
});
modalInstance.result.then(function (breadcrumbs) {
// User clicked the prime button
var onSuccess = function (datastore) {
var analyzed_breadcrumbs = managerDatastorePassword.analyze_breadcrumbs(breadcrumbs, datastore);
if (group.share_right_grant === false && typeof(analyzed_breadcrumbs['parent_share_id']) !== 'undefined') {
// No grant right, yet the parent is a a share?!?
alert("Wups, this should not happen. Error: 405989c9-44c7-4fe7-b443-4ee7c8e07ed1");
return;
}
var onSuccess = function (shares) {
managerDatastorePassword.create_share_links_in_datastore(shares, analyzed_breadcrumbs['target'],
analyzed_breadcrumbs['parent_path'], analyzed_breadcrumbs['path'],
analyzed_breadcrumbs['parent_share_id'], analyzed_breadcrumbs['parent_datastore_id'],
datastore);
remove_group_from_pending_list(group.group_id);
};
var onError = function (data) {
//pass
};
managerGroups.accept_membership(group.membership_id)
.then(onSuccess, onError);
};
var onError = function (data) {
//pass
};
managerDatastorePassword.get_password_datastore()
.then(onSuccess, onError);
}, function () {
// cancel triggered
});
}
/**
* @ngdoc
* @name psonocli.controller:GroupsCtrl#decline_group
* @methodOf psonocli.controller:GroupsCtrl
*
* @description
* Declines a given membership request
*
* @param {uuid} group The group to decline
*/
function decline_group(group) {
var onSuccess = function(data){
helper.remove_from_array($scope.groups, group);
helper.remove_from_array($scope.groups, group.membership_id, function(a, membership_id) {
return a['membership_id'] === membership_id;
});
};
var onError = function() {
//pass
};
managerGroups.delete_group(group['group_id'])
managerGroups.decline_membership(group.membership_id)
.then(onSuccess, onError);
}
}]);
......
(function(angular) {
'use strict';
/**
* @ngdoc controller
* @name psonocli.controller:ModalDeleteVerifyCtrl
* @requires $scope
* @requires $uibModalInstance
*
* @description
* Controller for the "delete verification" modal
*/
angular.module('psonocli').controller('ModalDeleteVerifyCtrl', ['$scope', '$uibModalInstance', 'title', 'description',
function ($scope, $uibModalInstance, title, description) {
$scope.confirm = confirm;
$scope.cancel = cancel;
$scope.title = title;
$scope.description = description;
/**
* @ngdoc
* @name psonocli.controller:ModalDeleteVerifyCtrl#save
* @methodOf psonocli.controller:ModalDeleteVerifyCtrl
*
* @description
* Triggered once someone clicks the confirm button in the modal
*/
function confirm() {
$uibModalInstance.close($scope.name);
}
/**
* @ngdoc
* @name psonocli.controller:ModalDeleteVerifyCtrl#cancel
* @methodOf psonocli.controller:ModalDeleteVerifyCtrl
*
* @description
* Triggered once someone clicks the cancel button in the modal
*/
function cancel() {
$uibModalInstance.dismiss('cancel');
}
}]);
}(angular));
......@@ -8,14 +8,17 @@
* @requires $routeParams
* @requires $uibModal
* @requires psonocli.managerShare
* @requires psonocli.managerShareLink
* @requires psonocli.managerDatastorePassword
* @requires psonocli.cryptoLibrary
*
* @description
* Controller for the Share view
*/
angular.module('psonocli').controller('ShareCtrl', ['$scope', '$routeParams', '$uibModal', 'managerShare', 'managerDatastorePassword', 'cryptoLibrary',
function ($scope, $routeParams, $uibModal, managerShare, managerDatastorePassword, cryptoLibrary) {
angular.module('psonocli').controller('ShareCtrl', ['$scope', '$routeParams', '$uibModal', 'managerShare',
'managerShareLink', 'managerDatastorePassword', 'cryptoLibrary',
function ($scope, $routeParams, $uibModal, managerShare,
managerShareLink, managerDatastorePassword, cryptoLibrary) {
$scope.accept = accept;
$scope.decline = decline;
......@@ -41,6 +44,11 @@
}
/**
* @ngdoc
* @name psonocli.controller:ShareCtrl#remove_item_from_pending_list
* @methodOf psonocli.controller:ShareCtrl
*
* @description
* Helper function to remove a specified item from the pending shares list
*
* @param item
......@@ -57,7 +65,6 @@
};
/**
* @ngdoc
* @name psonocli.controller:ShareCtrl#accept
......@@ -75,8 +82,17 @@
templateUrl: 'view/modal-accept-share.html',
controller: 'ModalAcceptShareCtrl',
resolve: {
title: function () {
return 'Accept Share';
},
item: function () {
return item;
},
user: function () {
return {
'user_id': item.share_right_create_user_id,
'user_username': item.share_right_create_user_username
};
}
}
});
......@@ -86,70 +102,25 @@
var onSuccess = function (datastore) {
var link_id = cryptoLibrary.generate_uuid();
var path;
var parent_path;
var target;
var parent_share_id;
var datastore_id;
if (typeof breadcrumbs.id_breadcrumbs !== "undefined") {
path = breadcrumbs.id_breadcrumbs.slice();
var path_copy = breadcrumbs.id_breadcrumbs.slice();
parent_path = breadcrumbs.id_breadcrumbs.slice();
// find drop zone
var val1 = managerDatastorePassword.find_in_datastore(breadcrumbs.id_breadcrumbs, datastore);
target = val1[0][val1[1]];
// get the parent (share or datastore)
var parent_share = managerShare.get_closest_parent_share(path_copy, datastore, datastore, 0);
if (parent_share.hasOwnProperty("datastore_id")) {
datastore_id = parent_share.datastore_id;
} else if (parent_share.hasOwnProperty("share_id")){
parent_share_id = parent_share.share_id;
} else {
alert("Wupsi, that should not happen: d6da43af-e0f5-46ba-ae5b-d7e5ccd2fa92")
}
} else {
path = [];
parent_path = [];
target = datastore;
datastore_id = target.datastore_id;
}
var analyzed_breadcrumbs = managerDatastorePassword.analyze_breadcrumbs(breadcrumbs, datastore);
if (item.share_right_grant === false && typeof(parent_share_id) !== 'undefined') {
if (item.share_right_grant === false && typeof(analyzed_breadcrumbs['parent_share_id']) !== 'undefined') {
// No grant right, yet the parent is a a share?!?
alert("Wups, this should not happen. Error: 781f3da7-d38b-470e-a3c8-dd5787642230");
}
var onSuccess = function (share) {
share.id = link_id;
if (typeof share.name === "undefined") {
share.name = item.share_right_title;
}
if (typeof share.type === "undefined") {
//its a folder, lets add it to folders
if (typeof target.folders === "undefined") {
target.folders = []
}
target.folders.push(share)
} else {
// its an item, lets add it to items
if (typeof target.items === "undefined") {
target.items = []
}
target.items.push(share)
}
path.push(share.id);
var changed_paths = managerDatastorePassword.on_share_added(share.share_id, path, datastore, 1);
changed_paths.push(parent_path);
var shares = [share];
managerDatastorePassword.save_datastore_content(datastore, changed_paths);
managerDatastorePassword.create_share_links_in_datastore(shares, analyzed_breadcrumbs['target'],
analyzed_breadcrumbs['parent_path'], analyzed_breadcrumbs['path'],
analyzed_breadcrumbs['parent_share_id'], analyzed_breadcrumbs['parent_datastore_id'],
datastore);
remove_item_from_pending_list(item, pending_shares);
};
......@@ -159,8 +130,8 @@
};
managerShare.accept_share_right(item.share_right_id, item.share_right_key,
item.share_right_key_nonce, breadcrumbs.user.data.user_public_key, link_id, parent_share_id,
datastore_id
item.share_right_key_nonce, breadcrumbs.user.data.user_public_key, analyzed_breadcrumbs['parent_share_id'],
analyzed_breadcrumbs['parent_datastore_id']
).then(onSuccess, onError);
};
var onError = function (data) {
......@@ -169,7 +140,6 @@
managerDatastorePassword.get_password_datastore()
.then(onSuccess, onError);
}, function () {
// cancel triggered
});
......
......@@ -17,15 +17,16 @@
* Controller for the "AcceptShare" modal
*/
angular.module('psonocli').controller('ModalAcceptShareCtrl', ['$scope', '$uibModalInstance', '$uibModal',
'managerDatastoreUser', 'message', 'shareBlueprint', 'item', 'cryptoLibrary',
'managerDatastoreUser', 'message', 'shareBlueprint', 'title', 'item', 'cryptoLibrary',
function ($scope, $uibModalInstance, $uibModal,
managerDatastoreUser, message, shareBlueprint, item, cryptoLibrary) {
managerDatastoreUser, message, shareBlueprint, title, item, cryptoLibrary) {
$scope.cut_breadcrumbs = cut_breadcrumbs;
$scope.clear_breadcrumbs = clear_breadcrumbs;
$scope.save = save;
$scope.cancel = cancel;
$scope.title = title;
$scope.item = item;
$scope.user_is_trusted = false;
$scope.trust = trust;
......
(function(angular) {
'use strict';
/**
* @ngdoc controller
* @name psonocli.controller:ModalDeleteVerifyCtrl
* @requires $scope
* @requires $uibModalInstance
*
* @description
* Controller for the "delete verification" modal
*/
angular.module('psonocli').controller('ModalDeleteVerifyCtrl', ['$scope', '$uibModalInstance', 'title', 'description',
function ($scope, $uibModalInstance, title, description) {