Search in sources :

Example 1 with UploadElement

use of org.jboss.hal.client.shared.uploadwizard.UploadElement in project console by hal.

the class StandaloneDeploymentColumn method replace.

private void replace(Deployment deployment) {
    UploadElement uploadElement = new UploadElement(resources.messages().noDeployment());
    Dialog dialog = new Dialog.Builder(resources.constants().replaceDeployment()).add(uploadElement.element()).cancel().primary(resources.constants().replace(), () -> {
        boolean valid = uploadElement.validate();
        if (valid) {
            ReplaceDeploymentPanel replaceDeploymentPanel = new ReplaceDeploymentPanel();
            replaceDeploymentPanel.on();
            series(new FlowContext(progress.get()), new CheckDeployment(dispatcher, deployment.getName()), // To replace an existing deployment, the original name and runtime-name must be preserved.
            new UploadOrReplace(environment, dispatcher, deployment.getName(), deployment.getRuntimeName(), uploadElement.getFiles().item(0), false)).subscribe(new Outcome<FlowContext>() {

                @Override
                public void onError(FlowContext context, Throwable error) {
                    replaceDeploymentPanel.off();
                    MessageEvent.fire(eventBus, Message.error(resources.messages().contentReplaceError(deployment.getName()), error.getMessage()));
                }

                @Override
                public void onSuccess(FlowContext context) {
                    refresh(Ids.content(deployment.getName()));
                    replaceDeploymentPanel.off();
                    MessageEvent.fire(eventBus, Message.success(resources.messages().contentReplaceSuccess(deployment.getName())));
                }
            });
        }
        return valid;
    }).build();
    dialog.show();
}
Also used : UploadOrReplace(org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace) CheckDeployment(org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment) Dialog(org.jboss.hal.ballroom.dialog.Dialog) CreateEmptyDialog(org.jboss.hal.client.deployment.dialog.CreateEmptyDialog) AddUnmanagedDialog(org.jboss.hal.client.deployment.dialog.AddUnmanagedDialog) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) Outcome(org.jboss.hal.flow.Outcome) UploadElement(org.jboss.hal.client.shared.uploadwizard.UploadElement) FlowContext(org.jboss.hal.flow.FlowContext)

Example 2 with UploadElement

use of org.jboss.hal.client.shared.uploadwizard.UploadElement in project console by hal.

the class ContentColumn method replace.

private void replace(Content content) {
    UploadElement uploadElement = new UploadElement(resources.messages().noContent());
    Dialog dialog = new Dialog.Builder(resources.constants().replaceContent()).add(uploadElement.element()).cancel().primary(resources.constants().replace(), () -> {
        boolean valid = uploadElement.validate();
        if (valid) {
            ReplaceDeploymentPanel replaceDeploymentPanel = new ReplaceDeploymentPanel();
            replaceDeploymentPanel.on();
            series(new FlowContext(progress.get()), new CheckDeployment(dispatcher, content.getName()), // To replace an existing content, the original name and runtime-name must be preserved.
            new UploadOrReplace(environment, dispatcher, content.getName(), content.getRuntimeName(), uploadElement.getFiles().item(0), false)).subscribe(new Outcome<FlowContext>() {

                @Override
                public void onError(FlowContext context, Throwable error) {
                    replaceDeploymentPanel.off();
                    MessageEvent.fire(eventBus, Message.error(resources.messages().contentReplaceError(content.getName()), error.getMessage()));
                }

                @Override
                public void onSuccess(FlowContext context) {
                    refresh(Ids.content(content.getName()));
                    replaceDeploymentPanel.off();
                    MessageEvent.fire(eventBus, Message.success(resources.messages().contentReplaceSuccess(content.getName())));
                }
            });
        }
        return valid;
    }).build();
    dialog.show();
}
Also used : UploadOrReplace(org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace) CheckDeployment(org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment) Dialog(org.jboss.hal.ballroom.dialog.Dialog) CreateEmptyDialog(org.jboss.hal.client.deployment.dialog.CreateEmptyDialog) AddUnmanagedDialog(org.jboss.hal.client.deployment.dialog.AddUnmanagedDialog) Outcome(org.jboss.hal.flow.Outcome) UploadElement(org.jboss.hal.client.shared.uploadwizard.UploadElement) FlowContext(org.jboss.hal.flow.FlowContext)

Aggregations

Dialog (org.jboss.hal.ballroom.dialog.Dialog)2 CheckDeployment (org.jboss.hal.client.deployment.DeploymentTasks.CheckDeployment)2 UploadOrReplace (org.jboss.hal.client.deployment.DeploymentTasks.UploadOrReplace)2 AddUnmanagedDialog (org.jboss.hal.client.deployment.dialog.AddUnmanagedDialog)2 CreateEmptyDialog (org.jboss.hal.client.deployment.dialog.CreateEmptyDialog)2 UploadElement (org.jboss.hal.client.shared.uploadwizard.UploadElement)2 FlowContext (org.jboss.hal.flow.FlowContext)2 Outcome (org.jboss.hal.flow.Outcome)2 SuccessfulOutcome (org.jboss.hal.core.SuccessfulOutcome)1