~ubuntu-core-dev/ubuntu/maverick/eucalyptus/devel

« back to all changes in this revision

Viewing changes to clc/modules/www/src/main/java/edu/ucsb/eucalyptus/admin/client/EucalyptusWebInterface.java

  • Committer: Dave Walker (Daviey)
  • Date: 2010-06-15 14:42:43 UTC
  • Revision ID: davewalker@ubuntu.com-20100615144243-es2308wfvh9h3htf
Ubuntu patches unapplied

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
import com.google.gwt.user.client.Window;
73
73
import com.google.gwt.user.client.rpc.AsyncCallback;
74
74
import com.google.gwt.user.client.ui.*;
75
 
import com.google.gwt.event.dom.client.ClickHandler;
76
 
import com.google.gwt.event.dom.client.ClickEvent;
77
75
import edu.ucsb.eucalyptus.admin.client.extensions.store.ImageStoreClient;
78
76
import edu.ucsb.eucalyptus.admin.client.extensions.store.ImageStoreWidget;
79
 
import edu.ucsb.eucalyptus.admin.client.extensions.store.FrameWidget;
80
77
import java.util.Date;
81
78
import java.util.HashMap;
82
79
import java.util.List;
158
155
        private static int confTabIndex = -1;
159
156
    private static int downTabIndex = -1;
160
157
    private static int storeTabIndex = -1;
161
 
    private static int servicesTabIndex = -1;
162
158
    private static boolean sortUsersLastFirst = true;
163
159
 
164
160
    /* UI selections remembered for future use */
224
220
        if (props == null) {
225
221
            throw new Exception("Invalid server configuration");
226
222
        }
227
 
        version = (String)props.get("version");
 
223
        version = (String)props.get("version");
228
224
        cloud_name = (String)props.get("cloud-name");
229
225
        signup_greeting = (String)props.get("signup-greeting");
230
226
        certificate_download_text = (String)props.get("certificate-download-text");
1341
1337
        allTabs.addTab ("Images"); imgTabIndex = nTabs++;
1342
1338
        /////allTabs.addTab ("Instances"); instTabIndex = nTabs++;
1343
1339
        if (loggedInUser.isAdministrator().booleanValue()) {
1344
 
            if (extensions != null && extensions.contains("store")) {
1345
 
                allTabs.addTab ("Store"); storeTabIndex = nTabs++;
1346
 
            }
1347
1340
                        allTabs.addTab ("Users"); usrTabIndex = nTabs++;
1348
1341
                        allTabs.addTab ("Configuration"); confTabIndex = nTabs++;
1349
 
            allTabs.addTab ("Services"); servicesTabIndex = nTabs++;
1350
1342
            allTabs.addTab ("Extras"); downTabIndex = nTabs++;
 
1343
            if (extensions!=null && extensions.contains ("store") ) {
 
1344
                allTabs.addTab ("Store"); storeTabIndex = nTabs++;
 
1345
            }
1351
1346
        }
1352
1347
                // can happen if admin user re-logs in as regular without reloading
1353
1348
                if (currentTabIndex > (nTabs-1) ) {
1365
1360
                                else if (tabIndex==confTabIndex) { displayConfTab(wrapper); }
1366
1361
                else if (tabIndex==downTabIndex) { displayDownloadsTab(wrapper); }
1367
1362
                else if (tabIndex==storeTabIndex) { displayStoreTab(wrapper); }
1368
 
                else if (tabIndex==servicesTabIndex) { displayServicesTab(wrapper); }
1369
1363
                else { displayErrorPage("Invalid tab!"); }
1370
1364
            }
1371
1365
            public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) {
1464
1458
 
1465
1459
                                                if (ex==null) {
1466
1460
                                                        ip = in;
1467
 
                                                        text = "<b>Warning:</b> RightScale could not discover the external IP address of your cloud.  Hence, the pre-filled cloud URL <i>may</i> be incorrect.  Check your firewall settings.</p>";
 
1461
                                                        text = "<b>Warning:</b> Rightscale could not discover the external IP address of your cloud.  Hence, the pre-filled cloud URL <i>may</i> be incorrect.  Check your firewall settings.</p> ";
1468
1462
 
1469
1463
                                                } else if (!ex.equals(in)) {
1470
1464
                                                        ip = ex;
1494
1488
                }
1495
1489
        }
1496
1490
 
