Skip to content

Commit

Permalink
Fix to service URL
Browse files Browse the repository at this point in the history
  • Loading branch information
samsmithnz committed Aug 3, 2021
1 parent 80edff2 commit a41373d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions FeatureFlags/FeatureFlags.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FeatureFlags.Models;
using FeatureFlags.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand All @@ -11,15 +12,21 @@ namespace FeatureFlags.Web.Controllers
public class HomeController : Controller
{
private readonly IServiceAPIClient _ServiceApiClient;
private readonly IConfiguration _configuration;

public HomeController(IServiceAPIClient ServiceApiClient)
public HomeController(IServiceAPIClient ServiceApiClient, IConfiguration configuration)
{
_ServiceApiClient = ServiceApiClient;
_configuration = configuration;
}

public async Task<IActionResult> Index()
{
Payload<List<FeatureFlag>> featureFlags = await _ServiceApiClient.GetFeatureFlags();
if (featureFlags != null)
{
featureFlags.ServiceURL = _configuration["AppSettings:WebServiceURL"];
}

return View(featureFlags);
}
Expand All @@ -29,7 +36,6 @@ public IActionResult AddFeatureFlag()
return View();
}


[HttpPost]
public async Task<IActionResult> AddFeatureFlagPost(string newName, string newDescription)
{
Expand Down
1 change: 1 addition & 0 deletions FeatureFlags/FeatureFlags.Web/Models/Payload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public Payload()
}

public T Data { get; set; }
public string ServiceURL { get; set; }
public string ServiceMessage { get; set; }
public string ServiceError { get; set; }
}
Expand Down
6 changes: 5 additions & 1 deletion FeatureFlags/FeatureFlags.Web/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
ViewData["Title"] = "Home Page";
}
@model Payload<List<FeatureFlag>>
@{
var ServiceURL = Model.ServiceURL;
}

<div class="text-center">
<h1 class="display-4">Sams Feature Flags management</h1>
Expand Down Expand Up @@ -134,8 +137,9 @@ else
var name = featureDetails[0];
var environment = featureDetails[1]
var isEnabled = item.checked;
//console.log("@ServiceURL/api/FeatureFlags/SaveFeatureFlagState?name=" + name + "&environment=" + environment + "&isEnabled=" + isEnabled);
$.ajax({
url: "https://featureflags-prod-eu-service.azurewebsites.net/api/FeatureFlags/SaveFeatureFlagState?name=" + name + "&environment=" + environment + "&isEnabled=" + isEnabled,
url: "@ServiceURL/api/FeatureFlags/SaveFeatureFlagState?name=" + name + "&environment=" + environment + "&isEnabled=" + isEnabled,
success: function (resultData) {
location.reload();
}
Expand Down

0 comments on commit a41373d

Please sign in to comment.