Search in sources :

Example 6 with JsIgnore

use of jsinterop.annotations.JsIgnore in project console by hal.

the class ComplexAttributeOperations method reset.

/**
 * Undefines all non required attributes in the specified form. After the attributes in the complex attribute have been
 * undefined a standard success message is fired and the specified callback is executed.
 * <p>
 * If the form contains only required attributes, a warning message is fired and the specified callback is executed.
 *
 * @param resource the resource name
 * @param complexAttribute the name of the complex attribute
 * @param type the human readable name of the complex attribute
 * @param template the address template which is resolved against the current statement context and the resource name to get
 *        the resource address for the operation
 * @param form the form which should be reset
 * @param callback the callback executed after the resource has been saved
 */
@JsIgnore
public <T> void reset(String resource, String complexAttribute, String type, AddressTemplate template, Metadata metadata, Form<T> form, Callback callback) {
    Set<String> attributes = stream(form.getBoundFormItems().spliterator(), false).map(FormItem::getName).collect(toSet());
    ResourceAddress address = template.resolve(statementContext, resource);
    Composite composite = operationFactory(complexAttribute).resetResource(address, attributes, metadata);
    reset(type, composite, callback);
}
Also used : Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) JsIgnore(jsinterop.annotations.JsIgnore)

Example 7 with JsIgnore

use of jsinterop.annotations.JsIgnore in project console by hal.

the class CrudOperations method save.

// ------------------------------------------------------ (u)pdate using address
/**
 * Writes the changed values to the specified resource. After the resource has been saved a standard success message is
 * fired and the specified callback is executed.
 * <p>
 * If the change set is empty, a warning message is fired and the specified callback is executed.
 *
 * @param type the human readable resource type used in the success message
 * @param name the resource name
 * @param address the fq address for the operation
 * @param changedValues the changed values / payload for the operation
 * @param metadata the metadata of the attributes in the change set
 * @param callback the callback executed after the resource has been saved
 */
@JsIgnore
public void save(String type, String name, ResourceAddress address, Map<String, Object> changedValues, Metadata metadata, Callback callback) {
    Composite operations = operationFactory.fromChangeSet(address, changedValues, metadata);
    save(operations, resources.messages().modifyResourceSuccess(type, name), callback);
}
Also used : Composite(org.jboss.hal.dmr.Composite) JsIgnore(jsinterop.annotations.JsIgnore)

Example 8 with JsIgnore

use of jsinterop.annotations.JsIgnore in project console by hal.

the class CrudOperations method readChildren.

/**
 * Read multiple different child resources using a composite operation. The steps in the composite result map to the
 * position of the resource in the {@code resources} collection.
 *
 * @param address the fq address for the {@code read-children-resource} operation
 * @param resources the child resources (not human readable, but the actual child resource name!)
 * @param callback the callback which gets the composite result
 */
@JsIgnore
public void readChildren(ResourceAddress address, Iterable<String> resources, ReadCompositeCallback callback) {
    List<Operation> operations = stream(resources.spliterator(), false).map(resource -> new Operation.Builder(address, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, resource).build()).collect(toList());
    dispatcher.execute(new Composite(operations), callback::execute);
}
Also used : Provider(javax.inject.Provider) StatementContext(org.jboss.hal.meta.StatementContext) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) JsPropertyMap(jsinterop.base.JsPropertyMap) FormItemValidation(org.jboss.hal.ballroom.form.FormItemValidation) Single(rx.Single) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Message(org.jboss.hal.spi.Message) Metadata(org.jboss.hal.meta.Metadata) Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) List(java.util.List) MetadataProcessor(org.jboss.hal.meta.processing.MetadataProcessor) Callback(org.jboss.hal.spi.Callback) StreamSupport.stream(java.util.stream.StreamSupport.stream) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Footer(org.jboss.hal.spi.Footer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ModelNode(org.jboss.hal.dmr.ModelNode) Iterables(com.google.common.collect.Iterables) MessageEvent(org.jboss.hal.spi.MessageEvent) SuccessfulMetadataCallback(org.jboss.hal.meta.processing.SuccessfulMetadataCallback) JsMethod(jsinterop.annotations.JsMethod) JsCallback(org.jboss.hal.ballroom.JsCallback) Inject(javax.inject.Inject) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Property(org.jboss.hal.dmr.Property) JsHelper(org.jboss.hal.js.JsHelper) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) JsFunction(jsinterop.annotations.JsFunction) EsParam(org.jboss.hal.spi.EsParam) JsType(jsinterop.annotations.JsType) Nullable(javax.annotation.Nullable) CompositeResult(org.jboss.hal.dmr.CompositeResult) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) EventBus(com.google.web.bindery.event.shared.EventBus) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) Composite(org.jboss.hal.dmr.Composite) JsIgnore(jsinterop.annotations.JsIgnore) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) FormItem(org.jboss.hal.ballroom.form.FormItem) Resources(org.jboss.hal.resources.Resources) Collections(java.util.Collections) Form(org.jboss.hal.ballroom.form.Form) Composite(org.jboss.hal.dmr.Composite) Operation(org.jboss.hal.dmr.Operation) JsIgnore(jsinterop.annotations.JsIgnore)

