Skip to content

Commit

Permalink
need to test
Browse files Browse the repository at this point in the history
  • Loading branch information
ezraroi committed Sep 12, 2024
1 parent 9de009a commit 8948f36
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Mundialito/Client/src/General/teamFlagTemplate.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<img ng-if="useFlagsCss !== 'true'" ng-src="{{::team.Flag}}" style="width: 28px; height: 28px; padding-left: 3px; padding-right: 3px;" class="img-reponsive img-rounded" />
<i ng-if="useFlagsCss === 'true'" ng-class="['flag','flag-fifa-{{team.ShortName | lowercase}}']" tooltip="{{team.Name}}"></i>&nbsp;&nbsp;
<img ng-if="useFlagsCss !== 'true'" ng-src="{{::team.Flag}}" style="width: 28px; height: 28px; margin-left: 3px; margin-right: 3px;" class="img-reponsive img-rounded" />
<i ng-if="useFlagsCss === 'true'" ng-class="['flag','flag-fifa-{{team.ShortName | lowercase}}']" tooltip="{{team.Name}}" style="margin-left: 3px; margin-right: 3px;"></i>
8 changes: 4 additions & 4 deletions Mundialito/Client/src/Users/ManageApp.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
</thead>
<tbody>
<tr ng-repeat="user in users">
<td><a href="{{user.getUrl()}}">{{user.Name}}</a></td>
<td><a href="{{user.getUrl()}}">{{::user.Name}}</a><span style="margin-left: 5px;" class="badge" ng-class="{'badge-success': user.Roles === 'Admin', 'label-default': user.Roles === 'Active', 'label-danger':user.Roles === 'Disabled'}">{{::user.Roles}}</span> </td>
<td>{{user.Email}}</td>
<td>
<button title="delete" type="button" class="btn btn-danger btn-sm" ng-click="deleteUser(user)" tooltip="Delete User"><i class="fa fa-times-circle"></i> <span class="hidden-xs">Delete</span></button>
<button title="makeadmin" ng-show="!user.IsAdmin" type="button" class="btn btn-primary btn-sm" ng-click="makeAdmin(user)" tooltip="Make Admin"><i class="fa fa-gear"></i> <span class="hidden-xs">Admin</span></button>
<button title="activate" ng-show="user.Roles === Disabled && !user.IsAdmin" type="button" class="btn btn-success btn-sm" ng-click="activate(user)" tooltip="Activate"><i class="fa-solid fa-user-check"></i> <span class="hidden-xs">Activate</span></button>
<button title="deactivate" ng-show="user.Roles === Active && !user.IsAdmin" type="button" class="btn btn-warning btn-sm" ng-click="deactivate(user)" tooltip="Deactivate"><i class="fa-solid fa-user-minus"></i> <span class="hidden-xs">Deactivate</span></button>
<button title="makeadmin" ng-show="user.Roles !== 'Admin'" type="button" class="btn btn-primary btn-sm" ng-click="makeAdmin(user)" tooltip="Make Admin"><i class="fa fa-gear"></i> <span class="hidden-xs">Admin</span></button>
<button title="activate" ng-show="user.Roles === 'Disabled'" type="button" class="btn btn-success btn-sm" ng-click="activate(user)" tooltip="Activate"><i class="fa-solid fa-user-check"></i> <span class="hidden-xs">Activate</span></button>
<button title="deactivate" ng-show="user.Roles === 'Active'" type="button" class="btn btn-warning btn-sm" ng-click="deactivate(user)" tooltip="Deactivate"><i class="fa-solid fa-user-minus"></i> <span class="hidden-xs">Deactivate</span></button>
</td>
</tr>
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions Mundialito/Client/src/Users/ManageAppCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ angular.module('mundialitoApp').controller('ManageAppCtrl', ['$scope', '$log', '

$scope.makeAdmin = (user) => {
user.makeAdmin().then(() => {
Alert.success('User was is now admin');
user.IsAdmin = true;
Alert.success('User is now admin');
user.Roles = "Admin";
});
};

Expand Down
12 changes: 1 addition & 11 deletions Mundialito/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public UsersController(ILogger<UsersController> logger, IActionLogsRepository ac
public ActionResult<IEnumerable<UserWithPointsModel>> GetAllUsers()
{
var res = GetTableDetails(userManager.Users.ToList()).ToList();
res.ForEach(user => IsAdmin(user));
return Ok(res);
}

Expand Down Expand Up @@ -143,7 +142,7 @@ public async Task<ActionResult<UserModel>> GetUserByUsername(string username)
var generalBet = generalBetsRepository.GetUserGeneralBet(username);
if (generalBet != null)
userModel.SetGeneralBet(new GeneralBetViewModel(generalBet, tournamentTimesUtils.GetGeneralBetsCloseTime()));
return await IsAdmin(userModel);
return userModel;
}

[HttpGet("me")]
Expand Down Expand Up @@ -308,15 +307,6 @@ private IEnumerable<UserCompareModel> CompareUsers(List<MundialitoUser> users)
return resEntries;
}

private async Task<ActionResult<UserModel>> IsAdmin(UserModel param)
{
var user = await userManager.FindByIdAsync(param.Id);
if (user == null)
return NotFound();
param.IsAdmin = user.Role == Role.Admin;
return Ok(param);
}

private void AddLog(ActionType actionType, string message)
{
try
Expand Down
3 changes: 3 additions & 0 deletions Mundialito/Models/UserModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public UserModel(MundialitoUser user)
[JsonPropertyName("Id")]
public string Id { get; private set; }

[JsonPropertyName("Roles")]
public string Roles { get; set; }

[JsonPropertyName("ProfilePicture")]
public string? ProfilePicture { get; private set; }
Expand Down Expand Up @@ -91,6 +93,7 @@ public UserWithPointsModel(MundialitoUser user) : base(user)
{
Points = 0;
Place = string.Empty;
Roles = user.Role.ToString();
}

[JsonPropertyName("Place")]
Expand Down
4 changes: 2 additions & 2 deletions Mundialito/wwwroot/App/General/teamFlagTemplate.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<img ng-if="useFlagsCss !== 'true'" ng-src="{{::team.Flag}}" style="width: 28px; height: 28px; padding-left: 3px; padding-right: 3px;" class="img-reponsive img-rounded" />
<i ng-if="useFlagsCss === 'true'" ng-class="['flag','flag-fifa-{{team.ShortName | lowercase}}']" tooltip="{{team.Name}}"></i>&nbsp;&nbsp;
<img ng-if="useFlagsCss !== 'true'" ng-src="{{::team.Flag}}" style="width: 28px; height: 28px; margin-left: 3px; margin-right: 3px;" class="img-reponsive img-rounded" />
<i ng-if="useFlagsCss === 'true'" ng-class="['flag','flag-fifa-{{team.ShortName | lowercase}}']" tooltip="{{team.Name}}" style="margin-left: 3px; margin-right: 3px;"></i>
8 changes: 4 additions & 4 deletions Mundialito/wwwroot/App/Users/ManageApp.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
</thead>
<tbody>
<tr ng-repeat="user in users">
<td><a href="{{user.getUrl()}}">{{user.Name}}</a></td>
<td><a href="{{user.getUrl()}}">{{::user.Name}}</a><span style="margin-left: 5px;" class="badge" ng-class="{'badge-success': user.Roles === 'Admin', 'label-default': user.Roles === 'Active', 'label-danger':user.Roles === 'Disabled'}">{{::user.Roles}}</span> </td>
<td>{{user.Email}}</td>
<td>
<button title="delete" type="button" class="btn btn-danger btn-sm" ng-click="deleteUser(user)" tooltip="Delete User"><i class="fa fa-times-circle"></i> <span class="hidden-xs">Delete</span></button>
<button title="makeadmin" ng-show="!user.IsAdmin" type="button" class="btn btn-primary btn-sm" ng-click="makeAdmin(user)" tooltip="Make Admin"><i class="fa fa-gear"></i> <span class="hidden-xs">Admin</span></button>
<button title="activate" ng-show="user.Roles === Disabled && !user.IsAdmin" type="button" class="btn btn-success btn-sm" ng-click="activate(user)" tooltip="Activate"><i class="fa-solid fa-user-check"></i> <span class="hidden-xs">Activate</span></button>
<button title="deactivate" ng-show="user.Roles === Active && !user.IsAdmin" type="button" class="btn btn-warning btn-sm" ng-click="deactivate(user)" tooltip="Deactivate"><i class="fa-solid fa-user-minus"></i> <span class="hidden-xs">Deactivate</span></button>
<button title="makeadmin" ng-show="user.Roles !== 'Admin'" type="button" class="btn btn-primary btn-sm" ng-click="makeAdmin(user)" tooltip="Make Admin"><i class="fa fa-gear"></i> <span class="hidden-xs">Admin</span></button>
<button title="activate" ng-show="user.Roles === 'Disabled'" type="button" class="btn btn-success btn-sm" ng-click="activate(user)" tooltip="Activate"><i class="fa-solid fa-user-check"></i> <span class="hidden-xs">Activate</span></button>
<button title="deactivate" ng-show="user.Roles === 'Active'" type="button" class="btn btn-warning btn-sm" ng-click="deactivate(user)" tooltip="Deactivate"><i class="fa-solid fa-user-minus"></i> <span class="hidden-xs">Deactivate</span></button>
</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion Mundialito/wwwroot/js/app-min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Mundialito/wwwroot/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2306,8 +2306,8 @@ angular.module('mundialitoApp').controller('ManageAppCtrl', ['$scope', '$log', '

$scope.makeAdmin = (user) => {
user.makeAdmin().then(() => {
Alert.success('User was is now admin');
user.IsAdmin = true;
Alert.success('User is now admin');
user.Roles = "Admin";
});
};

Expand Down

0 comments on commit 8948f36

Please sign in to comment.