Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3c07153
Switching to load users on an AJAX call
jeffkinnison Aug 4, 2016
4f5f026
updated controllers to only load shared users, added functions to ret…
jeffkinnison Aug 4, 2016
84f160a
changed AJAX call to POST and added resourceId field
jeffkinnison Aug 4, 2016
b742a23
updated views to incorporate new user loading scheme
jeffkinnison Aug 4, 2016
878df05
updated views to incorporate new user loading scheme
jeffkinnison Aug 4, 2016
7206631
added user list routes to project and experiments
jeffkinnison Aug 15, 2016
bb852b7
user lists load asynchronously
jeffkinnison Aug 15, 2016
98b6ca3
fixed issue 2005, 2014, 2021
jeffkinnison Aug 15, 2016
7b21101
minor fixes
jeffkinnison Aug 15, 2016
dcf8e47
Project summary page now only load experiments that the user may access
jeffkinnison Aug 16, 2016
39f9b23
Default Project owner granted read and write permissions at creation
jeffkinnison Aug 16, 2016
fe50621
project owner always granted sharing when permissions are set (to ens…
jeffkinnison Aug 16, 2016
cb57e29
Removed ability for users with read only permissions to access projec…
jeffkinnison Aug 16, 2016
9f0ee4e
changes to ensure project owner cannot have permissions changed by ot…
jeffkinnison Aug 16, 2016
ca0105c
redirect read-inly users from edit view to summary view
jeffkinnison Aug 17, 2016
a5dbbaa
minor logic change
jeffkinnison Aug 17, 2016
2fe80e7
Removed link to edit page to read-only users
jeffkinnison Aug 17, 2016
ebdc163
Removed edit links from browse
jeffkinnison Aug 17, 2016
face8c5
Added owner thumbnail, post-completion sharing, and verified that the…
jeffkinnison Aug 17, 2016
81628aa
fixed experiment ownership nomenclature issue
jeffkinnison Aug 17, 2016
9ff7296
Fixed create-complete screen
jeffkinnison Aug 17, 2016
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
166 changes: 111 additions & 55 deletions app/controllers/ExperimentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ public function createSubmit()
"allowedFileSize" => $allowedFileSize
);

$users = SharingUtilities::getAllUserProfiles($_POST['project'], ResourceType::PROJECT);
$users = SharingUtilities::getProfilesForSharedUsers($_POST['project'], ResourceType::PROJECT);
$owner = array();

return View::make("experiment/create-complete", array("expInputs" => $experimentInputs, "users" => json_encode($users)));
return View::make("experiment/create-complete", array("expInputs" => $experimentInputs, "users" => json_encode($users), "owner" => json_encode($owner)));
} else if (isset($_POST['save']) || isset($_POST['launch'])) {
$expId = ExperimentUtilities::create_experiment();

Expand All @@ -90,7 +91,7 @@ public function createSubmit()
<a href=' . URL::to('/') . '"/experiment/summary?expId=' . $expId . '">go directly</a> to experiment summary page.</p>');

}*/
$users = SharingUtilities::getAllUserProfiles($expId, ResourceType::EXPERIMENT);
$users = SharingUtilities::getProfilesForSharedUsers($expId, ResourceType::EXPERIMENT);
return Redirect::to('experiment/summary?expId=' . $expId);
} else
return Redirect::to("home")->with("message", "Something went wrong here. Please file a bug report using the link in the Help menu.");
Expand Down Expand Up @@ -135,14 +136,22 @@ public function summary()

$users = SharingUtilities::getProfilesForSharedUsers(Input::get("expId"), ResourceType::EXPERIMENT);

$owner = array();
if (strcmp(Session::get("username"), $experiment->userName) !== 0) {
$owner[$experiment->userName] = $users[$experiment->userName];
$users = array_diff_key($users, $owner);
}