1497
 
    private class LandscapeDialog extends DialogBox {
1498
 
 
1499
 
        private boolean cancelled = false;
1500
 
        private String landscapeUrl = null;
1501
 
 
1502
 
        public LandscapeDialog () {
1503
 
 
1504
 
            cancelled = false;
1505
 
            setHTML("<img src=\"themes/share/pending-FFCC33.gif\" align=\"middle\"> &nbsp; Checking the external IP address...");
1506
 
 
1507
 
            final Button okButton = new Button("OK",
1508
 
            new ClickListener() {
1509
 
                public void onClick(Widget sender) {
1510
 
                    LandscapeDialog.this.hide();
1511
 
                    if (landscapeUrl!=null) {
1512
 
                        Window.open(landscapeUrl, "_blank", "");
1513
 
                    }
1514
 
                }
1515
 
            });
1516
 
            okButton.setEnabled (false);
1517
 
            Button cancelButton = new Button("Cancel",
1518
 
            new ClickListener() {
1519
 
                public void onClick(Widget sender) {
1520
 
                    LandscapeDialog.this.hide();
1521
 
                    cancelled = true;
1522
 
                }
1523
 
            });
1524
 
 
1525
 
            HorizontalPanel buttonPanel = new HorizontalPanel();
1526
 
            buttonPanel.add (okButton);
1527
 
            buttonPanel.add (cancelButton);
1528
 
            setWidget (buttonPanel);
1529
 
 
1530
 
            EucalyptusWebBackend.App.getInstance().getCloudInfo(
1531
 
                sessionId,
1532
 
                true, // DO check external IP
1533
 
                new AsyncCallback () {
1534
 
                    public void onSuccess( Object result )
1535
 
                    {
1536
 
                        if (cancelled) {
1537
 
                            return;
1538
 
                        }
1539
 
                        cloudInfo = (CloudInfoWeb) result;
1540
 
                        String ex = cloudInfo.getExternalHostPort();
1541
 
                        String in = cloudInfo.getInternalHostPort();
1542
 
                        String text = "";
1543
 
                        String ip;
1544
 
 
1545
 
                        if (ex==null) {
1546
 
                            ip = in;
1547
 
                            text = "<b>Warning:</b> The external IP address of your cloud could not be discovered.  Hence, the pre-filled cloud URL <i>may</i> be incorrect.  Check your firewall settings.</p>";
1548
 
                        } else if (!ex.equals(in)) {
1549
 
                            ip = ex;
1550
 
                            text = "<b>Warning:</b> The external cloud IP discovered (" + ex + ") is different from the IP found by Eucalyptus (" + in + ").  Hence, the pre-filled cloud URL <i>may</i> be incorrect.  Check your firewall settings.</p>";
1551
 
                        } else {
1552
 
                            ip = ex;
1553
 
                        }
1554
 
                        String callbackUrl = "https://"
1555
 
                            + ip
1556
 
                            + cloudInfo.getServicePath();
1557
 
                        // XXX Should really use the info-url instead
1558
 
                        String ec2Url = "http://"
1559
 
                            + ip
1560
 
                            + "/services/Eucalyptus";
1561
 
                        landscapeUrl =
1562
 
                            "https://landscape.canonical.com/register-cloud"
1563
 
                            + "?endpoint="
1564
 
                            + GWTUtils.escape(ec2Url)
1565
 
                            + "&info-url="
1566
 
                            + GWTUtils.escape(callbackUrl)
1567
 
                            + "&cloud-id="
1568
 
                            + GWTUtils.escape(cloudInfo.getCloudId());
1569
 
                        String pre = "<h3>Cloud registration</h3> You are about to open a new window to Landscape's web site, on which you will be able to complete the registraton.</p>";
1570
 
                        setHTML(pre + text);
1571
 
                        okButton.setEnabled(true);
1572
 
                        center();
1573
 
                    }
1574
 
                    public void onFailure(Throwable caught)
1575
 
                    {
1576
 
                        displayErrorPage(caught.getMessage());
1577
 
                    }
1578
 
                }
1579
 
            );
1580
 
        }
1581
 
    }
1582
 
 
1583
1491
        public void actuallyDisplayCredentialsTab (VerticalPanel parent)
1584
1492
        {
1585
1493
        History.newItem("credentials");
1690
1598
//        g.setWidget( 2, 0, rpanel ); g.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
1691
1599
//              g.setWidget( 2, 1, secretButton ); g.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_TOP);
1692
1600
 
1693
 
/*
1694
1601
                if (loggedInUser.isAdministrator() && show_cloud_registration) {
1695
1602
                VerticalPanel cloud_panel = new VerticalPanel();
1696
1603
                        cloud_panel.setSpacing (0);
1732
1639
//                      g.getCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_TOP);
1733
1640
                        credspanel.add(vp);
1734
1641
                }
1735
 
        */
1736
1642
 
1737
1643
        //credspanel.add(g);
1738
1644
    }
