Search in sources :

Example 1 with RSConnectDeploymentRecord

use of org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord in project rstudio by rstudio.

the class RSConnectPublishButton method rebuildPopupMenu.

// rebuilds the popup menu--this can happen when the menu is invoked; it can
// also happen when the button is created if we're aggressively checking
// publish status
private void rebuildPopupMenu(final ToolbarPopupMenu.DynamicPopupMenuCallback callback) {
    final ToolbarPopupMenu menu = publishMenu_;
    // prevent reentrancy
    if (populating_) {
        if (callback != null)
            callback.onPopupMenu(menu);
        return;
    }
    // handle case where we don't have a content path (i.e. plots)
    if (contentPath_ == null) {
        setPreviousDeployments(null);
        if (callback != null)
            callback.onPopupMenu(menu);
        return;
    }
    // (unless we're forcefully repopulating)
    if (populatedPath_ != null && populatedPath_.equals(contentPath_)) {
        if (callback != null)
            callback.onPopupMenu(menu);
        return;
    }
    String contentPath = contentPath_;
    boolean parent = false;
    // CONTENT_TYPE_APP_SINGLE and their own deployment records)
    if (contentType_ == RSConnect.CONTENT_TYPE_APP && StringUtil.getExtension(contentPath_).equalsIgnoreCase("r"))
        parent = true;
    // if this is a document in a website, use the parent path
    if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE)
        parent = true;
    // apply parent path if needed
    if (parent) {
        FileSystemItem fsiContent = FileSystemItem.createFile(contentPath_);
        contentPath = fsiContent.getParentPathString();
    }
    populating_ = true;
    server_.getRSConnectDeployments(contentPath, outputPath_ == null ? "" : outputPath_, new ServerRequestCallback<JsArray<RSConnectDeploymentRecord>>() {

        @Override
        public void onResponseReceived(JsArray<RSConnectDeploymentRecord> recs) {
            populatedPath_ = contentPath_;
            populating_ = false;
            // that are static (as we can't update them)
            if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE && (docPreview_ == null || StringUtil.isNullOrEmpty(docPreview_.getOutputFile()))) {
                JsArray<RSConnectDeploymentRecord> codeRecs = JsArray.createArray().cast();
                for (int i = 0; i < recs.length(); i++) {
                    if (!recs.get(i).getAsStatic())
                        codeRecs.push(recs.get(i));
                }
                recs = codeRecs;
            }
            setPreviousDeployments(recs);
            if (callback != null)
                callback.onPopupMenu(menu);
        }

        @Override
        public void onError(ServerError error) {
            populating_ = false;
            if (callback != null)
                callback.onPopupMenu(menu);
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) JsArray(com.google.gwt.core.client.JsArray) ServerError(org.rstudio.studio.client.server.ServerError) RSConnectDeploymentRecord(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)

Example 2 with RSConnectDeploymentRecord

use of org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord in project rstudio by rstudio.

the class RSConnect method configureShinyApp.

// Manage, step 2: Get the status of the applications from the server
private void configureShinyApp(final String dir, JsArray<RSConnectDeploymentRecord> records) {
    if (records.length() == 0) {
        display_.showMessage(GlobalDisplay.MSG_INFO, "No Deployments Found", "No application deployments were found for '" + dir + "'");
        return;
    }
    // If we know the most recent deployment of the directory, act on that
    // deployment by default
    final ArrayList<RSConnectDeploymentRecord> recordList = new ArrayList<RSConnectDeploymentRecord>();
    RSConnectDeploymentRecord lastRecord = dirState_.getLastDeployment(dir);
    if (lastRecord != null) {
        recordList.add(lastRecord);
    }
    for (int i = 0; i < records.length(); i++) {
        RSConnectDeploymentRecord record = records.get(i);
        if (lastRecord == null) {
            recordList.add(record);
        } else {
            if (record.getUrl().equals(lastRecord.getUrl()))
                recordList.set(0, record);
        }
    }
    // We need to further filter the list by deployments that are 
    // eligible for termination (i.e. are currently running)
    server_.getRSConnectAppList(recordList.get(0).getAccountName(), recordList.get(0).getServer(), new ServerRequestCallback<JsArray<RSConnectApplicationInfo>>() {

        @Override
        public void onResponseReceived(JsArray<RSConnectApplicationInfo> apps) {
            configureShinyApp(dir, apps, recordList);
        }

        @Override
        public void onError(ServerError error) {
            display_.showErrorMessage("Error Listing Applications", error.getMessage());
        }
    });
}
Also used : RSConnectApplicationInfo(org.rstudio.studio.client.rsconnect.model.RSConnectApplicationInfo) JsArray(com.google.gwt.core.client.JsArray) ServerError(org.rstudio.studio.client.server.ServerError) ArrayList(java.util.ArrayList) RSConnectDeploymentRecord(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)

Example 3 with RSConnectDeploymentRecord

use of org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord in project rstudio by rstudio.

the class RSConnect method deployToRSConnect.

private void deployToRSConnect(String sourceFile, String deployDir, String deployFile, String websiteDir, String description, JsArrayString deployFiles, JsArrayString additionalFiles, JsArrayString ignoredFiles, boolean isSelfContained, boolean isShiny, boolean asMultiple, boolean asStatic, boolean launch, JavaScriptObject jsoRecord) {
    // front if we can
    if (Desktop.isDesktop())
        Desktop.getFrame().bringMainFrameToFront();
    else
        WindowEx.get().focus();
    ArrayList<String> deployFilesList = JsArrayUtil.fromJsArrayString(deployFiles);
    ArrayList<String> additionalFilesList = JsArrayUtil.fromJsArrayString(additionalFiles);
    ArrayList<String> ignoredFilesList = JsArrayUtil.fromJsArrayString(ignoredFiles);
    RSConnectDeploymentRecord record = jsoRecord.cast();
    events_.fireEvent(new RSConnectDeployInitiatedEvent(new RSConnectPublishSource(sourceFile, deployDir, deployFile, websiteDir, isSelfContained, asStatic, isShiny, description), new RSConnectPublishSettings(deployFilesList, additionalFilesList, ignoredFilesList, asMultiple, asStatic), launch, record));
}
Also used : RSConnectPublishSettings(org.rstudio.studio.client.rsconnect.model.RSConnectPublishSettings) RSConnectDeployInitiatedEvent(org.rstudio.studio.client.rsconnect.events.RSConnectDeployInitiatedEvent) JsArrayString(com.google.gwt.core.client.JsArrayString) RSConnectDeploymentRecord(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord) RSConnectPublishSource(org.rstudio.studio.client.rsconnect.model.RSConnectPublishSource)

Example 4 with RSConnectDeploymentRecord

use of org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord in project rstudio by rstudio.

the class RSConnectDeployDialog method processDeploymentRecords.

// Create a lookup from app URL to deployments made of this directory
// to that URL
private void processDeploymentRecords(JsArray<RSConnectDeploymentRecord> records) {
    for (int i = 0; i < records.length(); i++) {
        RSConnectDeploymentRecord record = records.get(i);
        deployments_.put(record.getUrl(), record);
    }
}
Also used : RSConnectDeploymentRecord(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)

Example 5 with RSConnectDeploymentRecord

use of org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord in project rstudio by rstudio.

the class RSConnectPublishButton method setPreviousDeployments.

private void setPreviousDeployments(JsArray<RSConnectDeploymentRecord> recs) {
    // clear existing deployment menu, if any
    publishMenu_.clearItems();
    defaultRec_ = null;
    // republish
    if (recs != null && recs.length() > 0) {
        applyCaption("Republish");
        // pass 
        for (int i = 0; i < recs.length(); i++) {
            final RSConnectDeploymentRecord rec = recs.get(i);
            if (rec == null)
                continue;
            if (defaultRec_ == null || defaultRec_.getWhen() < rec.getWhen()) {
                defaultRec_ = rec;
            }
        }
        // build the deployment menu
        for (int i = 0; i < recs.length(); i++) {
            final RSConnectDeploymentRecord rec = recs.get(i);
            final DeploymentMenuItem menuItem = new DeploymentMenuItem(rec, rec == defaultRec_, new Command() {

                @Override
                public void execute() {
                    onPublishRecordClick(rec);
                }
            });
            publishMenu_.addItem(menuItem);
        }
        publishMenu_.addSeparator();
        publishMenu_.addItem(new MenuItem(AppCommand.formatMenuLabel(commands_.rsconnectDeploy().getImageResource(), "Other Destination...", null), true, new Scheduler.ScheduledCommand() {

            @Override
            public void execute() {
                onPublishRecordClick(null);
            }
        }));
    } else {
        // show first-time publish button caption
        applyCaption("Publish");
        // no existing deployments to redeploy to, so just offer to make a new
        // one
        publishMenu_.addItem(new MenuItem(AppCommand.formatMenuLabel(commands_.rsconnectDeploy().getImageResource(), "Publish " + RSConnect.contentTypeDesc(contentType_) + "...", null), true, new Scheduler.ScheduledCommand() {

            @Override
            public void execute() {
                onPublishRecordClick(defaultRec_);
            }
        }));
    }
    // if it's a plot, show an MRU of recently deployed plot "names"
    if (contentType_ == RSConnect.CONTENT_TYPE_PLOT) {
        plotMru_.addPlotMruEntries(publishMenu_, new OperationWithInput<PlotPublishMRUList.Entry>() {

            @Override
            public void execute(Entry plot) {
                republishPlot(plot);
            }
        });
    }
    publishMenu_.addSeparator();
    publishMenu_.addItem(commands_.rsconnectManageAccounts().createMenuItem(false));
}
Also used : Entry(org.rstudio.studio.client.rsconnect.model.PlotPublishMRUList.Entry) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) MenuItem(com.google.gwt.user.client.ui.MenuItem) RSConnectDeploymentRecord(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)

Aggregations

RSConnectDeploymentRecord (org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)5 JsArray (com.google.gwt.core.client.JsArray)2 ServerError (org.rstudio.studio.client.server.ServerError)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 Command (com.google.gwt.user.client.Command)1 MenuItem (com.google.gwt.user.client.ui.MenuItem)1 ArrayList (java.util.ArrayList)1 AppCommand (org.rstudio.core.client.command.AppCommand)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)1 RSConnectDeployInitiatedEvent (org.rstudio.studio.client.rsconnect.events.RSConnectDeployInitiatedEvent)1 Entry (org.rstudio.studio.client.rsconnect.model.PlotPublishMRUList.Entry)1 RSConnectApplicationInfo (org.rstudio.studio.client.rsconnect.model.RSConnectApplicationInfo)1 RSConnectPublishSettings (org.rstudio.studio.client.rsconnect.model.RSConnectPublishSettings)1 RSConnectPublishSource (org.rstudio.studio.client.rsconnect.model.RSConnectPublishSource)1