$data = array(
"expId" => Input::get("expId"),
"experiment" => $experiment,
"project" => $project,
"jobDetails" => $jobDetails,
"expVal" => $expVal,
"autoRefresh"=> $autoRefresh,
"users" => json_encode($users)
"users" => json_encode($users),
"owner" => json_encode($owner),
"can_write" => SharingUtilities::userCanWrite(Session::get("username"), $experiment->experimentId, ResourceType::EXPERIMENT)
);
if( Input::has("dashboard"))
{
Expand Down Expand Up @@ -199,47 +208,58 @@ public function expChange()

public function editView()
{
$queueDefaults = array("queueName" => Config::get('pga_config.airavata')["queue-name"],
"nodeCount" => Config::get('pga_config.airavata')["node-count"],
"cpuCount" => Config::get('pga_config.airavata')["total-cpu-count"],
"wallTimeLimit" => Config::get('pga_config.airavata')["wall-time-limit"]
);
if (SharingUtilities::userCanWrite(Session::get("username"), $_GET['expId'], ResourceType::EXPERIMENT) === true) {
$queueDefaults = array("queueName" => Config::get('pga_config.airavata')["queue-name"],
"nodeCount" => Config::get('pga_config.airavata')["node-count"],
"cpuCount" => Config::get('pga_config.airavata')["total-cpu-count"],
"wallTimeLimit" => Config::get('pga_config.airavata')["wall-time-limit"]
);

$experiment = ExperimentUtilities::get_experiment($_GET['expId']);
$expVal = ExperimentUtilities::get_experiment_values($experiment);
$expVal["jobState"] = ExperimentUtilities::get_job_status($experiment);
$experiment = ExperimentUtilities::get_experiment($_GET['expId']);
$expVal = ExperimentUtilities::get_experiment_values($experiment);
$expVal["jobState"] = ExperimentUtilities::get_job_status($experiment);

$computeResources = CRUtilities::create_compute_resources_select($experiment->executionId, $expVal['scheduling']->resourceHostId);

$clonedExp = false; $savedExp = false;
if( Input::has("clonedExp"))
$clonedExp = true;
if( Input::has("savedExp"))
$savedExp = true;

$experimentInputs = array(
"clonedExp" => $clonedExp,
"savedExp" => $savedExp,
"disabled" => ' ',
"experimentName" => $experiment->experimentName,
"experimentDescription" => $experiment->description,
"application" => $experiment->executionId,
"autoSchedule" => $experiment->userConfigurationData->airavataAutoSchedule,
"userDN" => $experiment->userConfigurationData->userDN,
"allowedFileSize" => Config::get('pga_config.airavata')["server-allowed-file-size"],
'experiment' => $experiment,
"queueDefaults" => $queueDefaults,
'computeResources' => $computeResources,
"resourceHostId" => $expVal['scheduling']->resourceHostId,
'project' => $experiment->projectId,
'expVal' => $expVal,
'cloning' => true,
'advancedOptions' => Config::get('pga_config.airavata')["advanced-experiment-options"]
);
$computeResources = CRUtilities::create_compute_resources_select($experiment->executionId, $expVal['scheduling']->resourceHostId);

$clonedExp = false; $savedExp = false;
if( Input::has("clonedExp"))
$clonedExp = true;
if( Input::has("savedExp"))
$savedExp = true;

$experimentInputs = array(
"clonedExp" => $clonedExp,
"savedExp" => $savedExp,
"disabled" => ' ',
"experimentName" => $experiment->experimentName,
"experimentDescription" => $experiment->description,
"application" => $experiment->executionId,
"autoSchedule" => $experiment->userConfigurationData->airavataAutoSchedule,
"userDN" => $experiment->userConfigurationData->userDN,
"allowedFileSize" => Config::get('pga_config.airavata')["server-allowed-file-size"],
'experiment' => $experiment,
"queueDefaults" => $queueDefaults,
'computeResources' => $computeResources,
"resourceHostId" => $expVal['scheduling']->resourceHostId,
'project' => $experiment->projectId,
'expVal' => $expVal,
'cloning' => true,
'advancedOptions' => Config::get('pga_config.airavata')["advanced-experiment-options"]
);

$users = SharingUtilities::getProfilesForSharedUsers($_GET['expId'], ResourceType::EXPERIMENT);

$users = SharingUtilities::getAllUserProfiles($_GET['expId'], ResourceType::EXPERIMENT);
$owner = array();
if (strcmp(Session::get("username"), $experiment->userName) !== 0) {
$owner[$experiment->userName] = $users[$experiment->userName];
$users = array_diff_key($users, $owner);
}

return View::make("experiment/edit", array("expInputs" => $experimentInputs, "users" => json_encode($users)));
return View::make("experiment/edit", array("expInputs" => $experimentInputs, "users" => json_encode($users), "owner" => json_encode($owner)));
}
else {
Redirect::to("experiment/summary?expId=" . $experiment->experimentId)->with("error", "You do not have permission to edit this experiment");
}
}

public function cloneExperiment()
Expand All @@ -258,22 +278,24 @@ public function cloneExperiment()

public function editSubmit()
{
if (isset($_POST['save']) || isset($_POST['launch'])) {
$experiment = ExperimentUtilities::get_experiment(Input::get('expId')); // update local experiment variable
$updatedExperiment = ExperimentUtilities::apply_changes_to_experiment($experiment, Input::all());
if (SharingUtilities::userCanWrite(Session::get("username"), Input::get('expId'), ResourceType::EXPERIMENT)) {
if (isset($_POST['save']) || isset($_POST['launch'])) {
$experiment = ExperimentUtilities::get_experiment(Input::get('expId')); // update local experiment variable
$updatedExperiment = ExperimentUtilities::apply_changes_to_experiment($experiment, Input::all());

ExperimentUtilities::update_experiment($experiment->experimentId, $updatedExperiment);
ExperimentUtilities::update_experiment($experiment->experimentId, $updatedExperiment);

if (isset($_POST['save'])) {
$experiment = ExperimentUtilities::get_experiment(Input::get('expId')); // update local experiment variable
}
if (isset($_POST['launch'])) {
ExperimentUtilities::launch_experiment($experiment->experimentId);
}
if (isset($_POST['save'])) {
$experiment = ExperimentUtilities::get_experiment(Input::get('expId')); // update local experiment variable
}
if (isset($_POST['launch'])) {
ExperimentUtilities::launch_experiment($experiment->experimentId);
}

return Redirect::to('experiment/summary?expId=' . $experiment->experimentId);
} else
return View::make("home");
return Redirect::to('experiment/summary?expId=' . $experiment->experimentId);
} else
return View::make("home");
}
}

public function getQueueView()
Expand Down Expand Up @@ -305,14 +327,48 @@ public function browseView()
$expContainer = ExperimentUtilities::get_expsearch_results_with_pagination(Input::all(), $this->limit,
($pageNo - 1) * $this->limit);
$experimentStates = ExperimentUtilities::getExpStates();

$can_write = array();
foreach ($expContainer as $experiment) {
$can_write[$experiment['experiment']->experimentId] = SharingUtilities::userCanWrite(Session::get("username"), $experiment['experiment']->experimentId, ResourceType::EXPERIMENT);
}

return View::make('experiment/browse', array(
'input' => Input::all(),
'pageNo' => $pageNo,
'limit' => $this->limit,
'expStates' => $experimentStates,
'expContainer' => $expContainer
'expContainer' => $expContainer,
'can_write' => $can_write
));
}

