From 7d651b3bc6885550504357401bf2defbdcf9b355 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Jun 2025 07:31:04 +0000 Subject: [PATCH 1/6] Initial plan for issue From f7500eee5c8974af319d03d5de6c4953fd092b57 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Jun 2025 07:40:56 +0000 Subject: [PATCH 2/6] Add GitHub admin pages with models, service, and components Co-authored-by: maximgorbatyuk <13348685+maximgorbatyuk@users.noreply.github.com> --- src/app/models/github.ts | 45 +++++++ src/app/modules/admin/admin-routing.module.ts | 7 ++ src/app/modules/admin/admin.module.ts | 9 +- .../github-chats-page.component.html | 92 ++++++++++++++ .../github-chats-page.component.ts | 62 ++++++++++ .../github-jobs-page.component.html | 94 +++++++++++++++ .../github-jobs-page.component.ts | 94 +++++++++++++++ .../github-profiles-page.component.html | 114 ++++++++++++++++++ .../github-profiles-page.component.ts | 62 ++++++++++ src/app/services/github-admin.service.ts | 50 ++++++++ 10 files changed, 628 insertions(+), 1 deletion(-) create mode 100644 src/app/models/github.ts create mode 100644 src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.html create mode 100644 src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.ts create mode 100644 src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.html create mode 100644 src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.ts create mode 100644 src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.html create mode 100644 src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.ts create mode 100644 src/app/services/github-admin.service.ts diff --git a/src/app/models/github.ts b/src/app/models/github.ts new file mode 100644 index 0000000..269083c --- /dev/null +++ b/src/app/models/github.ts @@ -0,0 +1,45 @@ +export interface GitHubProfile { + id: string; + githubId: number; + username: string; + avatarUrl: string | null; + profileUrl: string; + name: string | null; + bio: string | null; + location: string | null; + email: string | null; + publicRepos: number; + followers: number; + following: number; + createdAt: string; + updatedAt: string; +} + +export interface GitHubChat { + id: string; + chatId: number; + chatName: string | null; + usageCount: number; + githubProfiles: GitHubProfile[]; + createdAt: string; + updatedAt: string; +} + +export interface GitHubProcessingJob { + id: string; + jobType: string; + status: GitHubJobStatus; + githubProfileId: string | null; + githubProfile: GitHubProfile | null; + errorMessage: string | null; + processedAt: string | null; + createdAt: string; + updatedAt: string; +} + +export enum GitHubJobStatus { + Pending = 0, + Processing = 1, + Completed = 2, + Failed = 3, +} \ No newline at end of file diff --git a/src/app/modules/admin/admin-routing.module.ts b/src/app/modules/admin/admin-routing.module.ts index 417c3ab..058c8f0 100644 --- a/src/app/modules/admin/admin-routing.module.ts +++ b/src/app/modules/admin/admin-routing.module.ts @@ -19,6 +19,9 @@ import { CompaniesAdminPageComponent } from "./components/companies/companies-ad import { CompanyAdminPageComponent } from "./components/companies/company-admin-page/company-admin-page.component"; import { ReviewsToApprovePageComponent } from "./components/companies/reviews-to-approve/reviews-to-approve-page.component"; import { InlineRepliesStatsComponent } from "./components/telegram/inline-replies-stats/inline-replies-stats.component"; +import { GitHubProfilesPageComponent } from "./components/github/github-profiles-page/github-profiles-page.component"; +import { GitHubChatsPageComponent } from "./components/github/github-chats-page/github-chats-page.component"; +import { GitHubJobsPageComponent } from "./components/github/github-jobs-page/github-jobs-page.component"; const routes: Routes = [ { path: "", component: AdminStartPageComponent }, @@ -61,6 +64,10 @@ const routes: Routes = [ component: ReviewsToApprovePageComponent, }, { path: "companies/:id", component: CompanyAdminPageComponent }, + + { path: "github/profiles", component: GitHubProfilesPageComponent }, + { path: "github/chats", component: GitHubChatsPageComponent }, + { path: "github/processing-jobs", component: GitHubJobsPageComponent }, ]; @NgModule({ diff --git a/src/app/modules/admin/admin.module.ts b/src/app/modules/admin/admin.module.ts index f267ede..64eaea5 100644 --- a/src/app/modules/admin/admin.module.ts +++ b/src/app/modules/admin/admin.module.ts @@ -23,12 +23,16 @@ import { StatDataCacheRecordsComponent } from "./components/telegram/stat-data-c import { GenerateQrPageComponent } from "./components/generate-qr-code-page/generate-qr-page.component"; import { CurrenciesPageComponent } from "./components/currencies-page/currencies-page.component"; import { AdminDashboardService } from "./services/admin-dashboard.service"; +import { GitHubAdminService } from "@services/github-admin.service"; import { CompaniesAdminPageComponent } from "./components/companies/companies-admin-page/companies-admin-page.component"; import { CompanyAdminPageComponent } from "./components/companies/company-admin-page/company-admin-page.component"; import { ReviewsToApprovePageComponent } from "./components/companies/reviews-to-approve/reviews-to-approve-page.component"; import { InlineRepliesStatsComponent } from "./components/telegram/inline-replies-stats/inline-replies-stats.component"; +import { GitHubProfilesPageComponent } from "./components/github/github-profiles-page/github-profiles-page.component"; +import { GitHubChatsPageComponent } from "./components/github/github-chats-page/github-chats-page.component"; +import { GitHubJobsPageComponent } from "./components/github/github-jobs-page/github-jobs-page.component"; -const adminServices = [AdminDashboardService]; +const adminServices = [AdminDashboardService, GitHubAdminService]; @NgModule({ declarations: [ @@ -54,6 +58,9 @@ const adminServices = [AdminDashboardService]; CompanyAdminPageComponent, ReviewsToApprovePageComponent, InlineRepliesStatsComponent, + GitHubProfilesPageComponent, + GitHubChatsPageComponent, + GitHubJobsPageComponent, ], imports: [ CommonModule, diff --git a/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.html b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.html new file mode 100644 index 0000000..1d39191 --- /dev/null +++ b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.html @@ -0,0 +1,92 @@ +GitHub Telegram Bot Chats + +
+
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Chat IDChat NameUsage CountGitHub ProfilesCreatedUpdated
{{ chat.chatId }}{{ chat.chatName || "-" }}{{ chat.usageCount | formatAsMoney }} + + {{ chat.githubProfiles.length }} profile(s) + + + No profiles + + {{ chat.createdAt | date: "yyyy-MM-dd HH:mm" }}{{ chat.updatedAt | date: "yyyy-MM-dd HH:mm" }}
+
+ +
+ +
+
+
+
+ + +
+
+
Нет данных.
+
+
+
+ + +
+ +
+
\ No newline at end of file diff --git a/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.ts b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.ts new file mode 100644 index 0000000..1c1a5c7 --- /dev/null +++ b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.ts @@ -0,0 +1,62 @@ +import { Component, OnDestroy, OnInit } from "@angular/core"; +import { defaultPageParams } from "@models/page-params"; +import { PaginatedList } from "@models/paginated-list"; +import { TitleService } from "@services/title.service"; +import { untilDestroyed } from "@shared/subscriptions/until-destroyed"; +import { GitHubAdminService } from "@services/github-admin.service"; +import { GitHubChat } from "@models/github"; + +@Component({ + templateUrl: "./github-chats-page.component.html", + standalone: false, +}) +export class GitHubChatsPageComponent implements OnInit, OnDestroy { + chats: Array | null = null; + source: PaginatedList | null = null; + currentPage: number = 1; + searchQuery: string = ""; + + constructor( + private readonly service: GitHubAdminService, + titleService: TitleService, + ) { + titleService.setTitle("GitHub Telegram Bot Chats"); + } + + ngOnInit(): void { + this.chats = null; + this.source = null; + this.loadData(this.currentPage); + } + + loadData(pageToRequest: number): void { + this.chats = null; + this.source = null; + this.currentPage = pageToRequest; + + this.service + .getChats({ + page: this.currentPage, + pageSize: defaultPageParams.pageSize, + search: this.searchQuery || undefined, + }) + .pipe(untilDestroyed(this)) + .subscribe((x) => { + this.chats = x.results; + this.source = x; + }); + } + + onSearch(): void { + this.loadData(1); + } + + clearSearch(): void { + this.searchQuery = ""; + this.loadData(1); + } + + ngOnDestroy(): void { + // ignored + } +} \ No newline at end of file diff --git a/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.html b/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.html new file mode 100644 index 0000000..c5d6ce4 --- /dev/null +++ b/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.html @@ -0,0 +1,94 @@ +GitHub Processing Jobs + +
+
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
IDJob TypeStatusGitHub ProfileError MessageProcessed AtCreatedActions
{{ job.id }}{{ job.jobType }} + + {{ getStatusLabel(job.status) }} + + + + + {{ job.githubProfile.username }} + + + - + + + {{ job.errorMessage.length > 50 ? (job.errorMessage | slice:0:50) + '...' : job.errorMessage }} + + - + + {{ job.processedAt ? (job.processedAt | date: "yyyy-MM-dd HH:mm") : "-" }} + {{ job.createdAt | date: "yyyy-MM-dd HH:mm" }} + +
+
+
+
+
+ + +
+
+
No processing jobs found.
+
+
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.ts b/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.ts new file mode 100644 index 0000000..bb5d715 --- /dev/null +++ b/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.ts @@ -0,0 +1,94 @@ +import { Component, OnDestroy, OnInit } from "@angular/core"; +import { TitleService } from "@services/title.service"; +import { untilDestroyed } from "@shared/subscriptions/until-destroyed"; +import { GitHubAdminService } from "@services/github-admin.service"; +import { GitHubProcessingJob, GitHubJobStatus } from "@models/github"; +import { ConfirmMsg } from "@shared/components/dialogs/models/confirm-msg"; +import { DialogMessage } from "@shared/components/dialogs/models/dialog-message"; + +@Component({ + templateUrl: "./github-jobs-page.component.html", + standalone: false, +}) +export class GitHubJobsPageComponent implements OnInit, OnDestroy { + jobs: Array | null = null; + confirmDeletionMessage: DialogMessage | null = null; + + constructor( + private readonly service: GitHubAdminService, + titleService: TitleService, + ) { + titleService.setTitle("GitHub Processing Jobs"); + } + + ngOnInit(): void { + this.jobs = null; + this.loadData(); + } + + loadData(): void { + this.jobs = null; + + this.service + .getProcessingJobs() + .pipe(untilDestroyed(this)) + .subscribe((x) => { + this.jobs = x; + }); + } + + openDeleteDialog(job: GitHubProcessingJob): void { + this.confirmDeletionMessage = new DialogMessage( + new ConfirmMsg( + "Delete Processing Job", + `Are you sure you want to delete job "${job.jobType}" (ID: ${job.id})?`, + () => { + this.deleteJob(job); + }, + ), + ); + } + + deleteJob(job: GitHubProcessingJob): void { + this.service + .deleteProcessingJob(job.id) + .pipe(untilDestroyed(this)) + .subscribe(() => { + this.loadData(); // Reload data after deletion + }); + } + + getStatusLabel(status: GitHubJobStatus): string { + switch (status) { + case GitHubJobStatus.Pending: + return "Pending"; + case GitHubJobStatus.Processing: + return "Processing"; + case GitHubJobStatus.Completed: + return "Completed"; + case GitHubJobStatus.Failed: + return "Failed"; + default: + return "Unknown"; + } + } + + getStatusClass(status: GitHubJobStatus): string { + switch (status) { + case GitHubJobStatus.Pending: + return "badge bg-warning"; + case GitHubJobStatus.Processing: + return "badge bg-info"; + case GitHubJobStatus.Completed: + return "badge bg-success"; + case GitHubJobStatus.Failed: + return "badge bg-danger"; + default: + return "badge bg-secondary"; + } + } + + ngOnDestroy(): void { + // ignored + } +} \ No newline at end of file diff --git a/src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.html b/src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.html new file mode 100644 index 0000000..d432945 --- /dev/null +++ b/src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.html @@ -0,0 +1,114 @@ +GitHub Profiles + +
+
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
AvatarUsernameNameLocationPublic ReposFollowersFollowingCreatedActions
+ Avatar + - + + + {{ profile.username }} + + {{ profile.name || "-" }}{{ profile.location || "-" }}{{ profile.publicRepos | formatAsMoney }}{{ profile.followers | formatAsMoney }}{{ profile.following | formatAsMoney }}{{ profile.createdAt | date: "yyyy-MM-dd HH:mm" }} + +
+
+ +
+ +
+
+
+
+ + +
+
+
Нет данных.
+
+
+
+ + +
+ +
+
\ No newline at end of file diff --git a/src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.ts b/src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.ts new file mode 100644 index 0000000..5795d7e --- /dev/null +++ b/src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.ts @@ -0,0 +1,62 @@ +import { Component, OnDestroy, OnInit } from "@angular/core"; +import { defaultPageParams } from "@models/page-params"; +import { PaginatedList } from "@models/paginated-list"; +import { TitleService } from "@services/title.service"; +import { untilDestroyed } from "@shared/subscriptions/until-destroyed"; +import { GitHubAdminService } from "@services/github-admin.service"; +import { GitHubProfile } from "@models/github"; + +@Component({ + templateUrl: "./github-profiles-page.component.html", + standalone: false, +}) +export class GitHubProfilesPageComponent implements OnInit, OnDestroy { + profiles: Array | null = null; + source: PaginatedList | null = null; + currentPage: number = 1; + searchQuery: string = ""; + + constructor( + private readonly service: GitHubAdminService, + titleService: TitleService, + ) { + titleService.setTitle("GitHub Profiles"); + } + + ngOnInit(): void { + this.profiles = null; + this.source = null; + this.loadData(this.currentPage); + } + + loadData(pageToRequest: number): void { + this.profiles = null; + this.source = null; + this.currentPage = pageToRequest; + + this.service + .getProfiles({ + page: this.currentPage, + pageSize: defaultPageParams.pageSize, + search: this.searchQuery || undefined, + }) + .pipe(untilDestroyed(this)) + .subscribe((x) => { + this.profiles = x.results; + this.source = x; + }); + } + + onSearch(): void { + this.loadData(1); + } + + clearSearch(): void { + this.searchQuery = ""; + this.loadData(1); + } + + ngOnDestroy(): void { + // ignored + } +} \ No newline at end of file diff --git a/src/app/services/github-admin.service.ts b/src/app/services/github-admin.service.ts new file mode 100644 index 0000000..a63963a --- /dev/null +++ b/src/app/services/github-admin.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from "@angular/core"; +import { defaultPageParams, PageParams } from "@models/page-params"; +import { PaginatedList } from "@models/paginated-list"; +import { ConvertObjectToHttpParams } from "@shared/value-objects/convert-object-to-http"; +import { Observable } from "rxjs"; +import { ApiService } from "./api.service"; +import { GitHubProfile, GitHubChat, GitHubProcessingJob } from "@models/github"; + +export interface GitHubProfilesQueryParams extends PageParams { + search?: string; +} + +export interface GitHubChatsQueryParams extends PageParams { + search?: string; +} + +@Injectable() +export class GitHubAdminService { + private readonly apiUrl: string; + + constructor(private readonly api: ApiService) { + this.apiUrl = `/api/admin/github/`; + } + + getProfiles( + params: GitHubProfilesQueryParams = defaultPageParams, + ): Observable> { + const httpParams = new ConvertObjectToHttpParams(params).get(); + return this.api.get>( + this.apiUrl + "profiles?" + httpParams, + ); + } + + getChats( + params: GitHubChatsQueryParams = defaultPageParams, + ): Observable> { + const httpParams = new ConvertObjectToHttpParams(params).get(); + return this.api.get>( + this.apiUrl + "chats?" + httpParams, + ); + } + + getProcessingJobs(): Observable { + return this.api.get(this.apiUrl + "processing-jobs"); + } + + deleteProcessingJob(id: string): Observable { + return this.api.delete(this.apiUrl + "processing-jobs/" + id); + } +} \ No newline at end of file From 80e2c6cf47384fb086f17b37cb8d811d828fa114 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Jun 2025 07:43:27 +0000 Subject: [PATCH 3/6] Add unit tests for GitHub admin components and service Co-authored-by: maximgorbatyuk <13348685+maximgorbatyuk@users.noreply.github.com> --- .../github-chats-page.component.spec.ts | 33 +++++++++++++++++++ .../github-jobs-page.component.spec.ts | 33 +++++++++++++++++++ .../github-profiles-page.component.spec.ts | 33 +++++++++++++++++++ src/app/services/github-admin.service.spec.ts | 20 +++++++++++ 4 files changed, 119 insertions(+) create mode 100644 src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.spec.ts create mode 100644 src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.spec.ts create mode 100644 src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.spec.ts create mode 100644 src/app/services/github-admin.service.spec.ts diff --git a/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.spec.ts b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.spec.ts new file mode 100644 index 0000000..c37c3bf --- /dev/null +++ b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.spec.ts @@ -0,0 +1,33 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { + mostUsedImports, + testUtilStubs, + mostUsedServices, +} from "@shared/test-utils"; +import { GitHubChatsPageComponent } from "./github-chats-page.component"; +import { GitHubAdminService } from "@services/github-admin.service"; + +describe("GitHubChatsPageComponent", () => { + let component: GitHubChatsPageComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [GitHubChatsPageComponent], + imports: [...mostUsedImports], + providers: [...testUtilStubs, ...mostUsedServices, GitHubAdminService], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(GitHubChatsPageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.spec.ts b/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.spec.ts new file mode 100644 index 0000000..305893d --- /dev/null +++ b/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.spec.ts @@ -0,0 +1,33 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { + mostUsedImports, + testUtilStubs, + mostUsedServices, +} from "@shared/test-utils"; +import { GitHubJobsPageComponent } from "./github-jobs-page.component"; +import { GitHubAdminService } from "@services/github-admin.service"; + +describe("GitHubJobsPageComponent", () => { + let component: GitHubJobsPageComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [GitHubJobsPageComponent], + imports: [...mostUsedImports], + providers: [...testUtilStubs, ...mostUsedServices, GitHubAdminService], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(GitHubJobsPageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.spec.ts b/src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.spec.ts new file mode 100644 index 0000000..0a73d1d --- /dev/null +++ b/src/app/modules/admin/components/github/github-profiles-page/github-profiles-page.component.spec.ts @@ -0,0 +1,33 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { + mostUsedImports, + testUtilStubs, + mostUsedServices, +} from "@shared/test-utils"; +import { GitHubProfilesPageComponent } from "./github-profiles-page.component"; +import { GitHubAdminService } from "@services/github-admin.service"; + +describe("GitHubProfilesPageComponent", () => { + let component: GitHubProfilesPageComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [GitHubProfilesPageComponent], + imports: [...mostUsedImports], + providers: [...testUtilStubs, ...mostUsedServices, GitHubAdminService], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(GitHubProfilesPageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/src/app/services/github-admin.service.spec.ts b/src/app/services/github-admin.service.spec.ts new file mode 100644 index 0000000..f48cf5a --- /dev/null +++ b/src/app/services/github-admin.service.spec.ts @@ -0,0 +1,20 @@ +import { TestBed } from "@angular/core/testing"; +import { GitHubAdminService } from "./github-admin.service"; +import { + provideHttpClient, + withInterceptorsFromDi, +} from "@angular/common/http"; + +describe("GitHubAdminService", () => { + beforeEach(() => + TestBed.configureTestingModule({ + imports: [], + providers: [provideHttpClient(withInterceptorsFromDi())], + }), + ); + + it("should be created", () => { + const service = TestBed.inject(GitHubAdminService); + expect(service).toBeTruthy(); + }); +}); \ No newline at end of file From 97f34e41531c15bb0fe9a42a821bdf2363a1f784 Mon Sep 17 00:00:00 2001 From: "maxim.gorbatyuk" Date: Sat, 21 Jun 2025 20:49:44 +0500 Subject: [PATCH 4/6] fixed models --- .../admin-navbar/admin-navbar.component.ts | 20 ++++++++ src/app/models/github.ts | 47 +++++-------------- .../company-admin-page.component.html | 6 +-- .../github-chats-page.component.html | 25 ++++------ .../github-chats-page.component.ts | 2 + .../github-jobs-page.component.html | 43 +++-------------- .../github-jobs-page.component.ts | 36 ++------------ .../github-profiles-page.component.html | 40 +++++----------- .../github-profiles-page.component.ts | 2 +- src/app/services/github-admin.service.ts | 6 +-- 10 files changed, 73 insertions(+), 154 deletions(-) diff --git a/src/app/components/admin-navbar/admin-navbar.component.ts b/src/app/components/admin-navbar/admin-navbar.component.ts index b9af29c..fa5eb76 100644 --- a/src/app/components/admin-navbar/admin-navbar.component.ts +++ b/src/app/components/admin-navbar/admin-navbar.component.ts @@ -123,6 +123,26 @@ export class AdminNavbarComponent { }, ], }, + { + title: "Github bot", + links: [ + { + title: "Запрошенные профили", + url: "/admin/github/profiles", + isExternal: false, + }, + { + title: "Чаты", + url: "/admin/github/chats", + isExternal: false, + }, + { + title: "Джобы", + url: "/admin/github/processing-jobs", + isExternal: false, + }, + ], + }, { title: "Инструменты", links: [ diff --git a/src/app/models/github.ts b/src/app/models/github.ts index 269083c..d2f847c 100644 --- a/src/app/models/github.ts +++ b/src/app/models/github.ts @@ -1,45 +1,24 @@ export interface GitHubProfile { - id: string; - githubId: number; username: string; - avatarUrl: string | null; - profileUrl: string; - name: string | null; - bio: string | null; - location: string | null; - email: string | null; - publicRepos: number; - followers: number; - following: number; - createdAt: string; - updatedAt: string; + version: number; + requestsCount: number; + dataSyncedAt: Date; + createdAt: Date; + updatedAt: Date; } export interface GitHubChat { id: string; chatId: number; - chatName: string | null; - usageCount: number; - githubProfiles: GitHubProfile[]; - createdAt: string; - updatedAt: string; + username: string; + isAdmin: boolean; + messagesCount: number; + createdAt: Date; + updatedAt: Date; } export interface GitHubProcessingJob { - id: string; - jobType: string; - status: GitHubJobStatus; - githubProfileId: string | null; - githubProfile: GitHubProfile | null; - errorMessage: string | null; - processedAt: string | null; - createdAt: string; - updatedAt: string; + username: string; + createdAt: Date; + updatedAt: Date; } - -export enum GitHubJobStatus { - Pending = 0, - Processing = 1, - Completed = 2, - Failed = 3, -} \ No newline at end of file diff --git a/src/app/modules/admin/components/companies/company-admin-page/company-admin-page.component.html b/src/app/modules/admin/components/companies/company-admin-page/company-admin-page.component.html index 0cc43d0..18e2f5b 100644 --- a/src/app/modules/admin/components/companies/company-admin-page/company-admin-page.component.html +++ b/src/app/modules/admin/components/companies/company-admin-page/company-admin-page.component.html @@ -199,18 +199,18 @@
Среднее: {{ - reviewToShow?.totalRating | number: "1.2-2" + reviewToShow.totalRating | number: "1.2-2" }}
Плюсы
-
+
Минусы
-
+
diff --git a/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.html b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.html index 1d39191..1d5f355 100644 --- a/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.html +++ b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.html @@ -1,4 +1,4 @@ -GitHub Telegram Bot Chats +Чаты с Github Bot
@@ -41,25 +41,18 @@ - - - - - + + + + + - - - + + + diff --git a/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.ts b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.ts index 1c1a5c7..af3d782 100644 --- a/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.ts +++ b/src/app/modules/admin/components/github/github-chats-page/github-chats-page.component.ts @@ -5,6 +5,8 @@ import { TitleService } from "@services/title.service"; import { untilDestroyed } from "@shared/subscriptions/until-destroyed"; import { GitHubAdminService } from "@services/github-admin.service"; import { GitHubChat } from "@models/github"; +import { ConfirmMsg } from "@shared/components/dialogs/models/confirm-msg"; +import { DialogMessage } from "@shared/components/dialogs/models/dialog-message"; @Component({ templateUrl: "./github-chats-page.component.html", diff --git a/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.html b/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.html index c5d6ce4..0d491a1 100644 --- a/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.html +++ b/src/app/modules/admin/components/github/github-jobs-page/github-jobs-page.component.html @@ -1,4 +1,4 @@ -GitHub Processing Jobs +GitHub джобы
@@ -19,44 +19,15 @@ >
Chat IDChat NameUsage CountGitHub ProfilesCreatedUpdatedUsernameОбращенийAdmin?СозданоОбновлено
{{ chat.chatId }}{{ chat.chatName || "-" }}{{ chat.usageCount | formatAsMoney }} - - {{ chat.githubProfiles.length }} profile(s) - - - No profiles - - {{ chat.username }}{{ chat.messagesCount | formatAsMoney }}{{ chat.isAdmin }} {{ chat.createdAt | date: "yyyy-MM-dd HH:mm" }} {{ chat.updatedAt | date: "yyyy-MM-dd HH:mm" }}
- - - - - - - - + + + - - - - - - + +
IDJob TypeStatusGitHub ProfileError MessageProcessed AtCreatedActionsUsernameСозданоОбновлено
{{ job.id }}{{ job.jobType }} - - {{ getStatusLabel(job.status) }} - - - - - {{ job.githubProfile.username }} - - - - - - - {{ job.errorMessage.length > 50 ? (job.errorMessage | slice:0:50) + '...' : job.errorMessage }} - - - - - {{ job.processedAt ? (job.processedAt | date: "yyyy-MM-dd HH:mm") : "-" }} - {{ job.username }} {{ job.createdAt | date: "yyyy-MM-dd HH:mm" }}{{ job.updatedAt | date: "yyyy-MM-dd HH:mm" }}