Exemplo n.º 1
0
        /// <summary>
        /// User selected an item in a dropdown menu in the Touch Portal UI.
        /// </summary>
        /// <param name="message"></param>
        public void OnListChangedEvent(ListChangeEvent message)
        {
            _logger?.LogInformation($"[OnListChanged] {message.ListId}/{message.ActionId}/{message.InstanceId} '{message.Value}'");

            switch (message.ListId)
            {
            //Dynamically updates the dropdown of data3 based on value chosen from data2 dropdown:
            case "category1.action1.data2" when message.InstanceId is not null:
                var prefix = message.Value;
                _client.ChoiceUpdate("category1.action1.data3", new[] { $"{prefix} second 1", $"{prefix} second 2", $"{prefix} second 3" }, message.InstanceId);
                break;
            }
        }
        /// <summary>
        /// Event fired when selecting a item from the dropdown in the TP Configurator.
        /// Updates a second list (instanceId) with the values from the selected client name/ip.
        /// </summary>
        /// <param name="message"></param>
        public void OnListChangedEvent(ListChangeEvent message)
        {
            try
            {
                //Choice is changed: I can now update the next list:
                _logger.LogInformation($"Choice Event: {message.ListId}'.");

                if (string.IsNullOrWhiteSpace(message.InstanceId))
                {
                    return;
                }

                //Profiles client selected, fetch profiles for client:
                if (message.ActionId.EndsWith(".multiple.profiles.action.change") &&
                    message.ListId.EndsWith(".multiple.profiles.action.change.data.clients"))
                {
                    var client = GetClients(message.Value);
                    if (client is null)
                    {
                        return;
                    }

                    var clientData = GetClients(message.Value);
                    if (clientData is null)
                    {
                        return;
                    }

                    _client.ChoiceUpdate(PluginId + ".multiple.profiles.action.change.data.profiles", clientData.Profiles, message.InstanceId);
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e.ToString());
            }
        }
Exemplo n.º 3
0
 public void OnListChangedEvent(ListChangeEvent message)
 {
     throw new NotImplementedException();
 }
 void ITouchPortalEventHandler.OnListChangedEvent(ListChangeEvent message)
 => _logger.LogDebug("Method invoked '{0}'", nameof(ITouchPortalEventHandler.OnListChangedEvent));