/**
* Generate JSON containing permissions information for this project.
*
* This function retrieves the user profile and permissions for every user
* other than the client that has access to the project. In the event that
* the project does not exist, return an error message.
*/
public function sharedUsers()
{
if (Session::has("authz-token") && array_key_exists('resourceId', $_GET)) {
return Response::json(SharingUtilities::getProfilesForSharedUsers($_GET['resourceId'], ResourceType::EXPERIMENT));
}
else {
return Response::json(array("error" => "Error: No project specified"));
}
}

public function unsharedUsers()
{
if (Session::has("authz-token") && array_key_exists('resourceId', $_GET)) {
return Response::json(SharingUtilities::getProfilesForUnsharedUsers($_GET['resourceId'], ResourceType::EXPERIMENT));
}
else {
return Response::json(array("error" => "Error: No experiment specified"));
}
}
}

?>
83 changes: 66 additions & 17 deletions app/controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public function __construct()
public function createView()
{
$users = SharingUtilities::getAllUserProfiles();
//var_dump($users);exit;
return View::make("project/create", array("users" => json_encode($users)));
return View::make("project/create", array("users" => json_encode($users), "owner" => json_encode(array())));
}

public function createSubmit()
Expand All @@ -45,31 +44,70 @@ public function summary()
if (Input::has("projId")) {
Session::put("projId", Input::get("projId"));

$project = ProjectUtilities::get_project(Input::get('projId'));

$users = SharingUtilities::getProfilesForSharedUsers(Input::get('projId'), ResourceType::PROJECT);

$owner = array();
if (strcmp(Session::get("username"), $project->owner) !== 0) {
$owner[$project->owner] = $users[$project->owner];
$users = array_diff_key($users, $owner);
}

$experiments = ProjectUtilities::get_experiments_in_project(Input::get("projId"));

$experiment_can_write = array();
foreach($experiments as $experiment) {
if (SharingUtilities::userCanWrite(Session::get("username"), $experiment->experimentId, ResourceType::EXPERIMENT)) {
$experiment_can_write[$experiment->experimentId] = true;
}
else {
$experiment_can_write[$experiment->experimentId] = false;
}
}

return View::make("project/summary",
array("projectId" => Input::get("projId"), "users" => json_encode($users)));
array("projectId" => Input::get("projId"),
"experiments" => $experiments,
"users" => json_encode($users),
"owner" => json_encode($owner),
"project_can_write" => SharingUtilities::userCanWrite(Session::get("username"), Input::get("projId"), ResourceType::PROJECT),
"experiment_can_write" => $experiment_can_write
));
} else
return Redirect::to("home");
}

