From 53a3c6a136ae6eb96afad2a0b515a07e0d4720e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20D=C4=99bowski?= Date: Tue, 10 Dec 2024 15:45:10 +0100 Subject: [PATCH] Zones: service, fe: model for getting zones data --- src/hiPower.Abstracts/IZoneService.cs | 10 +++++ .../CoreServicesExtensions.cs | 1 + src/hiPower.Core/ZoneService.cs | 37 ++++++++++++++++++ .../Controllers/ZonesController.cs | 12 +++++- src/hiPower.WebApi/appsettings.json | 7 ++++ .../dashboard/layout/layout.component.html | 1 - .../dashboard/layout/layout.component.scss | 6 ++- .../zones/components/zone/zone.component.html | 1 + .../zones/components/zone/zone.component.scss | 0 .../components/zone/zone.component.spec.ts | 23 +++++++++++ .../zones/components/zone/zone.component.ts | 12 ++++++ .../zones/core/models/record-item.ts | 4 ++ .../zones/core/models/zone-details.ts | 25 ++++++++++++ .../dashboard/zones/core/models/zone-item.ts | 15 +++++++ .../zones/core/models/zone-record.ts | 9 +++++ .../core/resolvers/zone-details-resolver.ts | 0 .../dashboard/zones/core/types/zone-kind.ts | 1 + .../dashboard/zones/home/home.component.html | 26 +++++++++++++ .../dashboard/zones/home/home.component.scss | 24 ++++++++++++ .../dashboard/zones/home/home.component.ts | 16 +++++++- .../zones/services/zones.service.spec.ts | 16 ++++++++ .../dashboard/zones/services/zones.service.ts | 39 +++++++++++++++++++ .../features/dashboard/zones/zones.module.ts | 11 +++++- src/powerdns-manager/src/styles/styles.scss | 4 +- .../src/styles/utils/_variables.scss | 2 +- 25 files changed, 292 insertions(+), 10 deletions(-) create mode 100644 src/hiPower.Abstracts/IZoneService.cs create mode 100644 src/hiPower.Core/ZoneService.cs create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.html create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.scss create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.spec.ts create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.ts create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/core/models/record-item.ts create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-details.ts create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-item.ts create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-record.ts create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/core/resolvers/zone-details-resolver.ts create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/core/types/zone-kind.ts create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/services/zones.service.spec.ts create mode 100644 src/powerdns-manager/src/app/features/dashboard/zones/services/zones.service.ts diff --git a/src/hiPower.Abstracts/IZoneService.cs b/src/hiPower.Abstracts/IZoneService.cs new file mode 100644 index 0000000..3b07ba0 --- /dev/null +++ b/src/hiPower.Abstracts/IZoneService.cs @@ -0,0 +1,10 @@ +namespace hiPower.Abstracts; + +public interface IZoneService +{ + Task> GetListAsync (string serviceId); + Task> GetDetailsAsync(string zoneId); + Task> UpdateDetailsAsync (); + Task> CreateMasterAsync(); + Task> CreateSlaveAsync(); +} diff --git a/src/hiPower.Core/Extensions/DependencyInjection/CoreServicesExtensions.cs b/src/hiPower.Core/Extensions/DependencyInjection/CoreServicesExtensions.cs index 7562c12..aabdc12 100644 --- a/src/hiPower.Core/Extensions/DependencyInjection/CoreServicesExtensions.cs +++ b/src/hiPower.Core/Extensions/DependencyInjection/CoreServicesExtensions.cs @@ -11,6 +11,7 @@ public static IServiceCollection ConfigureCoreServices(this IServiceCollection s { services.AddScoped (); services.AddScoped (); + services.AddScoped (); services.ConfigureMapster (); diff --git a/src/hiPower.Core/ZoneService.cs b/src/hiPower.Core/ZoneService.cs new file mode 100644 index 0000000..036bb78 --- /dev/null +++ b/src/hiPower.Core/ZoneService.cs @@ -0,0 +1,37 @@ +using System.Text.Json; +using System.Text.Json.Nodes; +using hiPower.Abstracts; + +namespace hiPower.Core; + +public class ZoneService : IZoneService +{ + public Task> CreateMasterAsync () + { + throw new NotImplementedException (); + } + + public Task> CreateSlaveAsync () + { + throw new NotImplementedException (); + } + + public async Task> GetDetailsAsync (string zoneId) + { + string json = "{\r\n \"account\": \"\",\r\n \"api_rectify\": false,\r\n \"catalog\": \"\",\r\n \"dnssec\": false,\r\n \"edited_serial\": 2024050502,\r\n \"id\": \"hihost.pl.\",\r\n \"kind\": \"Slave\",\r\n \"last_check\": 1732782113,\r\n \"master_tsig_key_ids\": [],\r\n \"masters\": [\r\n \"54.38.63.174\"\r\n ],\r\n \"name\": \"hihost.pl.\",\r\n \"notified_serial\": 0,\r\n \"nsec3narrow\": false,\r\n \"nsec3param\": \"\",\r\n \"rrsets\": [\r\n {\r\n \"comments\": [],\r\n \"name\": \"20210905._domainkey.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"\\\"v=DKIM1; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCiNKEpEquwoG1rHvkl0/zTe7pCe9VANvI+NBaSbI1qoO7LFY2w9toBR9ckuv/AFeSi5+t8b4TblFvAoNNTkbppUdf41YdTyDm5vpsAii5vUInwfb/fuawkSc7B1eu/xdzAUJQdoLxvjpLFmdTqaGFTd3u44D/egC96Ty1KmGRLiQIDAQAB;\\\"\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"TXT\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"www.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.171\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"support.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.172\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"autodiscover.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.165\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"ftp.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.161\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"help.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"support.hihost.pl.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"CNAME\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"_imaps._tcp.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"0 0 993 imap4.hihost.pl.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"SRV\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"_pop3s._tcp.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"0 0 995 pop3.hihost.pl.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"SRV\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"_autodiscover._tcp.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"0 0 80 autodiscover.hihost.pl.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"SRV\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"_imap._tcp.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"0 0 143 imap4.hihost.pl.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"SRV\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"_submission._tcp.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"0 0 587 smtp2.hihost.pl.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"SRV\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"_pop3._tcp.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"0 0 110 pop3.hihost.pl.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"SRV\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"google-site-verification.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"\\\"sYsoadOMu1x1lC-e_bWvptvdKJybcxpcj4e63lnUD-U\\\"\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"TXT\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"panel.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.170\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"devapi.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"stage02.hihost.pl.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"CNAME\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"vpngate.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.36.174.14\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"_dmarc.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"\\\"v=DMARC1; p=reject; rua=mailto:dmarc-reports@hihost.pl; ruf=mailto:dmarc-reports@hihost.pl; fo=1; adkim=s; aspf=s;\\\"\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"TXT\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"imap4.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.164\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"pop3.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.163\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"smtp2.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.162\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"admin2.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.165\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"poczta2.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.165\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"stage02.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"88.220.117.8\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"mx01.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.162\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"stage01.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.175\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"*.hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.171\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"mail01.hidnservice.com. .\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"RP\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"\\\"google-site-verification=sYsoadOMu1x1lC-e_bWvptvdKJybcxpcj4e63lnUD-U\\\"\",\r\n \"disabled\": false\r\n },\r\n {\r\n \"content\": \"\\\"v=spf1 mx ip4:54.38.63.162/32 -all\\\"\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"TXT\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"20 mx01.hihost.pl.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"MX\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"nst01.hidnservice.net. dnsmaster.hidnservice.net. 2024050502 1200 900 1209600 3600\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"SOA\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"nst02.hidnservice.net.\",\r\n \"disabled\": false\r\n },\r\n {\r\n \"content\": \"nst01.hidnservice.net.\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"NS\"\r\n },\r\n {\r\n \"comments\": [],\r\n \"name\": \"hihost.pl.\",\r\n \"records\": [\r\n {\r\n \"content\": \"54.38.63.171\",\r\n \"disabled\": false\r\n }\r\n ],\r\n \"ttl\": 3600,\r\n \"type\": \"A\"\r\n }\r\n ],\r\n \"serial\": 2024050502,\r\n \"slave_tsig_key_ids\": [],\r\n \"soa_edit\": \"\",\r\n \"soa_edit_api\": \"DEFAULT\",\r\n \"url\": \"/api/v1/servers/localhost/zones/hihost.pl.\"\r\n}"; + + var result = JsonSerializer.Deserialize(json); + + return await Task.FromResult (result!); + } + + public Task> GetListAsync (string serviceId) + { + throw new NotImplementedException (); + } + + public Task> UpdateDetailsAsync () + { + throw new NotImplementedException (); + } +} diff --git a/src/hiPower.WebApi/Controllers/ZonesController.cs b/src/hiPower.WebApi/Controllers/ZonesController.cs index 086b8a1..6de6aac 100644 --- a/src/hiPower.WebApi/Controllers/ZonesController.cs +++ b/src/hiPower.WebApi/Controllers/ZonesController.cs @@ -1,11 +1,19 @@ -using Microsoft.AspNetCore.Mvc; +using hiPower.Abstracts; +using Microsoft.AspNetCore.Mvc; namespace hiPower.WebApi.Controllers { [Route ("api/zones")] [ApiController] [Produces (MediaTypeNames.Application.Json)] - public class ZonesController : ControllerBase + public class ZonesController(IZoneService zoneService) : ControllerBase { + [HttpGet("{zoneId}")] + [ProducesResponseType(StatusCodes.Status200OK, Type=typeof(ApiResult))] + public async Task GetDetails ([FromRoute] string zoneId) + { + var result = await zoneService.GetDetailsAsync (zoneId); + return Ok (new ApiResult(!result.IsError, result.Value)); + } } } diff --git a/src/hiPower.WebApi/appsettings.json b/src/hiPower.WebApi/appsettings.json index e21fff7..bea0ba6 100644 --- a/src/hiPower.WebApi/appsettings.json +++ b/src/hiPower.WebApi/appsettings.json @@ -3,6 +3,13 @@ "DefaultDbConnection": "Server=[server address];Database=hiPower_Manager;user id=[userId];Password=[pwd]", "AzureBlobStorageConnection": "[Azure storage connection string]" }, + "JwtOptions": { + "Secret": "[secret]", + "Issuer": "[issuer]", + "Audiance": "[audiance]", + "ExpiretionAfterSeconds": 7200, + "RefreshTime": 1800 + }, "Serilog": { "MinimumLevel": { "Default": "Information", diff --git a/src/powerdns-manager/src/app/features/dashboard/layout/layout.component.html b/src/powerdns-manager/src/app/features/dashboard/layout/layout.component.html index 0ed44fb..b413c82 100644 --- a/src/powerdns-manager/src/app/features/dashboard/layout/layout.component.html +++ b/src/powerdns-manager/src/app/features/dashboard/layout/layout.component.html @@ -12,7 +12,6 @@ - diff --git a/src/powerdns-manager/src/app/features/dashboard/layout/layout.component.scss b/src/powerdns-manager/src/app/features/dashboard/layout/layout.component.scss index 2d8c6f4..7ae23a0 100644 --- a/src/powerdns-manager/src/app/features/dashboard/layout/layout.component.scss +++ b/src/powerdns-manager/src/app/features/dashboard/layout/layout.component.scss @@ -27,7 +27,7 @@ border-right: none; background-color: #05038a; color: $color-white; - border-radius: 1rem; + border-radius: $border-radius; padding: 1rem; text-align: center; box-shadow: $border-shadow; @@ -64,13 +64,15 @@ .content { height: calc(100vh - 105px); + overflow: hidden; + overflow-y: auto; margin: 1rem 2rem 1rem 2rem; padding: 1rem; display: flex; justify-content: center; font-size: 2rem; color: $color-blue; - border-radius: 1rem; + border-radius: $border-radius; background-color: $color-gray-light; border: solid .5px silver; box-shadow: $border-shadow; diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.html b/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.html new file mode 100644 index 0000000..81d4d3e --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.html @@ -0,0 +1 @@ +

Zone details

\ No newline at end of file diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.scss b/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.spec.ts b/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.spec.ts new file mode 100644 index 0000000..a8babbf --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ZoneComponent } from './zone.component'; + +describe('ZoneComponent', () => { + let component: ZoneComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ZoneComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ZoneComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.ts b/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.ts new file mode 100644 index 0000000..5395473 --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/components/zone/zone.component.ts @@ -0,0 +1,12 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-zone', + standalone: true, + imports: [], + templateUrl: './zone.component.html', + styleUrl: './zone.component.scss' +}) +export class ZoneComponent { + +} diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/core/models/record-item.ts b/src/powerdns-manager/src/app/features/dashboard/zones/core/models/record-item.ts new file mode 100644 index 0000000..2edb04b --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/core/models/record-item.ts @@ -0,0 +1,4 @@ +export interface RecordItem { + content: string; + disabled: boolean; +} \ No newline at end of file diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-details.ts b/src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-details.ts new file mode 100644 index 0000000..3bd3a74 --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-details.ts @@ -0,0 +1,25 @@ +import { ZoneKind } from "../types/zone-kind"; +import { ZoneRecord } from "./zone-record"; + +export interface ZoneDetails { + id: string; + name: string; + kind: ZoneKind, + account: string; + catalog: string; + serial: number; + notifiedSerial: number; + editedSerial: number; + last_check: number; + api_rectify: boolean; + masters: string[]; + dnssec: boolean; + masterTsigKeyIds: string[]; + slaveTsigKeyIds: string[], + msec3Narrow: boolean; + nsec3param: string; + soaEdit: string; + soaEditApi: string; + rrsets: ZoneRecord[]; + url: string; +} \ No newline at end of file diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-item.ts b/src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-item.ts new file mode 100644 index 0000000..4863664 --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-item.ts @@ -0,0 +1,15 @@ +import { ZoneKind } from "../types/zone-kind"; + +export interface ZoneItem { + id: string; + name: string; + serial: number; + editedSerial: number; + notifiedSerial: number; + lastCheck: string; + account: string; + catalog: string; + dnssec: boolean; + kind: ZoneKind; + masters: string[] +} \ No newline at end of file diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-record.ts b/src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-record.ts new file mode 100644 index 0000000..01476b1 --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/core/models/zone-record.ts @@ -0,0 +1,9 @@ +import { RecordItem } from "./record-item"; + +export interface ZoneRecord { + type: string; + name: string; + ttl: number; + comments: string []; + records: RecordItem[]; +} \ No newline at end of file diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/core/resolvers/zone-details-resolver.ts b/src/powerdns-manager/src/app/features/dashboard/zones/core/resolvers/zone-details-resolver.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/core/types/zone-kind.ts b/src/powerdns-manager/src/app/features/dashboard/zones/core/types/zone-kind.ts new file mode 100644 index 0000000..46264fa --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/core/types/zone-kind.ts @@ -0,0 +1 @@ +export type ZoneKind = 'Slave' | 'Master'; \ No newline at end of file diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.html b/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.html index 27f5044..c548824 100644 --- a/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.html +++ b/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.html @@ -1 +1,27 @@

zones home works!

+ +
    +
  • Name{{ zone.name }}
  • +
  • Serial{{ zone.serial }}
  • +
  • Last check{{ zone.last_check }}
  • +
  • Kind{{ zone.kind }}
  • +
  • DNS SEC{{ zone.dnssec}}
  • +
  • Records no{{ zone.rrsets.length }}
  • +
  • Api rectify{{ zone.api_rectify}}
  • +
  • Url{{ zone.url }}
  • +
+
+
    + @for(item of zone.rrsets; track (item.type + item.name) ) { +
  • {{ item.type }}
    + Name: {{ item.name }}
    + values: +
      + @for(recordValue of item.records; track recordValue.content ) { +
    • {{ recordValue.content }}
    • + } +
    +
  • + } +
+
diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.scss b/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.scss index e69de29..b88ad39 100644 --- a/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.scss +++ b/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.scss @@ -0,0 +1,24 @@ +:host { + ul { + font-size: 1rem; + list-style-type: '» '; + margin-left: 2rem; + + li { + font-weight: 600; + + & > span { + display: inline-block; + width: 12ch; + font-weight: 500; + + &::after { + content: ':'; + } + } + } + ul { + list-style-type: '- '; + } + } +} \ No newline at end of file diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.ts b/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.ts index 3a10d2a..7df36e1 100644 --- a/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.ts +++ b/src/powerdns-manager/src/app/features/dashboard/zones/home/home.component.ts @@ -1,10 +1,22 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { ZonesService } from '../services/zones.service'; +import { EMPTY, Observable } from 'rxjs'; +import { ZoneDetails } from '../core/models/zone-details'; @Component({ selector: 'app-home-zones', templateUrl: './home.component.html', styleUrl: './home.component.scss' }) -export class HomeComponent { +export class HomeComponent implements OnInit { + zoneDetails$: Observable = EMPTY; + + constructor(private zonesService: ZonesService){} + + ngOnInit(): void { + this.zoneDetails$ = this.zonesService.getDetails('hihost.pl'); + + this.zoneDetails$.subscribe(); + } } diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/services/zones.service.spec.ts b/src/powerdns-manager/src/app/features/dashboard/zones/services/zones.service.spec.ts new file mode 100644 index 0000000..6b591ae --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/services/zones.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ZonesServiceService } from './zones.service'; + +describe('ZonesServiceService', () => { + let service: ZonesServiceService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ZonesServiceService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/services/zones.service.ts b/src/powerdns-manager/src/app/features/dashboard/zones/services/zones.service.ts new file mode 100644 index 0000000..b059890 --- /dev/null +++ b/src/powerdns-manager/src/app/features/dashboard/zones/services/zones.service.ts @@ -0,0 +1,39 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { filter, map, Observable, + of } from 'rxjs'; + +import { DataService } from '@shared/base/data.service'; +import { ConfigService } from 'src/app/initializer/config.service'; +import { ZoneDetails } from '../core/models/zone-details'; +import { ApiResponse } from '@shared/models/api-response'; +import { ZoneItem } from '../core/models/zone-item'; + +@Injectable() +export class ZonesService extends DataService { + + private readonly apiUrl = this.configService + .getEndpoint('Zones'); + + constructor(httpClient: HttpClient, + private configService: ConfigService) + { + super(httpClient); + } + + getList(serviceId: string): Observable { + return this.get>(`${this.apiUrl}`) + .pipe( + filter(x => x.success), + map(x => x.data as ZoneItem[]) + ); + } + + getDetails(zoneId: string): Observable { + return this.get>(`${this.apiUrl}/{zoneId}`) + .pipe( + filter(x => x.success), + map(x => x.data as ZoneDetails) + ); + } +} diff --git a/src/powerdns-manager/src/app/features/dashboard/zones/zones.module.ts b/src/powerdns-manager/src/app/features/dashboard/zones/zones.module.ts index aa09c68..19210a6 100644 --- a/src/powerdns-manager/src/app/features/dashboard/zones/zones.module.ts +++ b/src/powerdns-manager/src/app/features/dashboard/zones/zones.module.ts @@ -1,9 +1,11 @@ -import { NgModule } from '@angular/core'; +import { ErrorHandler, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { ZonesRoutingModule } from './zones-routing.module'; import { HomeComponent } from './home/home.component'; import { SharedModule } from '@shared/shared.module'; import { MaterialsModule } from '@shared/materiald.module'; +import { ZonesService } from '@features/dashboard/zones/services/zones.service'; +import { ManagerErrorHandler } from '@shared/handlers/manager-error-handler'; @NgModule({ declarations: [ @@ -14,6 +16,13 @@ import { MaterialsModule } from '@shared/materiald.module'; ZonesRoutingModule, SharedModule, MaterialsModule + ], + providers: [ + ZonesService, + { + provide: ErrorHandler, + useClass: ManagerErrorHandler + } ] }) export class ZonesModule { } diff --git a/src/powerdns-manager/src/styles/styles.scss b/src/powerdns-manager/src/styles/styles.scss index 0974d4e..2d0958e 100644 --- a/src/powerdns-manager/src/styles/styles.scss +++ b/src/powerdns-manager/src/styles/styles.scss @@ -2,7 +2,9 @@ @import './utils/variables'; -mat-card { +mat-card { + border-radius: $border-radius !important; + mat-card-header { padding-bottom: 1rem !important; margin-bottom: 1rem !important; diff --git a/src/powerdns-manager/src/styles/utils/_variables.scss b/src/powerdns-manager/src/styles/utils/_variables.scss index 46b8f10..078e936 100644 --- a/src/powerdns-manager/src/styles/utils/_variables.scss +++ b/src/powerdns-manager/src/styles/utils/_variables.scss @@ -6,5 +6,5 @@ $color-white: rgb(255, 228, 196); $color-blue: #2E22E4; $color-blue-navy: #004a9f; -$border-radius: 16px; +$border-radius: 0; $border-shadow: 0 1px 1px hsl(0deg 0% 0% / 0.075), 0 2px 2px hsl(0deg 0% 0% / 0.075), 0 4px 4px hsl(0deg 0% 0% / 0.075), 0 8px 8px hsl(0deg 0% 0% / 0.075), 0 16px 16px hsl(0deg 0% 0% / 0.075); \ No newline at end of file