Example 9 with JsIgnore

use of jsinterop.annotations.JsIgnore in project console by hal.

the class CrudOperations method remove.

// ------------------------------------------------------ (d)elete using address
/**
 * Shows a confirmation dialog and removes the resource if confirmed by the user. After the resource has been removed a
 * success message is fired and the specified callback is executed.
 *
 * @param type the human readable resource type used in the success message
 * @param name the resource name
 * @param address the fq address for the {@code remove} operation
 * @param callback the callback executed after the resource has been removed
 */
@JsIgnore
public void remove(String type, String name, ResourceAddress address, Callback callback) {
    String title = resources.messages().removeConfirmationTitle(type);
    SafeHtml question = name == null ? resources.messages().removeSingletonConfirmationQuestion() : resources.messages().removeConfirmationQuestion(name);
    SafeHtml success = name == null ? resources.messages().removeSingletonResourceSuccess(type) : resources.messages().removeResourceSuccess(type, name);
    DialogFactory.showConfirmation(title, question, () -> {
        Operation operation = new Operation.Builder(address, REMOVE).build();
        dispatcher.execute(operation, result -> {
            MessageEvent.fire(eventBus, Message.success(success));
            callback.execute();
        });
    });
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Operation(org.jboss.hal.dmr.Operation) JsIgnore(jsinterop.annotations.JsIgnore)

Example 10 with JsIgnore

use of jsinterop.annotations.JsIgnore in project console by hal.

the class ExtensionRegistry method verifyMetadata.

@JsIgnore
public void verifyMetadata(String url, MetadataCallback metadataCallback) {
    SafeUri safeUrl = UriUtils.fromString(url);
    XMLHttpRequest xhr = new XMLHttpRequest();
    xhr.onload = event -> {
        int status = (int) xhr.status;
        if (status >= 200 && status < 400) {
            String responseText = xhr.responseText;
            if (Strings.isNullOrEmpty(responseText)) {
                // 415 - Unsupported Media Type
                metadataCallback.result(415, null);
            } else {
                JsonObject extensionJson = Json.parse(responseText);
                metadataCallback.result(status, extensionJson);
            }
        } else {
            metadataCallback.result(status, null);
        }
    };
    // NON-NLS
    xhr.addEventListener("error", event -> metadataCallback.result(503, null), false);
    xhr.open(GET.name(), safeUrl.asString(), true);
    xhr.send();
}
Also used : SafeUri(com.google.gwt.safehtml.shared.SafeUri) JsonObject(org.jboss.hal.js.JsonObject) XMLHttpRequest(elemental2.dom.XMLHttpRequest) Point(org.jboss.hal.core.extension.Extension.Point) JsIgnore(jsinterop.annotations.JsIgnore)

Aggregations

JsIgnore (jsinterop.annotations.JsIgnore)41 ModelNode (org.jboss.hal.dmr.ModelNode)11 Composite (org.jboss.hal.dmr.Composite)10 Operation (org.jboss.hal.dmr.Operation)10 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)9 Map (java.util.Map)7 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)6 CustomEventInit (elemental2.dom.CustomEventInit)6 Set (java.util.Set)6 JsProperty (jsinterop.annotations.JsProperty)6 JsType (jsinterop.annotations.JsType)5 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)5 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)5 CompositeResult (org.jboss.hal.dmr.CompositeResult)5 Property (org.jboss.hal.dmr.Property)5 Iterables (com.google.common.collect.Iterables)4 EventBus (com.google.web.bindery.event.shared.EventBus)4 Collectors.toSet (java.util.stream.Collectors.toSet)4 StreamSupport.stream (java.util.stream.StreamSupport.stream)4 Nullable (javax.annotation.Nullable)4