Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to PhoneEdit 1.0.2 #17

Merged
merged 7 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
name: Docker Packages

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
release:
types: [published]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ${{ vars.REGISTRY }}


jobs:
Build-PhoneEdit:
environment: PhoneEditApplication

runs-on: ubuntu-latest

permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install Cosign
uses: sigstore/[email protected]
with:
cosign-release: 'v2.1.1'
cosign-release: 'v2.2.4'
- name: Check install!
run: cosign version

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
Expand All @@ -39,12 +56,16 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ github.actor }}/${{ vars.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push PhoneEdit Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
Expand All @@ -56,6 +77,11 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published PhoneEdit Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
Expand Down
10 changes: 6 additions & 4 deletions Controllers/PhoneBookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public PhoneBookController(PhonebookContext context)
}

[AllowAnonymous]
public async Task<IActionResult> Index(string searchString, string currentFilter, int? cPage)
public async Task<IActionResult> Index(string? searchString, string? currentFilter, int? cPage)
{
if (searchString != null)
{
Expand All @@ -37,9 +37,11 @@ public async Task<IActionResult> Index(string searchString, string currentFilter
{
entriesQuery = entriesQuery.Where(e =>
e.Name.Contains(searchString) ||
e.Department.Contains(searchString) ||
e.Mail.Contains(searchString) ||
e.Room.Contains(searchString) ||
e.LocalPhoneNumber.Contains(searchString) ||
e.CityPhoneNumber.Contains(searchString) ||
e.PersonnelNumber.Contains(searchString));
}

Expand Down Expand Up @@ -78,7 +80,7 @@ public IActionResult Create()
}

// POST: PhoneBook/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
Expand Down Expand Up @@ -148,7 +150,7 @@ public async Task<IActionResult> Edit(int id, [Bind("Id,PersonnelNumber,Name,Pos
}
return View(bookEntry);
}

// GET: PhoneBook/Delete/5
public async Task<IActionResult> Delete(int? id)
{
Expand Down Expand Up @@ -182,7 +184,7 @@ private bool BookEntryExists(int id)
{
return _context.Entries.Any(e => e.Id == id);
}

// Valid only if personnelNumber is unique
private bool VerifyPersonnelNumber(string personnelNumber, int id)
{
Expand Down
6 changes: 2 additions & 4 deletions Models/BookEntry.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -15,19 +13,19 @@
[Remote(action: "RemoteVerifyPersonnelNumber",
controller: "PhoneBook", AdditionalFields = nameof(Id))]
[DisplayName("Табельный номер")]
public string PersonnelNumber { get; set; }

Check warning on line 16 in Models/BookEntry.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'PersonnelNumber' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Required(ErrorMessage = "Поле обязательно для заполнения")]
[DisplayName("ФИО")]
public string Name { get; set; }

Check warning on line 20 in Models/BookEntry.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Required(ErrorMessage = "Поле обязательно для заполнения")]
[DisplayName("Должность")]
public string Position { get; set; }

Check warning on line 24 in Models/BookEntry.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Position' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[Required(ErrorMessage = "Поле обязательно для заполнения")]
[DisplayName("Подразделение")]
public string Department { get; set; }

Check warning on line 28 in Models/BookEntry.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Department' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[DisplayName("Местный телефон")]
public string? LocalPhoneNumber { get; set; } = string.Empty;
Expand All @@ -41,12 +39,12 @@
[DisplayName("Комната")]
public string? Room { get; set; } = string.Empty;

[HiddenInput(DisplayValue = false)]
[HiddenInput(DisplayValue = false)]
public string Status { get; set; } = string.Empty;

public override string ToString()
{
// Used for full-text search
return $"Entry: {Name} {Department} {Mail} {Room}";
}
}
}
24 changes: 12 additions & 12 deletions PhoneEdit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
<PackageReference Include="X.PagedList" Version="8.4.7" />
<PackageReference Include="X.PagedList.Mvc.Core" Version="8.4.7" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="X.PagedList" Version="9.1.2" />
<PackageReference Include="X.PagedList.Mvc.Core" Version="9.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions Views/PhoneBook/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@using X.PagedList.Web.Common
@using X.PagedList.Mvc.Core
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model X.PagedList.IPagedList<BookEntry>
Expand Down Expand Up @@ -52,7 +51,7 @@
<br />
<table class="table table-striped table-hover table-sm">
<thead class="thead-light">
@if(Model.Any())
@if(Model.Any())
{
var item = Model.First();
<tr>
Expand Down Expand Up @@ -158,4 +157,4 @@
})
</nav>
<br/>
Страница @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) из @Model.PageCount
Страница @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) из @Model.PageCount
Loading