2335
2241
            showActions = true;
2336
2242
        }
2337
2243
 
2338
 
 
2339
2244
        if (nimages>0) {
2340
2245
            final Grid g = new Grid(nimages + 1, 6);
2341
2246
            g.setStyleName("euca-table");
2426
2331
        parent.clear();
2427
2332
        parent.add(imageStore);
2428
2333
    }
2429
 
 
2430
 
    private class SectionWidget extends Composite {
2431
 
        private VerticalPanel verticalPanel = new VerticalPanel();
2432
 
        public SectionWidget(String title, String contentHtml) {
2433
 
            initialize(title, new HTML(contentHtml));
2434
 
        }
2435
 
        public SectionWidget(String title, Widget contentWidget) {
2436
 
            initialize(title, contentWidget);
2437
 
        }
2438
 
        private void initialize(String title, Widget contentWidget) {
2439
 
            Label titleLabel = new Label(title);
2440
 
            titleLabel.setStyleName("istore-section-title");
2441
 
            verticalPanel.add(titleLabel);
2442
 
            verticalPanel.add(new FrameWidget(contentWidget));
2443
 
            contentWidget.addStyleName("istore-images-panel");
2444
 
            initWidget(verticalPanel);
2445
 
            setStyleName("istore-image-section-widget");
2446
 
        }
2447
 
    }
2448
 
 
2449
 
    public void displayServicesTab (final VerticalPanel parent)
