From a4b9c849318da4d3a41145c511785fc81c6e8c7d Mon Sep 17 00:00:00 2001 From: amirch1 Date: Thu, 10 Nov 2022 10:50:51 +0200 Subject: [PATCH] fix(studio): support studio v7 FEV-1579 --- .../src/permissions_uiconf.xml | 4 ++ .../studio-app/studio-app.module.ts | 4 +- .../studio-app/studio-app.routes.ts | 4 +- .../studio-app/studio-v7.component.html | 4 ++ .../studio-app/studio-v7.component.scss | 10 ++++ .../studio-app/studio-v7.component.ts | 45 +++++++++++++++ src/configuration/server-config.ts | 25 +++++++++ src/i18n/en.json | 2 + .../kmc-permissions/kmc-permissions.ts | 3 +- .../kmc-views/kmc-main-views.service.ts | 10 ++++ .../kmc-shared/kmc-views/kmc-views.module.ts | 2 + .../kmc-shared/kmc-views/main-views/index.ts | 1 + .../main-views/studio-v7-main-view.service.ts | 56 +++++++++++++++++++ 13 files changed, 167 insertions(+), 3 deletions(-) create mode 100644 src/applications/studio-app/studio-v7.component.html create mode 100644 src/applications/studio-app/studio-v7.component.scss create mode 100644 src/applications/studio-app/studio-v7.component.ts create mode 100644 src/shared/kmc-shared/kmc-views/main-views/studio-v7-main-view.service.ts diff --git a/dev/tools/legacy_permissions/src/permissions_uiconf.xml b/dev/tools/legacy_permissions/src/permissions_uiconf.xml index 7214f70dee..eca6ea8b0e 100644 --- a/dev/tools/legacy_permissions/src/permissions_uiconf.xml +++ b/dev/tools/legacy_permissions/src/permissions_uiconf.xml @@ -590,6 +590,10 @@ + + + + diff --git a/src/applications/studio-app/studio-app.module.ts b/src/applications/studio-app/studio-app.module.ts index 5bcc14764f..a8b71e3560 100644 --- a/src/applications/studio-app/studio-app.module.ts +++ b/src/applications/studio-app/studio-app.module.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { StudioV2Component } from './studio-v2.component'; import { StudioV3Component } from './studio-v3.component'; +import { StudioV7Component } from './studio-v7.component'; import { KalturaUIModule } from '@kaltura-ng/kaltura-ui'; import { routing } from './studio-app.routes'; import { RouterModule } from '@angular/router'; @@ -14,7 +15,8 @@ import { RouterModule } from '@angular/router'; ], declarations: [ StudioV2Component, - StudioV3Component + StudioV3Component, + StudioV7Component ], exports: [], providers: [], diff --git a/src/applications/studio-app/studio-app.routes.ts b/src/applications/studio-app/studio-app.routes.ts index 5266a81ff3..78256c3a97 100644 --- a/src/applications/studio-app/studio-app.routes.ts +++ b/src/applications/studio-app/studio-app.routes.ts @@ -2,9 +2,11 @@ import { Route } from '@angular/router'; import { StudioV2Component } from './studio-v2.component'; import { StudioV3Component } from './studio-v3.component'; +import { StudioV7Component } from './studio-v7.component'; export const routing: Route[] = [ { path: 'v2', component: StudioV2Component }, - { path: 'v3', component: StudioV3Component } + { path: 'v3', component: StudioV3Component }, + { path: 'v7', component: StudioV7Component } ]; diff --git a/src/applications/studio-app/studio-v7.component.html b/src/applications/studio-app/studio-v7.component.html new file mode 100644 index 0000000000..b3847b2191 --- /dev/null +++ b/src/applications/studio-app/studio-v7.component.html @@ -0,0 +1,4 @@ +
+ +
+ diff --git a/src/applications/studio-app/studio-v7.component.scss b/src/applications/studio-app/studio-v7.component.scss new file mode 100644 index 0000000000..9594d61b8b --- /dev/null +++ b/src/applications/studio-app/studio-v7.component.scss @@ -0,0 +1,10 @@ +@import "app-theme/_variables.scss"; + +.kStudio{ + height: $contentArea; + iframe{ + width: 100%; + height: 900px; + } +} + diff --git a/src/applications/studio-app/studio-v7.component.ts b/src/applications/studio-app/studio-v7.component.ts new file mode 100644 index 0000000000..3ccd9d7c47 --- /dev/null +++ b/src/applications/studio-app/studio-v7.component.ts @@ -0,0 +1,45 @@ +import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; +import { AppAuthentication, BrowserService } from 'app-shared/kmc-shell'; +import { AppEventsService } from 'app-shared/kmc-shared'; +import { serverConfig } from 'config/server'; +import { KalturaLogger } from '@kaltura-ng/kaltura-logger'; +import { PlayersUpdatedEvent } from 'app-shared/kmc-shared/events'; +import { KMCPermissionsService } from 'app-shared/kmc-shared/kmc-permissions'; +import { StudioV7MainViewService } from 'app-shared/kmc-shared/kmc-views'; + +@Component({ + selector: 'kStudioV7', + templateUrl: './studio-v7.component.html', + styleUrls: ['./studio-v7.component.scss'] +}) +export class StudioV7Component implements OnInit, OnDestroy { + + public studioUrl = ''; + + constructor( + private _appEvents: AppEventsService, private logger: KalturaLogger, + private _studioV7MainView: StudioV7MainViewService) { + } + + ngOnInit() { + if (this._studioV7MainView.viewEntered()) { + window['kmc'] = { + 'preview_embed': { + 'updateList': (isPlaylist: boolean) => { + this._updatePlayers(isPlaylist); + } + } + }; + this.studioUrl = serverConfig.externalApps.studioV7.uri; + } + } + + _updatePlayers(isPlaylist): void { + this._appEvents.publish(new PlayersUpdatedEvent(isPlaylist)); + } + + ngOnDestroy() { + this.studioUrl = ''; + window['kmc'] = null; + } +} diff --git a/src/configuration/server-config.ts b/src/configuration/server-config.ts index 8ab83a0905..8aead2fd6e 100644 --- a/src/configuration/server-config.ts +++ b/src/configuration/server-config.ts @@ -28,6 +28,15 @@ export interface ExternalApplications { playerBetaVersionsMap?: string, playerBetaConfVars?: string }; + studioV7?: { + uri: string, + html5_version: string, + html5lib: string, + playerVersionsMap?: string, + playerConfVars?: string, + playerBetaVersionsMap?: string, + playerBetaConfVars?: string + }; liveDashboard?: { uri: string, }; @@ -173,6 +182,22 @@ export const externalAppsConfigurationAdapter: ExternalAppsAdapter { + let result = false; + + if (configuration) { + result = !!configuration.uri && + !configuration.uri.match(/\s/g) && // not contains white spaces + !!configuration.html5_version && + !!configuration.html5lib; + + if (result) { + configuration.uri = buildBaseUri(configuration.uri); + } + } + + return result; + }, liveDashboard: (configuration) => { let result = false; diff --git a/src/i18n/en.json b/src/i18n/en.json index 08f8b64cd7..6cd979c886 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -49,6 +49,8 @@ "studioV2MenuTitle": "Universal Studio", "studioV3PageTitle": "Studio > TV Platform Studio", "studio3MenuTitle": "TV Platform Studio", + "studioV7PageTitle": "Studio > Studio V7", + "studio7MenuTitle": "Studio V7", "usageDashboardPageTitle": "Usage Dashboard", "usageDashboardMenuTitle": "Usage Dashboard", "restorePasswordPageTitle": "Reset Password", diff --git a/src/shared/kmc-shared/kmc-permissions/kmc-permissions.ts b/src/shared/kmc-shared/kmc-permissions/kmc-permissions.ts index 9337f15d87..1b5f44de7a 100644 --- a/src/shared/kmc-shared/kmc-permissions/kmc-permissions.ts +++ b/src/shared/kmc-shared/kmc-permissions/kmc-permissions.ts @@ -144,5 +144,6 @@ export enum KMCPermissions { 'APP_TOKEN_BASE' = 1134, 'APP_TOKEN_ADD' = 1135, 'APP_TOKEN_UPDATE' = 1136, - 'APP_TOKEN_DELETE' = 1137 + 'APP_TOKEN_DELETE' = 1137, + 'FEATURE_V7_STUDIO_PERMISSION' = 1138, } diff --git a/src/shared/kmc-shared/kmc-views/kmc-main-views.service.ts b/src/shared/kmc-shared/kmc-views/kmc-main-views.service.ts index 7cebf85cbb..89ecf08c0b 100644 --- a/src/shared/kmc-shared/kmc-views/kmc-main-views.service.ts +++ b/src/shared/kmc-shared/kmc-views/kmc-main-views.service.ts @@ -10,6 +10,7 @@ import { ContentUploadsMainViewService, ContentBulkUploadsMainViewService, ContentDropFoldersMainViewService, + StudioV7MainViewService, StudioV3MainViewService, StudioV2MainViewService, UsageDashboardMainViewService, @@ -63,6 +64,7 @@ export class KmcMainViewsService { private _contentDropFoldersMain: ContentDropFoldersMainViewService, private _studioV2Main: StudioV2MainViewService, private _studioV3Main: StudioV3MainViewService, + private _studioV7Main: StudioV7MainViewService, private _servicesDashboardMain: ServicesDashboardMainViewService, private _analyticsMainViewService: AnalyticsMainViewService, private _analyticsNewMainViewService: AnalyticsNewMainViewService, @@ -187,6 +189,14 @@ export class KmcMainViewsService { }, menuTitle: this._studioV3Main.getViewMetadata().menu }, + { + isAvailable: this._studioV7Main.isAvailable(), + isActiveView: (path) => this._studioV7Main.isActiveView(path), + open: () => { + this._studioV7Main.open(); + }, + menuTitle: this._studioV7Main.getViewMetadata().menu + } ] }, { diff --git a/src/shared/kmc-shared/kmc-views/kmc-views.module.ts b/src/shared/kmc-shared/kmc-views/kmc-views.module.ts index f189864c75..45ed4db93f 100644 --- a/src/shared/kmc-shared/kmc-views/kmc-views.module.ts +++ b/src/shared/kmc-shared/kmc-views/kmc-views.module.ts @@ -22,6 +22,7 @@ import { SettingsTranscodingMainViewService, StudioV2MainViewService, StudioV3MainViewService, + StudioV7MainViewService, UsageDashboardMainViewService, KavaAppMainViewService, AnalyticsNewMainViewService, @@ -72,6 +73,7 @@ export class KmcViewsModule { ContentCategoryViewService, StudioV2MainViewService, StudioV3MainViewService, + StudioV7MainViewService, AnalyticsMainViewService, UsageDashboardMainViewService, LiveAnalyticsMainViewService, diff --git a/src/shared/kmc-shared/kmc-views/main-views/index.ts b/src/shared/kmc-shared/kmc-views/main-views/index.ts index b1a130864b..b39da17331 100644 --- a/src/shared/kmc-shared/kmc-views/main-views/index.ts +++ b/src/shared/kmc-shared/kmc-views/main-views/index.ts @@ -8,6 +8,7 @@ export * from './content-bulk-uploads-main-view.service'; export * from './content-drop-folders-main-view.service'; export * from './studio-v2-main-view.service'; export * from './studio-v3-main-view.service'; +export * from './studio-v7-main-view.service'; export * from './usage-dashboard-main-view.service'; export * from './live-analytics-main-view.service'; export * from './admin-users-main-view.service'; diff --git a/src/shared/kmc-shared/kmc-views/main-views/studio-v7-main-view.service.ts b/src/shared/kmc-shared/kmc-views/main-views/studio-v7-main-view.service.ts new file mode 100644 index 0000000000..bdcf1370ac --- /dev/null +++ b/src/shared/kmc-shared/kmc-views/main-views/studio-v7-main-view.service.ts @@ -0,0 +1,56 @@ +import { Injectable } from '@angular/core'; +import { KMCPermissions, KMCPermissionsService } from '../../kmc-permissions'; +import { KalturaLogger } from '@kaltura-ng/kaltura-logger'; +import { KmcMainViewBaseService, ViewMetadata } from '../kmc-main-view-base.service'; +import { Router } from '@angular/router'; +import { serverConfig } from 'config/server'; +import { BrowserService } from 'app-shared/kmc-shell/providers/browser.service'; +import { AppLocalization } from '@kaltura-ng/mc-shared'; +import { Title } from '@angular/platform-browser'; +import { ContextualHelpService } from 'app-shared/kmc-shared/contextual-help/contextual-help.service'; + +@Injectable() +export class StudioV7MainViewService extends KmcMainViewBaseService { + + + constructor(logger: KalturaLogger, + browserService: BrowserService, + router: Router, + private _appPermissions: KMCPermissionsService, + private _appLocalization: AppLocalization, + titleService: Title, + contextualHelpService: ContextualHelpService) { + super(logger.subLogger('StudioV7MainViewService'), browserService, router, titleService, contextualHelpService); + } + + isAvailable(): boolean { + const isViewPermitted = this._appPermissions.hasAnyPermissions([ + KMCPermissions.STUDIO_BASE, + KMCPermissions.STUDIO_ADD_UICONF, + KMCPermissions.STUDIO_UPDATE_UICONF, + KMCPermissions.STUDIO_DELETE_UICONF, + KMCPermissions.STUDIO_DELETE_UICONF, + ]); + const studioHtmlIsAvailable = !!serverConfig.externalApps.studioV7; + const studioHtmlIsPermitted = this._appPermissions.hasPermission(KMCPermissions.FEATURE_V7_STUDIO_PERMISSION); + + this._logger.info(`handle isAvailable action by user`, + { isViewPermitted, studioHtmlIsAvailable, studioHtmlIsPermitted }); + + return isViewPermitted && studioHtmlIsAvailable && studioHtmlIsPermitted; + } + + getRoutePath(): string { + return 'studio/v7'; + } + + getViewMetadata(): ViewMetadata { + return { + viewKey: 'studio-v7', + title: this._appLocalization.get('app.titles.studioV7PageTitle'), + menu: this._appLocalization.get('app.titles.studio7MenuTitle') + }; + } +} + +