diff --git a/src/app/_modules/administration/administration.module.ts b/src/app/_modules/administration/administration.module.ts index 62df16f..edcdc1b 100644 --- a/src/app/_modules/administration/administration.module.ts +++ b/src/app/_modules/administration/administration.module.ts @@ -11,6 +11,7 @@ import {CompaniesModule} from "@app/_modules/companies/companies.module"; import {AdministrateSitePagesComponent} from "@app/_modules/administration/site-pages/administrate-site-pages.component"; import {PagesModule} from "@app/_modules/pages/pages.module"; import {WidjetModule} from "@app/_modules/widjet/widjet.module"; +import {AdministrateLicenceComponent} from "@app/_modules/administration/licence/administrate-licence.component"; type PathMatch = "full" | "prefix" | undefined; const routes = [ @@ -28,12 +29,13 @@ const routes = [ PagesModule, WidjetModule, ], - declarations: [ - AdministrationPageComponent, - AdministrateCompanyComponent, - AdministrateCommitteeComponent, - AdministrateSitePagesComponent - ], + declarations: [ + AdministrationPageComponent, + AdministrateCompanyComponent, + AdministrateCommitteeComponent, + AdministrateSitePagesComponent, + AdministrateLicenceComponent + ], exports: [ RouterModule ] diff --git a/src/app/_modules/administration/licence/administrate-licence.component.html b/src/app/_modules/administration/licence/administrate-licence.component.html new file mode 100644 index 0000000..4bd3946 --- /dev/null +++ b/src/app/_modules/administration/licence/administrate-licence.component.html @@ -0,0 +1,12 @@ + + + + + + + +
Состояние лицензии{{licence?.state?.title || 'Не найдено'}}
Номер лицензии{{number || '-'}}
Продукт{{product?.title || '-'}}
Доменное имя{{licence?.domain || '-'}}
Дата начала действия{{licence?.activeSince | date: 'dd.MM.yyyy'}}
Дата окончания действия{{licence?.activeTill | date: 'dd.MM.yyyy'}}
+ +

Доступные опции

+ +

отсутствуют

diff --git a/src/app/_modules/administration/licence/administrate-licence.component.scss b/src/app/_modules/administration/licence/administrate-licence.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/_modules/administration/licence/administrate-licence.component.ts b/src/app/_modules/administration/licence/administrate-licence.component.ts new file mode 100644 index 0000000..b007234 --- /dev/null +++ b/src/app/_modules/administration/licence/administrate-licence.component.ts @@ -0,0 +1,26 @@ +import {Component} from '@angular/core'; +import {LicenceService} from "@app/_services/licence.service"; + +@Component({ + selector: 'administrate-licence', + templateUrl: 'administrate-licence.component.html', + styleUrls: ['administrate-licence.component.scss'] +}) +export class AdministrateLicenceComponent { + constructor(private licenceService: LicenceService) { + } + + get number() { + return this.licenceService.number; + } + get licence() { + return this.licenceService.licence; + } + get product() { + return this.licence?.product?.data; + } + get options() { + return this.licence?.options?.data; + } + +} diff --git a/src/app/_modules/administration/page/administration-page.component.html b/src/app/_modules/administration/page/administration-page.component.html index 15d3c31..c5f5f1e 100644 --- a/src/app/_modules/administration/page/administration-page.component.html +++ b/src/app/_modules/administration/page/administration-page.component.html @@ -3,14 +3,14 @@

Панель управления

- +
+

Страница не найдена

- \ No newline at end of file diff --git a/src/app/_modules/administration/page/administration-page.component.ts b/src/app/_modules/administration/page/administration-page.component.ts index 1b0ce6a..dd0689d 100644 --- a/src/app/_modules/administration/page/administration-page.component.ts +++ b/src/app/_modules/administration/page/administration-page.component.ts @@ -35,7 +35,7 @@ export class AdministrationPageComponent { makeTabs() { //this.tabs = [{name: 'company', title: 'Структура ФАУ «ФЦС»'}, {name: 'committee', title: 'Структура ТК 465'}]; //if (this.authService.isSuperAdmin) this.tabs.push({name: 'site-pages', title: 'Структура сайта'}); - this.tabs = [{name: 'site-pages', title: 'Структура сайта'}]; + this.tabs = [{name: 'site-pages', title: 'Структура сайта'}, {name: 'licence', title: 'Данные о лицензии'}]; this.switchTab(this.route.snapshot.paramMap.get('tab')); } diff --git a/src/app/_modules/administration/site-pages/administrate-site-pages.component.html b/src/app/_modules/administration/site-pages/administrate-site-pages.component.html index 194e958..e2c7eee 100644 --- a/src/app/_modules/administration/site-pages/administrate-site-pages.component.html +++ b/src/app/_modules/administration/site-pages/administrate-site-pages.component.html @@ -1,8 +1,13 @@ -
+ +
- Показать удаленные - + Показать удаленные + -
- +
+ + + +

Лицензия не активна. Перейдите в раздел Данные о лицензии

+
diff --git a/src/app/_modules/administration/site-pages/administrate-site-pages.component.ts b/src/app/_modules/administration/site-pages/administrate-site-pages.component.ts index 385edb6..22442a7 100644 --- a/src/app/_modules/administration/site-pages/administrate-site-pages.component.ts +++ b/src/app/_modules/administration/site-pages/administrate-site-pages.component.ts @@ -1,6 +1,7 @@ import {Component} from '@angular/core'; import {PagesService} from "@app/_services/pages.service"; import { FormsService } from '@app/_services'; +import {LicenceService} from "@app/_services/licence.service"; @Component({ selector: 'administrate-site-pages', @@ -8,9 +9,17 @@ import { FormsService } from '@app/_services'; styleUrls: ['administrate-site-pages.component.scss'] }) export class AdministrateSitePagesComponent { - constructor(private pagesService: PagesService, private formsService: FormsService) { + constructor(private pagesService: PagesService, private formsService: FormsService, public licenceService: LicenceService) { } + get isLicenceActive() { + return this.licenceService.isActive; + } + get isMultilang() { + return this.isLicenceActive && this.licenceService.hasOption('multilang'); + } + + get showDeleted() { return this.pagesService.showDeleted; } @@ -23,12 +32,8 @@ export class AdministrateSitePagesComponent { } addLocale() { - this.formsService.createModel('localePage', null, 'pages-tree-root'); - this.pagesService.root({include:'children'}).subscribe( - res => { - this.pagesService.rootPages = res - } - ) + if (this.isMultilang) this.formsService.createModel('localePage', null, 'pages-tree-root'); + else alert('Отсутствует необходимая опция'); } toggle() { diff --git a/src/app/_modules/layout/jumbotron/jumbotron.component.html b/src/app/_modules/layout/jumbotron/jumbotron.component.html index 5ba35c1..83b81a7 100644 --- a/src/app/_modules/layout/jumbotron/jumbotron.component.html +++ b/src/app/_modules/layout/jumbotron/jumbotron.component.html @@ -9,7 +9,7 @@
Режим редактирования - -
+ +
- \ No newline at end of file + diff --git a/src/app/_modules/layout/jumbotron/jumbotron.component.ts b/src/app/_modules/layout/jumbotron/jumbotron.component.ts index 2ad5e97..3eab2a1 100644 --- a/src/app/_modules/layout/jumbotron/jumbotron.component.ts +++ b/src/app/_modules/layout/jumbotron/jumbotron.component.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; import { PagesService } from '@app/_services/pages.service'; +import {LicenceService} from "@app/_services/licence.service"; @Component({ selector: 'jumbotron', @@ -9,7 +10,7 @@ import { PagesService } from '@app/_services/pages.service'; export class JumbotronComponent { constructor( - private pagesService: PagesService, + private pagesService: PagesService ){} get currentPage(){ @@ -27,7 +28,7 @@ export class JumbotronComponent { height = 150; pictURL = this.currentPage?.picture?.data.links.open; } - + return { 'background-image' : `url(${pictURL})`||'none', 'height': (pictURL?400:height) + 'px' @@ -38,15 +39,15 @@ export class JumbotronComponent { return { color: this.currentPage?.picture?'var(--white)':'var(--second-act)'} } - get editable(){ + get editable() { return this.currentPage?.permissions?.edit || this.currentPage?.permissions?.anything; } - get editMode(){ + get editMode() { return this.pagesService.editMode; } - toggleEditMode(){ + toggleEditMode() { this.pagesService.editMode = !this.pagesService.editMode; } diff --git a/src/app/_services/authentication.service.ts b/src/app/_services/authentication.service.ts index 7443c36..878ce3e 100644 --- a/src/app/_services/authentication.service.ts +++ b/src/app/_services/authentication.service.ts @@ -6,13 +6,14 @@ import {Router} from "@angular/router"; import {environment} from '@environments/environment'; import {OauthToken, User} from '@app/_models'; import {UsersService} from "@app/_services/users.service"; +import {LicenceService} from "@app/_services/licence.service"; @Injectable({providedIn: 'root'}) export class AuthenticationService { public tokenSubject = new BehaviorSubject(JSON.parse(localStorage.getItem('oauthToken'))); public userSubject = new BehaviorSubject(null); - constructor(private http: HttpClient, private router: Router, private usersService: UsersService) { + constructor(private http: HttpClient, private router: Router, private usersService: UsersService, private licenceService: LicenceService) { } get token(): OauthToken { @@ -77,6 +78,7 @@ export class AuthenticationService { getCurrentUser(params?: any) { if (this.isLoggedIn) this.usersService.me(params).subscribe(res => { this.user = res.data; + this.licenceService.check(); }); } diff --git a/src/app/_services/licence.service.ts b/src/app/_services/licence.service.ts new file mode 100644 index 0000000..7040abd --- /dev/null +++ b/src/app/_services/licence.service.ts @@ -0,0 +1,71 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from '@angular/common/http'; +import {BehaviorSubject, Observable} from "rxjs"; +import {environment} from '@environments/environment'; + +@Injectable({providedIn: 'root'}) +export class LicenceService { + private host = 'https://services.testnir.ru'; + private productName = 'cms'; + public licenceSubject = new BehaviorSubject(null); + + constructor(private http: HttpClient) { + } + + get number() { + return environment.licence; + } + + get licence() { + return this.licenceSubject.value; + } + set licence(value: any) { + this.licenceSubject.next(value); + } + + get product() { + return this.licence?.product?.data; + } + get options() { + return this.licence?.options?.data; + } + + get isActive() { + return this.isActiveState && this.isCorrectProduct; + } + get isActiveState() { + return this.licence?.state?.name === 'active'; + } + get isCorrectProduct() { + return this.product?.name === this.productName; + } + + + public check() { + this.fetch().subscribe(res => { + this.licence = res?.data; + }); + } + + fetch(): Observable { + let include = ['product', 'options']; + return this.http.get(`${this.host}/api/licences/check/${this.number}`, {params: {include: include.join(',')}}); + } + + + public hasOption(name: string): boolean { + return !!this.options?.filter(item => {return item.name === name}).length; + } + + public checkEditAvailability(page?: any) { + if (!this.isActive) return this.error('Licence not active'); + if ((page?.type?.name === 'registry') && !this.hasOption('registries')) return this.error('Registries option required'); + if ((page?.type?.name === 'publications') && !this.hasOption('publications')) return this.error('Publications option required'); + return null; + } + + public error(msg: string) { + return msg; + } + +} diff --git a/src/app/_services/pages.service.ts b/src/app/_services/pages.service.ts index 83fa4ca..3aa9e49 100644 --- a/src/app/_services/pages.service.ts +++ b/src/app/_services/pages.service.ts @@ -2,6 +2,7 @@ import {Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {environment} from '@environments/environment'; import {Observable, BehaviorSubject} from "rxjs"; +import {LicenceService} from "@app/_services/licence.service"; @Injectable({providedIn: 'root'}) @@ -13,13 +14,11 @@ export class PagesService { public showDeletedSubject = new BehaviorSubject(false); public menuSelectedLink: string; - constructor(private http: HttpClient) { + public rootPage = {link:'', slug:environment.defaultLocale}; + + constructor(private http: HttpClient, private licenceService: LicenceService) { //this.find('/').subscribe(res => {this.rootPages = res.data}); } - rootPage={ - link:'', - slug:environment.defaultLocale - } get currentPage() { return this.currentPageSubject.value; @@ -40,6 +39,13 @@ export class PagesService { return this.editModeSubject.value; } set editMode(value: boolean) { + if (value) { + let error = this.licenceService.checkEditAvailability(this.currentPage); + if (error) { + alert(error); + return; + } + } this.editModeSubject.next(value); } diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 0768f24..3a37c74 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -4,5 +4,6 @@ export const environment = { clientId: 2, clientSecret: 'uMYJ7jTYfSKst631D9gKlSwlNF0bWlcrR1d5mTKX', project: null, + licence: '', defaultLocale: 'ru' }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 7fb86bf..8974e20 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -8,6 +8,7 @@ export const environment = { clientId: 2, clientSecret: 'gVk3jjKq6rWWM52025xgXlw2XGW1UACowyMIyhRR', project: null, + licence: 'POUFLO4YW7SU', defaultLocale: 'ru' }; diff --git a/src/environments/vniigaz-v2.env.dev.ts b/src/environments/vniigaz-v2.env.dev.ts index 3da4e0e..4f6277e 100644 --- a/src/environments/vniigaz-v2.env.dev.ts +++ b/src/environments/vniigaz-v2.env.dev.ts @@ -8,6 +8,7 @@ export const environment = { clientId: 2, clientSecret: 'v49Z7dwUb1cobcTIJ5JQVJBzOFcNyJMzMmiDspUm', project: 'vniigaz-v2', + licence: 'POUFLO4YW7SU', defaultLocale: 'ru' }; diff --git a/src/environments/vniigaz-v2.env.prod.ts b/src/environments/vniigaz-v2.env.prod.ts index 3772ded..80400fc 100644 --- a/src/environments/vniigaz-v2.env.prod.ts +++ b/src/environments/vniigaz-v2.env.prod.ts @@ -8,6 +8,7 @@ export const environment = { clientId: 2, clientSecret: 'hqhpnNTBrvqiv4o85ZNCewOO8n3Y2i9iaRYGfMnt', project: null, + licence: '', defaultLocale: 'ru' };