2450
 
    {
2451
 
        History.newItem ("services");
2452
 
        VerticalPanel servicesPanel = new VerticalPanel();
2453
 
        servicesPanel.add(new SectionWidget(
2454
 
            "Ubuntu Enterprise Cloud Documentation",
2455
 
            "<p>For UEC documentation, community pages and the " +
2456
 
            "UEC user mailing list please see the Ubuntu site:</p>" +
2457
 
            "<div style=\"padding-left: 2em; padding-bottom: 1em;\">" +
2458
 
            "<a href=\"http://www.ubuntu.com/cloud\">" +
2459
 
            "Ubuntu Enterprise Cloud" +
2460
 
            "</a></div>"));
2461
 
        servicesPanel.add(new SectionWidget(
2462
 
            "Training",
2463
 
            "<p>The Ubuntu Enterprise Cloud training course covers every " +
2464
 
            "aspect of running your own cloud. Including installing, " +
2465
 
            "configuring and optimising the infrastructure, along with " +
2466
 
            "setting up and managing virtual machines for your " +
2467
 
            "applications. To learn about the UEC course, and our other " +
2468
 
            "Ubuntu courses please see:</p>" +
2469
 
            "<div style=\"padding-left: 2em; padding-bottom: 1em;\">" +
2470
 
            "<a href=\"http://www.ubuntu.com/cloud/training\">" +
2471
 
            "Cloud training" +
2472
 
            "</a></div>"));
2473
 
        servicesPanel.add(new SectionWidget(
2474
 
            "Eucalyptus",
2475
 
            "<p>The UEC is powered by Eucalyptus, an open-source cloud " +
2476
 
            "computing platform with support for popular hypervisor and " +
2477
 
            "cloud computing interfaces.  Eucalyptus enables users to " +
2478
 
            "easily implement on-premise and hybrid clouds that leverage " +
2479
 
            "both internal and external resources.</p>" +
2480
 
            "<p>For open-source downloads, documentation and user forums " +
2481
 
            "please visit:</p>" +
2482
 
            "<div style=\"padding-left: 2em; padding-bottom: 1em;\">" +
2483
 
            "<a href=\"http://open.eucalyptus.com\">" +
2484
 
            "Eucalyptus Community Website" +
2485
 
            "</a></div>" +
2486
 
            "<p>For enterprise support, professional services and " +
2487
 
            "additional Eucalyptus products please visit:" +
2488
 
            "<div style=\"padding-left: 2em; padding-bottom: 1em;\">" +
2489
 
            "<a href=\"http://www.eucalyptus.com\">" +
2490
 
            "Eucalyptus Enterprise Website" +
2491
 
            "</a></div>"));
2492
 
 
2493
 
        HTMLPanel landscapePanel = new HTMLPanel(
2494
 
            "<p><a href=\"http://www.ubuntu.com/landscape\">Landscape</a> is " +
2495
 
            "a systems management service that provides package management, " +
2496
 
            "security alerts, custom script automation and monitoring.  " +
2497
 
            "With Landscape you can see and manage all of your Cloud " +
2498
 
            "environment.</p>" +
2499
 
            "<p>If you already have an account with Landscape, you can " +
2500
 
            "register this cloud now:</p>" +
2501
 
            "<div style=\"padding-left: 2em; padding-bottom: 1em;\">" +
2502
 
            "<a href=\"\" id=\"ls-anchor\">" +
2503
 
            "Register this cloud with Landscape" +
2504
 
            "</a></div>");
2505
 
 
2506
 
        Anchor landscapeAnchor = Anchor.wrap(
2507
 
            landscapePanel.getElementById("ls-anchor"));
2508
 
 
2509
 
        landscapeAnchor.addClickHandler(new ClickHandler() {
2510
 
            public void onClick(ClickEvent event) {
2511
 
                event.preventDefault();
2512
 
                new LandscapeDialog().center();
2513
 
            }
2514
 
        });
2515
 
 
2516
 
        servicesPanel.add(new SectionWidget(
2517
 
            "Landscape",
2518
 
            landscapePanel
2519
 
            ));
2520
 
 
2521
 
                if (loggedInUser.isAdministrator() && show_cloud_registration) {
2522
 
                HTMLPanel rightScalePanel = new HTMLPanel(
2523
 
                "<p>Your Eucalyptus cloud can also be registered with " +
2524
 
                "<a href=\"http://rightscale.com/\">RightScale</a>, " +
2525
 
                "providing you and your users with an easy-to-use interface " +
2526
 
                "to both EC2 and your Eucalyptus cloud.  The following two " +
2527
 
                "parameters will be necessary for registration:</p>" +
2528
 
                "<div style=\"padding-left: 2em;\">" +
2529
 
                "<p>Cloud URL: <span id=\"rs-cloud-url\"/></p>" +
2530
 
                "<p>Cloud ID: <span id=\"rs-cloud-id\"/></p>" +
2531
 
                "</div>" +
2532
 
                "<p>If you already have an account with RightScale, you can " +
2533
 
                "register this cloud now:</p>" +
2534
 
                "<div style=\"padding-left: 2em; padding-bottom: 1em;\">" +
2535
 
                "<a href=\"\" id=\"rs-anchor\">" +
2536
 
                "Register this cloud with RightScale" +
2537
 
                "</a></div>");
2538
 
 
2539
 
            rightScalePanel.add(new InlineLabel(
2540
 
                            "https://" +
2541
 
                                cloudInfo.getInternalHostPort() +
2542
 
                cloudInfo.getServicePath()
2543
 
                ), "rs-cloud-url");
2544
 
 
2545
 
            rightScalePanel.add(new InlineLabel(
2546
 
                cloudInfo.getCloudId()
2547
 
                ), "rs-cloud-id");
2548
 
 
2549
 
                        Anchor rightScaleAnchor = Anchor.wrap(
2550
 
                rightScalePanel.getElementById("rs-anchor"));
2551
 
 
2552
 
            rightScaleAnchor.addClickHandler(new ClickHandler() {
2553
 
                public void onClick(ClickEvent event) {
2554
 
                    event.preventDefault();
2555
 
                                        new RightscaleDialog().center();
2556
 
                }
2557
 
            });
2558
 
 
2559
 
            servicesPanel.add(new SectionWidget(
2560
 
                "RightScale",
2561
 
                rightScalePanel
2562
 
                ));
2563
 
                }
2564
 
 
2565
 
        servicesPanel.add(new SectionWidget(
2566
 
            "Support",
2567
 
            "<p>With commercial support you have the certainty that your " +
2568
 
            "bugs and issues will be responded to promptly.  Canonical " +
2569
 
            "provides business day and 24/7 for Ubuntu Enterprise Cloud. " +
2570
 
            "For more details on the service please see:</p>" +
2571
 
            "<div style=\"padding-left: 2em; padding-bottom: 1em;\">" +
2572
 
            "<a href=\"http://www.ubuntu.com/cloud/support\">" +
2573
 
            "Cloud support" +
2574
 
            "</a></div>"));
2575
 
 
2576
 
        parent.clear();
2577
 
        parent.add(servicesPanel);
2578
 
    }
2579
 
 
 
2334
        
2580
2335
    public void displayFirstTimeConfiguration()
2581
2336
    {
2582
2337
        displayStatusPage("Loading first-time configuration page...");