protected override void BuildForm(EditFormAdapter form) { form.AddViewCell(nameof(Model.Name)); form.AddViewCell(nameof(Model.Key)); form.AddViewCell(nameof(Model.HeaderName)); form.AddViewCell(nameof(Model.Value)); form.AddViewCell(nameof(Model.Description)); }
protected override void BuildForm(EditFormAdapter form) { form.AddViewCell(nameof(Model.Name)); form.AddViewCell(nameof(Model.Key)); form.AddViewCell(nameof(Model.ParameterType)); form.AddViewCell(nameof(Model.DefaultValue)); form.AddViewCell(nameof(Model.Description)); }
protected override void BuildForm(EditFormAdapter form) { View[nameof(Model.DeviceId).ToFieldKey()].IsUserEditable = LaunchArgs.LaunchType == LaunchTypes.Create; form.AddViewCell(nameof(Model.DeviceId)); form.AddViewCell(nameof(Model.SerialNumber)); form.AddViewCell(nameof(Model.DeviceType)); ShowProperties(); }
protected override void BuildForm(EditFormAdapter form) { if (String.IsNullOrEmpty(Model.Name)) { Model.Name = Model.DeviceId; } View[nameof(Model.DeviceId).ToFieldKey()].IsUserEditable = LaunchArgs.LaunchType == LaunchTypes.Create; form.AddViewCell(nameof(Model.Name)); form.AddViewCell(nameof(Model.DeviceId)); form.AddViewCell(nameof(Model.SerialNumber)); form.AddViewCell(nameof(Model.DeviceType)); form.AddViewCell(nameof(Model.GeoLocation)); ShowProperties(); }
public override Task InitAsync() { var model1 = new Model1(); model1.Model2Litems = new List <Model2>(); var response = DetailResponse <Model1> .Create(model1); var frmEditPasswordLink = FormField.Create("EditPassword", new LagoVista.Core.Attributes.FormFieldAttribute(FieldType: LagoVista.Core.Attributes.FieldTypes.LinkButton)); response.View["linkButton"].Command = new RelayCommand(HideLinkButton); frmEditPasswordLink.Label = "Edit Password"; frmEditPasswordLink.Name = "editPassword"; frmEditPasswordLink.Watermark = "-edit password-"; frmEditPasswordLink.IsVisible = true; frmEditPasswordLink.Command = new RelayCommand(EditPasswordTap); response.View.Add("editPassword", frmEditPasswordLink); FormAdapter = new EditFormAdapter(this, response.View, this.ViewModelNavigation); FormAdapter.AddViewCell(nameof(Model1.TextField1)); FormAdapter.AddViewCell(nameof(Model1.DropDownBox1)); FormAdapter.AddViewCell(nameof(Model1.CheckBox1)); FormAdapter.AddViewCell("editPassword"); FormAdapter.AddViewCell(nameof(Model1.LinkButton)); FormAdapter.AddViewCell(nameof(Model1.Password)); FormAdapter.AddViewCell(nameof(Model1.MultiLine1)); FormAdapter.AddChildList <ViewModel2>(nameof(Model1.Model2Litems), model1.Model2Litems); return(base.InitAsync()); }
protected override void BuildForm(EditFormAdapter form) { var rnd = new Random(); var keyOne = new byte[32]; var keyTwo = new byte[32]; rnd.NextBytes(keyOne); rnd.NextBytes(keyTwo); Model.PrimaryAccessKey = Convert.ToBase64String(keyOne); Model.SecondaryAccessKey = Convert.ToBase64String(keyTwo); form.AddViewCell(nameof(Model.DeviceId)); form.AddViewCell(nameof(Model.SerialNumber)); form.AddViewCell(nameof(Model.DeviceType)); form.AddViewCell(nameof(Model.PrimaryAccessKey)); form.AddViewCell(nameof(Model.SecondaryAccessKey)); }
protected override void BuildForm(EditFormAdapter form) { if (IsCreate) { var parent = LaunchArgs.GetParent <IoT.Simulator.Admin.Models.Simulator>(); Model.EndPoint = parent.DefaultEndPoint; Model.Port = parent.DefaultPort; Model.Transport = parent.DefaultTransport; Model.QueueName = parent.QueueName; Model.PayloadType = parent.DefaultPayloadType; View[nameof(Model.TextPayload).ToFieldKey()].IsVisible = false; View[nameof(Model.BinaryPayload).ToFieldKey()].IsVisible = false; } if (!EntityHeader.IsNullOrEmpty(Model.Transport)) { ShowErrorMessage = false; HasTransport = true; View[nameof(Model.TextPayload).ToFieldKey()].IsVisible = Model.PayloadType.Value == PaylodTypes.String; View[nameof(Model.BinaryPayload).ToFieldKey()].IsVisible = Model.PayloadType.Value == PaylodTypes.Binary; form.OptionSelected += Form_OptionSelected; form.DeleteItem += Form_DeleteItem; View[nameof(Model.Key).ToFieldKey()].IsUserEditable = IsCreate; form.AddViewCell(nameof(Model.Name)); form.AddViewCell(nameof(Model.Key)); /* At some point we may want to allow one simulator to target different transports/endpoint/ports * form.AddViewCell(nameof(Model.Transport)); * form.AddViewCell(nameof(Model.EndPoint)); * form.AddViewCell(nameof(Model.Port)); */ form.AddViewCell(nameof(Model.QualityOfServiceLevel)); form.AddViewCell(nameof(Model.RetainFlag)); form.AddViewCell(nameof(Model.To)); form.AddViewCell(nameof(Model.MessageId)); form.AddViewCell(nameof(Model.QueueName)); form.AddViewCell(nameof(Model.Topic)); form.AddViewCell(nameof(Model.AppendCR)); form.AddViewCell(nameof(Model.AppendLF)); form.AddViewCell(nameof(Model.PayloadType)); form.AddViewCell(nameof(Model.ContentType)); form.AddViewCell(nameof(Model.HttpVerb)); form.AddViewCell(nameof(Model.TextPayload)); form.AddViewCell(nameof(Model.BinaryPayload)); form.AddViewCell(nameof(Model.PathAndQueryString)); if (Model.Transport.Value == TransportTypes.RestHttp || Model.Transport.Value == TransportTypes.RestHttps) { form.AddChildList <MessageHeaderViewModel>(nameof(Model.MessageHeaders), Model.MessageHeaders); } form.AddChildList <DynamicAttributeViewModel>(nameof(Model.DynamicAttributes), Model.DynamicAttributes); ModelToView(Model, form); HideAll(); switch (Model.Transport.Value) { case TransportTypes.AzureIoTHub: SetForAzureIoTHub(); break; case TransportTypes.AzureEventHub: SetForAzureEventHub(); break; case TransportTypes.MQTT: SetForMQTT(); break; case TransportTypes.TCP: SetForTCP(); break; case TransportTypes.UDP: SetForUDP(); break; case TransportTypes.AzureServiceBus: SetForServiceBus(); break; case TransportTypes.RestHttp: case TransportTypes.RestHttps: SetForREST(); break; } } else { ShowErrorMessage = true; HasTransport = false; } }
protected override void BuildForm(EditFormAdapter form) { View[nameof(Model.Key).ToFieldKey()].IsUserEditable = LaunchArgs.LaunchType == LaunchTypes.Create; View[nameof(Model.DefaultTransport).ToFieldKey()].IsEnabled = LaunchArgs.LaunchType == LaunchTypes.Create; form.AddViewCell(nameof(Model.Name)); form.AddViewCell(nameof(Model.Key)); form.AddViewCell(nameof(Model.DefaultTransport)); form.AddViewCell(nameof(Model.DefaultEndPoint)); // form.AddViewCell(nameof(Model.TLSSSL)); form.AddViewCell(nameof(Model.DefaultPort)); form.AddViewCell(nameof(Model.DeviceId)); form.AddViewCell(nameof(Model.Anonymous)); form.AddViewCell(nameof(Model.BasicAuth)); form.AddViewCell(nameof(Model.UserName)); form.AddViewCell(nameof(Model.CredentialStorage)); form.AddViewCell(nameof(Model.Password)); form.AddViewCell(nameof(Model.AccessKeyName)); form.AddViewCell(nameof(Model.AccessKey)); form.AddViewCell(nameof(Model.HubName)); form.AddViewCell(nameof(Model.QueueName)); form.AddViewCell(nameof(Model.Subscription)); form.AddViewCell(nameof(Model.DefaultPayloadType)); form.AddViewCell(nameof(Model.Description)); form.AddChildList <MessageEditorViewModel>(nameof(Model.MessageTemplates), Model.MessageTemplates); ModelToView(Model, form); FormAdapter = form; if (Model.DefaultTransport != null) { ShowFieldsForTransport(Model.DefaultTransport.Value); } else { HideAll(); this.HideRow(nameof(Model.MessageTemplates)); } }
public void DeviceTypePicked(object obj) { if (!(obj is DeviceTypeSummary)) { throw new Exception("Must return DeviceTypeSummary from picker."); } var deviceTypeSummary = obj as DeviceTypeSummary; Model.DeviceType = new LagoVista.Core.Models.EntityHeader <DeviceType>() { Id = deviceTypeSummary.Id, Text = deviceTypeSummary.Name }; Model.DeviceConfiguration = new LagoVista.Core.Models.EntityHeader() { Id = deviceTypeSummary.DefaultDeviceConfigId, Text = deviceTypeSummary.DefaultDeviceConfigName }; View[nameof(Model.DeviceType).ToFieldKey()].Display = Model.DeviceType.Text; View[nameof(Model.DeviceType).ToFieldKey()].Value = Model.DeviceType.Id; PerformNetworkOperation(async() => { var result = await RestClient.GetAsync <List <CustomField> >($"/api/deviceconfig/{Model.DeviceConfiguration.Id}/properties"); var fields = new Dictionary <string, FormField>(); var adapter = new EditFormAdapter(Model.Properties, fields, ViewModelNavigation); if (result.Result != null) { foreach (var field in result.Result) { var formField = FormField.Create(field.Key, new FormFieldAttribute(), null); formField.Label = field.Label; switch (field.FieldType.Value) { case ParameterTypes.State: formField.Options = new List <EnumDescription>(); foreach (var state in field.StateSet.Value.States) { formField.Options.Add(new EnumDescription() { Key = state.Key, Label = state.Name, Name = state.Name }); } formField.FieldType = FormField.FieldType_Picker; var initialState = field.StateSet.Value.States.Where(st => st.IsInitialState).FirstOrDefault(); if (initialState != null) { formField.Value = initialState.Key; } break; case ParameterTypes.String: formField.FieldType = FormField.FieldType_Text; formField.Value = field.DefaultValue; break; case ParameterTypes.DateTime: formField.FieldType = FormField.FieldType_DateTime; formField.Value = field.DefaultValue; break; case ParameterTypes.Decimal: formField.FieldType = FormField.FieldType_Decimal; formField.Value = field.DefaultValue; break; case ParameterTypes.GeoLocation: formField.FieldType = FormField.FieldType_Text; formField.Value = field.DefaultValue; break; case ParameterTypes.TrueFalse: formField.FieldType = FormField.FieldType_CheckBox; formField.Value = field.DefaultValue; break; case ParameterTypes.ValueWithUnit: formField.FieldType = FormField.FieldType_Decimal; formField.Value = field.DefaultValue; break; } formField.IsRequired = field.IsRequired; formField.IsUserEditable = !field.IsReadOnly; fields.Add(field.Key, formField); Debug.WriteLine(field.Name); adapter.AddViewCell(field.Key); } } CustomFieldAdapter = adapter; }); }
private void ShowProperties() { PerformNetworkOperation(async() => { var result = await RestClient.GetAsync <List <CustomField> >($"/api/deviceconfig/{Model.DeviceConfiguration.Id}/properties"); var fields = new Dictionary <string, FormField>(); var adapter = new EditFormAdapter(Model.Properties, fields, ViewModelNavigation); if (result.Result != null) { foreach (var field in result.Result) { var formField = FormField.Create(field.Key, new FormFieldAttribute()); formField.Label = field.Label; switch (field.FieldType.Value) { case ParameterTypes.State: formField.Options = new List <EnumDescription>(); foreach (var state in field.StateSet.Value.States) { formField.Options.Add(new EnumDescription() { Key = state.Key, Label = state.Name, Name = state.Name }); } formField.FieldType = FormField.FieldType_Picker; var initialState = field.StateSet.Value.States.Where(st => st.IsInitialState).FirstOrDefault(); if (initialState != null) { formField.Value = initialState.Key; } break; case ParameterTypes.String: formField.FieldType = FormField.FieldType_Text; formField.Value = field.DefaultValue; break; case ParameterTypes.DateTime: formField.FieldType = FormField.FieldType_DateTime; formField.Value = field.DefaultValue; break; case ParameterTypes.Decimal: formField.FieldType = FormField.FieldType_Decimal; formField.Value = field.DefaultValue; break; case ParameterTypes.GeoLocation: formField.FieldType = FormField.FieldType_Text; formField.Value = field.DefaultValue; break; case ParameterTypes.TrueFalse: formField.FieldType = FormField.FieldType_CheckBox; formField.Value = field.DefaultValue; break; case ParameterTypes.ValueWithUnit: formField.FieldType = FormField.FieldType_Decimal; formField.Value = field.DefaultValue; break; } formField.IsRequired = field.IsRequired; formField.IsUserEditable = !field.IsReadOnly; fields.Add(field.Key, formField); adapter.AddViewCell(field.Key); } } CustomFieldAdapter = adapter; }); }
protected override void BuildForm(EditFormAdapter form) { View[nameof(Model.Key).ToFieldKey()].IsUserEditable = LaunchArgs.LaunchType == LaunchTypes.Create; View[nameof(Model.DefaultTransport).ToFieldKey()].IsEnabled = LaunchArgs.LaunchType == LaunchTypes.Create; var frmEditPasswordLink = FormField.Create(EDIT_PASSWORD_CONTROL, new LagoVista.Core.Attributes.FormFieldAttribute(FieldType: LagoVista.Core.Attributes.FieldTypes.LinkButton)); frmEditPasswordLink.Label = SimulatorCoreResources.SimulatorEdit_EditPassword; frmEditPasswordLink.Name = EDIT_PASSWORD_CONTROL.ToFieldKey(); frmEditPasswordLink.Watermark = SimulatorCoreResources.SimulatorEdit_EditPassword_Link; frmEditPasswordLink.Command = EditPasswordCommand; frmEditPasswordLink.IsVisible = false; View.Add(EDIT_PASSWORD_CONTROL.ToFieldKey(), frmEditPasswordLink); var frmEditAccessKey = FormField.Create(EDIT_PASSWORD_CONTROL, new LagoVista.Core.Attributes.FormFieldAttribute(FieldType: LagoVista.Core.Attributes.FieldTypes.LinkButton)); frmEditAccessKey.Label = SimulatorCoreResources.SimulatorEdit_EditAccessKey; frmEditAccessKey.Name = EDIT_ACCESSKEY_CONTROL.ToFieldKey(); frmEditAccessKey.Watermark = SimulatorCoreResources.SimulatorEdit_EditAccesKey_Link; frmEditAccessKey.Command = EditAccessKeyCommand; frmEditAccessKey.IsVisible = false; View.Add(EDIT_ACCESSKEY_CONTROL.ToFieldKey(), frmEditAccessKey); form.AddViewCell(nameof(Model.Name)); form.AddViewCell(nameof(Model.Key)); form.AddViewCell(nameof(Model.DefaultTransport)); form.AddViewCell(nameof(Model.DefaultEndPoint)); form.AddViewCell(nameof(Model.DefaultPort)); form.AddViewCell(nameof(Model.DeviceId)); form.AddViewCell(nameof(Model.Anonymous)); form.AddViewCell(nameof(Model.BasicAuth)); form.AddViewCell(nameof(Model.UserName)); form.AddViewCell(nameof(Model.CredentialStorage)); form.AddViewCell(nameof(Model.Password)); form.AddViewCell(EDIT_PASSWORD_CONTROL); form.AddViewCell(nameof(Model.AccessKeyName)); form.AddViewCell(EDIT_ACCESSKEY_CONTROL); form.AddViewCell(nameof(Model.AccessKey)); form.AddViewCell(nameof(Model.HubName)); form.AddViewCell(nameof(Model.QueueName)); form.AddViewCell(nameof(Model.Subscription)); form.AddViewCell(nameof(Model.DefaultPayloadType)); form.AddViewCell(nameof(Model.Description)); form.AddChildList <MessageEditorViewModel>(nameof(Model.MessageTemplates), Model.MessageTemplates); ModelToView(Model, form); FormAdapter = form; if (Model.DefaultTransport != null) { ShowFieldsForTransport(Model.DefaultTransport.Value); } else { HideAll(); this.HideRow(nameof(Model.MessageTemplates)); } }
protected override void BuildForm(EditFormAdapter form) { form.AddViewCell(nameof(Model.Name)); form.AddViewCell(nameof(Model.Namespace)); form.AddViewCell(nameof(Model.WebSite)); }