Search in sources :

Example 1 with RSConnectApplicationInfo

use of org.rstudio.studio.client.rsconnect.model.RSConnectApplicationInfo 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 2 with RSConnectApplicationInfo

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

the class RSConnectDeploy method setPreviousInfo.

private void setPreviousInfo() {
    // content as currently deployed
    if (fromPrevious_ != null) {
        appProgressName_.setText(fromPrevious_.getName());
        appExistingName_.setText(fromPrevious_.getDisplayName());
        appProgressPanel_.setVisible(true);
        appInfoPanel_.setVisible(true);
        final ServerRequestCallback<JsArray<RSConnectApplicationInfo>> onAppsReceived = new ServerRequestCallback<JsArray<RSConnectApplicationInfo>>() {

            @Override
            public void onResponseReceived(JsArray<RSConnectApplicationInfo> infos) {
                // hide server progress
                appProgressPanel_.setVisible(false);
                // find an app with the same account, server, and name;
                // when found, populate the UI with app details
                boolean found = false;
                if (infos != null) {
                    for (int i = 0; i < infos.length(); i++) {
                        RSConnectApplicationInfo info = infos.get(i);
                        if (info.getName() == fromPrevious_.getName()) {
                            showAppInfo(info);
                            found = true;
                            break;
                        }
                    }
                }
                if (!found) {
                    forgetPreviousDeployment();
                }
            }

            @Override
            public void onError(ServerError error) {
                // it's okay if we fail here, since the application info
                // display is purely informative
                appProgressPanel_.setVisible(false);
                showAppInfo(null);
            }
        };
        if (!StringUtil.isNullOrEmpty(fromPrevious_.getAppId())) {
            // we know this app's ID, so get its details directly
            server_.getRSConnectApp(fromPrevious_.getAppId(), fromPrevious_.getAccountName(), fromPrevious_.getServer(), new ServerRequestCallback<RSConnectApplicationInfo>() {

                @Override
                public void onResponseReceived(RSConnectApplicationInfo info) {
                    // create a single-entry array with the app ID 
                    JsArray<RSConnectApplicationInfo> infos = JsArray.createArray().cast();
                    if (info != null)
                        infos.push(info);
                    onAppsReceived.onResponseReceived(infos);
                }

                @Override
                public void onError(ServerError error) {
                    onAppsReceived.onError(error);
                }
            });
        } else {
            // we don't know the app ID, get the apps by name
            server_.getRSConnectAppList(fromPrevious_.getAccountName(), fromPrevious_.getServer(), onAppsReceived);
        }
    }
}
Also used : RSConnectApplicationInfo(org.rstudio.studio.client.rsconnect.model.RSConnectApplicationInfo) JsArray(com.google.gwt.core.client.JsArray) ServerError(org.rstudio.studio.client.server.ServerError) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback)

Aggregations

JsArray (com.google.gwt.core.client.JsArray)2 RSConnectApplicationInfo (org.rstudio.studio.client.rsconnect.model.RSConnectApplicationInfo)2 ServerError (org.rstudio.studio.client.server.ServerError)2 ArrayList (java.util.ArrayList)1 RSConnectDeploymentRecord (org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)1 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)1