public function editView()
{
if (Input::has("projId")) {
$users = SharingUtilities::getAllUserProfiles(Input::get('projId'), ResourceType::PROJECT);

return View::make("project/edit",
array("projectId" => Input::get("projId"),
"project" => ProjectUtilities::get_project($_GET['projId']),
"users" => json_encode($users)
));
if (SharingUtilities::userCanWrite(Session::get("username"), Input::get("projId"), ResourceType::PROJECT)) {
$project = ProjectUtilities::get_project($_GET['projId']);
$users = SharingUtilities::getProfilesForSharedUsers(Input::get('projId'), ResourceType::PROJECT);
$owner = array();

if (strcmp(Session::get("username"), $project->owner) !== 0) {
$owner[$project->owner] = $users[$project->owner];
$users = array_diff_key($users, $owner);
}

return View::make("project/edit",
array("projectId" => Input::get("projId"),
"project" => $project,
"users" => json_encode($users),
"owner" => json_encode($owner)
));
}
else {
return Redirect::to('project/summary?projId=' . Input::get("projId"))->with("error", "You do not have permission to edit this project.");
}
} else
return Redirect::to("home");
}

public function editSubmit()
{
if (isset($_POST['save'])) {
if (isset($_POST['save']) && SharingUtilities::userCanWrite(Session::get("username"), Input::get("projectId"), ResourceType::PROJECT)) {
$projectDetails = array();
$projectDetails["owner"] = Session::get("username");
$projectDetails["name"] = Input::get("project-name");
Expand Down Expand Up @@ -104,10 +142,22 @@ public function browseView()
$projects = ProjectUtilities::get_all_user_accessible_projects_with_pagination($this->limit, ($pageNo - 1) * $this->limit);
}

$can_write = array();
$user = Session::get("username");
foreach($projects as $project) {
if (SharingUtilities::userCanWrite($user, $project->projectID, ResourceType::PROJECT)) {
$can_write[$project->projectID] = true;
}
else {
$can_write[$project->projectID] = false;
}
}

return View::make('project/browse', array(
'pageNo' => $pageNo,
'limit' => $this->limit,
'projects' => $projects
'projects' => $projects,
'can_write' => $can_write
));
}

Expand All @@ -120,9 +170,8 @@ public function browseView()
*/
public function sharedUsers()
{
$response = array();
if (Input::has('projId')) {
return Response::json(SharingUtilities::getProfilesForSharedUsers());
if (Session::has("authz-token") && array_key_exists('resourceId', $_GET)) {
return Response::json(SharingUtilities::getProfilesForSharedUsers($_GET['resourceId'], ResourceType::PROJECT));
}
else {
return Response::json(array("error" => "Error: No project specified"));
Expand All @@ -131,8 +180,8 @@ public function sharedUsers()

public function unsharedUsers()
{
if (Input::has('projId')) {
return Response::json(SharingUtilities::getProfilesForUnsharedUsers);
if (Session::has("authz-token") && array_key_exists('resourceId', $_GET)) {
return Response::json(SharingUtilities::getProfilesForUnsharedUsers($_GET['resourceId'], ResourceType::PROJECT));
}
else {
return Response::json(array("error" => "Error: No project specified"));
Expand Down
Loading