public async Task UpdateConfiguration(RestApiConfiguration configuration, string path) { string fullQualifiedName = $"{configuration.Service}.WidgetConfigurationAdapter, {configuration.Service}"; IWidgetConfigurationAdapter widgetConfigurationAdapter = (IWidgetConfigurationAdapter)Activator.CreateInstance(Type.GetType(fullQualifiedName), configuration); widgetConfigurationAdapter.ValidateWidgetConfiguration(configuration); string result = await IOHelper.ReadFile(path); List <WidgetConfiguration> currentConfigList = JsonConvert.DeserializeObject <List <WidgetConfiguration> >(result); if (currentConfigList != null && currentConfigList.Any(item => item.WidgetType == "scm")) { this.widgetConfiguration = widgetConfigurationAdapter.GetWidgetConfiguration(); List <WidgetConfiguration> updatedConfigList = new List <WidgetConfiguration> { this.widgetConfiguration, }; if (currentConfigList != null) { foreach (WidgetConfiguration item in currentConfigList) { if (item.WidgetType != "scm") { updatedConfigList.Add(item); } } } string configJson = JsonConvert.SerializeObject(updatedConfigList); await IOHelper.WriteFile(path, configJson); } }
public async Task UpdateConfiguration(RestApiConfiguration configuration, string path) { string result = await IOHelper.ReadFile(path); List <WidgetConfiguration> currentConfigList = JsonConvert.DeserializeObject <List <WidgetConfiguration> >(result); if (currentConfigList != null && currentConfigList.Any(item => item.WidgetType == "iframe")) { List <WidgetConfiguration> updatedConfigList = new List <WidgetConfiguration>(); WidgetConfiguration config = new WidgetConfiguration() { WidgetType = "iframe", ServiceName = configuration.Html, }; updatedConfigList.Add(config); if (currentConfigList != null) { foreach (WidgetConfiguration item in currentConfigList) { if (item.WidgetType != "iframe") { updatedConfigList.Add(item); } } } string configJson = JsonConvert.SerializeObject(updatedConfigList); await IOHelper.WriteFile(path, configJson); } }
public void ReturnsAdaptedHeaderWithEmptyUserAgent() { // When WidgetConfiguration configuration = this.adapter.GetWidgetConfiguration(); string userAgent = configuration.RestApiHeader.UserAgent; // Then Assert.Equal(string.Empty, userAgent); }
public void ReturnsAdaptedUrl() { // When WidgetConfiguration configuration = this.adapter.GetWidgetConfiguration(); string adaptedUrl = configuration.RestApiUrls.FirstOrDefault(); // Then Assert.Equal("https://gitlab.com/api/v4/projects/0123456789/merge_requests", adaptedUrl.ToString()); }
public void ReturnsAdaptedUrl() { // When WidgetConfiguration configuration = this.adapter.GetWidgetConfiguration(); string adaptedUrl = configuration.RestApiUrls.FirstOrDefault(); // Then Assert.Equal("https://api.github.com/repos/user/project/pulls", adaptedUrl.ToString()); }
public void ReturnsAdaptedHeaderWithUserAgent() { // When WidgetConfiguration configuration = this.adapter.GetWidgetConfiguration(); string userAgent = configuration.RestApiHeader.UserAgent; // Then Assert.Equal("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 OPR/38.0.2220.41", userAgent); }
private void ConfigureText(WidgetConfiguration configuration) { Accessory = Metadata.IsReadOnly ? UITableViewCellAccessory.None : configuration.Accessory; Text.KeyboardType = configuration.KeyboardType; Text.UserInteractionEnabled = (false == Metadata.IsReadOnly) && configuration.UserInteractionEnabled; // If this is a read-only field, // use a different color. Text.TextColor = Metadata.IsReadOnly ? Theme.ReadOnlyTextColor : Theme.NonReadOnlyTextColor; }
public void ReturnsWidgetType() { // When WidgetConfiguration configuration = this.adapter.GetWidgetConfiguration(); string widgetType = configuration.WidgetType; // Then Assert.Equal("it", widgetType); }
public void ReturnsServiceName() { // When WidgetConfiguration configuration = this.adapter.GetWidgetConfiguration(); string serviceName = configuration.ServiceName; // Then Assert.Equal("Palantir.Redmine.RestApiService, Palantir.Redmine", serviceName); }
public void ReturnsAdaptedUrl() { // When WidgetConfiguration configuration = this.adapter.GetWidgetConfiguration(); string adaptedUrl = configuration.RestApiUrls.FirstOrDefault(); // Then Assert.Equal("http://localhost:5000/projects/test-credit-system/issues.json?status_id=8&limit=100", adaptedUrl.ToString()); }
public void ReturnsAdaptedHeaderWithAuthorizationToken() { // When WidgetConfiguration configuration = this.adapter.GetWidgetConfiguration(); string token = configuration.RestApiHeader.AuthorizationToken; // Then Assert.Equal("token", token); }
public void ReturnsAdaptedUrl() { // When WidgetConfiguration configuration = this.adapter.GetWidgetConfiguration(); string adaptedUrl = configuration.RestApiUrls.FirstOrDefault(); // Then Assert.Equal("https://api.travis-ci.org/repo/8722522/builds", adaptedUrl.ToString()); }
public IWidgetConfiguration Convert() { IWidgetConfiguration widgetConfiguration = new WidgetConfiguration() { WidgetConfigurationId = WidgetConfigurationId, Name = Name, IsEditable = IsEditable, IsDataConfig = IsDataConfig }; return(widgetConfiguration); }
public override void Init(object initData) { base.Init(initData); WidgetConfiguration = initData as WidgetConfiguration; User = new User { FullName = WidgetConfiguration.PageTitle }; AppSettings = AppSettingsService.Get <AppSettings>(MyAppConstants.AppSettings); InitWidgets(); }
public void ApplyPerspective(IPerspective perspective) { m_StatusService.HandleStatus(Status.Debug(string.Format("Loading perspective: {0}", perspective.Name))); /// @todo: remove m_CurrentPerspective = perspective; /// @todo: check if this should be placed at the end of the loading process WidgetConfiguration pageConfig = GetPageConfiguration(perspective); DetachToolbars(); CreateToolbars(pageConfig); ConfigurePage(pageConfig); CreatePanes(pageConfig); m_Page.PerformLayout(); }
public async Task <IActionResult> Get() { string result = await IOHelper.ReadFile(this.configFilePath); List <WidgetConfiguration> configList = JsonConvert.DeserializeObject <List <WidgetConfiguration> >(result); WidgetConfiguration widgetConfiguration = null; foreach (WidgetConfiguration item in configList) { if (item.WidgetType == "scm") { widgetConfiguration = item; } } return(this.Ok(widgetConfiguration)); }
private void Configure() { // How should we configure the control? // As a decimal, as a lookup, ... ? var configuration = WidgetConfiguration.GetConfiguration(Metadata.Widget()); // Is this cell the target of a lookup operation? IsLookup = Metadata.Widget() is LookupWidget; // Is this cell an image container? IsImage = Metadata.Widget() is ImageWidget; // Should we display a date picker when this cell is selected? IsDatePickerAvailable = configuration.IsDatePickerAvailable; ConfigureLabel(); ConfigureText(configuration); }
public IActionResult Configure() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) { return(AccessDeniedView()); } int storeScope = _storeContext.ActiveStoreScopeConfiguration; var settings = _settingService.LoadSetting <DunderMifflinSettings>(storeScope); var model = new WidgetConfiguration { ManagerName = settings.ManagerName, ManagerAssistantName = settings.ManagerAssistantName, AssistantOfManagerAssistantName = settings.AssistantOfManagerAssistantName }; return(View($"{DunderMiffilnConstants.ViewsPlugginPath}Configure.cshtml", model)); }
public IViewComponentResult Invoke(string widgetZone, object additionalData) { var settings = _settingService.LoadSetting <DunderMifflinSettings>(_storeContext.CurrentStore.Id); var model = new WidgetConfiguration { ManagerName = settings.ManagerName, ManagerAssistantName = settings.ManagerAssistantName, AssistantOfManagerAssistantName = settings.AssistantOfManagerAssistantName }; if (string.IsNullOrEmpty(model.ManagerName) && string.IsNullOrEmpty(model.ManagerAssistantName) && string.IsNullOrEmpty(model.AssistantOfManagerAssistantName)) { //no pictures uploaded return(Content("")); } return(View($"{DunderMiffilnConstants.ViewsPlugginPath}PublicInfo.cshtml", model)); }
private static WidgetConfiguration GetPageConfiguration(IPerspective perspective) { WidgetConfiguration pageConfig = new WidgetConfiguration(); if (perspective.Configuration.PageConfiguration != null) { return(perspective.Configuration.PageConfiguration as WidgetConfiguration); } if (string.IsNullOrEmpty(perspective.Configuration.PageConfigurationXml)) { throw new InvalidOperationException(string.Format("The Perspective ({0}) wasn't created correctly. Its PageConfiguration and PageConfigurationXml are both null or empty", perspective.Id)); } using (StringReader input = new StringReader(perspective.Configuration.PageConfigurationXml)) using (XmlReader reader = XmlReader.Create(input)) { pageConfig.ReadXml(reader); } return(pageConfig); }
protected internal virtual void RenderWidgets(StackLayout stackLayout, WidgetConfiguration widgetConfiguration) { var tab = widgetConfiguration.Tabs.Length > 0 ? widgetConfiguration.Tabs[0] : null; if (tab != null) { for (var i = 0; i < tab.Widgets.Length; ++i) { var widget = tab.Widgets[i]; switch (widget.WidgetType) { case WidgetType.List: RenderListWidget(stackLayout, widget, i); break; case WidgetType.Form: break; } } } }
private void CreateToolbars(WidgetConfiguration pageConfiguration) { foreach (ToolbarAreaConfiguration areaConfiguration in pageConfiguration.ToolbarAreas.Values) { ToolStripPanel area = GetToolStripPanel(areaConfiguration.Name); for (int row = 0; row < areaConfiguration.RowConfigurations.Length; row++) { for (int position = areaConfiguration.RowConfigurations[row].ToolbarConfigurations.Length - 1; position >= 0; position--) { ToolStrip strip = GetToolbarWidget(areaConfiguration .RowConfigurations[row] .ToolbarConfigurations[position] .ToolbarTypeId); //@todo Not implemented in Mono (find alternative?). They are just added. area.Join(strip, row); if (area.Orientation == Orientation.Horizontal) { strip.Left = areaConfiguration .RowConfigurations[row] .ToolbarConfigurations[position] .Offset; } else { strip.Top = areaConfiguration .RowConfigurations[row] .ToolbarConfigurations[position] .Offset; } area.PerformLayout(); } } } }
public IActionResult Configure(WidgetConfiguration model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) { return(AccessDeniedView()); } int storeScope = _storeContext.ActiveStoreScopeConfiguration; var settings = _settingService.LoadSetting <DunderMifflinSettings>(storeScope); settings.ManagerAssistantName = model.ManagerAssistantName; settings.ManagerName = model.ManagerName; settings.AssistantOfManagerAssistantName = model.AssistantOfManagerAssistantName; _settingService.SaveSettingOverridablePerStore(settings, x => x.ManagerName, true, storeScope, true); _settingService.SaveSettingOverridablePerStore(settings, x => x.ManagerAssistantName, true, storeScope, true); _settingService.SaveSettingOverridablePerStore(settings, x => x.AssistantOfManagerAssistantName, true, storeScope, true); _settingService.ClearCache(); _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return(Configure()); }
private void ConfigurePage(WidgetConfiguration pageConfig) { }
private void CreatePanes(WidgetConfiguration pageConfig) { }
public WidgetsController(IOptions <PostgresConfiguration> postgresConfiguration, IOptions <WidgetConfiguration> widgetConfiguration, ILogger <ServiceController> logger) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _widgetConfiguration = widgetConfiguration.Value ?? throw new ArgumentNullException(nameof(widgetConfiguration)); _db = new PostgresqlContext(postgresConfiguration); }