Ejemplo n.º 1
0
print "<h6 style='margin: 0px; width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;'><b>Project: </b><a href='{$proj_url}'>{$project_name}</a></h6>\n";
print "</div>";
if ($project_expiration) {
    $project_exp_hours = get_time_diff($project_expiration);
    $project_exp_print = get_time_diff_string($project_exp_hours);
    $project_exp_color = get_urgency_color($project_exp_hours);
    $project_exp_icon = get_urgency_icon($project_exp_hours);
    $project_line = "Project expires in <b style='color: {$project_exp_color}' title='{$project_expiration}'>{$project_exp_print}</b>";
    $project_line .= "<i class='material-icons' style='font-size: 18px; color: {$project_exp_color}'>{$project_exp_icon}</i>";
} else {
    $project_line = "Project has no expiration <i class='material-icons' style='font-size: 18px; color: #339933'>check_circle</i>";
}
$slice_exp_hours = get_time_diff($slice_expiration);
$slice_exp_print = get_time_diff_string($slice_exp_hours);
$slice_exp_color = get_urgency_color($slice_exp_hours);
$slice_exp_icon = get_urgency_icon($slice_exp_hours);
$slice_line = "Slice expires in <b style='color: {$slice_exp_color}' title='{$slice_expiration}'>{$slice_exp_print}</b>";
$slice_line .= "<i class='material-icons' style='font-size: 18px; color: {$slice_exp_color}'>{$slice_exp_icon}</i>";
print "<div style='display: table-cell; vertical-align: middle; width: 275px;'>";
print "<h6 style='margin: 0px;'>{$slice_line}</h6>";
print "<h6 style='margin: 0px;'>{$project_line}</h6>";
print "</div>";
print "<div style='display: table-cell; vertical-align: middle;'>";
print "<a class='button' href='{$add_url}' style='margin-right: 5px;' {$add_slivers_disabled} {$disable_buttons_str}>Add Resources</a>";
print "<a class='button' id='showrenewbox'>Renew</a>";
$hostname = $_SERVER['SERVER_NAME'];
print "<ul class='has-sub selector' id='slicetools' style='vertical-align: middle; float: none; margin: 5px !important;'>";
print "<span class='selectorshown'>Tools</span><ul class='submenu' style='width: 100px;'>";
print "<li {$add_slivers_disabled} onClick=\"window.open('{$gemini_url}')\" {$disable_buttons_str}>GENI Desktop</li>";
print "<li {$add_slivers_disabled} onClick=\"window.open('{$labwiki_url}')\" {$disable_buttons_str}>LabWiki</li>";
print "<li onClick=\"window.location='{$omni_url}'\" {$add_slivers_disabled} {$disable_buttons_str}>Omni</li>";
Ejemplo n.º 2
0
function make_project_box($project_id, $project_name, $user_id, $lead_id, $lead_name, $purpose, $expiration, $expired, $handle_req_str)
{
    global $project_slice_counts, $user;
    if (array_key_exists($project_id, $project_slice_counts)) {
        $slice_count = $project_slice_counts[$project_id];
    } else {
        $slice_count = 0;
    }
    $has_slices = $slice_count == 0 ? '' : "-HAS-SLICES-";
    $expired_project_class = $expired ? "-EXPIRED-PROJECTS-" : "-ACTIVE-PROJECTS-";
    $project_lead_class = $lead_id == $user_id ? "-MY-PROJECTS-" : "-THEIR-PROJECTS-";
    if ($expiration) {
        $exp_diff = get_time_diff($expiration);
    } else {
        $exp_diff = 100000000;
        // a very far away time indicating this will never expire
    }
    $box = '';
    // Give div specific classes for filtering purposes, data-* attributes for sorting purposes
    $box .= "<div class='floatleft slicebox {$expired_project_class} {$project_lead_class} {$has_slices}'\n                data-projname='{$project_name}' data-projexp='{$exp_diff}' data-slicecount='{$slice_count}'>";
    $box .= "<table><tr class='slicetopbar'>";
    $box .= "<td class='slicetopbar' style='text-align: left;'>";
    $box .= "<a href='project.php?project_id={$project_id}' class='projectname'>{$project_name}</a></td>";
    $box .= "<td class='slicetopbar sliceactions' style='text-align: right;'>";
    $box .= make_project_actions_dropdown($project_id, $expired);
    print "</td></tr>";
    if ($handle_req_str) {
        $box .= "<tr><td colspan='2'>";
        $box .= "<span class='smallleadname'><b>Lead:</b> {$lead_name} </span>";
        $box .= "<span class='requeststring'>{$handle_req_str}</span>";
        $box .= "</td></tr>";
    } else {
        $box .= "<tr><td colspan='2'>";
        $box .= "<span class='leadname'><b>Lead:</b> {$lead_name} </span>";
        $box .= "</td></tr>";
    }
    if ($slice_count == 0) {
        $box .= "<tr><td colspan='2'>";
        $box .= "<i> No slices</i>";
    } else {
        $slice_word = $slice_count > 1 ? "slices" : "slice";
        $box .= "<tr><td colspan='2'>Has <a onclick='show_slices_for_project(\"{$project_name}\");'>";
        $box .= "<b>{$slice_count}</b> {$slice_word}</a>";
    }
    $box .= "</td></tr>";
    if ($expiration) {
        if (!$expired) {
            $expiration_string = get_time_diff_string($exp_diff);
            $expiration_color = get_urgency_color($exp_diff);
            $expiration_string = "Project expires in <b title='{$expiration}'>{$expiration_string}</b>";
            $expiration_icon = get_urgency_icon($exp_diff);
            $expiration_icon = "<i class='material-icons' style='color: {$expiration_color}'>{$expiration_icon}</i>";
        } else {
            $expiration_string = "<b>Project is expired</b>";
            $expiration_icon = "<i class='material-icons' style='color: #EE583A;'>report</i>";
        }
    } else {
        $expiration_string = "<i>No expiration</i>";
        $expiration_icon = "";
    }
    $box .= "<tr style='height: 40px;'><td style='border-bottom:none;'>{$expiration_string}</td>";
    $box .= "<td style='vertical-align: middle; border-bottom:none;'>{$expiration_icon}</td></tr>";
    $box .= "</table></div>";
    return $box;
}
Ejemplo n.º 3
0
function list_slice($slice, $user)
{
    global $project_objects, $slice_owner_names;
    global $base_url, $slice_base_url, $listres_base_url, $resource_base_url;
    global $delete_sliver_base_url;
    global $gemini_base_url, $labwiki_base_url;
    global $disabled, $jfed_button_start, $jfed_button_part2;
    global $sa_url, $user;
    global $portal_max_slice_renewal_days;
    $slice_id = $slice[SA_SLICE_TABLE_FIELDNAME::SLICE_ID];
    $slice_urn = $slice[SA_ARGUMENT::SLICE_URN];
    $slice_expired = false;
    if (array_key_exists(SA_SLICE_TABLE_FIELDNAME::EXPIRED, $slice)) {
        $slice_expired = $slice[SA_SLICE_TABLE_FIELDNAME::EXPIRED];
    }
    $disable_buttons_str = "";
    if (isset($slice_expired) && convert_boolean($slice_expired)) {
        $disable_buttons_str = "disabled";
    }
    $slice_name = $slice[SA_ARGUMENT::SLICE_NAME];
    $args['slice_id'] = $slice_id;
    $query = http_build_query($args);
    $slice_url = $slice_base_url . $query;
    print "<tr class='slicetablerow'><td><a href='{$slice_url}'>{$slice_name}</a></td>";
    $slice_project_id = $slice[SA_ARGUMENT::PROJECT_ID];
    // There's an odd edge case in which a project has expired
    // but some slice of the project has not. In this case, $project_objects may not
    // contain the project of the slice. If so, list the project using something else.
    if (!array_key_exists($slice_project_id, $project_objects)) {
        $slice_project_name = "-Expired Project-";
        $project_expiration = "";
    } else {
        $project = $project_objects[$slice_project_id];
        $project_expiration = $project[PA_PROJECT_TABLE_FIELDNAME::EXPIRATION];
        $slice_project_name = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_NAME];
    }
    print "<td><a href='project.php?project_id={$slice_project_id}'>{$slice_project_name}</a></td>";
    // Slice owner name
    $slice_owner_id = $slice[SA_ARGUMENT::OWNER_ID];
    $slice_owner_name = $slice_owner_names[$slice_owner_id];
    print "<td>{$slice_owner_name}</td>";
    // Slice expiration
    $slice_exp_date = $slice[SA_ARGUMENT::EXPIRATION];
    $slice_exp_hours = get_time_diff($slice_exp_date);
    $slice_exp_str = dateUIFormat($slice_exp_date);
    $slice_exp_pretty_str = "In <b>" . get_time_diff_string($slice_exp_hours) . "</b>";
    $slice_exp_color = get_urgency_color($slice_exp_hours);
    $slice_exp_icon = get_urgency_icon($slice_exp_hours);
    print "<td><span title='{$slice_exp_str}'>{$slice_exp_pretty_str} ";
    print "<i class='material-icons' style='color:{$slice_exp_color}; font-size: 18px;'>{$slice_exp_icon}</i></span></td>";
    // Next resource expiration
    $slivers = lookup_sliver_info_by_slice($sa_url, $user, $slice_urn);
    $resource_count = count($slivers);
    if ($resource_count == 0) {
        $resource_exp_str = "";
        $resource_exp_pretty_str = "<i>No resources</i>";
        $resource_exp_color = "#5F584E";
        $resource_exp_icon = "";
        $resource_exp_hours = 1000000;
    } else {
        $first_sliver = reset($slivers);
        $next_exp = new DateTime($first_sliver[SA_SLIVER_INFO_TABLE_FIELDNAME::SLIVER_INFO_EXPIRATION]);
        foreach ($slivers as $sliver) {
            $this_date = new DateTime($sliver[SA_SLIVER_INFO_TABLE_FIELDNAME::SLIVER_INFO_EXPIRATION]);
            if ($next_exp > $this_date) {
                $next_exp = $this_date;
            }
        }
        $resource_exp_str = dateUIFormat($next_exp);
        $resource_exp_hours = get_time_diff($resource_exp_str);
        $resource_exp_pretty_str = "In <b>" . get_time_diff_string($resource_exp_hours) . "</b>";
        $resource_exp_color = get_urgency_color($resource_exp_hours);
        $resource_exp_icon = get_urgency_icon($resource_exp_hours);
    }
    print "<td><span title='{$resource_exp_str}'>{$resource_exp_pretty_str} ";
    print "<i class='material-icons' style='color:{$resource_exp_color}; font-size: 18px;'>{$resource_exp_icon}</i></span></td>";
    // Slice actions
    $add_url = $resource_base_url . $query;
    $remove_url = $delete_sliver_base_url . $query;
    $listres_url = $listres_base_url . $query;
    $gemini_url = $gemini_base_url . $query;
    $labwiki_url = $labwiki_base_url . $query;
    print "<td style='text-align: center;'>";
    print "<ul class='selectorcontainer slicetableactions' style='margin: 0px;'><li class='has-sub selector' style='float:none;'>";
    print "<span class='selectorshown'>Actions</span><ul class='submenu'>";
    print "<li><a href='{$slice_url}'>Manage slice</a></li>";
    if ($user->isAllowed(SA_ACTION::ADD_SLIVERS, CS_CONTEXT_TYPE::SLICE, $slice_id)) {
        print "<li><a href='{$add_url}'>Add resources</a></li>";
    }
    $dashboard_max_renewal_days = 7;
    $renewal_days = min($dashboard_max_renewal_days, $portal_max_slice_renewal_days);
    if ($project_expiration) {
        $project_expiration_dt = new DateTime($project_expiration);
        $now_dt = new DateTime();
        $difference = $project_expiration_dt->diff($now_dt);
        $renewal_days = $difference->days;
        $renewal_days = min($renewal_days, $portal_max_slice_renewal_days, $dashboard_max_renewal_days);
    }
    $slivers = lookup_sliver_info_by_slice($sa_url, $user, $slice_urn);
    $renewal_hours = 24 * $renewal_days;
    $disable_renewal = "";
    if ($slice_exp_hours > $renewal_hours && $resource_exp_hours > $renewal_hours) {
        $disable_renewal = "class='disabledaction'";
    }
    if ($resource_count > 0) {
        print "<li><a {$disable_renewal} onclick='renew_slice(\"{$slice_id}\", {$renewal_days}, {$resource_count}, {$slice_exp_hours}, {$resource_exp_hours});'>Renew resources ({$renewal_days} days)</a></li>";
        if ($user->isAllowed(SA_ACTION::GET_SLICE_CREDENTIAL, CS_CONTEXT_TYPE::SLICE, $slice_id)) {
            print "<li><a onclick='info_set_location(\"{$slice_id}\", \"{$listres_url}\")'>Resource details</a></li>";
        }
        if ($user->isAllowed(SA_ACTION::DELETE_SLIVERS, CS_CONTEXT_TYPE::SLICE, $slice_id)) {
            print "<li><a onclick='info_set_location(\"{$slice_id}\", \"{$remove_url}\")'>Delete resources</a></li>";
        }
    }
    print "</ul></li></ul>";
    print "</td></tr>\n";
}