Connect Admin Customization: create button that updates layout timestamp and create new css files

This commit is contained in:
argirok 2022-08-01 17:32:25 +03:00
parent 99c109bf3f
commit 1643eecc48
5 changed files with 116 additions and 1 deletions

@ -1 +1 @@
Subproject commit aaf8c50c684cc3a62f6f1dff739c5e2564c111be Subproject commit dbbb832bff746f73c0bbcc416ee09bdbcd77b9e4

View File

@ -38,6 +38,11 @@ import {RouterModule} from '@angular/router';
path: 'menu', path: 'menu',
loadChildren: () => import('../../openaireLibrary/dashboard/menu/menu.module').then(m => m.MenuModule), loadChildren: () => import('../../openaireLibrary/dashboard/menu/menu.module').then(m => m.MenuModule),
pathMatch: 'full' pathMatch: 'full'
},
{
path: 'customization',
loadChildren: () => import('../connect-admin-customization/connect-admin-customization.module').then(m => m.ConnectAdminCustomizationModule),
pathMatch: 'full'
} }
]) ])
] ]

View File

@ -0,0 +1,15 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {AdminLoginGuard} from "../../openaireLibrary/login/adminLoginGuard.guard";
import {ConnectAdminCustomizationComponent} from "./connect-admin-customization.component";
@NgModule({
imports: [
RouterModule.forChild([
{ path: '',component: ConnectAdminCustomizationComponent}
])
],
providers: [AdminLoginGuard]
})
export class ConnectAdminCustomizationRoutingModule {
}

View File

@ -0,0 +1,76 @@
import {Component, OnInit} from '@angular/core';
import {Subscription} from 'rxjs';
import {LayoutService} from "../../openaireLibrary/services/layout.service";
import {properties} from "../../../environments/environment";
declare var UIkit;
@Component({
selector: 'connect-admin-customization',
template: `
<div page-content>
<div header>
<div class="uk-flex uk-flex-middle uk-margin-top info">
<img src="assets/common-assets/placeholder.png" class="uk-margin-right">
<div>
<div class="uk-margin-remove uk-text-background uk-text-bold uk-h6">Admin Dashboard - Manage Options</div>
<h1 class="uk-h4 uk-margin-remove">Super Admin</h1>
</div>
</div>
<admin-tabs tab="customization" portal="connect"></admin-tabs>
</div>
<div inner>
<div class="uk-alert uk-alert-warning ">
<div class="uk-text-large">Use only after connect deployment. And only if there are css updates!</div>
Press the following button to update the timestamp in the saved layouts and recreate the css files.
</div>
<button (click)="updateCss()" class="uk-button uk-button-danger" [class.uk-disabled]="savingChanges"> Update CSS</button>
</div>
</div>
`
})
export class ConnectAdminCustomizationComponent implements OnInit {
private subscriptions: any[] = [];
savingChanges = false;
constructor( private layoutService: LayoutService,) {
}
ngOnInit() {
// this.sub =this.communityService.getCommunityAsObservable().subscribe(community => {
// this.community = community;
// });
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscription) {
subscription.unsubscribe();
}
});
}
updateCss(){
let date = new Date();
this.savingChanges = true;
this.subscriptions.push(this.layoutService.getLayouts(properties, ).subscribe(layouts => {
for(let layout of layouts){
if(layout.portalPid != 'connect'){
layout.date = date;
this.subscriptions.push(this.layoutService.saveLayout(properties, layout.portalPid, layout, "community").subscribe(data =>{
this.subscriptions.push(this.layoutService.createCSS(layout.portalPid,properties.connectPortalUrl, layout.date.valueOf(), layout.layoutOptions).subscribe(data =>{
UIkit.notification(layout.portalPid +"-"+ layout.date.valueOf() + ".css " + " was created successfully! ", {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
}));
}));
}
}
}));
}
}

View File

@ -0,0 +1,19 @@
import {NgModule} from '@angular/core';
import {RouterModule} from "@angular/router";
import {CommonModule} from "@angular/common";
import {ConnectAdminCustomizationComponent} from "./connect-admin-customization.component";
import {AdminTabsModule} from "../../openaireLibrary/dashboard/sharedComponents/admin-tabs/admin-tabs.module";
import {ConnectAdminCustomizationRoutingModule} from "./connect-admin-customization-routing.module";
import {PageContentModule} from "../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module";
import {LayoutService} from "../../openaireLibrary/services/layout.service";
@NgModule({
imports: [
CommonModule, RouterModule, AdminTabsModule, ConnectAdminCustomizationRoutingModule, PageContentModule
],
providers: [LayoutService],
declarations: [ConnectAdminCustomizationComponent],
exports: [ConnectAdminCustomizationComponent]
})
export class ConnectAdminCustomizationModule {
}