diff --git a/www/aptui/example-profiles.php b/www/aptui/example-profiles.php new file mode 100644 index 0000000000000000000000000000000000000000..99600a8e74d8295ccd9d92721e462368f538d465 --- /dev/null +++ b/www/aptui/example-profiles.php @@ -0,0 +1,100 @@ +. +# +# }}} +# +chdir(".."); +include("defs.php3"); +chdir("apt"); +include("quickvm_sup.php"); +include("profile_defs.php"); +$page_title = "Example Profiles"; + +# +# Get current user. +# +RedirectSecure(); +$this_user = CheckLoginOrRedirect(); + +# +# Eventually use the portal to determine what profiles to show. +# +$pid = "PortalProfiles"; + +SPITHEADER(1); + +echo "\n"; + +# Place to hang the toplevel template. +echo "
\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +# List of all profiles in the PortalProfiles project. +$profiles = array(); + +# Make sure the profile is public, no point in showing it if not. +$query_result + = DBQueryFatal("select p.*,v.*,DATE(v.created) as created ". + " from apt_profiles as p ". + "left join apt_profile_versions as v on ". + " v.profileid=p.profileid and ". + " v.version=p.version ". + "where (p.pid='$pid' and p.public!=0 and ". + " (p.examples_portals is null or ". + " FIND_IN_SET('$PORTAL_GENESIS',examples_portals))) ". + "order by p.name"); + +while ($row = mysql_fetch_array($query_result)) { + $blob = array(); + + $blob["uuid"] = $row["uuid"]; + $blob["version"] = $row["version"]; + $blob["name"] = $row["name"]; + $blob["desc"] = CleanString($row["description"]); + $blob["created"] = DateStringGMT($row["created"]); + + $parsed_xml = simplexml_load_string($row["rspec"]); + if ($parsed_xml && + $parsed_xml->rspec_tour && $parsed_xml->rspec_tour->description) { + $desc = $parsed_xml->rspec_tour->description; + $blob["desc"] = CleanString($desc); + } + $profiles[] = $blob; +} + +echo "\n"; + +REQUIRE_UNDERSCORE(); +REQUIRE_SUP(); +REQUIRE_MOMENT(); +AddTemplateList(array("example-profiles")); +SPITREQUIRE("js/example-profiles.js"); + +SPITFOOTER(); +?> diff --git a/www/aptui/js/example-profiles.js b/www/aptui/js/example-profiles.js new file mode 100644 index 0000000000000000000000000000000000000000..e39d5bce15a6832f774d322549ace89d5f8ad6a8 --- /dev/null +++ b/www/aptui/js/example-profiles.js @@ -0,0 +1,55 @@ +$(function () +{ + 'use strict'; + var template_list = ["example-profiles"]; + var templates = APT_OPTIONS.fetchTemplateList(template_list); + var listTemplate = _.template(templates["example-profiles"]); + var profiles = null; + + function initialize() + { + window.APT_OPTIONS.initialize(sup); + profiles = decodejson('#profiles-json'); + + $('#main-body').html(listTemplate({"profiles" : profiles})); + + // Format dates with moment before table update + $('.format-date').each(function() { + var date = $.trim($(this).html()); + if (date != "") { + $(this).html(moment($(this).html()).format("ll")); + } + }); + + var table = $('#list-profiles-table') + .tablesorter({ + theme : 'green', + + // initialize zebra and filter widgets + widgets: ["zebra", "filter", "resizable"], + + widgetOptions: { + // include child row content while filtering, if true + filter_childRows : true, + // include all columns in the search. + filter_anyMatch : true, + // class name applied to filter row and each input + filter_cssFilter : 'form-control', + // search from beginning + filter_startsWith : false, + // Set this option to false for case sensitive search + filter_ignoreCase : true, + // Only one search box. + filter_columnFilters : false, + } + }); + $.tablesorter.filter.bindSearch(table, $('#list-profiles-search')); + } + + // Helper. + function decodejson(id) { + return JSON.parse(_.unescape($(id)[0].textContent)); + } + + $(document).ready(initialize); +}); diff --git a/www/aptui/quickvm_sup.php b/www/aptui/quickvm_sup.php index 96b30307026a0b6e8af54db5ecd447d4510f22d5..adbfbd9e7e15da8ed874d24150faf5704f7dfa26 100644 --- a/www/aptui/quickvm_sup.php +++ b/www/aptui/quickvm_sup.php @@ -1,6 +1,6 @@ portal()) { $navbar_status $navbar_right\n"; - if ($PORTAL_WIKI) { - echo "\n"; - } - else { - echo "
  • - Docs -
  • \n"; +
  • Manual
  • "; + if ($PORTAL_WIKI) { + echo "
  • Wiki
  • "; } + echo "
  • Example Profiles
  • "; + echo " + \n"; + if ($login_user) { echo " diff --git a/www/aptui/template/example-profiles.html b/www/aptui/template/example-profiles.html new file mode 100644 index 0000000000000000000000000000000000000000..46af7373f99e7f8d849e97e8cb695b18a6d59389 --- /dev/null +++ b/www/aptui/template/example-profiles.html @@ -0,0 +1,33 @@ +
    +

    Example Profiles

    +
    + These profiles demonstrate how to construct various topologies and select + options such as node type, operating system, etc.
    +
    + + + + + + + + + + + <% _.each(profiles, function(value, name) { %> + + + + + + <% }); %> + +
    NameCreatedDescription
    + <%= value.name %> + <%- value.created %><%- value.desc %>
    +
    +
    +