Skip to content
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
11 changes: 1 addition & 10 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,7 @@ export class AppComponent implements OnInit, OnDestroy {
private readonly router: Router
) {}

ngOnInit(): void {
this.authService
.getCurrentUser()
.pipe(untilDestroyed(this))
.subscribe((user) => {
if (user != null) {
this.isAuthenticated = true;
}
});
}
ngOnInit(): void {}

ngOnDestroy(): void {}
}
12 changes: 10 additions & 2 deletions src/app/components/admin-navbar/admin-navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,16 @@ export class AdminNavbarComponent {
title: "Инструменты",
links: [
{
title: "Хз как назвать",
url: "/admin/background-jobs",
title: "Общее",
url: "/admin/tools/background-jobs",
},
{
title: "Курсы валют",
url: "/admin/tools/currencies",
},
{
title: "QR код",
url: "/admin/tools/generate-qr",
},
],
},
Expand Down
29 changes: 7 additions & 22 deletions src/app/components/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,20 @@ export class NavbarComponent implements OnInit, OnDestroy {

constructor(
private readonly authService: AuthService,
private readonly spinner: SpinnerService,
private readonly healthService: HealthCheckService
private readonly spinner: SpinnerService
) {}

ngOnInit(): void {
this.setupSubscribers();
this.authService
.getCurrentUser()
//.pipe(untilDestroyed(this))
.subscribe((currentUser) => {
if (currentUser != null) {
this.currentUser = currentUser;
}
this.loginButtonAvailable = true;

this.authService
.getCurrentUserFromStorage()
.pipe(untilDestroyed(this))
.subscribe((user) => {
this.currentUser = user;
this.renderNavbar();
});

this.healthService
.appHealth()
.pipe(untilDestroyed(this))
.subscribe(
(result) => {
this.loginButtonAvailable = true;
},
(err) => {
console.error(err);
this.healthCheckError = true;
}
);
}

private setupSubscribers(): void {
Expand Down
1 change: 1 addition & 0 deletions src/app/models/application-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface ApplicationUser {
salariesCount: number;
emailConfirmed: boolean;
identityId: number | null;
isMfaEnabled: boolean;
deletedAt: Date | null;
createdAt: Date;
updatedAt: Date;
Expand Down
4 changes: 4 additions & 0 deletions src/app/models/extended/application-user-extended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export class ApplicationUserExtended implements ApplicationUser {
return this.instance.roles;
}

get isMfaEnabled(): boolean {
return this.instance.isMfaEnabled;
}

constructor(public readonly instance: ApplicationUser) {
Assertion.notNull(instance, "instance", ApplicationUserExtended.name);

Expand Down
7 changes: 6 additions & 1 deletion src/app/modules/admin/admin-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { TelegramBotUsagesComponent } from "./components/telegram/telegram-bot-u
import { TelegramUserSettingsComponent } from "./components/telegram/telegram-user-settings/telegram-user-settings.component";
import { SourcedSalariesAdminPageComponent } from "./components/salaries/sourced-salaries-admin-page/sourced-salaries-admin-page.component";
import { StatDataCacheRecordsComponent } from "./components/telegram/stat-data-change-subscriptions/stat-data-cache-records.component";
import { CurrenciesPageComponent } from "./components/currencies-page/currencies-page.component";
import { GenerateQrPageComponent } from "./components/generate-qr-code-page/generate-qr-page.component";

const routes: Routes = [
{ path: "", component: AdminStartPageComponent },
Expand All @@ -21,7 +23,6 @@ const routes: Routes = [
path: "interview-templates",
component: InterviewTemplatesAdminPageComponent,
},
{ path: "background-jobs", component: BackgroundJobsComponent },
{ path: "skills", component: SkillsPaginatedTableComponent },
{ path: "work-industries", component: WorkIndustriesPaginatedTableComponent },
{ path: "professions", component: ProfessionsPaginatedTableComponent },
Expand All @@ -40,6 +41,10 @@ const routes: Routes = [
path: "telegram/stat-data-change-subscriptions",
component: StatDataCacheRecordsComponent,
},

{ path: "tools/background-jobs", component: BackgroundJobsComponent },
{ path: "tools/currencies", component: CurrenciesPageComponent },
{ path: "tools/generate-qr", component: GenerateQrPageComponent },
];

@NgModule({
Expand Down
4 changes: 4 additions & 0 deletions src/app/modules/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { TelegramBotUsagesComponent } from "./components/telegram/telegram-bot-u
import { TelegramUserSettingsComponent } from "./components/telegram/telegram-user-settings/telegram-user-settings.component";
import { SourcedSalariesAdminPageComponent } from "./components/salaries/sourced-salaries-admin-page/sourced-salaries-admin-page.component";
import { StatDataCacheRecordsComponent } from "./components/telegram/stat-data-change-subscriptions/stat-data-cache-records.component";
import { GenerateQrPageComponent } from "./components/generate-qr-code-page/generate-qr-page.component";
import { CurrenciesPageComponent } from "./components/currencies-page/currencies-page.component";

@NgModule({
declarations: [
Expand All @@ -39,6 +41,8 @@ import { StatDataCacheRecordsComponent } from "./components/telegram/stat-data-c
TelegramBotUsagesComponent,
TelegramUserSettingsComponent,
StatDataCacheRecordsComponent,
CurrenciesPageComponent,
GenerateQrPageComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,6 @@
></app-health-check-table>
</div>

<div class="mt-5">
<table class="table table-sm table-hover">
<thead>
<tr>
<th>Валюта</th>
<th>Курс</th>
<th>Дата</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of currencies" class="small">
<td>{{ item.currencyString }}</td>
<td>{{ item.value }} kzt</td>
<td>{{ item.pubDate | date : "yyyy-MM-dd" }}</td>
</tr>
</tbody>
</table>
</div>

<div class="mt-5">
<div class="mb-3 h5">Конфиги</div>
<pre class="small">{{ configs }}</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AuthService } from "@shared/services/auth/auth.service";
import { HealthCheckItem } from "../health-check-table/health-check-item";
import { AdminToolsService } from "@services/admin-tools.service";
import { untilDestroyed } from "@shared/subscriptions/until-destroyed";
import { CurrencyItem } from "./currency-item";

@Component({
selector: "app-background-jobs",
Expand All @@ -16,7 +15,6 @@ export class BackgroundJobsComponent implements OnInit, OnDestroy {
authorizationToken: string | null = null;
configs: string | null = null;
healthCheckItems: Array<HealthCheckItem> = [];
currencies: Array<CurrencyItem> = [];

constructor(
private readonly authService: AuthService,
Expand All @@ -38,13 +36,6 @@ export class BackgroundJobsComponent implements OnInit, OnDestroy {

this.checkHealth();

this.adminToolsService
.getCurrencies()
.pipe(untilDestroyed(this))
.subscribe((currencies) => {
this.currencies = currencies.map((x) => new CurrencyItem(x));
});

this.adminToolsService
.getConfigs()
.pipe(untilDestroyed(this))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<app-page-header>Курсы валюты</app-page-header>

<div class="container my-5">
<div class="card">
<div class="card-body">
<div>
<table class="table table-sm table-hover">
<thead>
<tr>
<th>Валюта</th>
<th>Курс</th>
<th>Дата</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of currencies" class="small">
<td>{{ item.currencyString }}</td>
<td>{{ item.value }} kzt</td>
<td>{{ item.pubDate | date : "yyyy-MM-dd" }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
import {
mostUsedImports,
mostUsedServices,
testUtilStubs,
} from "@shared/test-utils";

import { AdminToolsService } from "@services/admin-tools.service";
import { CurrenciesPageComponent } from "./currencies-page.component";

describe("CurrenciesPageComponent", () => {
let component: CurrenciesPageComponent;
let fixture: ComponentFixture<CurrenciesPageComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [CurrenciesPageComponent],
imports: [...mostUsedImports],
providers: [...testUtilStubs, ...mostUsedServices, AdminToolsService],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(CurrenciesPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it("should create", () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Component, OnDestroy, OnInit } from "@angular/core";
import { TitleService } from "@services/title.service";
import { HealthCheckItem } from "../health-check-table/health-check-item";
import { AdminToolsService } from "@services/admin-tools.service";
import { untilDestroyed } from "@shared/subscriptions/until-destroyed";
import { CurrencyItem } from "./currency-item";

@Component({
templateUrl: "./currencies-page.component.html",
styleUrls: ["./currencies-page.component.scss"],
})
export class CurrenciesPageComponent implements OnInit, OnDestroy {
authorizationToken: string | null = null;
configs: string | null = null;
healthCheckItems: Array<HealthCheckItem> = [];
currencies: Array<CurrencyItem> = [];

constructor(
private readonly titleService: TitleService,
private readonly adminToolsService: AdminToolsService
) {
this.titleService.setTitle("Курсы валют");
}

ngOnInit(): void {
this.adminToolsService
.getCurrencies()
.pipe(untilDestroyed(this))
.subscribe((currencies) => {
this.currencies = currencies.map((x) => new CurrencyItem(x));
});
}

ngOnDestroy(): void {
this.titleService.resetTitle();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<app-page-header>QR код</app-page-header>

<div class="container my-5">
<div class="card">
<div class="card-body">
<div class="mb-3">
<input
type="text"
[(ngModel)]="qrCodeSource"
class="form-control"
placeholder="Enter TOTP code"
/>
</div>
<div class="mb-3">
<button
type="button"
class="btn btn-primary"
(click)="generateQrCode()"
>
Generate QR
</button>
</div>
</div>
</div>

<app-dialog
[show]="shoQrCodeDialog"
(closed)="onQrModalDlgClose()"
[header]="'Сгенерированный QR'"
[additionalCss]="'modal-lg'"
>
<div class="text-center">
<img [src]="generatedQRBase64" alt="QR code" />
</div>
</app-dialog>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
import {
mostUsedImports,
mostUsedServices,
testUtilStubs,
} from "@shared/test-utils";

import { AdminToolsService } from "@services/admin-tools.service";
import { GenerateQrPageComponent } from "./generate-qr-page.component";

describe("GenerateQrPageComponent", () => {
let component: GenerateQrPageComponent;
let fixture: ComponentFixture<GenerateQrPageComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [GenerateQrPageComponent],
imports: [...mostUsedImports],
providers: [...testUtilStubs, ...mostUsedServices, AdminToolsService],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(GenerateQrPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it("should create", () => {
expect(component).toBeTruthy();
});
});
Loading
Loading