diff --git a/angular.json b/angular.json index c84184d..cd63dce 100644 --- a/angular.json +++ b/angular.json @@ -21,11 +21,11 @@ "src/robots.txt" ], "styles": [ - "src/styles.css", "src/material.scss", "node_modules/datatables.net-dt/css/jquery.dataTables.css", "node_modules/interactiveminingv3/assets/css/interactive-mining.css", - "node_modules/interactiveminingv3/assets/css/animations.css" + "node_modules/interactiveminingv3/assets/css/animations.css", + "src/styles.css" ], "scripts": [ "node_modules/jquery/dist/jquery.js", diff --git a/interactivemining-clean-install.sh b/interactivemining-install.sh similarity index 100% rename from interactivemining-clean-install.sh rename to interactivemining-install.sh diff --git a/interactivemining.sh b/interactivemining.sh deleted file mode 100755 index ee46e9b..0000000 --- a/interactivemining.sh +++ /dev/null @@ -1 +0,0 @@ -npm install --no-save ./interactiveminingv3.tgz diff --git a/interactiveminingv3.tgz b/interactiveminingv3.tgz index abff5cf..735160c 100644 Binary files a/interactiveminingv3.tgz and b/interactiveminingv3.tgz differ diff --git a/package.json b/package.json index 4a4fe3d..4b2e319 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,15 @@ "license": "MIT", "scripts": { "ng": "ng", + "clean-install": "rm -rf node_modules; npm install; npm run mining", + "mining": "./interactivemining-install.sh", "start": "ng serve --host 0.0.0.0 --disable-host-check --port=5000", "build": "ng build --prod; npm run after-build-clean", "build-beta": "ng build --configuration=beta; npm run after-build-clean", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", - "after-build-clean": "rm -rf dist/assets/common-assets/.svn/ dist/assets/connect-assets/.svn/" + "after-build-clean": "rm -rf dist/assets/common-assets/.svn/ dist/assets/connect-assets/.svn/ dist/assets/dashboard-theme/.svn/" }, "private": true, "dependencies": { diff --git a/src/app/app.component.css b/src/app/app.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/app.component.html b/src/app/app.component.html index ab20cf3..3bf4cff 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,30 +1,15 @@ - - -
-
- -
- - +
+ +
+
+
- - diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts deleted file mode 100644 index 9510495..0000000 --- a/src/app/app.component.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; - -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app).toBeTruthy(); - })); - - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('app'); - })); - - it('should render title in a h1 tag', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 0ce62da..29354be 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,414 +1,226 @@ -/** - * Created by stefania on 3/21/16. - */ - -import {Component, OnInit} from '@angular/core'; -import {MenuItem, RootMenuItem, SideMenuItem} from './openaireLibrary/sharedComponents/menu'; -import {ActivatedRoute, NavigationStart, Router} from '@angular/router'; -import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service'; -import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service'; +import {ChangeDetectorRef, Component, HostListener, OnInit} from '@angular/core'; +import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu'; +import {ActivatedRoute, NavigationEnd, Params, Router} from '@angular/router'; import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; import {Session, User} from './openaireLibrary/login/utils/helper.class'; -import {HelperFunctions} from './openaireLibrary/utils/HelperFunctions.class'; import {UserManagementService} from './openaireLibrary/services/user-management.service'; -import {ConnectHelper} from "./openaireLibrary/connect/connectHelper"; import {Header} from './openaireLibrary/sharedComponents/navigationBar.component'; - -declare var UIkit: any; +import {LayoutService} from "./openaireLibrary/dashboard/sharedComponents/sidebar/layout.service"; +import {properties} from "../environments/environment"; +import {BehaviorSubject, Subscriber} from "rxjs"; +import {CommunityInfo} from "./openaireLibrary/connect/community/communityInfo"; +import {CommunityService} from "./openaireLibrary/connect/community/community.service"; +import {arrow_left} from "./openaireLibrary/utils/icons/icons"; +import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll"; @Component({ - selector: 'app', + selector: 'app-root', templateUrl: './app.component.html', }) - export class AppComponent implements OnInit { - title = 'Metadata Registry Service'; - userMenuItems: MenuItem[] = []; - - menuItems: RootMenuItem [] = []; - sideMenuItems: SideMenuItem[] = []; - logInUrl = null; - logOutUrl = null; - community: { id: string, name: string, logoUrl: string } = null; - communityId = ''; - communityType = null; - properties: EnvProperties = null; - isPortalAdministrator = false; - showSidebar: boolean; - wellcome = false; - showMenu: boolean = false; + title = 'Research Community Dashboard | Administrator'; + properties: EnvProperties = properties; user: User; - logoPath: string = 'assets/common-assets/'; - header: Header; - + params: BehaviorSubject = new BehaviorSubject(null); + hasSidebar: boolean = false; + hasHeader: boolean = false; + hasAdminMenu: boolean = false; + isFrontPage: boolean = false; + isDashboard: boolean = false; + sideBarItems: MenuItem[] = []; + specialSideBarMenuItem: MenuItem = null; + menuItems: RootMenuItem[] = []; + menuHeader: Header = { + route: "/", + url: null, + title: "Default menu header", + logoUrl: null, + logoSmallUrl: null, + position: 'center', + badge: false, + stickyAnimation: false + }; + userMenuItems: MenuItem[] = []; + loading: boolean = true; + paramsResolved: boolean = false; + innerWidth; + public community: CommunityInfo = null; + private subscriptions: any[] = []; + headerLogoUrl: string; + headerUrl: string; + constructor(private route: ActivatedRoute, - private propertiesService: EnvironmentSpecificService, - private _communitiesService: CommunitiesService, - public router: Router, + private communityService: CommunityService, + private router: Router, + private cdr: ChangeDetectorRef, + private smoothScroll: SmoothScroll, + private layoutService: LayoutService, private userManagementService: UserManagementService) { - this.router.events.forEach((event) => { - if (event instanceof NavigationStart) { - HelperFunctions.scroll(); - this.wellcome = event.url === '/'; + this.subscriptions.push(this.router.events.subscribe(event => { + if (event instanceof NavigationEnd) { + let r = this.route; + let params = r.snapshot.params; + while (r.firstChild && !params['community']) { + r = r.firstChild; + params = r.snapshot.params + } + this.paramsResolved = true; + this.params.next(params); + } + })); + } + + ngOnInit() { + if (typeof document !== 'undefined' && window) { + this.innerWidth = window.innerWidth; + } + this.subscriptions.push(this.layoutService.hasSidebar.subscribe(hasSidebar => { + this.hasSidebar = hasSidebar; + this.cdr.detectChanges(); + })); + this.subscriptions.push(this.layoutService.hasHeader.subscribe(hasHeader => { + this.hasHeader = hasHeader; + this.cdr.detectChanges(); + })); + this.subscriptions.push(this.layoutService.hasAdminMenu.subscribe(hasAdminMenu => { + this.hasAdminMenu = hasAdminMenu; + this.cdr.detectChanges(); + })); + this.subscriptions.push(this.layoutService.isFrontPage.subscribe(isFrontPage => { + this.isFrontPage = isFrontPage; + this.cdr.detectChanges(); + })); + this.subscriptions.push(this.layoutService.isDashboard.subscribe(isDashboard => { + this.isDashboard = isDashboard; + this.cdr.detectChanges(); + })); + this.layoutService.setSmallScreen((this.innerWidth && this.innerWidth < 1219)); + this.layoutService.setOpen(!(this.innerWidth && this.innerWidth < 1219)); + this.subscriptions.push(this.params.subscribe(params => { + if (this.paramsResolved) { + this.loading = true; + if (params && params['community']) { + if (!this.community || this.community.communityId !== params['community']) { + this.subscriptions.push(this.communityService.getCommunity(params['community']).subscribe(community => { + if (community) { + this.community = community; + this.buildMenu(); + this.loading = false; + } else { + this.community = null; + this.buildMenu(); + this.loading = false; + } + })); + } else { + this.buildMenu(); + this.loading = false; + } + } else { + this.communityService.setCommunity(null); + this.layoutService.setOpen(!(this.innerWidth && this.innerWidth < 1219)); + this.community = null; + this.buildMenu(); + this.loading = false; + } + } + })); + this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { + this.user = user; + if (this.user) { + localStorage.setItem('user_id', this.user.id); + localStorage.setItem('mining_backend_address', this.properties.miningBackendURL); + localStorage.setItem('isCommunityManager', Session.isCommunityCurator(this.user) + ''); + this.buildMenu(); + } + })); + } + + @HostListener('window:resize', ['$event']) + onResize(event) { + if (this.layoutService.isSmallScreen && event.target.innerWidth > 1219) { + this.layoutService.setSmallScreen(false); + } else if (!this.layoutService.isSmallScreen && event.target.innerWidth < 1219) { + this.layoutService.setSmallScreen(true); + this.layoutService.setOpen(false); + } + } + + public ngOnDestroy() { + this.subscriptions.forEach(value => { + if (value instanceof Subscriber) { + value.unsubscribe(); } }); + this.communityService.clearSubscriptions(); + this.userManagementService.clearSubscriptions(); + this.layoutService.clearSubscriptions(); + this.smoothScroll.clearSubscriptions(); } - - ngOnInit() { - this.propertiesService.loadEnvironment() - .then(es => { - this.propertiesService.setEnvProperties(es); - this.properties = this.propertiesService.envSpecific; - this.logInUrl = this.properties.loginUrl; - this.logOutUrl = this.properties.logoutUrl; - this.showSidebar = false; - this.showMenu = false; - this.userManagementService.getUserInfo().subscribe(user => { - this.user = user; - if (this.user) { - localStorage.setItem('user_id', this.user.id); - localStorage.setItem('mining_backend_address', this.properties.miningBackendURL); - localStorage.setItem('isCommunityManager', Session.isCommunityCurator(this.user) + ''); - - this.isPortalAdministrator = Session.isPortalAdministrator(this.user); - } - this._communitiesService.updateCommunities(this.properties, this.properties.communityAPI + 'communities'); - this.route.queryParams.subscribe(params => { - this.communityId = (params['communityId']) ? params['communityId'] : ''; - ConnectHelper.setPortalTypeFromPid(this.communityId); - - this.communityType = null; - this.menuItems = []; - this.userMenuItems = []; - this._communitiesService.getCommunitiesState().subscribe( - communities => { - // this.community = community; - if (!communities || communities.length === 0) { - return; - } - this.userMenuItems = []; - let countCommunities = 0; - let index_managerOfCommunity = null; - for (let i = 0; i < communities.length; i++) { - const com = communities[i]; - if (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user)) { - this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId})); - } else { - for (const manager of com.managers) { - if (this.user && manager == this.user.email) { - countCommunities++; - index_managerOfCommunity = i; - this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId})); - break; - } - } - } - if (com.communityId === this.communityId) { - this.community = { - id: com.communityId, - name: (com.shortTitle) ? com.shortTitle : com.title, - logoUrl: com.logoUrl - }; - this.header = { - url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu', - title: this.community.name, - logoUrl: this.community.logoUrl, - logoSmallUrl: this.community.logoUrl, - position: 'left', - badge: true - }; - this.communityType = com.type; - this.menuItems = [ - { - rootItem: new MenuItem('dashboard', 'Overview', '/dashboard', '/dashboard', false, [], null, {communityId: com.communityId}), - items: [] - } - ]; - } else if (countCommunities === 1 && index_managerOfCommunity != null) { - this.community = { - id: communities[index_managerOfCommunity].communityId, - name: (communities[index_managerOfCommunity].shortTitle) ? communities[index_managerOfCommunity].shortTitle : com.title, - logoUrl: communities[index_managerOfCommunity].logoUrl - }; - this.header = { - url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu', - title: this.community.name, - logoUrl: this.community.logoUrl, - logoSmallUrl: this.community.logoUrl, - position: 'left', - badge: true - }; - this.menuItems = [ - { - rootItem: new MenuItem('dashboard', 'Overview', '/dashboard', '/dashboard', false, [], null, {communityId: communities[index_managerOfCommunity].communityId}), - items: [] - } - ]; - } - } - if (!this.communityId || this.communityId === '') { - this.header = { - route: "/", - url: null, - title: 'connect-admin', - logoUrl: this.logoPath + 'logo-large-connect.png', - logoSmallUrl:this.logoPath + 'logo-small-connect.png', - position:'left', - badge:true - }; - this.community = null; - } - if (this.communityId) { - this.userMenuItems.push(new MenuItem('manage-user-notifications', 'Manage notification settings', '', '/manage-user-notifications', false, [], [], {communityId: this.communityId})); - this.userMenuItems.push(new MenuItem('personal', 'Manage Personal Info', '', '/personal', false, [], [], {communityId: this.communityId})); - this.userMenuItems.push(new MenuItem('', 'Support', 'https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611', '', false, [], [], {})); - } - this.showMenu = true; - this.buildSideBar(); - }, - error => { - if ((this.communityId && this.communityId !== '') || window.location.pathname === '/') { - UIkit.notification({ - message: 'System error retrieving communities.', - status: 'warning', - timeout: 3000, - pos: 'top-center' - }); - } - } - ); - }); - }); - }); + + public get open() { + return this.layoutService.open; } - - private buildSideBar() { - this.sideMenuItems = []; - this.showSidebar = false; - if ((!this.communityId || this.communityId == '') && this.isPortalAdministrator) { - const adminTools: SideMenuItem = { - rootItem: new MenuItem('adminTools', 'Admin Tools', '', - '', false, [], [], null), - items: [], - ukIcon: 'desktop' - }; - adminTools.items.push({ - rootItem: new MenuItem('communities', 'Communities', '/communities', - '/communities', false, [], [], null), - items: [] - } - ); - adminTools.items.push({ - rootItem: new MenuItem('classes', 'Classes', '/classes', - '/classes', false, [], [], null), - items: [] - } - ); - adminTools.items.push({ - rootItem: new MenuItem('pages', 'Pages', '/pages', - '/pages', false, [], [], null), - items: [] - } - ); - adminTools.items.push({ - rootItem: new MenuItem('entities', 'Entities', '/entities', - '/entities', false, [], [], null), - items: [] - } - ); - this.sideMenuItems.push(adminTools); - this.sideMenuItems.push({ - rootItem: new MenuItem('communities', 'Manage Communities', '/', - '/', false, [], [], null), - items: [], - ukIcon: 'cog' - }); - this.sideMenuItems.push({ - rootItem: new MenuItem('communities', 'Explore', '', - '/dashboard', false, [], [], {communityId: 'openaire'}), - items: [], - ukIcon: 'cog' - }); - this.sideMenuItems.push({ - rootItem: new MenuItem('communities', 'Connect', '', - '/dashboard', false, [], [], {communityId: 'connect'}), - items: [], - ukIcon: 'cog' - }); - } else if (this.communityId && this.communityId !== '') { - this.sideMenuItems.push({ - rootItem: new MenuItem('overview', 'Overview', '/dashboard', - '/dashboard', false, [], [], {communityId: this.communityId}), - items: [], - ukIcon: 'home' - }); - if (this.isPortalAdministrator) { - const adminTools: SideMenuItem = { - rootItem: new MenuItem('adminTools', 'Admin Tools', '/communities', - '/communities', false, [], [], null), - items: [], - ukIcon: 'desktop' - }; - this.sideMenuItems.push(adminTools); + + private buildMenu() { + this.menuItems = []; + this.userMenuItems = []; + this.sideBarItems = []; + if (this.user) { + if (this.isCurator()) { + this.userMenuItems.push(new MenuItem("", "Manage communities", + "", "/", false, [], [], {})); } - if (this.communityId !== 'openaire' && this.communityId !== 'connect') { - const community: SideMenuItem = { - rootItem: new MenuItem('community', 'Community', '', - '', false, [], [], null), - items: [], - ukIcon: 'album' - }; - community.items.push({ - rootItem: new MenuItem('communityProfile', 'Community Profile', '/community-edit-form', - '/community-edit-form', false, [], [], {communityId: this.communityId}), - items: [] - }); - community.items.push({ - rootItem: new MenuItem('communityAffiliations', 'Organizations', '/organizations', - '/organizations', false, [], [], {communityId: this.communityId}), - items: [] - }); - /*community.items.push({ - rootItem: new MenuItem('layout', 'Customize Layout', '/customize-layout', - '/customize-layout', false, [], [], {communityId: this.communityId}), - items: [] - });*/ - this.sideMenuItems.push(community); - const communityContent: SideMenuItem = { - rootItem: new MenuItem('communityContent', 'Community Content', '', - '', false, [], [], null), - items: [], - ukIcon: 'list' - }; - communityContent.items.push({ - rootItem: new MenuItem('projects', 'Projects', '/manage-projects', - '/manage-projects', false, [], [], {communityId: this.communityId}), - items: [] - } - ); - communityContent.items.push({ - rootItem: new MenuItem('contentProviders', 'Content providers', '/manage-content-providers', - '/manage-content-providers', false, [], [], {communityId: this.communityId}), - items: [] - }); - if (this.communityType && this.communityType != 'ri') { - communityContent.items.push({ - rootItem: new MenuItem('subjects', 'Subjects', '/manage-subjects', - '/manage-subjects', false, [], [], {communityId: this.communityId}), - items: [] - }); - } - communityContent.items.push({ - rootItem: new MenuItem('zenodoCommunities', 'Zenodo communities', '/manage-zenodo-communities', - '/manage-zenodo-communities', false, [], [], {communityId: this.communityId}), - items: [] - }); - this.sideMenuItems.push(communityContent); - } - const entities: SideMenuItem = { - rootItem: new MenuItem('entitiesPages', 'Entities & pages', '', - '', false, [], [], null), - items: [], - ukIcon: 'world' - }; - entities.items.push({ - rootItem: new MenuItem('entities', 'Activate Entities', '/entities', - '/entities', false, [], [], {communityId: this.communityId}), - items: [] - }); - const pages: MenuItem[] = []; - pages.push(new MenuItem('search', 'Search', '/pages', - '/pages', false, [], [], {communityId: this.communityId, type: 'search'})); - pages.push(new MenuItem('link', 'Link', '/pages', - '/pages', false, [], [], {communityId: this.communityId, type: 'link'})); - pages.push(new MenuItem('share', 'Share', '/pages', - '/pages', false, [], [], {communityId: this.communityId, type: 'share'})); - pages.push(new MenuItem('landing', 'Landing', '/pages', - '/pages', false, [], [], {communityId: this.communityId, type: 'landing'})); - // pages.push(new MenuItem('html', 'HTML', '/pages', - // '/pages', false, [], [], {communityId: this.communityId, type: 'html'})); - pages.push(new MenuItem('other', 'Other', '/pages', - '/pages', false, [], [], {communityId: this.communityId, type: 'other'})); - entities.items.push({ - rootItem: new MenuItem('pages', 'Pages', '/pages', - '/pages', false, [], [], {communityId: this.communityId}), - items: pages - }); - this.sideMenuItems.push(entities); - const help: SideMenuItem = { - rootItem: new MenuItem('help', 'Help Texts', '', - '', false, [], [], null), - items: [], - ukIcon: 'file-edit' - }; - help.items.push({ - rootItem: new MenuItem('pages', 'Page Help Texts', '/pageContents', - '/pageContents', false, [], [], {communityId: this.communityId}), - items: [] - }); - if (this.communityId === 'openaire' || this.communityId === 'connect') { - help.items.push({ - rootItem: new MenuItem('classes', 'Class Help Texts', '/classContents', - '/classContents', false, [], [], {communityId: this.communityId}), - items: [] - }); - } - this.sideMenuItems.push(help); - if (this.communityId !== 'openaire' && this.communityId !== 'connect') { - const stats: SideMenuItem = { - rootItem: new MenuItem('stats', 'Statistics & Charts', '/stats', - '/stats', false, [], [], {communityId: this.communityId}), - items: [], - ukIcon: 'image' - }; - this.sideMenuItems.push(stats); - const claims: SideMenuItem = { - rootItem: new MenuItem('claims', 'Links', '/claims', - '/claims', false, [], [], {communityId: this.communityId}), - items: [], - ukIcon: 'link' - }; - this.sideMenuItems.push(claims); - if (this.communityType && this.communityType === 'ri') { - const mining: SideMenuItem = { - rootItem: new MenuItem('mining', 'Text Mining Rules', '/mining/manage-profiles', - '/mining/manage-profiles', false, [], [], {communityId: this.communityId}), - items: [], - ukIcon: 'settings' - }; - this.sideMenuItems.push(mining); - } - const users: SideMenuItem = { - rootItem: new MenuItem('users', 'Users', '', - '', false, [], [], null), - items: [], - ukIcon: 'user' - }; - users.items.push({ - rootItem: new MenuItem('invite', 'Invite to Subscribe', 'https://beta.' + this.communityId + '.openaire.eu/invite', - '', false, [], [], null), - items: [] - }); - users.items.push({ - rootItem: new MenuItem('subscribers', 'Subscribers', '/manage-subscribers', - '/manage-subscribers', false, [], [], {communityId: this.communityId}), - items: [] - }); - users.items.push({ - rootItem: new MenuItem('personalInfo', 'Personal Info', '/personal', - '/personal', false, [], [], {communityId: this.communityId}), - items: [] - }); - users.items.push({ - rootItem: new MenuItem('notifications', 'Notification settings', '/manage-user-notifications', - '/manage-user-notifications', false, [], [], {communityId: this.communityId}), - items: [] - }); - this.sideMenuItems.push(users); + if (Session.isPortalAdministrator(this.user)) { + this.userMenuItems.push(new MenuItem("adminOptions", "Super Admin options", "", "/admin-tools/portals", false, [], [], {})); + this.userMenuItems.push(new MenuItem("connectOptions", "Connect portal options", "", "/connect/admin-tools/pages", false, [], [], {})); + this.userMenuItems.push(new MenuItem("exploreOptions", "Explore portal options", "", "/openaire/admin-tools/pages", false, [], [], {})); + } + this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {})); } - if (this.sideMenuItems.length > 0) { - this.showSidebar = true; + if (this.community) { + this.headerLogoUrl = this.community.logoUrl; + this.headerUrl = 'https://' + ((properties.environment !== 'production')?'beta.':'') + this.community.communityId + '.openaire.eu'; + this.menuHeader = { + route: "/" + this.community.communityId, + url: null, + title: 'Admin - ' + this.community.shortTitle, + logoUrl: null, + logoSmallUrl: null, + position: 'center', + badge: false, + stickyAnimation: false + }; + this.sideBarItems.push(new MenuItem("community", "Community Info", "", "/" + this.community.communityId, false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info")); + this.sideBarItems.push(new MenuItem("users", "Users", "", "/" + this.community.communityId + "/users", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/users")); + this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/" + this.community.communityId + "/admin-tools/pages", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/admin-tools")); + this.sideBarItems.push(new MenuItem("customization", "Customization", "", "/" + this.community.communityId + "/customize-layout", false, [], [], {})); + if (this.community.type === 'ri') { + this.sideBarItems.push(new MenuItem("mining", "Mining", "", "/" + this.community.communityId + "/mining/manage-profiles", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/mining")); + } + this.specialSideBarMenuItem = new MenuItem("back", "Manage communities", "", "/", false, [], null, {}); + this.specialSideBarMenuItem.icon = '' + arrow_left.data + ''; + this.specialSideBarMenuItem.customClass = 'uk-text-uppercase uk-text-bold uk-text-secondary'; + } else { + this.headerLogoUrl = null; + this.headerUrl = 'https://' + ((properties.environment !== 'production')?'beta.':'') + 'connect.openaire.eu'; + this.menuHeader = { + route: null, + url: null, + title: 'Admin - Research Community Dashboard', + logoUrl: null, + logoSmallUrl: null, + position: 'center', + badge: false, + stickyAnimation: false + }; + this.sideBarItems.push(new MenuItem("communities", "Manage Communities", "", "/", false, [], [], {})); + this.specialSideBarMenuItem = null; } } + + private isCurator() { + return this.user && (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || Session.isKindOfCommunityManager(this.user)); + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2767a5d..88965e1 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,65 +1,59 @@ -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { HttpClientModule } from '@angular/common/http'; -import { AppComponent } from './app.component'; -import { AppRoutingModule} from './app.routing'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; - -import { HelpContentService } from './services/help-content.service'; - +import {NgModule} from '@angular/core'; +import {BrowserModule} from '@angular/platform-browser'; +import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http'; +import {AppComponent} from './app.component'; +import {AppRoutingModule} from './app.routing'; +import {ReactiveFormsModule} from '@angular/forms'; import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module'; -import { CookieLawModule } from './openaireLibrary/sharedComponents/cookie-law/cookie-law.module'; - import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module'; -import { ConnectAdminLoginGuard} from './openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import { EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; -import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service'; - -import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service'; -import {CommunityErrorPageComponent} from './openaireLibrary/connect/communityGuard/communityErrorPage.component'; +import {ConnectAdminLoginGuard} from './openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; import {IsCommunity} from './openaireLibrary/connect/communityGuard/isCommunity.guard'; import {AdminErrorPageComponent} from './pages/error/errorPage.component'; import {ErrorModule} from './openaireLibrary/error/error.module'; import {TitleCasePipe} from '@angular/common'; - -import {AlertModalModule} from './openaireLibrary/utils/modal/alertModal.module'; -import {FABModule} from './utils/fabModule.module'; -import {SafeHtmlPipeModule} from './openaireLibrary/utils/pipes/safeHTMLPipe.module'; import {InteractiveMiningModule} from 'interactiveminingv3'; import {CommunityService} from './openaireLibrary/connect/community/community.service'; import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service'; import {ConnectRIGuard} from './openaireLibrary/connect/communityGuard/connectRIGuard.guard'; -import {SideBarModule} from "./openaireLibrary/sharedComponents/sidebar/sideBar.module"; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; -import {CommunityErrorModule} from './openaireLibrary/connect/communityGuard/communityError.module'; +import {LoadingModule} from "./openaireLibrary/utils/loading/loading.module"; +import {SideBarModule} from "./openaireLibrary/dashboard/sharedComponents/sidebar/sideBar.module"; +import {SharedModule} from "./openaireLibrary/shared/shared.module"; +import {ErrorInterceptorService} from "./openaireLibrary/error-interceptor.service"; +import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service"; +import {AdminLoginGuard} from "./openaireLibrary/login/adminLoginGuard.guard"; +import {LoginGuard} from "./openaireLibrary/login/loginGuard.guard"; @NgModule({ - imports: [ - AppRoutingModule, - BrowserModule, - HttpClientModule, - FormsModule, - ReactiveFormsModule, - BottomModule, NavigationBarModule, CookieLawModule, - ErrorModule, - AlertModalModule, SafeHtmlPipeModule, FABModule, - InteractiveMiningModule, - SideBarModule, - BrowserAnimationsModule, CommunityErrorModule - ], - declarations: [ - AppComponent, - // CommunityErrorPageComponent, - AdminErrorPageComponent - ], - providers: [ - HelpContentService, CommunityService, SubscribeService, - ConnectAdminLoginGuard, - EnvironmentSpecificResolver, EnvironmentSpecificService, - IsCommunity, ConnectRIGuard, CommunitiesService, TitleCasePipe - - ], - bootstrap: [ AppComponent ] + imports: [ + AppRoutingModule, + BrowserModule, + HttpClientModule, + ReactiveFormsModule, + BottomModule, NavigationBarModule, + ErrorModule, + SharedModule, + InteractiveMiningModule, + BrowserAnimationsModule, LoadingModule, SideBarModule + ], + declarations: [ + AppComponent, + AdminErrorPageComponent + ], + providers: [ + SubscribeService, + ConnectAdminLoginGuard, AdminLoginGuard, LoginGuard, + IsCommunity, ConnectRIGuard, TitleCasePipe, + { + provide: HTTP_INTERCEPTORS, + useClass: ErrorInterceptorService, + multi: true + }, + [{provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true}], + [{provide: DEFAULT_TIMEOUT, useValue: 30000}] + ], + bootstrap: [AppComponent] }) -export class AppModule { } +export class AppModule { +} diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts index 0c09942..4dd6d4f 100644 --- a/src/app/app.routing.ts +++ b/src/app/app.routing.ts @@ -1,176 +1,70 @@ -/** - * Created by stefania on 9/16/16. - */ -import { NgModule} from '@angular/core'; -import { Routes, RouterModule} from '@angular/router'; +import {NgModule} from '@angular/core'; +import {PreloadAllModules, RouterModule, Routes} from '@angular/router'; import {IsCommunity} from './openaireLibrary/connect/communityGuard/isCommunity.guard'; import {ConnectAdminLoginGuard} from './openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {ConnectRIGuard} from './openaireLibrary/connect/communityGuard/connectRIGuard.guard'; - -import {EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; - -import {CommunityErrorPageComponent} from './openaireLibrary/connect/communityGuard/communityErrorPage.component'; import {AdminErrorPageComponent} from './pages/error/errorPage.component'; +import {AdminLoginGuard} from "./openaireLibrary/login/adminLoginGuard.guard"; +import {LoginGuard} from "./openaireLibrary/login/loginGuard.guard"; -const appRoutes: Routes = [ +const routes: Routes = [ { path: '', - loadChildren: './pages/wellcome/wellcome.module#WellcomeModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'dashboard', - loadChildren: './pages/dashboard/dashboard.module#DashboardModule', - resolve: {envSpecific: EnvironmentSpecificResolver} - }, - { - path: 'manage-user-notifications', - loadChildren: './pages/usernotifications/manage-user-notifications.module#ManageUserNotificationsModule', - resolve: {envSpecific: EnvironmentSpecificResolver} - }, - { - path: 'personal', - loadChildren: './pages/curator/curator.module#CuratorModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'organizations', - loadChildren: './pages/affiliations/affiliations.module#AffiliationsModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'communities', - loadChildren: './pages/community/communities.module#CommunitiesModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'community-edit-form', - loadChildren: './pages/community/community-edit-form/community-edit-form.module#CommunityEditFormModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'manage-zenodo-communities', - loadChildren: './pages/zenodo-communities/zenodo-communities.module#ZenodoCommunitiesModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'manage-subscribers', - loadChildren: './pages/subscribers/manage-subscribers.module#ManageSubscribersModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'manage-subjects', - loadChildren: './pages/subjects/subjects-edit-form/subjects-edit-form.module#SubjectsEditFormModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'entities', - loadChildren: './pages/entity/entities.module#EntitiesModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'classes', - loadChildren: './pages/divId/divIds.module#DivIdsModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'pages', - loadChildren: './pages/page/pages.module#PagesModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'pageContents', - loadChildren: './pages/helpcontent/page-help-contents.module#PageHelpContentsModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'pageContents/new', - loadChildren: './pages/helpcontent/new-page-help-content.module#NewPageHelpContentModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'pageContents/edit', - loadChildren: './pages/helpcontent/edit-page-help-content.module#EditPageHelpContentModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'classContents', - loadChildren: './pages/divhelpcontent/div-help-contents.module#DivHelpContentsModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'classContents/new', - loadChildren: './pages/divhelpcontent/new-div-help-content.module#NewDivHelpContentModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'classContents/edit', - loadChildren: './pages/divhelpcontent/edit-div-help-content.module#EditDivHelpContentModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'htmlPageContent/edit', - loadChildren: './pages/htmlpagecontent/edit-html-page-content.module#EditHtmlPageContentModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - { - path: 'claims', - loadChildren: './pages/claims/claims.module#ClaimsModule', - resolve: { envSpecific: EnvironmentSpecificResolver } + loadChildren: './pages/manage-communities/manage-communities.module#ManageCommunitiesModule', + canActivateChild: [LoginGuard] }, { path: 'reload', loadChildren: './reload/libReload.module#LibReloadModule', - resolve: { envSpecific: EnvironmentSpecificResolver } + data: {hasSidebar: false, hasHeader: false} }, { path: 'user-info', loadChildren: './login/libUser.module#LibUserModule', - resolve: { envSpecific: EnvironmentSpecificResolver } + data: {hasSidebar: false} + }, + { path: 'error', + pathMatch: 'full', + component: AdminErrorPageComponent, + data: {hasSidebar: false} }, { - path: 'stats', - loadChildren: './pages/stats/stats.module#StatsModule', - resolve: { envSpecific: EnvironmentSpecificResolver } + path: 'connect/admin-tools', + loadChildren: './pages/admin-tools/admin-tools-routing.module#AdminToolsRoutingModule', + canActivateChild: [AdminLoginGuard], + data: {portal: 'connect'} }, { - path: 'manage-projects', - loadChildren: './pages/community/projects/communityProjects.module#CommunityProjectsModule', - resolve: { envSpecific: EnvironmentSpecificResolver } + path: 'openaire/admin-tools', + loadChildren: './pages/admin-tools/admin-tools-routing.module#AdminToolsRoutingModule', + canActivateChild: [AdminLoginGuard], + data: {portal: 'openaire'} }, { - path: 'manage-content-providers', - loadChildren: './pages/community/content-providers/communityContentProviders.module#CommunityContentProvidersModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - }, - /*{ - path: 'customize-layout', - loadChildren: './pages/customization/customization.module#CustomizationModule', - resolve: { envSpecific: EnvironmentSpecificResolver } - },*/ - { - path: 'manage-content-providers/criteria', - loadChildren: './pages/community/content-providers/criteria/criteria.module#CriteriaModule', - resolve: { envSpecific: EnvironmentSpecificResolver } + path: 'admin-tools', + loadChildren: './pages/admin-tools/portal-admin-tools-routing.module#PortalAdminToolsRoutingModule', + canActivateChild: [AdminLoginGuard] }, { - path: 'mining', - loadChildren: './pages/mining/mining.module#MiningModule', - canLoad: [IsCommunity, ConnectAdminLoginGuard, ConnectRIGuard] + path: ':community', redirectTo: '/:community/info/profile', pathMatch: 'full' }, { - path: 'errorcommunity', - component: CommunityErrorPageComponent + path: ':community', + loadChildren: './pages/community-routing.module#CommunityRoutingModule', + canActivateChild: [IsCommunity, ConnectAdminLoginGuard] }, { path: '**', pathMatch: 'full', component: AdminErrorPageComponent } - ]; +]; @NgModule({ - imports: [ RouterModule.forRoot(appRoutes) ], + imports: [RouterModule.forRoot(routes, { + preloadingStrategy: PreloadAllModules, + onSameUrlNavigation: "reload", + relativeLinkResolution: 'corrected' + })], exports: [ RouterModule ] }) export class AppRoutingModule {} diff --git a/src/app/pages/admin-tools/admin-tools-routing.module.ts b/src/app/pages/admin-tools/admin-tools-routing.module.ts new file mode 100644 index 0000000..504f219 --- /dev/null +++ b/src/app/pages/admin-tools/admin-tools-routing.module.ts @@ -0,0 +1,41 @@ +import {NgModule} from '@angular/core'; +import {RouterModule} from '@angular/router'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { + path: 'entities', + loadChildren: '../../openaireLibrary/dashboard/entity/entities.module#EntitiesModule', + pathMatch: 'full' + }, + { + path: 'classContents', + loadChildren: '../../openaireLibrary/dashboard/divhelpcontent/class-help-contents.module#ClassHelpContentsModule', + pathMatch: 'full' + }, + { + path: 'classContents/edit', + loadChildren: '../../openaireLibrary/dashboard/divhelpcontent/class-help-content-form.module#ClassHelpContentFormModule', + pathMatch: 'full' + }, + { + path: 'helptexts', + loadChildren: '../../openaireLibrary/dashboard/helpTexts/page-help-contents.module#PageHelpContentsModule', + pathMatch: 'full' + }, + { + path: 'helptexts/edit', + loadChildren: '../../openaireLibrary/dashboard/helpTexts/page-help-content-form.module#PageHelpContentFormModule', + pathMatch: 'full' + }, + { + path: 'pages', + loadChildren: '../../openaireLibrary/dashboard/page/pages.module#PagesModule', + pathMatch: 'full' + } + ]) + ] +}) +export class AdminToolsRoutingModule { +} diff --git a/src/app/pages/admin-tools/portal-admin-tools-routing.module.ts b/src/app/pages/admin-tools/portal-admin-tools-routing.module.ts new file mode 100644 index 0000000..6be1de5 --- /dev/null +++ b/src/app/pages/admin-tools/portal-admin-tools-routing.module.ts @@ -0,0 +1,13 @@ +import {NgModule} from "@angular/core"; +import {RouterModule} from "@angular/router"; + +@NgModule({ + imports: [RouterModule.forChild([ + {path: '', loadChildren: './admin-tools-routing.module#AdminToolsRoutingModule'}, + {path: 'portals', loadChildren: '../../openaireLibrary/dashboard/portal/portals.module#PortalsModule'}, + {path: 'classes', loadChildren: '../../openaireLibrary/dashboard/divId/divIds.module#DivIdsModule'} + ])] +}) +export class PortalAdminToolsRoutingModule { + +} diff --git a/src/app/pages/affiliations/affiliations-routing.module.ts b/src/app/pages/affiliations/affiliations-routing.module.ts index 6979146..d77d4bc 100644 --- a/src/app/pages/affiliations/affiliations-routing.module.ts +++ b/src/app/pages/affiliations/affiliations-routing.module.ts @@ -1,13 +1,11 @@ -import { NgModule } from '@angular/core'; +import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; import {AffiliationsComponent} from './affiliations.component'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: AffiliationsComponent} + { path: '', component: AffiliationsComponent} ]) ] }) diff --git a/src/app/pages/affiliations/affiliations.component.html b/src/app/pages/affiliations/affiliations.component.html index 9af90bb..cae7adb 100644 --- a/src/app/pages/affiliations/affiliations.component.html +++ b/src/app/pages/affiliations/affiliations.component.html @@ -1,135 +1,83 @@ - - - - - -
-

- My Affiliations - Related Organizations -

-
- -
- -
- Do you need to add more information about the Related Organizations? Click - - - - here +
+
+ +
+ + + - . - +
+
+
+ +
+
+
+
No organizations found
+
+
+ + +
+
+
+
+
+ +
+
+
{{affiliation.name}}
+ URL: {{affiliation.website_url}} +
+
+ +
+
+
+ +
- - - - -
- -
- -
-
- {{message}} -
- -
-
-
- -
- - - - - - - - - - - - - - - - - -
- Name - - * - - : - - -
- Logo Url - - * - - : - - -
- Website Url - - * - - : - - -
+ +
+
+
+
+
+
+
diff --git a/src/app/pages/affiliations/affiliations.component.ts b/src/app/pages/affiliations/affiliations.component.ts index 328a7b9..29e0c9c 100644 --- a/src/app/pages/affiliations/affiliations.component.ts +++ b/src/app/pages/affiliations/affiliations.component.ts @@ -1,288 +1,210 @@ -import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; +import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {Affiliation} from '../../openaireLibrary/utils/entities/CuratorInfo'; -import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class'; import {AlertModal} from '../../openaireLibrary/utils/modal/alert'; -import {UtilitiesService} from '../../openaireLibrary/services/utilities.service'; import {AffiliationService} from "../../openaireLibrary/connect/affiliations/affiliation.service"; import {HelpContentService} from "../../services/help-content.service"; import {Title} from '@angular/platform-browser'; import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; +import {properties} from "../../../environments/environment"; +import {Page} from "../../openaireLibrary/utils/entities/adminTool/page"; +import {FormBuilder, FormGroup, Validators} from "@angular/forms"; +import {Subscription} from "rxjs"; +import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; + +declare var UIkit; @Component({ selector: 'affiliations', templateUrl: './affiliations.component.html', }) - -export class AffiliationsComponent implements OnInit { - +export class AffiliationsComponent implements OnInit, OnDestroy { + public loading = true; + public properties: EnvProperties = properties; + public index = 0; + public affiliations: Affiliation[]; + public affiliationFb: FormGroup; + public communityId: string; + public organizationsPage: Page; + public page: number = 1; + public pageSize: number = 10; + private subs: any[] = []; @ViewChild('affiliationModal') affiliationModal: AlertModal; @ViewChild('removeAffiliationModal') removeAffiliationModal: AlertModal; - public showLoading = false; - public message = ''; - public messageType = ''; - - public affiliation: Affiliation = new Affiliation(); - public properties: EnvProperties = null; - - private index = 0; - private maxCharacters = 70; - - @Input() hasChanged: boolean = false; - @Input() curatorAffiliations: boolean = false; - @Input() public affiliations: Affiliation[] = []; - @Output() affiliationsChange: EventEmitter = new EventEmitter(); - @Output() resetCuratorMessages: EventEmitter = new EventEmitter(); - public communityId: string; - public organizationsPageId: string; - public organizationsEnabled = false; - - constructor(private element: ElementRef, - private route: ActivatedRoute, - private _router: Router, + + constructor(private route: ActivatedRoute, + private router: Router, private title: Title, + private fb: FormBuilder, + private communityService: CommunityService, private affiliationService: AffiliationService, - private _helpContentService: HelpContentService) { + private helpContentService: HelpContentService) { } - - + + ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - if(!this.curatorAffiliations) { - this.title.setTitle('Administration Dashboard | Related Organizations'); - } - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} - }); - } else { - this.showLoading = true; - this.message = ''; - - this.route.queryParams.subscribe( - communityId => { - this.communityId = communityId['communityId']; - - if(!this.curatorAffiliations) { - this.getAffiliations(); - } - this.organizationsPageStatus(); - } - ); - } - }); + this.loading = true; + this.subs.push(this.route.params.subscribe(params => { + this.communityId = params['community']; + this.title.setTitle(this.communityId.toUpperCase() + ' | Organizations'); + this.getAffiliations(); + this.organizationsPageStatus(); + })); } - + + ngOnDestroy() { + this.subs.forEach(sub => { + if (sub instanceof Subscription) { + sub.unsubscribe(); + } + }) + } + getAffiliations() { + this.loading = true; this.affiliationService.initAffiliations(this.communityId); this.affiliationService.affiliations.subscribe( affiliations => { this.affiliations = affiliations; - this.getOrganizationsPageId(); - //this.showLoading = false; + this.loading = false; }, error => { - console.error("Affiliations Component: Error getting affiliations for community with id: "+this.communityId, error); - this.showLoading = false; + console.error("Affiliations Component: Error getting affiliations for community with id: " + this.communityId, error); + this.loading = false; } ); } - - getOrganizationsPageId() { - this._helpContentService.getCommunityPageByRoute("/organizations", this.properties.adminToolsAPIURL, this.communityId).subscribe( - page => { - if(page) { - this.organizationsPageId = page._id; - } - this.showLoading = false; - }, - error => { - console.error("Affiliations Component: Error getting page with route '/organizations' for community with id: "+this.communityId, error); - this.showLoading = false; - } - ); + + public get organizationsEnabled(): boolean { + return !this.organizationsPage || this.organizationsPage.isEnabled; } - - initAffiliation(affiliation: Affiliation = null) { - this.resetMessages(); - - if (affiliation) { - this.affiliation = {...affiliation}; - if(!this.curatorAffiliations) { - this.affiliation.communityId = affiliation.communityId; - this.affiliation.id = affiliation.id; - } - if(this.curatorAffiliations) { - this.affiliationModal.okButtonText = 'OK'; - } else { - this.affiliationModal.okButtonText = 'Save Affiliation'; - } + + editAffiliationOpen(index: number = -1) { + let affiliation: Affiliation; + this.index = index; + if (index === -1) { + affiliation = new Affiliation(); + affiliation.communityId = this.communityId; + this.affiliationModal.alertTitle = 'Add Organization'; + this.affiliationModal.okButtonText = 'Add'; } else { - this.index = -1; - this.affiliation = new Affiliation(); - if(!this.curatorAffiliations) { - this.affiliation.communityId = this.communityId; - } + affiliation = this.affiliations[this.index]; + this.affiliationModal.alertTitle = 'Edit Organization'; + this.affiliationModal.okButtonText = 'Update'; } + this.affiliationFb = this.fb.group({ + communityId: this.fb.control(affiliation.communityId, Validators.required), + id: this.fb.control(affiliation.id), + name: this.fb.control(affiliation.name, Validators.required), + logo_url: this.fb.control(affiliation.logo_url, [Validators.required, StringUtils.urlValidator()]), + website_url: this.fb.control(affiliation.website_url, [Validators.required, StringUtils.urlValidator()]) + }); this.affiliationModal.okButtonLeft = false; - if(this.curatorAffiliations) { - this.affiliationModal.okButtonText = 'OK'; - } else { - this.affiliationModal.okButtonText = 'Save Affiliation'; - } + this.affiliationModal.cancelButtonText = 'Cancel'; this.affiliationModal.open(); } - - public chooseAffiliation(index: number, action: string = 'delete') { - this.resetMessages(); + + deleteAffiliationOpen(index: number) { this.index = index; - const affiliation: Affiliation = this.affiliations[index]; - if (action === 'delete') { - this.removeAffiliationModal.message = 'Do you want to remove ' + - affiliation.name + ' from your Affiliations?'; - this.removeAffiliationModal.okButtonText = 'Yes'; - this.removeAffiliationModal.cancelButtonText = 'No'; - this.removeAffiliationModal.open(); - } else if (action === 'edit') { - this.initAffiliation(affiliation); - } + let affiliation: Affiliation = this.affiliations[index]; + this.removeAffiliationModal.alertTitle = 'Delete Organization'; + this.removeAffiliationModal.message = 'Do you want to remove ' + + affiliation.name + ' from Organizations?'; + this.removeAffiliationModal.okButtonText = 'Yes'; + this.removeAffiliationModal.cancelButtonText = 'No'; + this.removeAffiliationModal.open(); } - - updateCommunityAffiliations(index: number) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: - {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} - }); + + get currentPage(): Affiliation[] { + if (this.affiliations) { + return this.affiliations.slice((this.page - 1) * this.pageSize, this.page * this.pageSize); } else { - HelperFunctions.scroll(); - - this.showLoading = true; - - this.affiliationService.updateAffiliation(this.properties.communityAPI + this.communityId + '/organizations', - this.affiliation).subscribe((affiliation) => { - if (affiliation) { - if (index === -1) { - this.affiliations.push(affiliation); - } else { - this.affiliations[index] = affiliation; - } - if(this.affiliation.id) { - this.handleUpdateSuccess('Your organization has been updated successfully!'); - } else { - this.handleUpdateSuccess('Your organization has been saved successfully!'); - } - } - }, - error => { - if(this.affiliation.id) { - this.handleUpdateError('Your organization could not be updated. Try again later!', error); - } else { - this.handleUpdateError('Organization could not be saved. Try again later!', error); - } - }); + return []; } } - - addAffiliation() { - if (!this.isEmptyAffiliation()) { - if (!this.curatorAffiliations) { - this.updateCommunityAffiliations(this.index); + + getIndex(index: number): number { + return (this.page - 1)*this.pageSize + index; + } + + public updatePage(event) { + this.page = event.value; + } + + editAffiliation() { + this.loading = true; + this.affiliationService.updateAffiliation(this.properties.communityAPI + this.communityId + '/organizations', + this.affiliationFb.value).subscribe((affiliation) => { + if (affiliation) { + if (this.index === -1) { + this.affiliations.push(affiliation); + this.page = Math.ceil(this.affiliations.length/this.pageSize); } else { - if (this.index === -1) { - this.affiliations.push(this.affiliation); - } else { - this.affiliations[this.index] = this.affiliation; - } + this.affiliations[this.index] = affiliation; } - this.change(); - } + if (affiliation.id) { + this.handleUpdateSuccess('Your organization has been updated successfully!'); + } else { + this.handleUpdateSuccess('Your organization has been saved successfully!'); + } + } + }, + error => { + this.handleUpdateError('An error has been occurred. Try again later!'); + }); } - + removeAffiliation() { - if(!this.curatorAffiliations) { - HelperFunctions.scroll(); - - this.showLoading = true; - this.affiliationService.deleteAffiliation(this.properties.communityAPI + this.communityId + '/organizations', - this.affiliations[this.index].id).subscribe((deleteOK) => { - this.affiliations.splice(this.index, 1); - this.handleUpdateSuccess('Organization has been deleted'); - }, - error => { - this.handleUpdateError('Organization could not be deleted. Try again later!', error); + this.loading = true; + this.affiliationService.deleteAffiliation(this.properties.communityAPI + this.communityId + '/organizations', + this.affiliations[this.index].id).subscribe((deleteOK) => { + this.affiliations.splice(this.index, 1); + if (this.currentPage.length === 0) { + this.page = 1; } - ); - } else { - this.affiliations.splice(this.index, 1); - this.change(); - } + this.handleUpdateSuccess('Organization has been deleted'); + }, + error => { + this.handleUpdateError('An error has been occurred. Try again later!'); + }); } - + private organizationsPageStatus() { - this._helpContentService.getCommunityFull(this.communityId, this.properties.adminToolsAPIURL).subscribe((community) => { - for(let page of community.pages) { - if(page['route'] === '/organizations') { - this.organizationsEnabled = page['isEnabled']; - return; - } - } - this.organizationsEnabled = false; + this.helpContentService.getCommunityPagesByRoute(this.communityId, '/organizations', this.properties.adminToolsAPIURL).subscribe((page) => { + this.organizationsPage = page; }) } - - private change() { - this.hasChanged = true; - if(this.curatorAffiliations) { - this.affiliationsChange.emit(this.hasChanged); - } + + handleUpdateError(message: string) { + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + this.loading = false; } - - private resetMessages() { - this.message = ''; - if(this.curatorAffiliations) { - this.resetCuratorMessages.emit(true); - } - } - - handleUpdateError(message: string, error) { - this.resetMessages(); - this.message = message; - this.messageType = "warning"; - console.log('Server responded: ', error); - - this.showLoading = false; - } - + handleUpdateSuccess(message) { - this.resetMessages(); - this.message = message; - this.messageType = "success"; - this.showLoading = false; + UIkit.notification(message, { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.loading = false; } - - isEmptyAffiliation(): boolean { - return ((!this.affiliation.name || this.affiliation.name === '') || - (!this.affiliation.logo_url || this.affiliation.logo_url === '') || - (!this.affiliation.website_url || this.affiliation.website_url === '')); + + enableAffiliations() { + this.helpContentService.togglePages(this.communityId, [this.organizationsPage._id], true, this.properties.adminToolsAPIURL).subscribe(() => { + this.organizationsPage.isEnabled = true; + UIkit.notification('Organizations Page has been enabled successfully', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + }, error => { + this.handleUpdateError('An error has been occurred. Try again later!'); + }); } - - _format(name: string){ - if(name) { - return (((name).length > this.maxCharacters) ? (name.substring(0, (this.maxCharacters - ('...').length)) + '...') : name); - } else { - return null; - } - } - - public urlPrefix(url: string): string { - return StringUtils.urlPrefix(url); - } - } diff --git a/src/app/pages/affiliations/affiliations.module.ts b/src/app/pages/affiliations/affiliations.module.ts index 1e3048d..98b5737 100644 --- a/src/app/pages/affiliations/affiliations.module.ts +++ b/src/app/pages/affiliations/affiliations.module.ts @@ -1,31 +1,44 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; -import {FormsModule} from '@angular/forms'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {RouterModule} from '@angular/router'; import {AffiliationsComponent} from './affiliations.component'; import {AffiliationsRoutingModule} from './affiliations-routing.module'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; import {AffiliationService} from '../../openaireLibrary/connect/affiliations/affiliation.service'; import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; import {UtilitiesService} from '../../openaireLibrary/services/utilities.service'; +import {InputModule} from "../../openaireLibrary/sharedComponents/input/input.module"; +import {PageContentModule} from "../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; +import {CommunityInfoModule} from "../community-info/community-info.module"; +import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; +import {IconsService} from "../../openaireLibrary/utils/icons/icons.service"; +import {add, edit, preview, remove} from "../../openaireLibrary/utils/icons/icons"; +import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; +import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"; +import {UrlPrefixModule} from "../../openaireLibrary/utils/pipes/url-prefix.module"; +import {HelpContentService} from "../../services/help-content.service"; @NgModule({ imports: [ AffiliationsRoutingModule, CommonModule, FormsModule, RouterModule, - AlertModalModule + AlertModalModule, ReactiveFormsModule, InputModule, PageContentModule, CommunityInfoModule, IconsModule, NoLoadPaging, LoadingModule, UrlPrefixModule ], declarations: [ AffiliationsComponent ], providers: [ - AffiliationService, UtilitiesService, IsCommunity, ConnectAdminLoginGuard + AffiliationService, UtilitiesService, HelpContentService ], exports: [ AffiliationsComponent ] }) -export class AffiliationsModule { } +export class AffiliationsModule { + + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([add, preview, edit, remove]) + } +} diff --git a/src/app/pages/claims/claims-routing.module.ts b/src/app/pages/claims/claims-routing.module.ts index 78b46f5..111a1fb 100644 --- a/src/app/pages/claims/claims-routing.module.ts +++ b/src/app/pages/claims/claims-routing.module.ts @@ -1,13 +1,11 @@ -import { NgModule } from '@angular/core'; +import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; import {ClaimsComponent} from './claims.component'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: ClaimsComponent} + { path: '', component: ClaimsComponent} ]) ] }) diff --git a/src/app/pages/claims/claims.component.ts b/src/app/pages/claims/claims.component.ts index ef86bca..fe7dc8c 100644 --- a/src/app/pages/claims/claims.component.ts +++ b/src/app/pages/claims/claims.component.ts @@ -1,33 +1,48 @@ - -import { Component, ViewChild, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {properties} from '../../../environments/environment'; +import {Subscriber} from 'rxjs'; +import {Title} from "@angular/platform-browser"; @Component({ - selector: 'claims', - template: ` - `, + selector: 'claims', + template: ` +
+
+ +
+
+ + +
+
+ `, }) export class ClaimsComponent implements OnInit { - - communityPid:string; - claimsInfoURL:string; - externalPortalUrl:string =""; - - ngOnInit() { - - this.route.queryParams.subscribe(params => { - this.communityPid = params['communityId']; - - }); - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.claimsInfoURL = data.envSpecific.claimsInformationLink; - console.log(this.claimsInfoURL); - this.externalPortalUrl = "https://"+(data.envSpecific.environment =='beta'?'beta.':'')+((this.communityPid == "openaire")?"explore":this.communityPid)+".openaire.eu" - }); + communityId: string; + claimsInfoURL: string; + externalPortalUrl = ''; + sub; + + constructor(private route: ActivatedRoute, + private title: Title) { + } + + ngOnInit() { + this.sub = this.route.params.subscribe(params => { + this.communityId = params['community']; + this.title.setTitle(this.communityId.toUpperCase() + ' | Manage Links'); + this.claimsInfoURL = properties.claimsInformationLink; + this.externalPortalUrl = 'https://' + (properties.environment == 'beta' ? 'beta.' : '') + ((this.communityId == 'openaire') ? 'explore' : this.communityId) + '.openaire.eu'; + }); + + } + + ngOnDestroy() { + if (this.sub instanceof Subscriber) { + this.sub.unsubscribe(); } - - constructor(private route: ActivatedRoute) {} - + } } diff --git a/src/app/pages/claims/claims.module.ts b/src/app/pages/claims/claims.module.ts index 42eafd7..13fc201 100644 --- a/src/app/pages/claims/claims.module.ts +++ b/src/app/pages/claims/claims.module.ts @@ -2,9 +2,11 @@ import { NgModule } from '@angular/core'; import {ClaimsAdminModule} from '../../openaireLibrary/claims/claimsAdmin/claimsAdmin.module'; import {ClaimsComponent} from './claims.component'; import {ClaimsRoutingModule} from './claims-routing.module'; +import {PageContentModule} from '../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; +import {UsersTabsModule} from '../users/users-tabs.module'; @NgModule({ imports: [ - ClaimsAdminModule, ClaimsRoutingModule + ClaimsAdminModule, ClaimsRoutingModule, PageContentModule, UsersTabsModule, PageContentModule ], declarations: [ClaimsComponent], exports: [ClaimsComponent] diff --git a/src/app/pages/community-info/community-info-routing.module.ts b/src/app/pages/community-info/community-info-routing.module.ts new file mode 100644 index 0000000..337aaca --- /dev/null +++ b/src/app/pages/community-info/community-info-routing.module.ts @@ -0,0 +1,21 @@ +import {NgModule} from '@angular/core'; +import {RouterModule} from '@angular/router'; +import {ConnectCommunityGuard} from "../../openaireLibrary/connect/communityGuard/connectCommunityGuard.guard"; + +@NgModule({ + imports: [ + RouterModule.forChild([ + {path: '', redirectTo: 'profile', pathMatch: 'full'}, + {path: 'profile', loadChildren: './profile/profile.module#ProfileModule'}, + {path: 'organizations', loadChildren: '../affiliations/affiliations.module#AffiliationsModule'}, + {path: 'projects', loadChildren: '../projects/communityProjects.module#CommunityProjectsModule'}, + {path: 'content-providers', loadChildren: '../content-providers/communityContentProviders.module#CommunityContentProvidersModule'}, + {path: 'content-providers/:provider', loadChildren: '../content-providers/criteria/criteria.module#CriteriaModule'}, + {path: 'zenodo-communities', loadChildren: '../zenodo-communities/zenodo-communities.module#ZenodoCommunitiesModule'}, + {path: 'subjects', canActivateChild: [ConnectCommunityGuard], loadChildren: '../subjects/subjects-edit-form/subjects-edit-form.module#SubjectsEditFormModule'}, + ]) + ], + providers: [ConnectCommunityGuard] +}) +export class CommunityInfoRoutingModule { +} diff --git a/src/app/pages/community-info/community-info.component.ts b/src/app/pages/community-info/community-info.component.ts new file mode 100644 index 0000000..a048115 --- /dev/null +++ b/src/app/pages/community-info/community-info.component.ts @@ -0,0 +1,40 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; +import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; +import {Subscription} from 'rxjs'; + +@Component({ + selector: 'community-info', + template: ` + + ` +}) +export class CommunityInfoComponent implements OnInit { + @Input() + public type: string; + @Input() + public tab: "profile"| "organizations" | "projects" | "content-providers" | "subjects" | "zenodo-communities" = 'profile'; + public community: CommunityInfo; + private sub; + + constructor(private communityService: CommunityService) { + } + + ngOnInit() { + this.sub =this.communityService.getCommunityAsObservable().subscribe(community => { + this.community = community; + }); + } + ngOnDestroy() { + if (this.sub instanceof Subscription) { + this.sub.unsubscribe(); + } + } +} diff --git a/src/app/pages/community-info/community-info.module.ts b/src/app/pages/community-info/community-info.module.ts new file mode 100644 index 0000000..13be1fe --- /dev/null +++ b/src/app/pages/community-info/community-info.module.ts @@ -0,0 +1,14 @@ +import {NgModule} from '@angular/core'; +import {RouterModule} from "@angular/router"; +import {CommonModule} from "@angular/common"; +import {CommunityInfoComponent} from "./community-info.component"; + +@NgModule({ + imports: [ + CommonModule, RouterModule + ], + declarations: [CommunityInfoComponent], + exports: [CommunityInfoComponent] +}) +export class CommunityInfoModule { +} diff --git a/src/app/pages/community-info/profile/edit-community/edit-community.component.css b/src/app/pages/community-info/profile/edit-community/edit-community.component.css new file mode 100644 index 0000000..d279cde --- /dev/null +++ b/src/app/pages/community-info/profile/edit-community/edit-community.component.css @@ -0,0 +1,10 @@ +.uk-border-circle { + width: 100px; + height: 100px; + position: relative; +} + +.uk-border-circle > img { + max-width: 64px; + max-height: 64px; +} diff --git a/src/app/pages/community-info/profile/edit-community/edit-community.component.ts b/src/app/pages/community-info/profile/edit-community/edit-community.component.ts new file mode 100644 index 0000000..31e8f50 --- /dev/null +++ b/src/app/pages/community-info/profile/edit-community/edit-community.component.ts @@ -0,0 +1,318 @@ +import {Component, Input} from "@angular/core"; +import {FormBuilder, FormGroup, Validators} from "@angular/forms"; +import {EnvProperties} from "../../../../openaireLibrary/utils/properties/env-properties"; +import {properties} from "../../../../../environments/environment"; +import {CommunityInfo} from "../../../../openaireLibrary/connect/community/communityInfo"; +import {Session, User} from "../../../../openaireLibrary/login/utils/helper.class"; +import {CommunityService} from "../../../../openaireLibrary/connect/community/community.service"; +import {UtilitiesService} from "../../../../openaireLibrary/services/utilities.service"; +import {UserManagementService} from "../../../../openaireLibrary/services/user-management.service"; +import {StringUtils} from "../../../../openaireLibrary/utils/string-utils.class"; +import {Subscription} from "rxjs"; +import {Option} from "../../../../openaireLibrary/sharedComponents/input/input.component"; + +declare var UIkit; + +@Component({ + selector: 'edit-community', + template: ` +
+
+
+
+
+ + + + +
+
Description
+
The description of the community
+ + +
+ + +
+
+
+
+ +
+
+ OR +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
{{uploadError}}
+
+
+
+
`, + styleUrls: ['edit-community.component.css'] +}) +export class EditCommunityComponent { + @Input() + public maxHeight = 'none'; + @Input() + public paddingLarge: boolean = false; + public communityFb: FormGroup; + public statuses: Option[] = [ + {label: 'Visible', value: 'all'}, + {label: 'Visible to managers', value: 'manager'}, + {label: 'Hidden', value: 'hidden'} + ] + public community: CommunityInfo; + public isNew: boolean; + public properties: EnvProperties = properties + ; + private subscriptions: any[] = []; + /** + * Photo upload + * */ + public file: File; + public photo: string | ArrayBuffer; + public uploadError: string; + public deleteCurrentPhoto: boolean = false; + private maxsize: number = 200 * 1024; + user: User; + + constructor(private fb: FormBuilder, + private communityService: CommunityService, + private utilsService: UtilitiesService, + private userManagementService: UserManagementService) { + } + + ngOnDestroy() { + this.reset(); + } + + public init(community: CommunityInfo, isNew: boolean = false) { + this.reset(); + this.deleteCurrentPhoto = false; + this.community = community; + this.isNew = isNew; + this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { + this.user = user; + this.communityFb = this.fb.group({ + communityId: this.fb.control(this.community.communityId), + name: this.fb.control(this.community.title, Validators.required), + shortName: this.fb.control(this.community.shortTitle, Validators.required), + description: this.fb.control(this.community.description), + status: this.fb.control(this.community.status), + managers: this.fb.control(this.community.managers), + isUpload: this.fb.control(this.community.isUpload), + logoUrl: this.fb.control(this.community.logoUrl) + }); + if (this.community.isUpload) { + this.communityFb.get('logoUrl').clearValidators(); + this.communityFb.get('logoUrl').updateValueAndValidity(); + } else { + this.communityFb.get('logoUrl').setValidators([StringUtils.urlValidator()]); + this.communityFb.get('logoUrl').updateValueAndValidity(); + } + this.subscriptions.push(this.communityFb.get('isUpload').valueChanges.subscribe(value => { + if (value == true) { + this.communityFb.get('logoUrl').clearValidators(); + this.communityFb.updateValueAndValidity(); + } else { + this.communityFb.get('logoUrl').setValidators([StringUtils.urlValidator()]); + this.communityFb.updateValueAndValidity(); + } + })); + this.initPhoto(); + if (!isNew) { + if (!this.isAdmin) { + setTimeout(() => { + this.communityFb.get('shortName').disable(); + }, 0); + } + } + } + )); + } + + public get isAdmin() { + return Session.isPortalAdministrator(this.user); + } + + public get disabled(): boolean { + return (this.communityFb && this.communityFb.invalid) || + (this.communityFb && this.communityFb.pristine && !this.isNew && !this.file) || + (this.uploadError && this.uploadError.length > 0); + } + + public get dirty(): boolean { + return this.communityFb && this.communityFb.dirty; + } + + reset() { + this.uploadError = null; + this.communityFb = null; + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }); + } + + public save(callback: Function, errorCallback: Function = null) { + if (this.file) { + this.communityFb.get('shortName').enable(); + this.subscriptions.push(this.utilsService.uploadPhoto(this.properties.utilsService + "/upload/stakeholder/" + encodeURIComponent(this.communityFb.value.communityId), this.file).subscribe(res => { + this.deletePhoto(); + this.removePhoto(); + this.communityFb.get('logoUrl').setValue(res.filename); + this.saveCommunity(callback, errorCallback); + }, error => { + this.uploadError = "An error has been occurred during upload your image. Try again later"; + this.saveCommunity(callback, errorCallback); + })); + } else if (this.deleteCurrentPhoto) { + this.deletePhoto(); + this.saveCommunity(callback, errorCallback); + } else { + this.saveCommunity(callback, errorCallback); + } + } + + public saveCommunity(callback: Function, errorCallback: Function = null) { + if (this.isNew) { + this.removePhoto(); + this.subscriptions.push(this.communityService.updateCommunity( + this.properties.communityAPI + this.community.communityId, this.communityFb.value).subscribe(() => { + this.communityService.getCommunity(this.community.communityId, true).subscribe(community => { + UIkit.notification(community.shortTitle + ' has been successfully created', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + callback(community); + }); + }, error => { + UIkit.notification('An error has occurred. Please try again later', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + if (errorCallback) { + errorCallback(error) + } + })); + } else { + this.subscriptions.push(this.communityService.updateCommunity(this.properties.communityAPI + this.community.communityId, this.communityFb.value).subscribe(() => { + this.communityService.getCommunity(this.community.communityId, true).subscribe(community => { + UIkit.notification(community.shortTitle + ' has been successfully saved', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + callback(community); + }); + }, error => { + UIkit.notification('An error has occurred. Please try again later', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + })); + } + } + + fileChangeEvent(event) { + if (event.target.files && event.target.files[0]) { + this.file = event.target.files[0]; + if (this.file.type !== 'image/png' && this.file.type !== 'image/jpeg') { + this.uploadError = 'You must choose a file with type: image/png or image/jpeg!'; + this.communityFb.get('isUpload').setValue(false); + this.communityFb.get('isUpload').markAsDirty(); + this.removePhoto(); + } else if (this.file.size > this.maxsize) { + this.uploadError = 'File exceeds size\'s limit! Maximum resolution is 256x256 pixels.'; + this.communityFb.get('isUpload').setValue(false); + this.communityFb.get('isUpload').markAsDirty(); + this.removePhoto(); + } else { + this.uploadError = null; + const reader = new FileReader(); + reader.readAsDataURL(this.file); + reader.onload = () => { + this.photo = reader.result; + this.communityFb.get('isUpload').setValue(true); + this.communityFb.get('isUpload').markAsDirty(); + }; + } + } + } + + initPhoto() { + if (this.communityFb.value.isUpload) { + this.photo = this.properties.utilsService + "/download/" + this.communityFb.get('logoUrl').value; + } + } + + removePhoto() { + if (this.file) { + if (typeof document != 'undefined') { + (document.getElementById("photo")).value = ""; + } + this.initPhoto(); + this.file = null; + } + } + + remove() { + this.communityFb.get('isUpload').setValue(false); + this.communityFb.get('isUpload').markAsDirty(); + this.removePhoto(); + this.communityFb.get('logoUrl').setValue(null); + if (this.community.isUpload) { + this.deleteCurrentPhoto = true; + } + } + + public deletePhoto() { + if (this.community.logoUrl) { + this.subscriptions.push(this.utilsService.deletePhoto(this.properties.utilsService + '/delete/stakeholder/' + this.community.logoUrl).subscribe()); + } + } +} diff --git a/src/app/pages/community-info/profile/edit-community/edit-community.module.ts b/src/app/pages/community-info/profile/edit-community/edit-community.module.ts new file mode 100644 index 0000000..aeaf66c --- /dev/null +++ b/src/app/pages/community-info/profile/edit-community/edit-community.module.ts @@ -0,0 +1,24 @@ +import {NgModule} from "@angular/core"; +import {EditCommunityComponent} from "./edit-community.component"; +import {CommonModule} from "@angular/common"; +import {ReactiveFormsModule} from "@angular/forms"; +import {CKEditorModule} from 'ng2-ckeditor'; +// import { CKEditorModule } from 'ckeditor4-angular'; +import {InputModule} from "../../../../openaireLibrary/sharedComponents/input/input.module"; +import {IconsModule} from "../../../../openaireLibrary/utils/icons/icons.module"; +import {IconsService} from "../../../../openaireLibrary/utils/icons/icons.service"; +import {cloud_upload, edit, remove} from "../../../../openaireLibrary/utils/icons/icons"; + +@NgModule({ + imports: [CommonModule, ReactiveFormsModule, InputModule, IconsModule + , CKEditorModule + ], + declarations: [EditCommunityComponent], + exports: [EditCommunityComponent] +}) +export class EditCommunityModule { + + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([remove, edit, cloud_upload]) + } +} diff --git a/src/app/pages/community-info/profile/profile.component.ts b/src/app/pages/community-info/profile/profile.component.ts new file mode 100644 index 0000000..8de833b --- /dev/null +++ b/src/app/pages/community-info/profile/profile.component.ts @@ -0,0 +1,101 @@ +import {Component, OnDestroy, OnInit, ViewChild} from "@angular/core"; +import {CommunityInfo} from "../../../openaireLibrary/connect/community/communityInfo"; +import {EnvProperties} from "../../../openaireLibrary/utils/properties/env-properties"; +import {properties} from "../../../../environments/environment"; +import {EditCommunityComponent} from "./edit-community/edit-community.component"; +import {CommunityService} from "../../../openaireLibrary/connect/community/community.service"; +import {Title} from "@angular/platform-browser"; +import {Subscription} from "rxjs"; + +@Component({ + selector: 'community-profile', + template: ` +
+
+ +
+
+
+
+
+
+ Manage Community Profile +
+
+ {{community.shortTitle}} + (unsaved changes) +
+
+
+ + +
+
+
+
+
+ +
+
+ +
+
+
+
+ ` +}) +export class ProfileComponent implements OnInit, OnDestroy { + + public community: CommunityInfo; + public properties: EnvProperties = properties; + public loading: boolean = false; + private subscriptions: any[] = []; + @ViewChild('editCommunityComponent') editCommunityComponent: EditCommunityComponent; + + constructor(private communityService: CommunityService, + private title: Title) { + } + + ngOnInit() { + this.loading = true; + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { + this.community = community; + if (this.community) { + this.title.setTitle(this.community.communityId.toUpperCase() + " | Profile"); + setTimeout(() => { + this.reset(); + this.loading = false; + }, 200); + } + })); + } + + public reset() { + this.editCommunityComponent.init(this.community); + } + + public save() { + this.loading = true; + this.editCommunityComponent.save((community) => { + this.community = community; + this.reset(); + this.loading = false; + }, (error) => { + this.loading = false; + }); + } + + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }); + } +} diff --git a/src/app/pages/community-info/profile/profile.module.ts b/src/app/pages/community-info/profile/profile.module.ts new file mode 100644 index 0000000..ca8e55a --- /dev/null +++ b/src/app/pages/community-info/profile/profile.module.ts @@ -0,0 +1,27 @@ +import {NgModule} from '@angular/core'; +import {RouterModule} from "@angular/router"; +import {CommonModule} from "@angular/common"; +import {PageContentModule} from "../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; +import {ProfileComponent} from "./profile.component"; +import {EditCommunityModule} from "./edit-community/edit-community.module"; +import {LoadingModule} from "../../../openaireLibrary/utils/loading/loading.module"; +import {CommunityInfoModule} from "../community-info.module"; + +@NgModule({ + imports: [ + CommonModule, + RouterModule.forChild([ + { + path: '', component: ProfileComponent + } + ]), + PageContentModule, + EditCommunityModule, + LoadingModule, + CommunityInfoModule, + ], + declarations: [ProfileComponent], + exports: [ProfileComponent] +}) +export class ProfileModule { +} diff --git a/src/app/pages/community-routing.module.ts b/src/app/pages/community-routing.module.ts new file mode 100644 index 0000000..ae0007f --- /dev/null +++ b/src/app/pages/community-routing.module.ts @@ -0,0 +1,37 @@ +import {NgModule} from "@angular/core"; +import {RouterModule} from "@angular/router"; +import {ConnectRIGuard} from "../openaireLibrary/connect/communityGuard/connectRIGuard.guard"; + +@NgModule({ + imports: [RouterModule.forChild([ + { + path: 'info', + loadChildren: './community-info/community-info-routing.module#CommunityInfoRoutingModule', + }, + { + path: 'users', + loadChildren: './users/users-routing.module#UsersRoutingModule' + }, + { + path: 'mining', + loadChildren: './mining/mining.module#MiningModule', + canActivateChild: [ConnectRIGuard] + }, + { + path: 'admin-tools', + loadChildren: './admin-tools/admin-tools-routing.module#AdminToolsRoutingModule', + data: { + param: 'community' + } + }, + { + path: 'stats', + loadChildren: './stats/stats.module#StatsModule' + }, + { + path: 'customize-layout', + loadChildren: './customization/customization.module#CustomizationModule', + } + ])] +}) +export class CommunityRoutingModule {} diff --git a/src/app/pages/community/communities-routing.module.ts b/src/app/pages/community/communities-routing.module.ts deleted file mode 100644 index e2f09a0..0000000 --- a/src/app/pages/community/communities-routing.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommunitiesComponent} from './communities.component'; -import {AdminLoginGuard} from '../../openaireLibrary/login/adminLoginGuard.guard'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [AdminLoginGuard], component: CommunitiesComponent} - ]) - ] -}) -export class CommunitiesRoutingModule { } diff --git a/src/app/pages/community/communities.component.html b/src/app/pages/community/communities.component.html deleted file mode 100644 index a32a641..0000000 --- a/src/app/pages/community/communities.component.html +++ /dev/null @@ -1,112 +0,0 @@ -
- - -
-
-
- - - -
-
-
- -
- -
-
-
-
- -
-
-
-
- - - - - - - - - - - - - - - - - -
NameTypeActions
- -
{{check.community.name}}
-
-
{{check.community.type}}
-
-
- - -
-
- -
-
No communities found
-
-
-
-
-
-
-
-
- - -
- - - - - - - - - - - - - - diff --git a/src/app/pages/community/communities.component.ts b/src/app/pages/community/communities.component.ts deleted file mode 100644 index 86bf982..0000000 --- a/src/app/pages/community/communities.component.ts +++ /dev/null @@ -1,289 +0,0 @@ -/** - * Created by stefania on 7/13/17. - */ -import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { HelpContentService } from '../../services/help-content.service'; -import { FormGroup } from '@angular/forms'; -import { CommunityFormComponent } from './community-form.component'; -import { CheckPortal, Portal } from '../../domain/portal'; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Title} from '@angular/platform-browser'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'communities', - templateUrl: './communities.component.html', -}) - -export class CommunitiesComponent implements OnInit { - - // @ViewChild(ModalFormComponent) - // @ViewChild('saveModal') - // public modal:ModalFormComponent; - // - // @ViewChild('updateModal') - // public updateModal:ModalFormComponent; - - // @ViewChild('deleteConfirmationModal') - // public deleteConfirmationModal : DeleteConfirmationDialogComponent; - @ViewChild('AlertModalSaveCommunity') alertModalSaveCommunity; - @ViewChild('AlertModalUpdateCommunity') alertModalUpdateCommunity; - @ViewChild('AlertModalDeleteCommunities') alertModalDeleteCommunities; - private selectedCommunities: string[] = []; - - @ViewChild(CommunityFormComponent) - public formComponent: CommunityFormComponent; - - public checkboxes: CheckPortal[] = []; - - public communities: Portal[] = []; - - // public errorMessage: string; - - public formGroup: FormGroup; - - private searchText: RegExp = new RegExp(''); - public keyword = ''; - - public properties: EnvProperties = null; - - public showLoading = true; - public errorMessage = ''; - public updateErrorMessage = ''; - public modalErrorMessage = ''; - - ngOnInit() { - this.formGroup = this.formComponent.form; - - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | Communities'); - this.properties = data.envSpecific; - this.getCommunities(); - }); - } - - constructor(private element: ElementRef, private route: ActivatedRoute, - private title: Title, - private _router: Router, private _helpContentService: HelpContentService, - private _clearCacheService: ClearCacheService) {} - - - getCommunities() { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ''; - this.errorMessage = ''; - - - this._helpContentService.getCommunitiesFull( this.properties.adminToolsAPIURL).subscribe( - communities => { - this.communities = communities; - communities.forEach(_ => { - this.checkboxes.push({community : _, checked : false}); - }); - this.showLoading = false; - }, - error => this.handleError('System error retrieving communities', error)); - } - } - - // public showModal():void { - // this.modal.showModal(); - // } - - public toggleCheckBoxes(event) { - this.checkboxes.forEach(_ => _.checked = event.target.checked); - } - - public applyCheck(flag: boolean) { - this.checkboxes.forEach(_ => _.checked = flag); - } - - public getSelectedCommunities(): string[] { - return this.checkboxes.filter(community => community.checked === true). - map(checkedCommunity => checkedCommunity.community).map(res => res._id); - } - - private deleteCommunitiesFromArray(ids: string[]): void { - for (let id of ids) { - let i = this.checkboxes.findIndex(_ => _.community._id === id); - this.checkboxes.splice(i, 1); - } - } - - public confirmDeleteCommunity(id: string) { - // this.deleteConfirmationModal.ids = [id]; - // this.deleteConfirmationModal.showModal(); - this.selectedCommunities = [id]; - this.confirmModalOpen(); - } - - public confirmDeleteSelectedCommunities() { - // this.deleteConfirmationModal.ids = this.getSelectedCommunities(); - // this.deleteConfirmationModal.showModal(); - this.selectedCommunities = this.getSelectedCommunities(); - this.confirmModalOpen(); - } - - private confirmModalOpen() { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - this.alertModalDeleteCommunities.cancelButton = true; - this.alertModalDeleteCommunities.okButton = true; - this.alertModalDeleteCommunities.alertTitle = 'Delete Confirmation'; - this.alertModalDeleteCommunities.message = 'Are you sure you want to delete the selected community(-ies)?'; - this.alertModalDeleteCommunities.okButtonText = 'Yes'; - this.alertModalDeleteCommunities.open(); - } - } - - public confirmedDeleteCommunities(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ''; - - this._helpContentService.deleteCommunities(this.selectedCommunities, this.properties.adminToolsAPIURL). - subscribe( - _ => { - this.deleteCommunitiesFromArray(this.selectedCommunities); - this.showLoading = false; - this._clearCacheService.clearCache("communities deleted"); - }, - error => this.handleUpdateError('System error deleting the selected communities', error) - ); - } - } - - public editCommunity(i: number) { - const community: Portal = this.checkboxes[i].community; - this.formGroup.patchValue(community); - this.formGroup.controls['type'].disable(); - // this.updateModal.showModal(); - this.modalErrorMessage = ''; - this.communitiesModalOpen(this.alertModalUpdateCommunity, 'Update', 'Update Community'); - } - - public newCommunity() { - this.formGroup.controls['type'].enable(); - this.formComponent.reset(); - this.modalErrorMessage = ''; - this.communitiesModalOpen(this.alertModalSaveCommunity, 'Save', 'Add a new Community'); - } - - private communitiesModalOpen(modal: any, title: string, yesBtn: string) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - modal.cancelButton = true; - modal.okButton = true; - modal.alertTitle = title; - modal.okButtonText = yesBtn; - modal.open(); - } - } - - public communitySaveConfirmed(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if (!this.formGroup.valid) { - this.communitiesModalOpen(this.alertModalSaveCommunity, 'Save', 'Add a new Community'); - this.modalErrorMessage = 'Please fill in all required fields marked with *'; - } else { - this.modalErrorMessage = ''; - this._helpContentService.saveCommunity( this.formGroup.value, - this.properties.adminToolsAPIURL).subscribe( - community => { - this.communitySavedSuccessfully(community); - this._clearCacheService.clearCache("community saved"); - }, - error => this.handleUpdateError('System error creating community', error) - ); - } - } - } - - public communityUpdateConfirmed(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if (!this.formGroup.valid) { - this.communitiesModalOpen(this.alertModalUpdateCommunity, 'Update', 'Update Community'); - this.modalErrorMessage = 'Please fill in all required fields marked with *'; - } else { - this.formGroup.controls['type'].enable(); - this._helpContentService.updateCommunity( this.formGroup.value, - this.properties.adminToolsAPIURL).subscribe( - community => { - this.communityUpdatedSuccessfully(community); - this._clearCacheService.clearCache("community updated"); - }, - error => this.handleUpdateError('System error updating community', error) - ); - } - } - } - - public communitySavedSuccessfully(community: Portal) { - this.checkboxes.push({community : community, checked : false}); - this.applyCheck(false); - } - - public communityUpdatedSuccessfully(community: Portal) { - this.checkboxes.find(checkItem => checkItem.community._id === community._id).community = community; - this.applyCheck(false); - } - - public filterBySearch(text: string) { - this.searchText = new RegExp(text, 'i'); - this.applyFilter(); - } - - public applyFilter() { - this.checkboxes = []; - this.communities.filter(item => this.filterCommunities(item)).forEach( - _ => this.checkboxes.push({community: _, checked: false}) - ); - } - - public filterCommunities(community: Portal): boolean { - const textFlag = this.searchText.toString() === '' || (community.name || community.type).match(this.searchText) != null; - return textFlag; - } - - handleUpdateError(message: string, error) { - if (error == null) { - this.formComponent.reset(); - } else { - this.updateErrorMessage = message; - console.log('Server responded: ' + error); - } - - this.showLoading = false; - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } -} diff --git a/src/app/pages/community/communities.module.ts b/src/app/pages/community/communities.module.ts deleted file mode 100644 index 5e92de9..0000000 --- a/src/app/pages/community/communities.module.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import {CommunitiesComponent} from './communities.component'; -import {CommunityFormComponent} from './community-form.component'; -import {CommunitiesRoutingModule} from './communities-routing.module'; -import {RouterModule} from '@angular/router'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {FABModule} from '../../utils/fabModule.module'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {AdminLoginGuard} from '../../openaireLibrary/login/adminLoginGuard.guard'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, FABModule, AlertModalModule, - ReactiveFormsModule, - CommunitiesRoutingModule, RouterModule - ], - declarations: [CommunitiesComponent, CommunityFormComponent], - providers: [AdminLoginGuard], - exports: [CommunitiesComponent] -}) -export class CommunitiesModule { } diff --git a/src/app/pages/community/community-edit-form/community-edit-form-routing.module.ts b/src/app/pages/community/community-edit-form/community-edit-form-routing.module.ts deleted file mode 100644 index a2ad0e3..0000000 --- a/src/app/pages/community/community-edit-form/community-edit-form-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommunityEditFormComponent} from './community-edit-form.component'; -import {IsCommunity} from '../../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: CommunityEditFormComponent} - ]) - ] -}) -export class CommunityEditFormRoutingModule { } diff --git a/src/app/pages/community/community-edit-form/community-edit-form.component.html b/src/app/pages/community/community-edit-form/community-edit-form.component.html deleted file mode 100644 index 0a2797b..0000000 --- a/src/app/pages/community/community-edit-form/community-edit-form.component.html +++ /dev/null @@ -1,117 +0,0 @@ -
-
Manage community profile
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name * : -
Please add name.
-
Short Name: -
Description: -
Logo Url: -
Status: -
Managers: -
-
-
Please add a valid email.
- - - - - - -
- - - -
-
* Required fields
-
- - - - - - - - - - - - - -
-
- - - -
-
-
-
diff --git a/src/app/pages/community/community-edit-form/community-edit-form.component.ts b/src/app/pages/community/community-edit-form/community-edit-form.component.ts deleted file mode 100644 index 93229cd..0000000 --- a/src/app/pages/community/community-edit-form/community-edit-form.component.ts +++ /dev/null @@ -1,352 +0,0 @@ -import {Component, OnInit, Input, ElementRef} from '@angular/core'; -import {FormGroup, FormBuilder, Validators} from '@angular/forms'; -import {ActivatedRoute, Router} from '@angular/router'; - -import {HelpContentService} from '../../../services/help-content.service'; -import {CommunityService} from '../../../openaireLibrary/connect/community/community.service'; -import {SubscribeService} from '../../../openaireLibrary/utils/subscribe/subscribe.service'; -import {EmailService} from '../../../openaireLibrary/utils/email/email.service'; - -import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; -import {Email} from '../../../openaireLibrary/utils/email/email'; -import {Composer} from '../../../openaireLibrary/utils/email/composer'; -import {Validator} from '../../../openaireLibrary/utils/email/validator'; - -import {Session} from '../../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class"; -import {Title} from '@angular/platform-browser'; - -@Component({ - selector: 'community-edit-form', - templateUrl: './community-edit-form.component.html', -}) - -export class CommunityEditFormComponent implements OnInit{ - - @Input('group') - myForm: FormGroup; - - public showLoading = true; - public errorMessage = ''; - public updateErrorMessage = ''; - - public successfulSaveMessage = ''; - public successfulResetMessage = ''; - - public hasChanged = false; - - public res = []; - - params: any; - - public communityId = null; - public community = null; - public firstVersionOfManagers: string[]; - public newManagersToSubscribe: string[]; - - public email: Email; - - public emailToInform: Email; - - public note = ''; - - public properties: EnvProperties = null; - - constructor (private element: ElementRef, - private title: Title, - private route: ActivatedRoute, - private _router: Router, - public _fb: FormBuilder, - private _helpContentService: HelpContentService, - private _communityService: CommunityService, - private _subscribeService: SubscribeService, - private _emailService: EmailService) { } - - - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe( - communityId => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | Community Profile'); - this.communityId = communityId['communityId']; - - this.email = {body: '', subject: '', recipients: []}; - this.emailToInform = {body: '', subject: '', recipients: []}; - - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if (this.communityId != null && this.communityId !== '') { - this.showLoading = true; - this.updateErrorMessage = ''; - this.errorMessage = ''; - - this._communityService.getCommunity(this.properties, - this.properties.communityAPI + this.communityId).subscribe ( - community => { - this.community = community; - this.params = {community: encodeURIComponent( - '"' + community.queryId + '"')}; - this.firstVersionOfManagers = community.managers.slice(); - this.showLoading = false; - }, - error => this.handleError('System error retrieving community profile', error) - ); - } - } - }); - }); - } - - public addManager() { - this.community.managers.push(''); - } - - public removeManager(i: any) { - this.community.managers.splice(i, 1); - } - - // public addSubject() { - // this.community.subjects.push(""); - // } - // - // public removeSubject(i : any) { - // this.community.subjects.splice(i,1); - // } - - public resetForm(communityId: string) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { queryParams: - { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if (communityId != null && communityId !== '') { - this.showLoading = true; - this.updateErrorMessage = ''; - this.errorMessage = ''; - - this._communityService.getCommunity(this.properties, - this.properties.communityAPI + communityId).subscribe ( - community => { - this.community = community; - this.params = {community: encodeURIComponent( - '"' + community.queryId + '"')}; - this.showLoading = false; - this.handleSuccessfulReset('Form reset!'); - }, - error => this.handleError('System error retrieving community profile', error) - ); - } - this.resetChange(); - } - } - - public validEmail(email: string): boolean { - return Validator.emailValidator(email); - } - - public updateCommunity() { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { queryParams: - { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if (this.communityId != null && this.communityId !== '') { - const community = this.parseUpdatedCommunity(); - - if (!Validator.hasValidEmails(community['managers']) || !this.hasFilled(community['name'])) { - return; - } else { - this.showLoading = true; - const newManagers = this.getNewManagers(); - this._communityService.updateCommunity( - this.properties.communityAPI + this.communityId, community).subscribe( - - community => { - if (newManagers !== null) { - this.sendMailToNewManagers(newManagers); - this.informOldManagersForTheNewOnes(); - for (let i = 0; i < newManagers.length; i++) { - this._subscribeService.subscribeToCommunityByEmail(this.properties, this.communityId, newManagers[i]).subscribe( - res => { - // console.log(res); - } - ); - this._subscribeService.getCommunitySubscribers - (this.properties, this.communityId).subscribe( - res => { - // console.log(res); - } - ); - } - } - this.handleSuccessfulSave('Community saved!'); - }, - error => { - this.handleUpdateError('System error updating community profile', error); - }, - () => { this.firstVersionOfManagers = this.community['managers'].slice(); } - ); - this._router.navigate(['/community-edit-form'], { - queryParams: { 'communityId': this.communityId}}); - } - } - this.resetChange(); - } - } - - - private parseUpdatedCommunity(): {} { - const community = {}; - - community['name'] = this.community.title; - community['shortName'] = this.community.shortTitle; - community['status'] = this.community.status; - community['description'] = this.community.description; - community['logoUrl'] = this.community.logoUrl; - - community['managers'] = new Array(); - this.community.managers = this.getNonEmptyItems(this.community.managers); - community['managers'] = this.community.managers; - - return community; - } - - private getNewManagers(): Array { - - let newManagers = null; - for (let i = 0; i < this.community['managers'].length; i++) { - if (!this.firstVersionOfManagers.includes(this.community['managers'][i])) { - if(newManagers === null) { - newManagers = new Array(); - } - newManagers.push(this.community['managers'][i]); - } - } - return newManagers; - } - - private sendMailToNewManagers(managers: any) { - this._emailService.sendEmail(this.properties, - Composer.composeEmailForNewManager(this.communityId, - this.community.title, managers, this.properties.admins[0])).subscribe( - res => { - // console.log("The email has been sent successfully!") - }, - error => console.log(error) - ); - } - - private informOldManagersForTheNewOnes() { - this._emailService.notifyForNewManagers( - this.properties, this.communityId, - Composer.composeEmailToInformOldManagersForTheNewOnes(this.community.title, this.communityId, - this.firstVersionOfManagers, - this.community.managers, this.properties.admins[0])).subscribe( - res => { - // console.log("The email has been sent successfully!") - }, - error => console.log(error) - ); - } - - private subscribeNewManagers(newManagers: string[]): boolean { - return true; - } - - private getNonEmptyItems(data: string[]): string[] { - const length = data.length; - const arrayNonEmpty = new Array(); - - let j = 0; - for (let i = 0; i < length; i++) { - if (this.isEmpty(data[i])) { - // console.log(data[i]); - } else if (this.isNonEmpty(data[i])) { - arrayNonEmpty[j] = data[i]; - j++; - // console.log(data[i]); - } - } - return arrayNonEmpty; - } - - private hasFilled(data: any): boolean { - if (this.isNonEmpty(data) && !this.isEmpty(data)) { - return true; - } - return false; - } - - private isEmpty(data: string): boolean { - if (data !== undefined && !data.replace(/\s/g, '').length) { - return true; - } else { - return false; - - } - } - - private isNonEmpty(data: string): boolean { - if (data !== undefined && data != null) { - return true; - } else { - return false; - -} - } - - private change() { - this.hasChanged = true; - this.successfulSaveMessage = ''; - this.successfulResetMessage = ''; - } - - private resetChange() { - this.hasChanged = false; - } - - public get form() { - return this._fb.group({ - _id : '', - name : ['', Validators.required] - }); - } - - public reset() { - this.myForm.patchValue({ - name : '', - _id : '' - }); - } - - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } - - handleSuccessfulSave(message) { - this.showLoading = false; - this.successfulSaveMessage = message; - } - - handleSuccessfulReset(message) { - this.showLoading = false; - this.successfulResetMessage = message; - } - - trackByFn(index: any, item: any) { - return index; - } -} diff --git a/src/app/pages/community/community-edit-form/community-edit-form.module.ts b/src/app/pages/community/community-edit-form/community-edit-form.module.ts deleted file mode 100644 index 3dd58ae..0000000 --- a/src/app/pages/community/community-edit-form/community-edit-form.module.ts +++ /dev/null @@ -1,29 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; -import {FormsModule} from '@angular/forms'; -import {RouterModule} from '@angular/router'; - -import {CommunityEditFormComponent} from './community-edit-form.component'; - -import {CommunityService} from '../../../openaireLibrary/connect/community/community.service'; -import {EmailService} from '../../../openaireLibrary/utils/email/email.service'; -import {CommunityEditFormRoutingModule} from './community-edit-form-routing.module'; -import {IsCommunity} from '../../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; - -@NgModule({ - imports: [ - CommunityEditFormRoutingModule, CommonModule, FormsModule, RouterModule - ], - declarations: [ - CommunityEditFormComponent - ], - providers: [ - CommunityService, EmailService, IsCommunity, ConnectAdminLoginGuard - ], - exports: [ - CommunityEditFormComponent - ] -}) - -export class CommunityEditFormModule { } diff --git a/src/app/pages/community/community-form.component.html b/src/app/pages/community/community-form.component.html deleted file mode 100644 index c63ec86..0000000 --- a/src/app/pages/community/community-form.component.html +++ /dev/null @@ -1,20 +0,0 @@ -
-
- - -
-
- - -
-
- - -
- -
diff --git a/src/app/pages/community/community-form.component.ts b/src/app/pages/community/community-form.component.ts deleted file mode 100644 index 8b5dfb4..0000000 --- a/src/app/pages/community/community-form.component.ts +++ /dev/null @@ -1,44 +0,0 @@ -import {Component, OnInit, Input} from '@angular/core'; -import {FormGroup, FormBuilder, Validators} from "@angular/forms"; - -@Component({ - selector: 'community-form', - templateUrl: './community-form.component.html', -}) - -export class CommunityFormComponent implements OnInit{ - - @Input('group') - myForm: FormGroup; - - public errorMessage: string; - - constructor(public _fb: FormBuilder) {} - - ngOnInit(): void {} - - public get form() { - return this._fb.group({ - _id: '', - pid: ['', Validators.required], - name: ['', Validators.required], - type: ['', Validators.required] - }); - } - - public reset() { - this.myForm.patchValue({ - name : '', - _id : '', - pid: '', - type: '' - }); - } - - handleError(message: string, error) { - if(error == null) { - this.reset(); - } - this.errorMessage = message + ' (Server responded: ' + error + ')'; - } -} diff --git a/src/app/pages/community/content-providers/add-content-providers.component.html b/src/app/pages/community/content-providers/add-content-providers.component.html deleted file mode 100644 index fbf8d63..0000000 --- a/src/app/pages/community/content-providers/add-content-providers.component.html +++ /dev/null @@ -1,130 +0,0 @@ -
-
-
-
- - -
-
-
-
- -
- - Newly added content providers will be linked to your community on the next run of our algorithms. -
- - -
- - If you cannot find a content provider relevant to your community, probably it is not OpenAIRE compliant. - Feel free to contact us (feedback@openaire.eu) to let us know and we'll try to get the provider on board! -
- -
-
- - {{openaireSearchUtils.totalResults | number}} content providers, page {{openaireSearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
- - - -
-

For more results please try a new, more specific query

-
- -
-
- - {{openaireSearchUtils.totalResults | number}} content providers, page {{openaireSearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
diff --git a/src/app/pages/community/content-providers/add-content-providers.component.ts b/src/app/pages/community/content-providers/add-content-providers.component.ts deleted file mode 100644 index f2c7bc0..0000000 --- a/src/app/pages/community/content-providers/add-content-providers.component.ts +++ /dev/null @@ -1,218 +0,0 @@ -import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import {SearchResult} from '../../../openaireLibrary/utils/entities/searchResult'; -import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes'; -import {SearchFields, FieldDetails} from '../../../openaireLibrary/utils/properties/searchFields'; -import {SearchUtilsClass } from '../../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; -import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; -import {SearchDataprovidersService} from '../../../openaireLibrary/services/searchDataproviders.service'; -import {RouterHelper} from '../../../openaireLibrary/utils/routerHelper.class'; -import {DOI, StringUtils} from '../../../openaireLibrary/utils/string-utils.class'; -import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service'; -import {Session} from '../../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class'; - -@Component({ - selector: 'add-content-providers', - templateUrl: './add-content-providers.component.html', -}) - -export class AddContentProvidersComponent implements OnInit { - @Input() communityContentProviders = []; - - private community: string = ''; - - public openaireContentProviders = []; - public undo = {}; - public queryParameters: string = ""; - - public disableForms: boolean = false; - - public warningMessage = ""; - public infoMessage = ""; - - public rowsOnPage:number = 10; - - public routerHelper:RouterHelper = new RouterHelper(); - public errorCodes: ErrorCodes; - public openaireSearchUtils:SearchUtilsClass = new SearchUtilsClass(); - public properties:EnvProperties = null; - public pagingLimit:number = 0; - public resultsPerPage: number = 0; - - public subResults: any; subAdd: any; subRemove: any; - public body:string = "Send from page"; - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.pagingLimit = data.envSpecific.pagingLimit; - this.resultsPerPage =data.envSpecific.resultsPerPage; - - this.route.queryParams.subscribe(params => { - this.community = params['communityId']; - this._getOpenaireContentProviders("", 1, 10); - - var referrer = null; - if (typeof location !== 'undefined') { - referrer = location.href; - } - this.body = "[Please write your message here]"; - this.body = StringUtils.URIEncode(this.body); - }); - }); - } - - constructor(private route: ActivatedRoute, private _router: Router, private _searchContentProvidersService: SearchDataprovidersService, private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService) { - this.errorCodes = new ErrorCodes(); - this.openaireSearchUtils.status = this.errorCodes.LOADING; - } - - public ngOnDestroy() { - if(this.subResults){ - this.subResults.unsubscribe(); - } - if(this.subAdd) { - this.subAdd.unsubscribe(); - } - if(this.subRemove) { - this.subRemove.unsubscribe(); - } - } - - public addContentProvider(contenProvider: SearchResult) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subAdd = this._manageCommunityContentProvidersService.addContentProvider(this.properties, this.community, contenProvider).subscribe( - data => { - this.undo[contenProvider.id] = data.id; - }, - err => { - console.log(err.status); - }/*, - () => { - console.info("completed ADD"); - }*/ - ); - } - } - - public removeContentProvider(contentProviderId: string, communityContentProviderId: string) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subRemove = this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community, contentProviderId).subscribe( - data => { - //console.info(data); - }, - err => { - console.log(err); - }, - () => { - this.undo[communityContentProviderId] = ""; - } - ) - } - } - - public inCommunity(contentProvider: any): any { - for(let communityContentProvider of this.communityContentProviders) { - if(communityContentProvider.openaireId == contentProvider.id) { - return true; - } - } - - if(this.undo[contentProvider.id]) { - return true; - } - return false; - } - - private _getOpenaireContentProviders(parameters:string, page: number, size: number){ - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - if(page > this.pagingLimit) { - size=0; - } - - if(this.openaireSearchUtils.status == this.errorCodes.LOADING) { - this.openaireSearchUtils.status = this.errorCodes.LOADING; - - this.disableForms = true; - this.openaireContentProviders = []; - this.openaireSearchUtils.totalResults = 0; - - this.subResults = this._searchContentProvidersService.searchDataproviders(parameters, null, page, size, [], this.properties).subscribe( - data => { - this.undo = {}; - this.openaireSearchUtils.totalResults = data[0]; - this.openaireContentProviders = data[1]; - - this.openaireSearchUtils.status = this.errorCodes.DONE; - if(this.openaireSearchUtils.totalResults == 0 ){ - this.openaireSearchUtils.status = this.errorCodes.NONE; - } - - this.disableForms = false; - - if(this.openaireSearchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.openaireSearchUtils.totalResults/(this.openaireSearchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.openaireSearchUtils.totalResults = 0; - this.openaireSearchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - console.log(err); - //TODO check erros (service not available, bad request) - if(err.status == '404') { - this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.openaireSearchUtils.status = this.errorCodes.ERROR; - } else { - this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE; - } - - this.disableForms = false; - } - ); - } - } - } - - totalPages(): number { - let totalPages:any = this.openaireSearchUtils.totalResults/(this.rowsOnPage); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - return totalPages; - } - - keywordChanged(keyword) { - this.openaireSearchUtils.keyword = keyword; - this.buildQueryParameters(); - this.goTo(1); - } - - buildQueryParameters() { - this.queryParameters = ""; - - if(this.openaireSearchUtils.keyword) { - this.queryParameters = "q="+StringUtils.URIEncode(this.openaireSearchUtils.keyword); - } - } - - goTo(page:number = 1){ - this.openaireSearchUtils.page=page; - this.openaireSearchUtils.status = this.errorCodes.LOADING; - this._getOpenaireContentProviders(this.queryParameters, page, 10); - } -} diff --git a/src/app/pages/community/content-providers/communityContentProviders-routing.module.ts b/src/app/pages/community/content-providers/communityContentProviders-routing.module.ts deleted file mode 100644 index 9a16d8e..0000000 --- a/src/app/pages/community/content-providers/communityContentProviders-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {ManageContentProvidersComponent} from './manage-content-providers.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: ManageContentProvidersComponent} - ]) - ] -}) -export class CommunityContentProvidersRoutingModule { } diff --git a/src/app/pages/community/content-providers/communityContentProviders.module.ts b/src/app/pages/community/content-providers/communityContentProviders.module.ts deleted file mode 100644 index a432dbf..0000000 --- a/src/app/pages/community/content-providers/communityContentProviders.module.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { NgModule } from '@angular/core'; -import { HttpClientModule } from '@angular/common/http'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; - -import { EnvironmentSpecificResolver } from '../../../openaireLibrary/utils/properties/environmentSpecificResolver'; -import { EnvironmentSpecificService } from '../../../openaireLibrary/utils/properties/environment-specific.service'; - -import { DataTablesModule } from 'angular-datatables'; -import { ManageContentProvidersComponent } from './manage-content-providers.component'; -import { ManageCommunityContentProvidersService } from '../../../services/manageContentProviders.service'; -import {SearchDataprovidersServiceModule} from '../../../openaireLibrary/connect/contentProviders/searchDataprovidersService.module'; - -import { RemoveContentProvidersComponent } from './remove-content-providers.component'; -import { AddContentProvidersComponent } from './add-content-providers.component'; -import { SearchDataprovidersService } from '../../../openaireLibrary/services/searchDataproviders.service'; -import { PagingModule } from '../../../openaireLibrary/utils/paging.module'; -import { SearchPagingModule } from '../../../openaireLibrary/searchPages/searchUtils/searchPaging.module'; - -import {ErrorMessagesModule} from '../../../openaireLibrary/utils/errorMessages.module'; -import {AlertModalModule} from '../../../openaireLibrary/utils/modal/alertModal.module'; -import {FABModule} from '../../../utils/fabModule.module'; -import {CommonModule} from '@angular/common'; -import {CommunityContentProvidersRoutingModule} from './communityContentProviders-routing.module'; - -@NgModule({ - imports: [ - CommonModule, - HttpClientModule, - FormsModule, - FormsModule, - ReactiveFormsModule, - RouterModule, - DataTablesModule, - PagingModule, SearchPagingModule, - ErrorMessagesModule, - AlertModalModule, - SearchDataprovidersServiceModule, - FABModule, - CommunityContentProvidersRoutingModule - ], - declarations: [ - ManageContentProvidersComponent, - RemoveContentProvidersComponent, - AddContentProvidersComponent - ], - providers: [ - ManageCommunityContentProvidersService, - SearchDataprovidersService, - EnvironmentSpecificResolver, EnvironmentSpecificService - ], - exports: [ManageContentProvidersComponent] -}) - -export class CommunityContentProvidersModule { } diff --git a/src/app/pages/community/content-providers/criteria/criteria-routing.module.ts b/src/app/pages/community/content-providers/criteria/criteria-routing.module.ts deleted file mode 100644 index 90a3a97..0000000 --- a/src/app/pages/community/content-providers/criteria/criteria-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {CriteriaComponent} from './criteria.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: CriteriaComponent} - ]) - ] -}) -export class CriteriaRoutingModule { } diff --git a/src/app/pages/community/content-providers/criteria/criteria.component.html b/src/app/pages/community/content-providers/criteria/criteria.component.html deleted file mode 100644 index a7881f0..0000000 --- a/src/app/pages/community/content-providers/criteria/criteria.component.html +++ /dev/null @@ -1,108 +0,0 @@ - -
-
-
- -
- Criteria for
- {{dataProvider.officialname}} -
-
-
- -
-
-
- -
- If no criteria are specified, all research results of this content provider will be included in your community. -
-
-
- Add criteria to limit research results.
- Results which satisfy any of the above criteria will be included in your community. -
- -
-
- No criteria are specified -
-
-
-
-
- Criterion {{i + 1}}
-
-
-
- -
-
- -
-
- -
-
-
-
-
- -
-
- -
-
- -
-
- AND -
-
- -
-
- -
-
-
-
- - Add Constraint -
-
-
-
-
-
- - Add Criterion -
-
diff --git a/src/app/pages/community/content-providers/criteria/criteria.component.ts b/src/app/pages/community/content-providers/criteria/criteria.component.ts deleted file mode 100644 index f7001bf..0000000 --- a/src/app/pages/community/content-providers/criteria/criteria.component.ts +++ /dev/null @@ -1,138 +0,0 @@ -import {Component, OnInit} from '@angular/core'; -import {ActivatedRoute, Router} from '@angular/router'; -import {HelperFunctions} from '../../../../openaireLibrary/utils/HelperFunctions.class'; -import {SearchCommunityDataprovidersService} from '../../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; -import {EnvProperties} from '../../../../openaireLibrary/utils/properties/env-properties'; -import {ContentProvider} from '../../../../openaireLibrary/utils/entities/contentProvider'; -import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms'; -import {ManageCommunityContentProvidersService} from '../../../../services/manageContentProviders.service'; -import {Title} from '@angular/platform-browser'; - -@Component({ - selector: 'criteria', - templateUrl: './criteria.component.html' -}) - -export class CriteriaComponent implements OnInit { - public community: string = ''; - public openaireId: string = ''; - public dataProvider: ContentProvider = null; - public selectioncriteria: FormGroup; - private properties: EnvProperties; - showLoading = true; - public errorMessage: string; - - constructor(private route: ActivatedRoute, private _router: Router, - private title: Title, - private searchCommunityDataprovidersService: SearchCommunityDataprovidersService, - private manageCommunityContentProvidersService: ManageCommunityContentProvidersService, - private fb: FormBuilder) { - } - - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe(params => { - if (params['communityId']) { - this.community = params['communityId']; - } - if (params['openaireId']) { - this.openaireId = params['openaireId']; - } - this.title.setTitle('Administration Dashboard | Criteria'); - this.searchCommunityDataprovidersService.searchDataproviders(this.properties, this.community).subscribe(dataProviders => { - dataProviders.forEach(dataProvider => { - if (dataProvider.openaireId == this.openaireId) { - this.dataProvider = dataProvider; - } - }); - if (!this.dataProvider) { - this._router.navigate(['manage-content-providers'], - {queryParams: {'communityId': this.community}}); - } - this.buildForm(); - this.showLoading = false; - }); - HelperFunctions.scroll(); - }); - }); - } - - public ngOnDestroy() { - } - - buildForm() { - this.selectioncriteria = this.fb.group({ - criteria: this.fb.array([]) - }); - let selectionCriteria = this.dataProvider.selectioncriteria; - if (selectionCriteria) { - selectionCriteria.criteria.forEach(criterion => { - let constraintArray: FormArray = this.fb.array([]); - criterion.constraint.forEach(constraint => { - constraintArray.push(this.fb.group({ - field: this.fb.control(constraint.field, Validators.required), - verb: this.fb.control(constraint.verb, Validators.required), - value: this.fb.control(constraint.value, Validators.required) - })); - }); - this.criteria.push(this.fb.group({ - constraint: constraintArray - })); - }); - } - } - - public get criteria(): FormArray { - return this.selectioncriteria.get('criteria') as FormArray; - } - - public getConstraint(i: number): FormArray { - return this.criteria.at(i).get('constraint') as FormArray; - } - - public addCriteria() { - let constraintArray: FormArray = this.fb.array([ - this.fb.group({ - field: this.fb.control('', Validators.required), - verb: this.fb.control('contains', Validators.required), - value: this.fb.control('', Validators.required) - }) - ]); - this.criteria.push(this.fb.group({ - constraint: constraintArray - })); - } - - public addConstraint(i: number) { - let constraintArray: FormArray = this.criteria.at(i).get('constraint') as FormArray; - constraintArray.push(this.fb.group({ - field: this.fb.control('', Validators.required), - verb: this.fb.control('contains', Validators.required), - value: this.fb.control('', Validators.required) - })); - } - - public removeConstraint(i: number, j: number) { - let constraintArray: FormArray = this.criteria.at(i).get('constraint') as FormArray; - constraintArray.removeAt(j); - if (constraintArray.length === 0) { - this.criteria.removeAt(i); - } - } - - save() { - this.errorMessage = null; - if (this.selectioncriteria.status === 'VALID') { - this.dataProvider.selectioncriteria = this.selectioncriteria.value; - this.manageCommunityContentProvidersService. - saveContentProvider(this.properties, this.dataProvider).subscribe( () => { - this._router.navigate(['manage-content-providers'], { - queryParams: {communityId: this.dataProvider.communityId} - }); - }); - } else { - this.errorMessage = 'Please fill all fields of each constraint or remove all constraints with empty fields.'; - } - } -} diff --git a/src/app/pages/community/content-providers/criteria/criteria.module.ts b/src/app/pages/community/content-providers/criteria/criteria.module.ts deleted file mode 100644 index 13c7d63..0000000 --- a/src/app/pages/community/content-providers/criteria/criteria.module.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {NgModule} from '@angular/core'; - -import {EnvironmentSpecificResolver} from '../../../../openaireLibrary/utils/properties/environmentSpecificResolver'; -import {EnvironmentSpecificService} from '../../../../openaireLibrary/utils/properties/environment-specific.service'; -import {CommonModule} from '@angular/common'; -import {CriteriaComponent} from './criteria.component'; -import {CriteriaRoutingModule} from './criteria-routing.module'; -import {SearchCommunityDataprovidersService} from '../../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; -import {RouterModule} from '@angular/router'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {ManageCommunityContentProvidersService} from '../../../../services/manageContentProviders.service'; - -@NgModule({ - imports: [ - CommonModule, - CriteriaRoutingModule, - RouterModule, - FormsModule, - ReactiveFormsModule, - ], - declarations: [ - CriteriaComponent - ], - providers: [ - SearchCommunityDataprovidersService, - ManageCommunityContentProvidersService, - EnvironmentSpecificResolver, EnvironmentSpecificService - ], - exports: [CriteriaComponent] -}) - -export class CriteriaModule { } diff --git a/src/app/pages/community/content-providers/manage-content-providers.component.ts b/src/app/pages/community/content-providers/manage-content-providers.component.ts deleted file mode 100644 index bf1a21f..0000000 --- a/src/app/pages/community/content-providers/manage-content-providers.component.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { Component, ViewChild, OnInit, ViewEncapsulation, Input, ElementRef } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; - -import {RemoveContentProvidersComponent} from './remove-content-providers.component'; -import {AddContentProvidersComponent} from './add-content-providers.component'; - -import {Session} from '../../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class"; -import {Title} from '@angular/platform-browser'; - -@Component({ - selector: 'manage-content-providers', - template: ` -
- - -
- - -
- -
- ` -}) - -export class ManageContentProvidersComponent implements OnInit { - private community: string = ''; - - @Input() communityContentProviders =[]; - @ViewChild (RemoveContentProvidersComponent) removeContentProvidersComponent : RemoveContentProvidersComponent ; - @ViewChild (AddContentProvidersComponent) addContentProvidersComponent : AddContentProvidersComponent ; - - public warningMessage = ""; - public infoMessage = ""; - - public toggle: boolean = true; - public updateCommunityContentProvidersOnToggle: boolean = false; - public pageTitle: string = "Manage content providers"; - public toggleLinkMessage: string = "Manage content providers"; - - ngOnInit() { - this.route.queryParams.subscribe(params => { - if(params['communityId']) { - this.community = params['communityId']; - this.title.setTitle('Administration Dashboard | Content Providers'); - } - HelperFunctions.scroll(); - }); - } - - constructor(private element: ElementRef, - private title: Title, - private route: ActivatedRoute, private _router: Router) {} - - public ngOnDestroy() {} - - public updateCommunityContentProviders() { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - HelperFunctions.scroll(); - - this.toggle = !this.toggle; - if(this.toggle) { - this.pageTitle = "Manage content providers"; - //this.toggleLinkMessage = "Missing content providers?"; - - this.removeContentProvidersComponent._getCommunityContentProviders(); - this.addContentProvidersComponent.undo = {}; - } else { - this.updateCommunityContentProvidersOnToggle = false; - this.pageTitle = "Search content providers"; - //this.toggleLinkMessage = "Manage content providers"; - } - } - } - - public communityContentProvidersChanged($event) { - this.communityContentProviders = $event.value; - } -} diff --git a/src/app/pages/community/content-providers/remove-content-providers.component.html b/src/app/pages/community/content-providers/remove-content-providers.component.html deleted file mode 100644 index 87f88e9..0000000 --- a/src/app/pages/community/content-providers/remove-content-providers.component.html +++ /dev/null @@ -1,99 +0,0 @@ -
-
-
-
- - -
-
-
-
-
-
- All the research results collected from the content providers specified here will be automatically linked to your - community dashboard. -
- -
- - -
-
- - {{communitySearchUtils.totalResults | number}} content providers, page {{communitySearchUtils.page | number}} - of {{(totalPages()) | number}} - - - - -
-
- - -
-
- - - - - - - - - - - - - - - - - -
NameOfficial NameCriteriaAction
- - {{result.name}} - [no name available] - - - - {{result.officialname}} - - - - - {{getCriteriaLabel(result.selectioncriteria)}} - - - -
-
-
- -
-
- - {{communitySearchUtils.totalResults | number}} content providers, page {{communitySearchUtils.page | number}} - of {{(totalPages()) | number}} - - - - -
-
- - diff --git a/src/app/pages/community/content-providers/remove-content-providers.component.ts b/src/app/pages/community/content-providers/remove-content-providers.component.ts deleted file mode 100644 index 15527bf..0000000 --- a/src/app/pages/community/content-providers/remove-content-providers.component.ts +++ /dev/null @@ -1,329 +0,0 @@ -import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import { Subject } from 'rxjs'; -import { DataTableDirective } from 'angular-datatables'; - -import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes'; -import {SearchUtilsClass } from '../../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; -import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; -import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service'; -import {SearchCommunityDataprovidersService} from '../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; -import {RouterHelper} from '../../../openaireLibrary/utils/routerHelper.class'; -import {DOI, StringUtils} from '../../../openaireLibrary/utils/string-utils.class'; - -import {Session} from '../../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class'; -import {SelectionCriteria} from '../../../openaireLibrary/utils/entities/contentProvider'; -import {CriteriaComponent} from './criteria/criteria.component'; - -@Component({ - selector: 'remove-content-providers', - templateUrl: './remove-content-providers.component.html', - styles: [` - #dpTable_info, #dpTable_paginate, #dpTable_length, #dpTable_filter{ - display: none; - } - - `], - encapsulation: ViewEncapsulation.None // this used in order styles to work -}) - -export class RemoveContentProvidersComponent implements OnInit { - public routerHelper:RouterHelper = new RouterHelper(); - - private community: string = ''; - public communityUrl: string = "https://beta.explore.openaire.eu"; - - private errorCodes: ErrorCodes; - - @Output() communityContentProvidersChanged = new EventEmitter(); - public communityContentProviders = []; - public communitySearchUtils:SearchUtilsClass = new SearchUtilsClass(); - - public sub: any; public subResults: any; subRemove: any; - properties:EnvProperties; - - public disableForms: boolean = false; - - dtOptions: DataTables.Settings = {}; - showTable = false; filteringAdded = false; - @ViewChild(DataTableDirective) datatableElement: DataTableDirective; - dtTrigger: Subject = new Subject(); //necessary - - public rowsOnPage:number = 10; - - public queryParameters: string = ""; - - public query = ''; - public selectedContentProviders=[] ; - public elementRef; - - public contentProviders:string[]; - private triggered: boolean = false; - - private selectedCommunityContentProvider: any; - - @ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity; - - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - }); - - this.route.queryParams.subscribe(params => { - if(params['communityId']) { - this.community = params['communityId']; - this.communityUrl = "https://beta."+this.community+".openaire.eu"; - - this._getCommunityContentProviders(); - } - }); - - this.dtOptions = { - "pageLength": this.rowsOnPage, - "language": { - "search": "", - "searchPlaceholder": "Search content providers..." - } - }; - - this.communitySearchUtils.keyword = ""; - } - - constructor(private route: ActivatedRoute, private _router: Router, - private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService, - private _searchCommunityContentProvidersService: SearchCommunityDataprovidersService) { - this.errorCodes = new ErrorCodes(); - this.communitySearchUtils.status = this.errorCodes.LOADING; - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } - if(this.subRemove){ - this.subRemove.unsubscribe(); - } - - $.fn['dataTable'].ext.search.pop(); - } - - rerender(): void { - this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => { - // Destroy the table first - dtInstance.destroy(); - - // Call the dtTrigger to rerender again - this.dtTrigger.next(); - }); - } - - ngAfterViewInit(): void { - $.fn['dataTable'].ext.search.push((settings, data, dataIndex) => { - - if (this.filterData(data, this.communitySearchUtils.keyword)) { - return true; - } - return false; - }); - - //console.info("ngAfterViewInit"); - } - - public getCriteriaLabel(selectionCriteria: SelectionCriteria): string { - if(selectionCriteria && selectionCriteria.criteria.length > 0) { - return (selectionCriteria.criteria.length === 1)?'1 criterion':(selectionCriteria.criteria.length + ' criteria') - } else { - return 'no criteria'; - } - } - - filterData(row: any, query: string) { - let returnValue: boolean = false; - - if(query) { - for(var i=0; i <2; i++){ - var r= this.filterQuery(row[i], query); - if(r) { - returnValue = true; - break; - } - } - - if(!returnValue) { - return false; - } - } - - return true; - } - - filterQuery(data, query){ - if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){ - return true; - }else{ - return false; - } - } - - - /* - Trigger a table draw in order to get the initial filtering - */ - triggerInitialLoad(){ - this.triggered = true; - //console.info("triggerInitialLoad"); - setTimeout(function(){ - var table = ($('#dpTable')).DataTable(); - table.page( 0 ).draw( false ); - }, 500); - this.dtTrigger.next(); - } - - goTo(page:number = 1){ - this.communitySearchUtils.page=page; - - var table = $('#dpTable').DataTable(); - table.page( page - 1 ).draw( false ); - - var info = table.page.info(); - this.communitySearchUtils.totalResults = info.recordsDisplay; - } - - totalPages(): number { - let totalPages:any = this.communitySearchUtils.totalResults/(this.rowsOnPage); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - return totalPages; - } - - public confirmedDeleteContentProvider(data : any) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subRemove = this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community, this.selectedCommunityContentProvider.id).subscribe( - data => { - //console.info(data); - }, - err => { - console.log(err); - }, - () => { - let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider); - this.communityContentProviders.splice(index, 1); - - this.communitySearchUtils.totalResults--; - this.communitySearchUtils.page=1; - - this.rerender(); - } - ) - } - } - - public removeContentProvider(communityContentProvider: any) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.selectedCommunityContentProvider = communityContentProvider; - this.alertModalDeleteCommunity.cancelButton = true; - this.alertModalDeleteCommunity.okButton = true; - this.alertModalDeleteCommunity.alertTitle = "Remove content provider?"; - let title = ""; - if(communityContentProvider.name) { - title = communityContentProvider.name; - } - if(communityContentProvider.name && communityContentProvider.acronym) { - title += " ("; - } - if(communityContentProvider.acronym) { - title += communityContentProvider.acronym; - } - if(communityContentProvider.name && communityContentProvider.acronym) { - title += ") "; - } - this.alertModalDeleteCommunity.message = "Content Provider"; - if(title) { - this.alertModalDeleteCommunity.message += " '"+title+"' "; - } - this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?"; - this.alertModalDeleteCommunity.okButtonText = "Yes"; - this.alertModalDeleteCommunity.open(); - } - } - - public _getCommunityContentProviders(){ - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.communitySearchUtils.status = this.errorCodes.LOADING; - this.disableForms = true; - this.communityContentProviders = []; - this.communitySearchUtils.totalResults = 0; - this.communitySearchUtils.page=1; - this.communitySearchUtils.keyword = ""; - - this.subResults = this._searchCommunityContentProvidersService.searchDataproviders(this.properties, this.community).subscribe( - data => { - //console.info("search Content Providers [total communityContentProviders:"+data.length+"]"); - this.communityContentProviders = data; - - this.communitySearchUtils.totalResults = data.length; - this.communitySearchUtils.status = this.errorCodes.DONE; - // if(this.communitySearchUtils.totalResults == 0 ){ - // this.communitySearchUtils.status = this.errorCodes.NONE; - // } - this.disableForms = false; - if(!this.triggered) { - this.triggerInitialLoad(); - } else { - var table = $('#dpTable').DataTable(); - table.clear(); - - this.rerender(); - } - - this.communityContentProvidersChanged.emit({ - value: this.communityContentProviders, - }); - }, - err => { - console.log(err); - //TODO check erros (service not available, bad request) - - if(err.status == '404') { - this.communitySearchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.communitySearchUtils.status = this.errorCodes.ERROR; - } else { - this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE; - } - - this.disableForms = false; - if(!this.triggered) { - this.triggerInitialLoad(); - } else { - var table = $('#dpTable').DataTable(); - table.clear(); - - this.rerender(); - } - } - ); - } - } - - goToCriteria(openaireId: string) { - this._router.navigate(['criteria'], { - queryParams: { - communityId: this.community, - openaireId: openaireId - }, - relativeTo: this.route - }) - } -} diff --git a/src/app/pages/community/projects/add-projects.component.html b/src/app/pages/community/projects/add-projects.component.html deleted file mode 100644 index 5ccd78a..0000000 --- a/src/app/pages/community/projects/add-projects.component.html +++ /dev/null @@ -1,132 +0,0 @@ -
-
-
-
- -
-
-
-
-
-
- - -
-
-
-
- -
- -Newly added projects will be linked to your community on the next run of our algorithms. - - - -
-
- -If you cannot find a funder that is relevant for your community, please contact us (feedback@openaire.eu) and we'll try to get the funder on board! - - -
- - -
- - If you wish to suggest a new funder to include or report a missing project, please contact us via - feedback@openaire.eu. -
- -
-
- - {{openaireSearchUtils.totalResults | number}} projects, page {{openaireSearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
- - - -
-

For more results please try a new, more specific query

-
- -
-
- - {{openaireSearchUtils.totalResults | number}} projects, page {{openaireSearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
diff --git a/src/app/pages/community/projects/add-projects.component.ts b/src/app/pages/community/projects/add-projects.component.ts deleted file mode 100644 index 7af77ab..0000000 --- a/src/app/pages/community/projects/add-projects.component.ts +++ /dev/null @@ -1,260 +0,0 @@ -import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -//import { Subject } from 'rxjs/Subject'; -import {SearchResult} from '../../../openaireLibrary/utils/entities/searchResult'; -import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes'; -import {SearchFields, FieldDetails} from '../../../openaireLibrary/utils/properties/searchFields'; -import {SearchUtilsClass } from '../../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; -import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; -import {SearchProjectsService} from '../../../openaireLibrary/services/searchProjects.service'; -import {RouterHelper} from '../../../openaireLibrary/utils/routerHelper.class'; -import {DOI, StringUtils} from '../../../openaireLibrary/utils/string-utils.class'; -import {ManageCommunityProjectsService} from '../../../services/manageProjects.service'; - -import {Session} from '../../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class'; - -@Component({ - selector: 'add-projects', - templateUrl: './add-projects.component.html', -}) - -export class AddProjectsComponent implements OnInit { - @Input() communityProjects = []; - //@Output() communityProjectsChanged = new EventEmitter(); - - private community: string = ''; - - public openaireProjects = []; - public undo = {}; - public queryParameters: string = ""; - - public funders:string[]; - public selectedFunderId:string ="0"; - selectedFunderName:string ="Select funder:"; - - public disableForms: boolean = false; - - public warningMessage = ""; - public infoMessage = ""; - - public rowsOnPage:number = 10; - - public routerHelper:RouterHelper = new RouterHelper(); - public errorCodes: ErrorCodes; - public openaireSearchUtils:SearchUtilsClass = new SearchUtilsClass(); - public properties:EnvProperties = null; - public pagingLimit:number = 0; - public resultsPerPage: number = 0; - - public subFunders: any; public subResults: any; subAdd: any; subRemove: any; - public body:string = "Send from page"; - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.pagingLimit = data.envSpecific.pagingLimit; - this.resultsPerPage =data.envSpecific.resultsPerPage; - - this.route.queryParams.subscribe(params => { - this.community = params['communityId']; - this.getFunders(); - this._getOpenaireProjects("", 1, 10); - - var referrer = null; - if (typeof location !== 'undefined') { - referrer = location.href; - } - this.body = "[Please write your message here]"; - this.body = StringUtils.URIEncode(this.body); - }); - }); - } - - constructor(private route: ActivatedRoute, private _router: Router, private _searchProjectsService: SearchProjectsService, private _manageCommunityProjectsService: ManageCommunityProjectsService) { - this.errorCodes = new ErrorCodes(); - this.openaireSearchUtils.status = this.errorCodes.LOADING; - } - - public ngOnDestroy() { - if(this.subFunders){ - this.subFunders.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } - if(this.subAdd) { - this.subAdd.unsubscribe(); - } - if(this.subRemove) { - this.subRemove.unsubscribe(); - } - } - - public addProject(project: SearchResult) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subAdd = this._manageCommunityProjectsService.addProject(this.properties, this.community, project).subscribe( - data => { - this.undo[project.id] = data.id; - }, - err => { - console.log(err.status); - }/*, - () => { - console.info("completed ADD"); - }*/ - ); - } - } - - public removeProject(projectId: string, communityProjectId: string) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subRemove = this._manageCommunityProjectsService.removeProject(this.properties, this.community, projectId).subscribe( - data => { - //console.info(data); - }, - err => { - console.log(err); - }, - () => { - this.undo[communityProjectId] = ""; - } - ) - } - } - - public inCommunity(project: any): any { - for(let communityProject of this.communityProjects) { - if(communityProject.openaireId == project.id) { - return true; - } else if(project.code == communityProject.grantId && project.funderShortname == communityProject.funder) { - return true; - } - } - - if(this.undo[project.id]) { - return true; - } - return false; - } - - getFunders () { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subFunders = this._searchProjectsService.getFunders(this.properties).subscribe( - data => { - this.funders = data[1]; - }, - err => console.log(err) - ); - } - } - - private _getOpenaireProjects(parameters:string, page: number, size: number){ - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - if(page > this.pagingLimit) { - size=0; - } - - if(this.openaireSearchUtils.status == this.errorCodes.LOADING) { - this.openaireSearchUtils.status = this.errorCodes.LOADING; - - this.disableForms = true; - this.openaireProjects = []; - this.openaireSearchUtils.totalResults = 0; - - this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, [], this.properties).subscribe( - data => { - this.undo = {}; - //console.info("total openaire projects = "+data[0]); - this.openaireSearchUtils.totalResults = data[0]; - this.openaireProjects = data[1]; - - //this.searchPage.checkSelectedFilters(this.filters); - - this.openaireSearchUtils.status = this.errorCodes.DONE; - if(this.openaireSearchUtils.totalResults == 0 ){ - this.openaireSearchUtils.status = this.errorCodes.NONE; - } - - this.disableForms = false; - - if(this.openaireSearchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.openaireSearchUtils.totalResults/(this.openaireSearchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.openaireSearchUtils.totalResults = 0; - this.openaireSearchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - console.log(err); - //TODO check erros (service not available, bad request) - if(err.status == '404') { - this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.openaireSearchUtils.status = this.errorCodes.ERROR; - } else { - this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE; - } - - this.disableForms = false; - } - ); - } - } - } - - totalPages(): number { - let totalPages:any = this.openaireSearchUtils.totalResults/(this.rowsOnPage); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - return totalPages; - } - - keywordChanged(keyword) { - this.openaireSearchUtils.keyword = keyword; - this.buildQueryParameters(); - this.goTo(1); - } - - funderChanged(funderId:string, funderName:string){ - this.selectedFunderId = funderId; - this.selectedFunderName = funderName; - - this.buildQueryParameters(); - this.goTo(1); - } - - buildQueryParameters() { - this.queryParameters = ""; - - if(this.openaireSearchUtils.keyword) { - this.queryParameters = "q="+StringUtils.URIEncode(this.openaireSearchUtils.keyword); - } - - if(this.selectedFunderId != "0") { - this.queryParameters += this.queryParameters ? "&" : ""; - this.queryParameters += "fq=funder exact " + '"'+StringUtils.URIEncode(this.selectedFunderId)+ '"'; - } - } - - goTo(page:number = 1){ - this.openaireSearchUtils.page=page; - this.openaireSearchUtils.status = this.errorCodes.LOADING; - this._getOpenaireProjects(this.queryParameters, page, 10); - } -} diff --git a/src/app/pages/community/projects/communityProjects-routing.module.ts b/src/app/pages/community/projects/communityProjects-routing.module.ts deleted file mode 100644 index 7b2b04c..0000000 --- a/src/app/pages/community/projects/communityProjects-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {ManageProjectsComponent} from './manage-projects.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: ManageProjectsComponent} - ]) - ] -}) -export class CommunityProjectsRoutingModule { } diff --git a/src/app/pages/community/projects/communityProjects.module.ts b/src/app/pages/community/projects/communityProjects.module.ts deleted file mode 100644 index 6a679fa..0000000 --- a/src/app/pages/community/projects/communityProjects.module.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { NgModule } from '@angular/core'; -import { HttpClientModule } from '@angular/common/http'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; - - -import { EnvironmentSpecificResolver } from '../../../openaireLibrary/utils/properties/environmentSpecificResolver'; -import { EnvironmentSpecificService } from '../../../openaireLibrary/utils/properties/environment-specific.service'; - -import { DataTablesModule } from 'angular-datatables'; -import { ManageProjectsComponent } from './manage-projects.component'; -import { ManageCommunityProjectsService } from '../../../services/manageProjects.service'; -import { SearchProjectsServiceModule } from '../../../openaireLibrary/connect/projects/searchProjectsService.module'; - -import { RemoveProjectsComponent } from './remove-projects.component'; -import { AddProjectsComponent } from './add-projects.component'; -import { SearchProjectsService } from '../../../openaireLibrary/services/searchProjects.service'; -import { PagingModule } from '../../../openaireLibrary/utils/paging.module'; -import { SearchPagingModule } from '../../../openaireLibrary/searchPages/searchUtils/searchPaging.module'; - -import {ErrorMessagesModule} from '../../../openaireLibrary/utils/errorMessages.module'; -import {AlertModalModule} from '../../../openaireLibrary/utils/modal/alertModal.module'; -import {FABModule} from '../../../utils/fabModule.module'; -import {CommonModule} from '@angular/common'; -import {CommunityProjectsRoutingModule} from './communityProjects-routing.module'; - -@NgModule({ - imports: [ - CommonModule, - HttpClientModule, - FormsModule, - ReactiveFormsModule, - RouterModule, - DataTablesModule, - PagingModule, SearchPagingModule, - ErrorMessagesModule, - AlertModalModule, - SearchProjectsServiceModule, - FABModule, - CommunityProjectsRoutingModule - ], - declarations: [ - ManageProjectsComponent, - RemoveProjectsComponent, - AddProjectsComponent - ], - providers: [ - ManageCommunityProjectsService, - SearchProjectsService, - EnvironmentSpecificResolver, EnvironmentSpecificService - ], - exports: [ManageProjectsComponent] -}) - -export class CommunityProjectsModule { } diff --git a/src/app/pages/community/projects/manage-projects.component.ts b/src/app/pages/community/projects/manage-projects.component.ts deleted file mode 100644 index 7d6d2c0..0000000 --- a/src/app/pages/community/projects/manage-projects.component.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { Component, ViewChild, OnInit, ViewEncapsulation, Input, ElementRef } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; - -import {RemoveProjectsComponent} from './remove-projects.component'; -import {AddProjectsComponent} from './add-projects.component'; - -import {Session} from '../../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class"; -import {Title} from '@angular/platform-browser'; - -@Component({ - selector: 'manage-projects', - template: ` -
- - -
- - -
- -
- ` -}) - -export class ManageProjectsComponent implements OnInit { - private community: string = ''; - - @Input() communityProjects =[]; - @ViewChild (RemoveProjectsComponent) removeProjectsComponent : RemoveProjectsComponent ; - @ViewChild (AddProjectsComponent) addProjectsComponent : AddProjectsComponent ; - - public warningMessage = ""; - public infoMessage = ""; - - public toggle: boolean = true; - public updateCommunityProjectsOnToggle: boolean = false; - public pageTitle: string = "Manage projects"; - public toggleLinkMessage: string = "Manage projects"; - - ngOnInit() { - this.route.queryParams.subscribe(params => { - if(params['communityId']) { - this.community = params['communityId']; - this.title.setTitle('Administration Dashboard | Projects'); - } - }); - } - - constructor(private element: ElementRef, - private title: Title, - private route: ActivatedRoute, private _router: Router) {} - - public ngOnDestroy() {} - - public updateCommunityProjects() { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - HelperFunctions.scroll(); - - this.toggle = !this.toggle; - if(this.toggle) { - this.pageTitle = "Manage projects"; - // this.toggleLinkMessage = "Missing projects?"; - - //if(this.updateCommunityProjectsOnToggle) { - this.removeProjectsComponent._getCommunityProjects(); - this.addProjectsComponent.undo = {}; - //} - } else { - this.updateCommunityProjectsOnToggle = false; - this.pageTitle = "Search projects"; - //this.toggleLinkMessage = "Manage projects"; - } - } - } - - public communityProjectsChanged($event) { - this.communityProjects = $event.value; - } - - // public updateCommunityProjects($event) { - // this.updateCommunityProjectsOnToggle = true; - // } -} diff --git a/src/app/pages/community/projects/remove-projects.component.html b/src/app/pages/community/projects/remove-projects.component.html deleted file mode 100644 index 1106b22..0000000 --- a/src/app/pages/community/projects/remove-projects.component.html +++ /dev/null @@ -1,99 +0,0 @@ -
-
-
-
- -
-
-
-
-
-
- - -
-
-
-
- - -
- - All the research results linked to the projects specified here will be automatically linked to your community dashboard. -
-
-
- - {{communitySearchUtils.totalResults | number}} projects, page {{communitySearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
- - -
-
- - - - - - - - - - - - - - - - - - -
ProjectGrant IdFunderAction
- - {{result.name}} - ({{result.acronym}}) - [no title available] - - - - {{result.grantId}} - - - - {{result.funder}} - - - - - -
-
-
- -
-
- - {{communitySearchUtils.totalResults | number}} projects, page {{communitySearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
- - - - diff --git a/src/app/pages/community/projects/remove-projects.component.ts b/src/app/pages/community/projects/remove-projects.component.ts deleted file mode 100644 index 364e4d5..0000000 --- a/src/app/pages/community/projects/remove-projects.component.ts +++ /dev/null @@ -1,349 +0,0 @@ -import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import { Subject } from 'rxjs'; -import { DataTableDirective } from 'angular-datatables'; - -import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes'; -import {SearchUtilsClass } from '../../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; -import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; -import {ManageCommunityProjectsService} from '../../../services/manageProjects.service'; -import {SearchCommunityProjectsService} from '../../../openaireLibrary/connect/projects/searchProjects.service'; -import {RouterHelper} from '../../../openaireLibrary/utils/routerHelper.class'; -import {DOI, StringUtils} from '../../../openaireLibrary/utils/string-utils.class'; - -import {Session} from '../../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class'; - -@Component({ - selector: 'remove-projects', - templateUrl: './remove-projects.component.html', - styles: [` - #dpTable_info, #dpTable_paginate, #dpTable_length, #dpTable_filter{ - display: none; - } - - `], - encapsulation: ViewEncapsulation.None // this used in order styles to work -}) - -export class RemoveProjectsComponent implements OnInit { - public routerHelper:RouterHelper = new RouterHelper(); - - private community: string = ''; - private communityUrl = "https://beta.explore.openaire.eu"; - - public errorCodes: ErrorCodes; - - @Output() communityProjectsChanged = new EventEmitter(); - public communityProjects = []; - public communitySearchUtils:SearchUtilsClass = new SearchUtilsClass(); - - public sub: any; public subResults: any; subRemove: any; - properties:EnvProperties; - - public disableForms: boolean = false; - - dtOptions: DataTables.Settings = {}; - showTable = false; filteringAdded = false; - @ViewChild(DataTableDirective) datatableElement: DataTableDirective; - dtTrigger: Subject = new Subject(); //necessary - - public rowsOnPage:number = 10; - - public queryParameters: string = ""; - - public query = ''; - public selectedProjects=[] ; - public elementRef; - - public funders:Set; - public selectedFunder:string =""; - //@Output() projectSelected = new EventEmitter(); - //@Input() public properties:EnvProperties; - - public projects:string[]; - private triggered: boolean = false; - - private selectedCommunityProject: any; - - @ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity; - - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - }); - - this.route.queryParams.subscribe(params => { - if(params['communityId']) { - this.community = params['communityId']; - this.communityUrl = "https://beta."+this.community+".openaire.eu"; - - this._getCommunityProjects(); - //this.getFunders(); - //this._getOpenaireProjects("", 1, 10); - } - }); - - this.dtOptions = { - // "paging": true, - // "searching": true, - // "lengthChange": false, - "pageLength": this.rowsOnPage, - "language": { - "search": "", - "searchPlaceholder": "Search projects..." - } - }; - - this.communitySearchUtils.keyword = ""; - } - - constructor(private route: ActivatedRoute, private _router: Router, private _manageCommunityProjectsService: ManageCommunityProjectsService, private _searchCommunityProjectsService: SearchCommunityProjectsService) { - this.errorCodes = new ErrorCodes(); - this.communitySearchUtils.status = this.errorCodes.LOADING; - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } - if(this.subRemove){ - this.subRemove.unsubscribe(); - } - - $.fn['dataTable'].ext.search.pop(); - } - - rerender(): void { - this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => { - // Destroy the table first - dtInstance.destroy(); - - // Call the dtTrigger to rerender again - this.dtTrigger.next(); - }); - } - - ngAfterViewInit(): void { - $.fn['dataTable'].ext.search.push((settings, data, dataIndex) => { - - if (this.filterData(data, this.communitySearchUtils.keyword, this.selectedFunder)) { - return true; - } - return false; - }); - - //console.info("ngAfterViewInit"); - } - - filterData(row: any, query: string, selectedFunder: string) { - let returnValue: boolean = false; - - if(query) { - for(var i=0; i <3; i++){ - var r= this.filterQuery(row[i], query); - if(r) { - returnValue = true; - break; - } - } - - if(!returnValue) { - return false; - } - } - - if(selectedFunder){ - return this.filterQuery(row[2], selectedFunder); - } - - return true; - } - - filterQuery(data, query){ - if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){ - return true; - }else{ - return false; - } - } - - - /* - Trigger a table draw in order to get the initial filtering - */ - triggerInitialLoad(){ - this.triggered = true; - //console.info("triggerInitialLoad"); - setTimeout(function(){ - var table = ($('#dpTable')).DataTable(); - table.page( 0 ).draw( false ); - }, 500); - this.dtTrigger.next(); - } - - public inCommunity(result: any): any { - let found = false; - for(let project of this.communityProjects) { - if(project.opeaireId == result.id) { - return true; - } else if(result['title'].name.search("("+project.grantId+")") != -1 && result.funderShortname == project.funder) { - return true; - } - } - return found; - - } - - goTo(page:number = 1){ - this.communitySearchUtils.page=page; - - var table = $('#dpTable').DataTable(); - table.page( page - 1 ).draw( false ); - - var info = table.page.info(); - this.communitySearchUtils.totalResults = info.recordsDisplay; - } - - totalPages(): number { - let totalPages:any = this.communitySearchUtils.totalResults/(this.rowsOnPage); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - return totalPages; - } - - public confirmedDeleteProject(data : any) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subRemove = this._manageCommunityProjectsService.removeProject(this.properties, this.community, this.selectedCommunityProject.id).subscribe( - data => { - //console.info(data); - }, - err => { - console.log(err); - }, - () => { - let index = this.communityProjects.indexOf(this.selectedCommunityProject); - this.communityProjects.splice(index, 1); - - this.communitySearchUtils.totalResults--; - this.communitySearchUtils.page=1; - - this.rerender(); - } - ) - } - } - - public removeProject(communityProject: any) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.selectedCommunityProject = communityProject; - this.alertModalDeleteCommunity.cancelButton = true; - this.alertModalDeleteCommunity.okButton = true; - this.alertModalDeleteCommunity.alertTitle = "Remove project?"; - let title = ""; - if(communityProject.name) { - title = communityProject.name; - } - if(communityProject.name && communityProject.acronym) { - title += " ("; - } - if(communityProject.acronym) { - title += communityProject.acronym; - } - if(communityProject.name && communityProject.acronym) { - title += ")"; - } - this.alertModalDeleteCommunity.message = "Project"; - if(title) { - this.alertModalDeleteCommunity.message += " '"+title+"' "; - } - this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?"; - this.alertModalDeleteCommunity.okButtonText = "Yes"; - this.alertModalDeleteCommunity.open(); - } - } - - public _getCommunityProjects(){ - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.communitySearchUtils.status = this.errorCodes.LOADING; - this.disableForms = true; - this.communityProjects = []; - this.communitySearchUtils.totalResults = 0; - this.communitySearchUtils.page=1; - this.communitySearchUtils.keyword = ""; - this.selectedFunder = ""; - - this.subResults = this._searchCommunityProjectsService.searchProjects(this.properties, this.community).subscribe( - data => { - //console.info("search Projects [total communityProjects:"+data.length+"]"); - this.communityProjects = data; - - this.communitySearchUtils.totalResults = data.length; - this.communitySearchUtils.status = this.errorCodes.DONE; - // if(this.communitySearchUtils.totalResults == 0 ){ - // this.communitySearchUtils.status = this.errorCodes.NONE; - // } - this.disableForms = false; - if(!this.triggered) { - this.triggerInitialLoad(); - } else { - var table = $('#dpTable').DataTable(); - table.clear(); - - this.rerender(); - } - - this.communityProjectsChanged.emit({ - value: this.communityProjects, - }); - - this.createFunderFilter(); - }, - err => { - console.log(err); - //TODO check erros (service not available, bad request) - - if(err.status == '404') { - this.communitySearchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.communitySearchUtils.status = this.errorCodes.ERROR; - } else { - this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE; - } - - this.disableForms = false; - if(!this.triggered) { - this.triggerInitialLoad(); - } else { - var table = $('#dpTable').DataTable(); - table.clear(); - - this.rerender(); - } - } - ); - } - } - - private createFunderFilter(): Set { - this.funders = new Set(); - let i; - for(i=0; i +
+
+ +
+
+ +
+
+
+
No OpenAIRE content providers available
+
An Error Occurred. No OpenAIRE content providers found
+
Service temporarily unavailable. Please try again later.
+
No OpenAIRE content providers found
+
+
+ + + + + + + + + + + + + + + + +
diff --git a/src/app/pages/content-providers/add-content-providers.component.ts b/src/app/pages/content-providers/add-content-providers.component.ts new file mode 100644 index 0000000..eb4ffe9 --- /dev/null +++ b/src/app/pages/content-providers/add-content-providers.component.ts @@ -0,0 +1,299 @@ +import {Component, OnInit, Input, Output, EventEmitter, ViewChild} from '@angular/core'; +import { ActivatedRoute, Router } from "@angular/router"; +import {SearchResult} from '../../openaireLibrary/utils/entities/searchResult'; +import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; +import {SearchUtilsClass } from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; +import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {SearchDataprovidersService} from '../../openaireLibrary/services/searchDataproviders.service'; +import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class'; +import {StringUtils} from '../../openaireLibrary/utils/string-utils.class'; +import {ManageCommunityContentProvidersService} from '../../services/manageContentProviders.service'; +import {Session} from '../../openaireLibrary/login/utils/helper.class'; +import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; +import {properties} from "../../../environments/environment"; +import {FormBuilder, FormGroup} from "@angular/forms"; +import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component"; +import {Subscriber} from "rxjs"; +import {debounceTime, distinctUntilChanged} from "rxjs/operators"; +import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview"; + +declare var UIkit; + +@Component({ + selector: 'add-content-providers', + templateUrl: './add-content-providers.component.html', +}) + +export class AddContentProvidersComponent implements OnInit { + private subscriptions: any[] = []; + public subResults: any; + + private community: string = ''; + + public routerHelper: RouterHelper = new RouterHelper(); + public properties: EnvProperties = properties; + public errorCodes: ErrorCodes; + public openaireSearchUtils: SearchUtilsClass = new SearchUtilsClass(); + @Output() communityContentProvidersChanged = new EventEmitter(); + @Input() communityContentProviders = []; + public openaireContentProviders = []; + public queryParameters: string = ""; + + // public pagingLimit: number = properties.pagingLimit; + public resultsPerPage: number = properties.resultsPerPage; + + filterForm: FormGroup; + @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; + + private contentProviderUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider; + public body: string = "Send from page"; + + @Output() toggleView: EventEmitter = new EventEmitter(); + + constructor(private route: ActivatedRoute, private _router: Router, + private _searchContentProvidersService: SearchDataprovidersService, + private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService, + private _fb: FormBuilder) { + this.errorCodes = new ErrorCodes(); + this.openaireSearchUtils.status = this.errorCodes.LOADING; + } + + ngOnInit() { + this.subscriptions.push(this.route.params.subscribe(params => { + this.openaireSearchUtils.status = this.errorCodes.LOADING; + + this.community = params['community']; + // this.contentProviderUrl = "https://" + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "") + // + this.community + ".openaire.eu" + this.properties.searchLinkToDataProvider; + + this._getOpenaireContentProviders("", 1, this.resultsPerPage); + + this.body = "[Please write your message here]"; + this.body = StringUtils.URIEncode(this.body); + })); + + this.openaireSearchUtils.keyword = ""; + + this.filterForm = this._fb.group({ + keyword: [''], + }); + + this.subscriptions.push(this.filterForm.get('keyword').valueChanges + .pipe(debounceTime(1000), distinctUntilChanged()) + .subscribe(value => { + this.keywordChanged(value); + }) + ); + } + + public ngOnDestroy() { + this.subscriptions.forEach(sub => { + if (sub instanceof Subscriber) { + sub.unsubscribe(); + } + }); + + if(this.subResults){ + this.subResults.unsubscribe(); + } + } + + public addContentProvider(contenProvider: SearchResult) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.subscriptions.push(this._manageCommunityContentProvidersService.addContentProvider(this.properties, this.community, contenProvider).subscribe( + data => { + this.communityContentProviders.push(data); + UIkit.notification('Content Provider successfully added!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.communityContentProvidersChanged.emit({ + value: this.communityContentProviders, + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.error(err.status); + } + )); + } + } + + public removeContentProvider(contentProvider) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + let communityContentProvider = this.getCommunityContentProvider(contentProvider); + let contentProviderId: string = communityContentProvider['id']; + this.subscriptions.push(this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community, contentProviderId).subscribe( + data => { + let index = this.communityContentProviders.indexOf(communityContentProvider); + this.communityContentProviders.splice(index, 1); + UIkit.notification('Content Provider successfully removed!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.communityContentProvidersChanged.emit({ + value: this.communityContentProviders, + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.error(err); + } + )); + } + } + + public getCommunityContentProvider(contentProvider: any): string { + let index: number = 0; + for (let communityContentProvider of this.communityContentProviders) { + if (communityContentProvider.openaireId == contentProvider.id) { + return communityContentProvider; + } + index++; + } + return ""; + } + + public getResultPreview(result: SearchResult): ResultPreview { + return ResultPreview.searchResultConvert(result, "dataprovider"); + } + + // public inCommunity(contentProvider: any): any { + // for(let communityContentProvider of this.communityContentProviders) { + // if(communityContentProvider.openaireId == contentProvider.id) { + // return true; + // } + // } + // + // if(this.undo[contentProvider.id]) { + // return true; + // } + // return false; + // } + + private _getOpenaireContentProviders(parameters: string, page: number, size: number) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + // if (page > this.pagingLimit) { + // size = 0; + // } + + if (this.openaireSearchUtils.status == this.errorCodes.LOADING) { + this.openaireSearchUtils.status = this.errorCodes.LOADING; + + this.openaireContentProviders = []; + this.openaireSearchUtils.totalResults = 0; + + if(this.subResults){ + this.subResults.unsubscribe(); + } + this.subResults = this._searchContentProvidersService.searchDataproviders(parameters, null, page, size, [], this.properties).subscribe( + data => { + this.openaireSearchUtils.totalResults = data[0]; + this.openaireContentProviders = data[1]; + + //this.searchPage.checkSelectedFilters(this.filters); + this.openaireSearchUtils.status = this.errorCodes.DONE; + if (this.openaireSearchUtils.totalResults == 0) { + this.openaireSearchUtils.status = this.errorCodes.NONE; + } + + // if (this.openaireSearchUtils.status == this.errorCodes.DONE) { + // // Page out of limit!!! + // let totalPages: any = this.openaireSearchUtils.totalResults / (this.openaireSearchUtils.size); + // if (!(Number.isInteger(totalPages))) { + // totalPages = (parseInt(totalPages, 10) + 1); + // } + // if (totalPages < page) { + // this.openaireSearchUtils.totalResults = 0; + // this.openaireSearchUtils.status = this.errorCodes.OUT_OF_BOUND; + // } + // } + }, + err => { + console.error(err); + //TODO check erros (service not available, bad request) + if (err.status == '404') { + this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND; + } else if (err.status == '500') { + this.openaireSearchUtils.status = this.errorCodes.ERROR; + } else { + this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + } + ); + } + } + } + + totalPages(): number { + let totalPages: any = this.openaireSearchUtils.totalResults / (this.resultsPerPage); + if (!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + return totalPages; + } + + keywordChanged(keyword) { + this.openaireSearchUtils.keyword = keyword; + this.buildQueryParameters(); + this.goTo(1); + } + + buildQueryParameters() { + this.queryParameters = ""; + + if (this.openaireSearchUtils.keyword) { + this.queryParameters = "q=" + StringUtils.URIEncode(this.openaireSearchUtils.keyword); + } + } + + goTo(page: number = 1) { + this.openaireSearchUtils.page = page; + this.openaireSearchUtils.status = this.errorCodes.LOADING; + this._getOpenaireContentProviders(this.queryParameters, page, this.resultsPerPage); + } + + back() { + this.toggleView.emit(null); + } + + public onSearchClose() { + this.openaireSearchUtils.keyword = this.filterForm.get('keyword').value; + } + + public resetInput() { + this.openaireSearchUtils.keyword = null; + this.searchInputComponent.reset() + } + + handleError(message: string) { + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + } +} diff --git a/src/app/pages/content-providers/communityContentProviders.module.ts b/src/app/pages/content-providers/communityContentProviders.module.ts new file mode 100644 index 0000000..60bb644 --- /dev/null +++ b/src/app/pages/content-providers/communityContentProviders.module.ts @@ -0,0 +1,68 @@ +import {NgModule} from '@angular/core'; +import {HttpClientModule} from '@angular/common/http'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {RouterModule} from '@angular/router'; + +import {PagingModule} from '../../openaireLibrary/utils/paging.module'; +import {SearchPagingModule} from '../../openaireLibrary/searchPages/searchUtils/searchPaging.module'; + +import {ErrorMessagesModule} from '../../openaireLibrary/utils/errorMessages.module'; +import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; +import {CommonModule} from '@angular/common'; +import {PageContentModule} from "../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; +import {CommunityInfoModule} from "../community-info/community-info.module"; +import {InputModule} from "../../openaireLibrary/sharedComponents/input/input.module"; +import {SearchInputModule} from "../../openaireLibrary/sharedComponents/search-input/search-input.module"; +import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; +import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"; +import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; +import {IconsService} from "../../openaireLibrary/utils/icons/icons.service"; +import {add, arrow_left, close, edit, remove_circle_outline} from "../../openaireLibrary/utils/icons/icons"; +import {FullScreenModalModule} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module"; +import {ResultPreviewModule} from "../../openaireLibrary/utils/result-preview/result-preview.module"; +import {SearchDataprovidersServiceModule} from "../../openaireLibrary/connect/contentProviders/searchDataprovidersService.module"; +import {ManageContentProvidersComponent} from "./manage-content-providers.component"; +import {RemoveContentProvidersComponent} from "./remove-content-providers.component"; +import {AddContentProvidersComponent} from "./add-content-providers.component"; +import {ManageCommunityContentProvidersService} from "../../services/manageContentProviders.service"; +import {SearchDataprovidersService} from "../../openaireLibrary/services/searchDataproviders.service"; + +@NgModule({ + imports: [ + CommonModule, + HttpClientModule, + FormsModule, + ReactiveFormsModule, + RouterModule, + PagingModule, SearchPagingModule, + ErrorMessagesModule, + AlertModalModule, + SearchDataprovidersServiceModule, + PageContentModule, + CommunityInfoModule, + InputModule, + SearchInputModule, + RouterModule.forChild([ + { + path: '', component: ManageContentProvidersComponent + } + ]), + NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule + ], + declarations: [ + ManageContentProvidersComponent, + RemoveContentProvidersComponent, + AddContentProvidersComponent + ], + providers: [ + ManageCommunityContentProvidersService, + SearchDataprovidersService + ], + exports: [ManageContentProvidersComponent] +}) + +export class CommunityContentProvidersModule { + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([remove_circle_outline, add, edit, close, arrow_left]); + } +} diff --git a/src/app/pages/content-providers/criteria-utils.ts b/src/app/pages/content-providers/criteria-utils.ts new file mode 100644 index 0000000..63d5aa5 --- /dev/null +++ b/src/app/pages/content-providers/criteria-utils.ts @@ -0,0 +1,18 @@ +import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; + +export class CriteriaUtils { + public static readonly fields: Option[] = [ + {value: 'title', label: 'Title'}, + {value: 'author', label: 'Author\'s name'}, + {value: 'author ORCID', label: 'Author\'s ORCID'}, + {value: 'contributor', label: 'Contributor'}, + {value: 'description', label: 'Description'} + ] + + public static readonly verbs: Option[] = [ + {value: 'contains', label: 'contains'}, + {value: 'equals', label: 'equals'}, + {value: 'not_contains', label: 'not contains'}, + {value: 'not_equals', label: 'not equals'} + ] +} diff --git a/src/app/pages/content-providers/criteria/criteria-routing.module.ts b/src/app/pages/content-providers/criteria/criteria-routing.module.ts new file mode 100644 index 0000000..745c32f --- /dev/null +++ b/src/app/pages/content-providers/criteria/criteria-routing.module.ts @@ -0,0 +1,13 @@ +import {NgModule} from '@angular/core'; +import {RouterModule} from '@angular/router'; +import {CriteriaComponent} from './criteria.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + {path: '', component: CriteriaComponent} + ]) + ] +}) +export class CriteriaRoutingModule { +} diff --git a/src/app/pages/content-providers/criteria/criteria.component.css b/src/app/pages/content-providers/criteria/criteria.component.css new file mode 100644 index 0000000..18e6796 --- /dev/null +++ b/src/app/pages/content-providers/criteria/criteria.component.css @@ -0,0 +1,6 @@ +.criterion { + border: rgba(26,26,26,0.5) solid 1px; + border-radius: 4px; + max-height: 400px; + overflow: auto; +} diff --git a/src/app/pages/content-providers/criteria/criteria.component.html b/src/app/pages/content-providers/criteria/criteria.component.html new file mode 100644 index 0000000..d70b17f --- /dev/null +++ b/src/app/pages/content-providers/criteria/criteria.component.html @@ -0,0 +1,170 @@ +
+ +
+
+
+
+
Filters for
+
+ {{dataProvider.officialname}} + (unsaved changes) +
+
+
+ + +
+
+
+
+
+
+
No filters for {{dataProvider.officialname}}.
+
If no filters are specified, all research results of this content provider will be included in your + community. +
+
+
+
+ + +
+
Filter {{getIndex(i) + 1}}
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ AND +
+
+ + + +
+
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+ AND +
+
+
+
+
+ +
+
+ + + +
+
+
+ + +
+
+
+
+ +
+
+ +
+
+
+
diff --git a/src/app/pages/content-providers/criteria/criteria.component.ts b/src/app/pages/content-providers/criteria/criteria.component.ts new file mode 100644 index 0000000..4c3e0a9 --- /dev/null +++ b/src/app/pages/content-providers/criteria/criteria.component.ts @@ -0,0 +1,257 @@ +import {ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {SearchCommunityDataprovidersService} from '../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; +import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; +import { + Constraint, + ContentProvider, + Criteria, + SelectionCriteria +} from '../../../openaireLibrary/utils/entities/contentProvider'; +import {AbstractControl, FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms'; +import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service'; +import {Title} from '@angular/platform-browser'; +import {properties} from "../../../../environments/environment"; +import {Subscription} from "rxjs"; +import {Option} from "../../../openaireLibrary/sharedComponents/input/input.component"; +import {MatSlideToggleChange} from "@angular/material/slide-toggle"; +import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class"; +import {CriteriaUtils} from "../criteria-utils"; + +declare var UIkit; + +@Component({ + selector: 'criteria', + templateUrl: './criteria.component.html', + styleUrls: ['criteria.component.css'], +}) +export class CriteriaComponent implements OnInit, OnDestroy { + public community: string = ''; + public openaireId: string = ''; + public dataProvider: ContentProvider = null; + public selectionCriteria: FormGroup; + public properties: EnvProperties = properties; + public fields: Option[] = CriteriaUtils.fields; + public verbs: Option[] = CriteriaUtils.verbs; + public loading = true; + /** Paging */ + public page: number = 1; + public pageSize: number = 5; + private subs: any[] = []; + + constructor(private route: ActivatedRoute, private router: Router, + private title: Title, + private searchCommunityDataprovidersService: SearchCommunityDataprovidersService, + private manageCommunityContentProvidersService: ManageCommunityContentProvidersService, + private cdr: ChangeDetectorRef, + private fb: FormBuilder) { + } + + ngOnInit() { + this.subs.push(this.route.params.subscribe(params => { + this.community = params['community']; + this.route.params.subscribe(params => { + if (params['provider']) { + this.openaireId = params['provider']; + } + this.searchCommunityDataprovidersService.searchDataproviders(this.properties, this.community).subscribe(dataProviders => { + dataProviders.forEach(dataProvider => { + if (dataProvider.openaireId == this.openaireId) { + this.dataProvider = dataProvider; + this.title.setTitle(this.community.toUpperCase() + ' | Criteria for ' + this.dataProvider.officialname); + } + }); + if (!this.dataProvider) { + this.navigateToError(); + } else { + this.reset(); + this.loading = false; + } + }); + }); + })); + } + + public ngOnDestroy() { + this.subs.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }) + } + + private navigateToError() { + this.router.navigate(['/error'], {queryParams: {'page': this.properties.baseLink + this.router.url}}); + } + + reset() { + this.page = 1; + if (this.dataProvider) { + this.selectionCriteria = this.fb.group({ + criteria: this.fb.array([]) + }); + let selectionCriteria = this.dataProvider.selectioncriteria; + if (selectionCriteria) { + selectionCriteria.criteria.forEach(criterion => { + let constraintArray: FormArray = this.fb.array([]); + criterion.constraint.forEach(constraint => { + constraintArray.push(this.fb.group({ + field: this.fb.control(constraint.field, Validators.required), + verb: this.fb.control(this.removeSuffix(constraint.verb), Validators.required), + value: this.fb.control(constraint.value, Validators.required), + verb_suffix: this.fb.control(this.getSuffix(constraint.verb)) + })); + }); + this.criteria.push(this.fb.group({ + constraint: constraintArray + })); + }); + } + } + } + + get currentPage(): AbstractControl[] { + if (this.criteria) { + return this.criteria.controls.slice((this.page - 1) * this.pageSize, this.page * this.pageSize); + } else { + return []; + } + } + + getIndex(index: number): number { + return (this.page - 1)*this.pageSize + index; + } + + public get criteria(): FormArray { + return this.selectionCriteria.get('criteria') as FormArray; + } + + public getConstraint(i: number): FormArray { + return this.criteria.at(i).get('constraint') as FormArray; + } + + public addCriteria() { + let constraintArray: FormArray = this.fb.array([ + this.fb.group({ + field: this.fb.control('', Validators.required), + verb: this.fb.control('contains', Validators.required), + value: this.fb.control('', Validators.required), + verb_suffix: this.fb.control('_caseinsensitive') + }) + ]); + this.criteria.push(this.fb.group({ + constraint: constraintArray + })); + this.page = Math.ceil(this.criteria.length/this.pageSize); + this.cdr.detectChanges(); + } + + public addConstraint(i: number) { + let constraintArray: FormArray = this.criteria.at(i).get('constraint') as FormArray; + constraintArray.push(this.fb.group({ + field: this.fb.control('', Validators.required), + verb: this.fb.control('contains', Validators.required), + value: this.fb.control('', Validators.required), + verb_suffix: this.fb.control('_caseinsensitive') + })); + this.cdr.detectChanges(); + } + + public removeConstraint(i: number, j: number) { + let constraintArray: FormArray = this.criteria.at(i).get('constraint') as FormArray; + constraintArray.removeAt(j); + if (constraintArray.length === 0) { + this.criteria.removeAt(i); + if (this.currentPage.length === 0) { + this.page = 1; + } + } + this.cdr.detectChanges(); + } + + get dataProviderCriteria(): Criteria[] { + return (this.dataProvider && this.dataProvider.selectioncriteria && this.dataProvider.selectioncriteria.criteria)?this.dataProvider.selectioncriteria.criteria:[]; + } + + get dirty() { + if(!this.dataProvider || !this.criteria) { + return false; + } else if(this.criteria.length !== this.dataProviderCriteria.length) { + return true; + } else { + return this.dataProviderCriteria.filter((criterion, i) => { + if(criterion.constraint.length !== this.getConstraint(i).length) { + return true; + } else { + let temp = this.getConstraint(i).value; + return criterion.constraint.filter((constraint, j) => { + return constraint.field !== temp[j].field || constraint.verb !== (temp[j].verb + temp[j].verb_suffix) || constraint.value !== temp[j].value; + }).length > 0; + } + }).length > 0; + } + } + + save() { + if (this.selectionCriteria.valid) { + this.loading = true; + this.dataProvider.selectioncriteria = this.parseForm(this.selectionCriteria.value); + this.manageCommunityContentProvidersService.saveContentProvider(this.properties, this.dataProvider).subscribe(() => { + this.reset(); + this.loading = false; + UIkit.notification('Filters has been successfully updated', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + }, error => { + UIkit.notification('An error has been occurred. Try again later!', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + }); + } else { + UIkit.notification('An error has been occurred. Try again later!', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + } + } + + caseSensitive(event: MatSlideToggleChange, constraint: AbstractControl) { + if(event.checked) { + constraint.get('verb_suffix').setValue(''); + } else { + constraint.get('verb_suffix').setValue('_caseinsensitive'); + } + } + + removeSuffix(verb: string) { + return verb.replace('_caseinsensitive', ''); + } + + getSuffix(verb: string) { + if(verb.includes('_caseinsensitive')) { + return '_caseinsensitive'; + } else { + return ''; + } + } + + parseForm(formValue): SelectionCriteria { + let value = HelperFunctions.copy(formValue); + let selectionCriteria: SelectionCriteria = new SelectionCriteria(); + selectionCriteria.criteria = []; + value.criteria.forEach(criterion => { + let criteria = new Criteria(); + criteria.constraint = []; + criterion.constraint.forEach(constraint => { + criteria.constraint.push(new Constraint(constraint.verb + constraint.verb_suffix, constraint.field, constraint.value)); + }); + selectionCriteria.criteria.push(criteria); + }) + return selectionCriteria; + } +} diff --git a/src/app/pages/content-providers/criteria/criteria.module.ts b/src/app/pages/content-providers/criteria/criteria.module.ts new file mode 100644 index 0000000..aecf8ba --- /dev/null +++ b/src/app/pages/content-providers/criteria/criteria.module.ts @@ -0,0 +1,48 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {CriteriaComponent} from './criteria.component'; +import {CriteriaRoutingModule} from './criteria-routing.module'; +import {SearchCommunityDataprovidersService} from '../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; +import {RouterModule} from '@angular/router'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service'; +import {PageContentModule} from "../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; +import {IconsModule} from "../../../openaireLibrary/utils/icons/icons.module"; +import {IconsService} from "../../../openaireLibrary/utils/icons/icons.service"; +import {add, arrow_left, close} from "../../../openaireLibrary/utils/icons/icons"; +import {LoadingModule} from "../../../openaireLibrary/utils/loading/loading.module"; +import {InputModule} from "../../../openaireLibrary/sharedComponents/input/input.module"; +import {MatSlideToggleModule} from "@angular/material/slide-toggle"; +import {ScrollingModule} from "@angular/cdk/scrolling"; +import {NoLoadPaging} from "../../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; + +@NgModule({ + imports: [ + CommonModule, + CriteriaRoutingModule, + RouterModule, + FormsModule, + ReactiveFormsModule, + PageContentModule, + IconsModule, + LoadingModule, + InputModule, + MatSlideToggleModule, + ScrollingModule, + NoLoadPaging, + ], + declarations: [ + CriteriaComponent + ], + providers: [ + SearchCommunityDataprovidersService, + ManageCommunityContentProvidersService + ], + exports: [CriteriaComponent] +}) + +export class CriteriaModule { + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([arrow_left, add, close]) + } +} diff --git a/src/app/pages/content-providers/manage-content-providers.component.ts b/src/app/pages/content-providers/manage-content-providers.component.ts new file mode 100644 index 0000000..2e74dd9 --- /dev/null +++ b/src/app/pages/content-providers/manage-content-providers.component.ts @@ -0,0 +1,111 @@ +import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core'; +import {ActivatedRoute, Router} from "@angular/router"; + +import {RemoveContentProvidersComponent} from './remove-content-providers.component'; + +import {Session} from '../../openaireLibrary/login/utils/helper.class'; +import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; +import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; +import {Title} from '@angular/platform-browser'; +import {FullScreenModalComponent} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component"; +import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; +import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties"; +import {properties} from "../../../environments/environment"; +import {Subscriber} from "rxjs"; + +@Component({ + selector: 'manage-content-providers', + template: ` + + + +
+ +
+
+ If you cannot find a content provider relevant to your community, probably it is not OpenAIRE compliant. + Feel free to contact us + ({{properties.feedbackmailForMissingEntities}}) + to let us know and we'll try to get the provider on board! +
+
+
+ + +
+ ` +}) + +export class ManageContentProvidersComponent implements OnInit { + @Input() communityContentProviders = []; + @ViewChild(RemoveContentProvidersComponent) removeContentProvidersComponent: RemoveContentProvidersComponent; + @ViewChild('fsModal') fullscreen: FullScreenModalComponent; + + public toggle: boolean = false; + + private subscriptions: any[] = []; + + public showLoadingInRemove: boolean = true; + + public body: string = "Send from page"; + public properties: EnvProperties = properties; + public communityId: string = ""; + + constructor(private element: ElementRef, + private title: Title, + private route: ActivatedRoute, private _router: Router) { + } + + ngOnInit() { + this.subscriptions.push(this.route.params.subscribe(params => { + this.communityId = params['community']; + + if (this.communityId) { + this.title.setTitle(this.communityId.toUpperCase() + ' | Content Providers'); + this.body = "[Please write your message here]"; + this.body = StringUtils.URIEncode(this.body); + } + })); + + this.fullscreen.title = "Search and Add Content Providers"; + this.fullscreen.okButtonText = "Done"; + this.fullscreen.okButton = true; + } + + public ngOnDestroy() { + this.subscriptions.forEach(sub => { + if (sub instanceof Subscriber) { + sub.unsubscribe(); + } + }); + } + + public toggleAction() { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} + }); + } else { + HelperFunctions.scroll(); + + this.toggle = !this.toggle; + if (this.toggle) { + this.fullscreen.open(); + } + } + } + + public communityContentProvidersChanged($event) { + this.communityContentProviders = $event.value; + this.showLoadingInRemove = false; + + if (this.toggle) { + this.removeContentProvidersComponent.applyFilters(); + } + } +} diff --git a/src/app/pages/content-providers/remove-content-providers.component.html b/src/app/pages/content-providers/remove-content-providers.component.html new file mode 100644 index 0000000..7fad95a --- /dev/null +++ b/src/app/pages/content-providers/remove-content-providers.component.html @@ -0,0 +1,150 @@ +
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + +
+
+
No content providers for {{name}}
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + {{item.officialname}} + {{item.name}} + [no title available] + + + + {{item.officialname}} + {{item.name}} + [no title available] + +
+ + + + + + +
+
+ +
+
+
+ + +
+
+ +
+
diff --git a/src/app/pages/content-providers/remove-content-providers.component.ts b/src/app/pages/content-providers/remove-content-providers.component.ts new file mode 100644 index 0000000..5a417c3 --- /dev/null +++ b/src/app/pages/content-providers/remove-content-providers.component.ts @@ -0,0 +1,386 @@ +import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; +import {ActivatedRoute, Router} from "@angular/router"; +import {Subscriber} from 'rxjs'; + +import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; +import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; +import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {ManageCommunityContentProvidersService} from '../../services/manageContentProviders.service'; +import {SearchCommunityDataprovidersService} from '../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; +import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class'; + +import {Session} from '../../openaireLibrary/login/utils/helper.class'; +import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; +import {Criteria, SelectionCriteria} from '../../openaireLibrary/utils/entities/contentProvider'; +import {properties} from "../../../environments/environment"; +import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component"; +import {FormBuilder, FormGroup} from "@angular/forms"; +import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; +import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; +import {CriteriaUtils} from "./criteria-utils"; + +declare var UIkit; + +@Component({ + selector: 'remove-content-providers', + templateUrl: './remove-content-providers.component.html' +}) +export class RemoveContentProvidersComponent implements OnInit { + public portal: string; + public name: string; + public routerHelper: RouterHelper = new RouterHelper(); + public contentProviderUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider; + public previewCommunityContentProviders = []; + public communitySearchUtils: SearchUtilsClass = new SearchUtilsClass(); + public errorCodes: ErrorCodes; + @Input() public showLoading: boolean = true; + @Input() public communityContentProviders = []; + @Output() communityContentProvidersChanged = new EventEmitter(); + private properties: EnvProperties = properties; + private subscriptions: any[] = []; + private selectedCommunityContentProvider: any; + @ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity; + /** Criteria */ + private fields = CriteriaUtils.fields; + private verbs = CriteriaUtils.verbs; + /** Paging */ + page: number = 1; + resultsPerPage: number = properties.resultsPerPage; + /** Search */ + @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; + filterForm: FormGroup; + private searchText: RegExp = new RegExp(''); + public keyword: string = ''; + sortOptions: Option[] = [ + {label: "Name ", value: {sort: "name", descending: false}}, + {label: "Official Name ", value: {sort: "officialname", descending: false}} + ]; + + @Output() toggleView: EventEmitter = new EventEmitter(); + @Input() public toggle: boolean = true; + + constructor(private route: ActivatedRoute, private _router: Router, + private _fb: FormBuilder, private communityService: CommunityService, + private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService, + private _searchCommunityContentProvidersService: SearchCommunityDataprovidersService) { + this.errorCodes = new ErrorCodes(); + this.communitySearchUtils.status = this.errorCodes.LOADING; + } + + ngOnInit() { + this.communitySearchUtils.keyword = ""; + + this.filterForm = this._fb.group({ + keyword: [''], + // sort: this._fb.control(this.sortOptions[0].value) + }); + + this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => { + this.searchText = new RegExp(value, 'i'); + this.page = 1; + this.applyFilters(); + })); + + // this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => { + // this.page = 1; + // this.sort(); + // })); + + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { + if (community) { + this.portal = community.communityId; + this.name = community.shortTitle; + this.contentProviderUrl = "https://" + + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "") + + this.portal + ".openaire.eu" + this.properties.searchLinkToDataProvider; + + this.keyword = ''; + this._getCommunityContentProviders(); + } + })); + } + + public ngOnDestroy() { + this.subscriptions.forEach(sub => { + if (sub instanceof Subscriber) { + sub.unsubscribe(); + } + }); + } + + public getCriteriaLabel(selectionCriteria: SelectionCriteria): string { + if (selectionCriteria && selectionCriteria.criteria.length > 0) { + return (selectionCriteria.criteria.length === 1) ? '1 criterion' : (selectionCriteria.criteria.length + ' criteria') + } else { + return 'no criteria'; + } + } + + // filterData(row: any, query: string) { + // let returnValue: boolean = false; + // + // if(query) { + // for(var i=0; i <2; i++){ + // var r= this.filterQuery(row[i], query); + // if(r) { + // returnValue = true; + // break; + // } + // } + // + // if(!returnValue) { + // return false; + // } + // } + // + // return true; + // } + // + // filterQuery(data, query){ + // if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){ + // return true; + // }else{ + // return false; + // } + // } + + public inCommunity(result: any): any { + let found = false; + for (let contentProvider of this.communityContentProviders) { + if (contentProvider.opeaireId == result.id) { + return true; + } + } + return found; + + } + + totalPages(): number { + let totalPages: any = this.communitySearchUtils.totalResults / (this.resultsPerPage); + if (!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + return totalPages; + } + + getFiltersAsText(criteria: Criteria[]): string { + let text = criteria.slice(0,3).map((criterion, index) => (index + 1) + ". " + criterion.constraint.map(constraint => { + let field = this.fields.find(field => field.value === constraint.field).label; + let matchCase = false; + if(!constraint.verb.includes('_caseinsensitive')) { + matchCase = true; + } + let verb = this.verbs.find(verb => verb.value === constraint.verb.replace("_caseinsensitive", "")).label; + let value = '"' + constraint.value + '"' + (matchCase?" (Match case)":""); + return field + " " + verb + " " + value; + }).join(" and ")); + return text.join("
"); + } + + // goTo(page:number = 1){ + // this.communitySearchUtils.page=page; + // + // var table = $('#dpTable').DataTable(); + // table.page( page - 1 ).draw( false ); + // + // var info = table.page.info(); + // this.communitySearchUtils.totalResults = info.recordsDisplay; + // } + + public confirmedDeleteContentProvider(data: any) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.subscriptions.push(this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.portal, this.selectedCommunityContentProvider.id).subscribe( + data => { + let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider); + this.communityContentProviders.splice(index, 1); + + this.applyFilters(); + + UIkit.notification('Content Provider successfully removed!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + + this.communityContentProvidersChanged.emit({ + value: this.communityContentProviders, + }); + + this.communitySearchUtils.totalResults--; + this.communitySearchUtils.page = 1; + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.error(err); + } + )); + } + } + + public removeContentProvider(communityContentProvider: any) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.selectedCommunityContentProvider = communityContentProvider; + this.alertModalDeleteCommunity.cancelButton = true; + this.alertModalDeleteCommunity.okButton = true; + this.alertModalDeleteCommunity.alertTitle = "Remove content provider?"; + let title = ""; + if (communityContentProvider.name) { + title = communityContentProvider.name; + } + if (communityContentProvider.name && communityContentProvider.acronym) { + title += " ("; + } + if (communityContentProvider.acronym) { + title += communityContentProvider.acronym; + } + if (communityContentProvider.name && communityContentProvider.acronym) { + title += ")"; + } + this.alertModalDeleteCommunity.message = "Content Provider"; + if (title) { + this.alertModalDeleteCommunity.message += " '" + title + "' "; + } + this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?"; + this.alertModalDeleteCommunity.okButtonText = "Yes"; + this.alertModalDeleteCommunity.open(); + } + } + + public _getCommunityContentProviders() { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.communitySearchUtils.status = this.errorCodes.LOADING; + this.communityContentProviders = []; + this.communitySearchUtils.totalResults = 0; + this.communitySearchUtils.page = 1; + this.communitySearchUtils.keyword = ""; + + this.subscriptions.push(this._searchCommunityContentProvidersService.searchDataproviders(this.properties, this.portal).subscribe( + data => { + this.communityContentProviders = data; + this.previewCommunityContentProviders = this.communityContentProviders; + // this.sort(); + + this.communitySearchUtils.totalResults = data.length; + this.communitySearchUtils.status = this.errorCodes.DONE; + + this.communityContentProvidersChanged.emit({ + value: this.communityContentProviders, + }); + + this.showLoading = false; + }, + err => { + console.error(err); + //TODO check erros (service not available, bad request) + + if (err.status == '404') { + this.communitySearchUtils.status = this.errorCodes.NOT_FOUND; + } else if (err.status == '500') { + this.communitySearchUtils.status = this.errorCodes.ERROR; + } else { + this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + + this.showLoading = false; + } + )); + } + } + + public updatePage($event) { + this.page = $event.value; + } + + addNew() { + this.toggleView.emit(null); + } + + public applyFilters() { + this.previewCommunityContentProviders = this.communityContentProviders.filter(contentProvider => { + return this.filterCommunityContentProviderByKeyword(contentProvider); + }); + + // check paging here!!! + if (this.previewCommunityContentProviders.slice((this.page - 1) * this.resultsPerPage, this.page * this.resultsPerPage).length == 0) { + this.page = 1; + } + + // this.sort(); + } + + public filterCommunityContentProviderByKeyword(contentProvider): boolean { + const textFlag = this.searchText.toString() === '' + || (contentProvider.name + " " + contentProvider.officialname).match(this.searchText) != null; + return textFlag; + } + + private sort() { + let sortOption: { sort: string, descending: boolean } = this.filterForm.get('sort').value; + + this.previewCommunityContentProviders.sort((left, right): number => { + if (sortOption.sort == "name") { + if (left.name > right.name) { + return sortOption.descending ? -1 : 1; + } else if (left.name < right.name) { + return sortOption.descending ? 1 : -1; + } + } else if (sortOption.sort == "officialname") { + if (left.officialname > right.officialname) { + return sortOption.descending ? -1 : 1; + } else if (left.officialname < right.officialname) { + return sortOption.descending ? 1 : -1; + } + } + + return 0; + }); + } + + public onSearchClose() { + this.communitySearchUtils.keyword = this.filterForm.get('keyword').value; + } + + public resetInput() { + this.communitySearchUtils.keyword = null; + this.searchInputComponent.reset() + } + + handleError(message: string) { + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + } + + goToCriteria(openaireId: string) { + this._router.navigate([openaireId], { + queryParams: { + // community: this.portal, + // provider: openaireId + }, + relativeTo: this.route + }) + } +} diff --git a/src/app/pages/curator/curator-routing.module.ts b/src/app/pages/curator/curator-routing.module.ts deleted file mode 100644 index 68db1e7..0000000 --- a/src/app/pages/curator/curator-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CuratorComponent} from './curator.component'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: CuratorComponent} - ]) - ] -}) -export class CuratorRoutingModule { } diff --git a/src/app/pages/curator/curator.component.html b/src/app/pages/curator/curator.component.html deleted file mode 100644 index 549ca07..0000000 --- a/src/app/pages/curator/curator.component.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - -
Manage Personal Info
-
- -
-
- -
- Your personal info will be visible in the Curators' page of your Community Gateway. - Read privacy policy statement.
- - Curators' page is disabled. Please enable it here. - -
-
-
- - - - - - - - - - - - - - - - - - - - - - -
- Name - - * - - : - -
Please add name.
- -
Photo: -
-
- Curator Photo -
-
-
- - -
-
- -
-
-
-
- Maximum photo resolution is 256x256 pixels. -
-
Biography: - -
-
- * Required fields -
-
- - -
-
- - -
-
-
- -
-
- -
- - Your photo will be removed after you save your data. Are you sure you want to proceed? - - -
- Your personal data and photo are processed by OpenAIRE in conformity with personal data protection legal framework. - They will be stored safely in our system for as long as OpenAIRE exists. Since you press the "save" button, - you give us the consent to make them public in your Community Gateway to let users know who is - configuring the platform. You always have the right to exercise your rights and ask for access, - rectification, erasure and restriction of your data. Please contact rcd-helpdesk@openaire.eu if - you have any inquiries. -
-
diff --git a/src/app/pages/curator/curator.component.ts b/src/app/pages/curator/curator.component.ts deleted file mode 100644 index c8069af..0000000 --- a/src/app/pages/curator/curator.component.ts +++ /dev/null @@ -1,268 +0,0 @@ -import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; -import {ActivatedRoute, Router} from '@angular/router'; - -import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session, User} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {CuratorService} from '../../openaireLibrary/connect/curators/curator.service'; -import {Curator} from '../../openaireLibrary/utils/entities/CuratorInfo'; -import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class'; -import {UtilitiesService} from '../../openaireLibrary/services/utilities.service'; -import {HelpContentService} from '../../services/help-content.service'; -import {AlertModal} from '../../openaireLibrary/utils/modal/alert'; -import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; -import {Title} from '@angular/platform-browser'; - -@Component({ - selector: 'curator', - templateUrl: './curator.component.html', -}) - -export class CuratorComponent implements OnInit { - - public showLoading = true; - public updateErrorMessage = ''; - public successfulSaveMessage = ''; - - public curatorsEnabled = false; - public newCurator = false; - - public communityId = null; - - public affiliationsChanged = false; - public hasChanged = false; - public curatorId = null; - public curator: Curator = null; - public photo: any = null; - public properties: EnvProperties = null; - public user: User; - - private file: File = null; - private maxsize: number = 200 * 1024; - public enabled = true; - private deletePhoto = false; - - @ViewChild('privacyStatement') privacyStatement: AlertModal; - - constructor(private element: ElementRef, - private route: ActivatedRoute, - private _router: Router, - private title: Title, - private curatorService: CuratorService, - private utilitiesService: UtilitiesService, - private helpContentService: HelpContentService, - private userManagementService: UserManagementService) { - } - - - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} - }); - } else { - this.route.queryParams.subscribe((params) => { - this.communityId = params['communityId']; - this.title.setTitle('Administration Dashboard | Personal Info'); - this.showLoading = true; - this.updateErrorMessage = ''; - this.userManagementService.getUserInfo().subscribe(user => { - this.user = user; - if(this.user) { - this.curatorId = this.user.id; - this.getCurator(); - } - }); - }); - } - }); - - } - - public getCurator() { - this.curatorService.getCurator(this.properties, this.curatorId).subscribe( - curator => { - if (curator && Object.keys(curator).length > 0) { - this.curator = curator; - this.curator.email = this.user.email; - if (this.curator.photo && this.curator.photo !== '') { - this.photo = this.properties.utilsService + '/download/' + this.curator.photo; - } else { - this.photo = 'assets/common-assets/curator-default.png'; - } - this.curatorsPageStatus(); - this.showLoading = false; - HelperFunctions.scroll(); - } else { - this.newCurator = true; - this.curator = new Curator(); - this.curator._id = this.curatorId; - this.curator.email = this.user.email; - this.curator.name = this.user.fullname; - this.curator.affiliations = []; - this.curator.bio = ''; - this.curator.photo = null; - this.photo = 'assets/common-assets/curator-default.png'; - this.showLoading = false; - HelperFunctions.scroll(); - } - }, - error => { - } - ); - } - - - public resetForm() { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: - {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} - }); - } else { - if (this.curatorId != null && this.curatorId !== '') { - this.showLoading = true; - this.updateErrorMessage = ''; - this.getCurator(); - } - this.resetChange(); - } - } - - private curatorsPageStatus() { - this.curatorsEnabled = false; - this.helpContentService.getCommunityFull(this.communityId, this.properties.adminToolsAPIURL).subscribe((community) => { - for (let page of community.pages) { - if (page['route'] === '/curators') { - this.curatorsEnabled = page['isEnabled']; - return; - } - } - }); - } - - private change() { - this.hasChanged = true; - this.affiliationsChanged = true; - } - - private resetChange() { - this.hasChanged = false; - this.affiliationsChanged = false; - } - - public resetMessages() { - this.successfulSaveMessage = ''; - this.updateErrorMessage = ''; - } - - handleUpdateError(message: string, error) { - this.resetMessages(); - this.updateErrorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } - - handleSuccessfulSave(message) { - this.resetMessages(); - this.showLoading = false; - HelperFunctions.scroll(); - this.successfulSaveMessage = message; - } - - fileChangeEvent(event) { - this.showLoading = true; - if (event.target.files && event.target.files[0]) { - this.file = event.target.files[0]; - if (this.file.type !== 'image/png' && this.file.type !== 'image/jpeg') { - this.handleUpdateError('You must choose a file with type: image/png or image/jpeg!', null); - this.file = null; - } else if (this.file.size > this.maxsize) { - this.handleUpdateError('File exceeds size\'s limit! Maximum resolution is 256x256 pixels.', null); - this.file = null; - } else { - this.updateErrorMessage = ''; - const reader = new FileReader(); - reader.readAsDataURL(this.file); - reader.onload = () => { - this.photo = reader.result; - this.showLoading = false; - HelperFunctions.scroll(); - }; - } - } - } - - saveCurator() { - this.curatorService.updateCurator(this.properties, this.curator).subscribe((curator) => { - if (curator) { - this.handleSuccessfulSave('Your data has been saved successfully!'); - this.newCurator = false; - this.file = null; - this.deletePhoto = false; - this.resetChange(); - } - }, - error => { - this.handleUpdateError('An error has occurred. Try again later!', error); - this.resetChange(); - }); - } - - - updateCurator() { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: - {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} - }); - } else { - if ((this.hasChanged || this.affiliationsChanged) && this.curator && this.curator.name && this.curator.name !== '') { - this.showLoading = true; - if (this.file) { - this.utilitiesService.uploadPhoto(this.properties.utilsService + '/upload/' + this.curator._id, this.file).subscribe((res) => { - if (this.curator.photo && this.curator.photo !== '') { - this.utilitiesService.deletePhoto(this.properties.utilsService + '/delete/' + this.curator.photo).subscribe(); - } - this.curator.photo = res.filename; - this.saveCurator(); - }, error => { - this.handleUpdateError('An error has occurred during photo uploading.', error); - } - ); - } else { - if (this.deletePhoto) { - if(this.curator.photo && this.curator.photo != '') { - this.utilitiesService.deletePhoto(this.properties.utilsService + '/delete/' + this.curator.photo).subscribe(); - this.curator.photo = ''; - } - } - this.saveCurator(); - } - } - } - } - - onNameChange() { - this.hasChanged = true; - this.enabled = !(!this.curator.name || this.curator.name === ''); - } - - removePhoto() { - this.deletePhoto = true; - this.hasChanged = true; - this.file = null; - this.photo = 'assets/common-assets/curator-default.png'; - } - - privacy() { - this.privacyStatement.cancelButton = false; - this.privacyStatement.okButtonText = 'Close'; - this.privacyStatement.alertTitle = 'Privacy policy statement'; - this.privacyStatement.open(); - } -} diff --git a/src/app/pages/curator/curator.module.ts b/src/app/pages/curator/curator.module.ts deleted file mode 100644 index 0c320ed..0000000 --- a/src/app/pages/curator/curator.module.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; -import {FormsModule} from '@angular/forms'; -import {RouterModule} from '@angular/router'; - -import {CuratorComponent} from './curator.component'; - -import {CuratorRoutingModule} from './curator-routing.module'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {CuratorService} from '../../openaireLibrary/connect/curators/curator.service'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {UtilitiesService} from '../../openaireLibrary/services/utilities.service'; -import {AffiliationsModule} from "../affiliations/affiliations.module"; - -@NgModule({ - imports: [ - CuratorRoutingModule, CommonModule, FormsModule, RouterModule, - AlertModalModule, AffiliationsModule - ], - declarations: [ - CuratorComponent - ], - providers: [ - CuratorService, UtilitiesService, IsCommunity, ConnectAdminLoginGuard - ], - exports: [ - CuratorComponent - ] -}) - -export class CuratorModule { } diff --git a/src/app/pages/customization/Border.component.ts b/src/app/pages/customization/Border.component.ts index 03949b1..6e1d0b0 100644 --- a/src/app/pages/customization/Border.component.ts +++ b/src/app/pages/customization/Border.component.ts @@ -4,32 +4,41 @@ import {Component, EventEmitter, Input, OnInit, Output,} from '@angular/core'; @Component({ selector: 'border', template: ` -
-
Radius:
-
- +
+
+
Border radius (px)
+ +
+ +
-
-
-
Width:
-
- +
+
Border width (px)
+ +
+ +
-
-
-
Style:
-
- - - +
+
Border style
+ +
+ + + solid + dotted + dashed + + +
+ + ` }) diff --git a/src/app/pages/customization/Color.component.ts b/src/app/pages/customization/Color.component.ts index 3c42f19..9ec7fe9 100644 --- a/src/app/pages/customization/Color.component.ts +++ b/src/app/pages/customization/Color.component.ts @@ -1,17 +1,19 @@ import {Component, EventEmitter, Input, OnInit, Output,} from '@angular/core'; +import {CustomizationOptions} from '../../openaireLibrary/connect/community/CustomizationOptions'; @Component({ selector: 'color', template: ` -
-
-
{{label}}:
-
- +
+
+
+
{{label}}
+ Contrast ratio may be too low.
` }) @@ -21,7 +23,10 @@ export class ColorComponent implements OnInit { @Input() label = 'Color'; @Input() addMargin: boolean = false; @Output() colorChange = new EventEmitter(); - + @Input() light:boolean; + public warningForContrast(color:string){ + return (this.light && CustomizationOptions.isForLightBackground(color)) || (!this.light && !CustomizationOptions.isForLightBackground(color)); + } constructor() { } diff --git a/src/app/pages/customization/background.component.ts b/src/app/pages/customization/background.component.ts new file mode 100644 index 0000000..bf0f794 --- /dev/null +++ b/src/app/pages/customization/background.component.ts @@ -0,0 +1,149 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {CustomizationOptions} from '../../openaireLibrary/connect/community/CustomizationOptions'; +import {properties} from '../../../environments/environment'; +import {UtilitiesService} from '../../openaireLibrary/services/utilities.service'; +import {Subscription} from 'rxjs'; + +declare var UIkit; + +@Component({ + selector: 'background', + template: ` + +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+ ` +}) + +export class BackgroundComponent implements OnInit { + @Input() label:string = ""; + @Input() background; + @Input() oldBackground; + @Input() light:boolean; + @Input() upload:boolean = false; + @Input() communityId:string = ""; + + public file: File; + // public photo: string | ArrayBuffer; + private maxsize: number = 200 * 1024; + properties; + private subscriptions: any[] = []; + + constructor(private utilsService: UtilitiesService) { + } + + + ngOnInit() { + this.properties = properties; + } + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }); + } + + removePhoto() { + + if (typeof document != 'undefined') { + (document.getElementById("photo")).value = ""; + } + // this.initPhoto(); + console.log(this.background.imageFile + " " + this.oldBackground.imageFile) + if(this.background.imageFile != this.oldBackground.imageFile){ + this.deletePhoto(); + } + this.background.imageFile = null; + this.file = null; + + } + + + + public deletePhoto() { + console.log("deletePhoto") + if (this.background.imageFile) { + console.log("deletePhoto@@") + this.subscriptions.push(this.utilsService.deletePhoto(properties.utilsService + '/delete/stakeholder/' +this.background.imageFile).subscribe()); + } + } + + fileChangeEvent(event) { + if (event.target.files && event.target.files[0]) { + this.file = event.target.files[0]; + if (this.file.type !== 'image/png' && this.file.type !== 'image/jpeg') { + UIkit.notification('You must choose a file with type: image/png or image/jpeg!', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + this.removePhoto(); + } else if (this.file.size > this.maxsize) { + UIkit.notification('File exceeds size\'s limit ('+this.maxsize/1024+'KB)! ', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + this.removePhoto(); + } else { + /*const reader = new FileReader(); + reader.readAsDataURL(this.file); + reader.onload = () => { + this.background.imageFile = reader.result; + + };*/ + this.save(); + } + } + } + + public save() { + if (this.file) { + this.subscriptions.push(this.utilsService.uploadPhoto(this.properties.utilsService + "/upload/stakeholder/" + encodeURIComponent(this.communityId+"-"+this.label), this.file).subscribe(res => { + this.deletePhoto(); + this.removePhoto(); + this.background.imageFile = res.filename; + + }, error => { + UIkit.notification("An error has been occurred during upload your image. Try again later", { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + })); + } + } +} diff --git a/src/app/pages/customization/customization-routing.module.ts b/src/app/pages/customization/customization-routing.module.ts index 0bbc52a..9ce8b7a 100644 --- a/src/app/pages/customization/customization-routing.module.ts +++ b/src/app/pages/customization/customization-routing.module.ts @@ -1,13 +1,11 @@ -import { NgModule } from '@angular/core'; +import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; import {CustomizationComponent} from './customization.component'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: CustomizationComponent} + { path: '', component: CustomizationComponent} ]) ] }) diff --git a/src/app/pages/customization/customization.component.html b/src/app/pages/customization/customization.component.html index b13982e..670e4b1 100644 --- a/src/app/pages/customization/customization.component.html +++ b/src/app/pages/customization/customization.component.html @@ -1,675 +1,214 @@ -
- + - -
+
- -
-
-
-
- - - - Customization -
-
-
Download the saved customization settings and upload a customization file:
- -
- - Upload -
-
-
{{errorMessage}}
-
-
- Style - -
- - -
- View - -
- -
- - Go to - -
- -
-
-
-
- - - - Backgrounds -
- - -
- - Set the banner background color and which fonts to be used (for dark or light background). -
-
-
    -
  • - Banners - -
    - - - - -
    BUTTONS & LINKS
    -
    - - -
    -
    QUICK LOOK - - - -
    -
    -
    Banner Big Text -
    -
    Banner Small Text -
    -
    - Link -
    - Button - -
    -
    - - Link -
    - - Button - -
    - - -
    - -
    -
  • -
- - -
- - -
- -
-
- - - - Fonts -
- -
- - Customize the banner fonts, and the links for dark and light background -
-
-
    -
  • - Banner Big Text -
    - - - -
    QUICK LOOK - - - -
    -
    -
    Banner Big Text -
    -
    -
    -
  • -
-
-
-
    -
  • - Banner Small Text -
    - - - - -
    QUICK LOOK - - - -
    -
    -
    Banner Small Text -
    -
    - -
    -
  • -
-
-
- -
- -
- -
-
- - - Elements -
- -
- - Customize the layout of dashboard elements. -
-
- -
- - -
- -
-
- - - Identity -
- -
- - Identity colors are used in several spots in your community Dashboard. Check the quick look section! -
-
-
    -
  • - Identity Colors -
    - - - - - -
    QUICK LOOK - - - -
    -
    - - -
    -
      -
    • Item - 1 - -
    • -
    • Item - 2 -
      -

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.

      -
      -
    • -
    • Item 3 - -
    • -
    -
    - -
    Text in primary - color -
    -
    Text in secondary - color -
    -
    -
    -
  • -
-
- - -
-
-
- - - Buttons -
- -
- - Customize the buttons for dark and light backgrounds -
-
- -
- - -
-
{{successfulSaveMessage}}
-
{{errorMessage}}
- +
+
-
- - +
+
+
+
+
+ + +
Customization (Unsaved changes)
+
+
+
+ + +
+
+
+
+
Quick look + +
+ + +
+
+ +
Backgrounds & Buttons + +
+ +
+ Custom style + + + + +
+
+ Backgrounds and buttons are set in the default values. +
+ +
+
Background Colors
+ + + + +
Buttons
+ +
    +
  • + +
  • +
  • + +
  • +
+
+
+ + +
+
+
+ + +
+
+ +
+
+
Quick look +
+
+ +
+
+
+ +
Identity +
+ +
+
+ Custom style + + +
+
+ Identity is set in the default values. +
+
+
+
Colors
+ + +
+ +
+ +
+ + +
+
+ +
+
Preview
+
+
+
+
+
+ +
+
Style has been changed.
+
Click to refresh the view.
+
+
+
+ + +
+ +
+
- -
If you leave that Page without applying or publishing, changes will be lost.
-
Are you sure that you want to proceed?
-
+
+
- -
If you leave that Page without applying or publishing, changes will be lost.
-
Are you sure that you want to proceed?
-
diff --git a/src/app/pages/customization/customization.component.ts b/src/app/pages/customization/customization.component.ts index 4876438..5a2e96d 100644 --- a/src/app/pages/customization/customization.component.ts +++ b/src/app/pages/customization/customization.component.ts @@ -1,83 +1,109 @@ -import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; +import {Component, ElementRef, OnInit} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {Curator} from '../../openaireLibrary/utils/entities/CuratorInfo'; import {DomSanitizer, Title} from '@angular/platform-browser'; -import {CustomizationOptions} from '../../openaireLibrary/connect/community/CustomizationOptions'; +import {CustomizationOptions, Layout} from '../../openaireLibrary/connect/community/CustomizationOptions'; import {StringUtils} from '../../openaireLibrary/utils/string-utils.class'; import {LayoutService} from '../../openaireLibrary/services/layout.service'; -import {AlertModal} from '../../openaireLibrary/utils/modal/alert'; +import {properties} from '../../../environments/environment'; +import {UtilitiesService} from '../../openaireLibrary/services/utilities.service'; +import {Subscription} from 'rxjs'; + +declare var UIkit; @Component({ selector: 'customization', templateUrl: './customization.component.html', + styles:[` + .refresh-indicator { + background-color: rgba(0, 0, 0, 0.50); + border-radius: 4px; + position: absolute; + color: white; + } + iframe, .refresh-indicator{ + height:900px; + } + `] }) export class CustomizationComponent implements OnInit { - menuSelected = 'main'; + menuSelected = 'identity'; color = 'white'; + defaultCustomizationOptions:CustomizationOptions = new CustomizationOptions(); + publishedLayout: Layout = null; publishedCustomizationOptions: CustomizationOptions = null; draftCustomizationOptions: CustomizationOptions = null; appliedCustomizationOptions: CustomizationOptions = null; previewUrl = null; previewCustomization = null; - buttonDarkBackgroundPreview; - buttonLightBackgroundPreview; - linkDarkBackgroundPreview; - linkLightBackgroundPreview; - hoveredText; + + public showLoading = true; - public errorMessage = ''; - public successfulSaveMessage = ''; public communityId = null; public properties: EnvProperties = null; + private subscriptions: any[] = []; public enabled = true; - @ViewChild('backAlert') backAlert: AlertModal; - @ViewChild('exitAlert') exitAlert: AlertModal; constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, private title: Title, private sanitizer: DomSanitizer, - private layoutService: LayoutService) { + private layoutService: LayoutService, + private utilsService: UtilitiesService) { } + ngOnDestroy() { + this.deleteDraftImages(); - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} - }); - } else { - this.route.queryParams.subscribe((params) => { - this.communityId = params['communityId']; - this.title.setTitle('Administration Dashboard | Customization'); - this.showLoading = true; - this.errorMessage = ''; - this.successfulSaveMessage = ''; - this.layoutService.getLayout(this.properties, this.communityId).subscribe(layout => { - this.publishedCustomizationOptions = (layout?layout:new CustomizationOptions()); - this.initializeCustomizationOptions(true); - }, error => { - this.publishedCustomizationOptions = new CustomizationOptions(); - this.initializeCustomizationOptions(true); - this.errorMessage = "An error occured fetching customizations options" - }); - }); + } + cleanUp(){ + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); } }); + } + ngOnInit() { + this.properties = properties; + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} + }); + } else { + this.subscriptions.push(this.route.params.subscribe((params) => { + this.communityId = params['community']; + if(this.communityId == "covid-19"){ + this.defaultCustomizationOptions= new CustomizationOptions(CustomizationOptions.getIdentity(this.communityId).mainColor,CustomizationOptions.getIdentity(this.communityId).secondaryColor); + } + this.title.setTitle('Administration Dashboard | Customization'); + this.showLoading = true; + this.subscriptions.push(this.layoutService.getLayout(this.properties, this.communityId).subscribe(layout => { + this.publishedLayout = (layout?layout:new Layout(this.communityId,this.defaultCustomizationOptions)); + this.publishedCustomizationOptions = (layout?CustomizationOptions.checkForObsoleteVersion(layout.layoutOptions,this.communityId):Object.assign({},this.defaultCustomizationOptions)); + this.initializeCustomizationOptions(true); + }, error => { + this.publishedCustomizationOptions = new CustomizationOptions(CustomizationOptions.getIdentity(this.communityId).mainColor,CustomizationOptions.getIdentity(this.communityId).secondaryColor); + this.initializeCustomizationOptions(true); + UIkit.notification("An error occured fetching customizations options", { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + })); + })); + } + } hasChanges(object1,object2):boolean{ @@ -89,28 +115,54 @@ export class CustomizationComponent implements OnInit { queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); } - this.layoutService.saveLayout(this.properties, this.communityId, this.draftCustomizationOptions).subscribe(layout => { - this.publishedCustomizationOptions = layout; + this.publishedLayout.layoutOptions = this.draftCustomizationOptions; + this.subscriptions.push(this.layoutService.saveLayout(this.properties, this.communityId, this.publishedLayout).subscribe(layout => { + this.deleteOldImages(); + this.publishedLayout = layout; + this.publishedCustomizationOptions = layout.layoutOptions; this.initializeCustomizationOptions(JSON.stringify(this.publishedCustomizationOptions) != this.previewCustomization); - this.successfulSaveMessage = "Customization Options saved!" + UIkit.notification("Customizations was succesfully saved!", { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => { - this.errorMessage = "An error occured on save" - }); - } + UIkit.notification("An error occured on save", { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + })); + } + private deleteOldImages( ) { + if( this.publishedCustomizationOptions.backgrounds.form.imageFile && this.draftCustomizationOptions.backgrounds.form.imageFile !=this.publishedCustomizationOptions.backgrounds.form.imageFile){ + this.deleteImage(this.publishedCustomizationOptions.backgrounds.form.imageFile) + } + } + private deleteDraftImages( ) { + console.log("delete drafr images") + if( this.draftCustomizationOptions.backgrounds.form.imageFile && this.draftCustomizationOptions.backgrounds.form.imageFile !=this.publishedCustomizationOptions.backgrounds.form.imageFile){ + this.subscriptions.push(this.utilsService.deletePhoto(this.properties.utilsService + '/delete/stakeholder/' + this.draftCustomizationOptions.backgrounds.form.imageFile).subscribe( + re => { + console.log("delete!!!!!!!!") + this.cleanUp() + } + )); + }else{ + this.cleanUp() + } + } + private deleteImage( filename:string) { + this.subscriptions.push(this.utilsService.deletePhoto(this.properties.utilsService + '/delete/stakeholder/' + filename).subscribe()); + } initializeCustomizationOptions(updatePreviewUrl) { this.draftCustomizationOptions = this.copyObject(this.publishedCustomizationOptions); this.appliedCustomizationOptions = this.copyObject(this.publishedCustomizationOptions); - if(updatePreviewUrl){ this.previewUrl = this.getCommunityUrlSatinized(JSON.stringify(this.appliedCustomizationOptions)); } - - this.buttonDarkBackgroundPreview = this.changeStyle(this.draftCustomizationOptions.buttons.darkBackground); - this.buttonLightBackgroundPreview = this.changeStyle(this.draftCustomizationOptions.buttons.lightBackground); - this.linkDarkBackgroundPreview = this.changeFontsStyle(this.draftCustomizationOptions.links.darkBackground, this.draftCustomizationOptions.links.darkBackground.color); - this.linkLightBackgroundPreview = this.changeStyle(this.draftCustomizationOptions.links.lightBackground, this.draftCustomizationOptions.links.lightBackground.color); } applyLayout() { @@ -121,288 +173,68 @@ export class CustomizationComponent implements OnInit { } resetLayout() { - - if (this.menuSelected == 'backgrounds') { - this.resetBackgrounds(); - } else if (this.menuSelected == 'fonts') { - this.resetFonts(); - } else if (this.menuSelected == 'elements') { - this.resetElements(); - } else if (this.menuSelected == 'buttons') { - this.resetButtons(); - } else if (this.menuSelected == 'identity') { - this.resetIdentity(); - } else { - this.draftCustomizationOptions = this.copyObject(this.publishedCustomizationOptions); - - this.appliedCustomizationOptions = this.copyObject(this.publishedCustomizationOptions); - } - // console.log(JSON.stringify(this.appliedCustomizationOptions)) - // console.log(this.previewCustomization) this.initializeCustomizationOptions(JSON.stringify(this.appliedCustomizationOptions) != this.previewCustomization); + } + resetBackgroundsTo(backgrounds) { + this.draftCustomizationOptions.backgrounds.dark.color = backgrounds.dark.color; + this.draftCustomizationOptions.backgrounds.light.color = backgrounds.light.color; + this.draftCustomizationOptions.backgrounds.form.color = backgrounds.form.color; } - resetBackgrounds() { - this.draftCustomizationOptions.panel.onDarkBackground = this.publishedCustomizationOptions.panel.onDarkBackground; - this.draftCustomizationOptions.panel.background.color = this.publishedCustomizationOptions.panel.background.color; - - this.appliedCustomizationOptions.panel.onDarkBackground = this.publishedCustomizationOptions.panel.onDarkBackground; - this.appliedCustomizationOptions.panel.background.color = this.publishedCustomizationOptions.panel.background.color; + resetBackgroundsAndButtonsTo(c:CustomizationOptions){ + this.resetBackgroundsTo(c.backgrounds); + this.resetButtonsTo(c.buttons); + } + resetBackgroundsAndButtonsToPublished(){ + this.resetBackgroundsAndButtonsTo(this.publishedCustomizationOptions); + } + resetBackgroundsAndButtonsToDefault(){ + this.resetBackgroundsAndButtonsTo(this.publishedCustomizationOptions); + this.updateBackgroundsAndButtonsBasedOnIdentity(); } - resetFonts() { - this.resetFontsBig(); - this.resetFontsSmall(); - this.resetFontsLinksDark(); - this.resetFontsLinksLight(); - + resetButtonsTo(buttonsToRevert) { + this.draftCustomizationOptions.buttons= this.copyObject(buttonsToRevert); } - resetFontsBig() { - this.draftCustomizationOptions.panel.title = this.copyObject(this.publishedCustomizationOptions.panel.title); - - this.appliedCustomizationOptions.panel.title = this.copyObject(this.publishedCustomizationOptions.panel.title); + resetIdentityTo( original:CustomizationOptions) { + this.draftCustomizationOptions.identity.mainColor = this.copyObject(original.identity.mainColor); + this.draftCustomizationOptions.identity.secondaryColor = this.copyObject(original.identity.secondaryColor); } - - resetFontsSmall() { - this.draftCustomizationOptions.panel.fonts = this.copyObject(this.publishedCustomizationOptions.panel.fonts); - - this.appliedCustomizationOptions.panel.fonts = this.copyObject(this.publishedCustomizationOptions.panel.fonts); - + resetIdentityToPublished() { + this.resetIdentityTo( this.publishedCustomizationOptions); + this.updateBackgroundsAndButtonsBasedOnIdentity() + } + resetIdentityToDefault() { + this.resetIdentityTo( this.defaultCustomizationOptions); + this.draftCustomizationOptions.identityIsCustom = false; + this.updateBackgroundsAndButtonsBasedOnIdentity() } - - resetFontsLinksDark() { - this.draftCustomizationOptions.links.darkBackground = this.copyObject(this.publishedCustomizationOptions.links.darkBackground); - - this.appliedCustomizationOptions.links.darkBackground = this.copyObject(this.publishedCustomizationOptions.links.darkBackground); - - this.linkDarkBackgroundPreview=this.changeFontsStyle(this.publishedCustomizationOptions.links.darkBackground, this.publishedCustomizationOptions.links.darkBackground.color); - } - - resetFontsLinksLight() { - this.draftCustomizationOptions.panel.title = this.copyObject(this.publishedCustomizationOptions.panel.title); - this.draftCustomizationOptions.links.lightBackground = this.copyObject(this.publishedCustomizationOptions.links.lightBackground); - - this.appliedCustomizationOptions.panel.title = this.copyObject(this.publishedCustomizationOptions.panel.title); - this.appliedCustomizationOptions.links.lightBackground = this.copyObject(this.publishedCustomizationOptions.links.lightBackground); - - this.linkLightBackgroundPreview=this.changeFontsStyle(this.publishedCustomizationOptions.links.lightBackground, this.publishedCustomizationOptions.links.lightBackground.color); - } - - resetElements() { - this.draftCustomizationOptions.panel.panelElements = this.copyObject(this.publishedCustomizationOptions.panel.panelElements); - - this.appliedCustomizationOptions.panel.panelElements = this.copyObject(this.publishedCustomizationOptions.panel.panelElements); - } - - resetButtons() { - this.resetButtonsDark(); - this.resetButtonsLight(); - } - - resetButtonsDark() { - this.draftCustomizationOptions.buttons.darkBackground = this.copyObject(this.publishedCustomizationOptions.buttons.darkBackground); - - this.appliedCustomizationOptions.buttons.darkBackground = this.copyObject(this.publishedCustomizationOptions.buttons.darkBackground); - - this.buttonDarkBackgroundPreview=this.changeStyle(this.publishedCustomizationOptions.buttons.darkBackground); - } - - resetButtonsLight() { - this.draftCustomizationOptions.buttons.lightBackground = this.copyObject(this.publishedCustomizationOptions.buttons.lightBackground); - - this.appliedCustomizationOptions.buttons.lightBackground = this.copyObject(this.publishedCustomizationOptions.buttons.lightBackground); - - this.buttonLightBackgroundPreview=this.changeStyle(this.publishedCustomizationOptions.buttons.lightBackground); - } - - resetIdentity() { - this.draftCustomizationOptions.mainColor = this.publishedCustomizationOptions.mainColor; - this.draftCustomizationOptions.secondaryColor = this.publishedCustomizationOptions.secondaryColor; - - this.appliedCustomizationOptions.mainColor = this.publishedCustomizationOptions.mainColor; - this.appliedCustomizationOptions.secondaryColor = this.publishedCustomizationOptions.secondaryColor; - } - - changeStyle(colorOptions, borderOptions = null) { - let style = ''; - if (!borderOptions) { - borderOptions = colorOptions; + updateBackgroundsAndButtonsBasedOnIdentity(){ + if(!this.draftCustomizationOptions.backgroundsAndButtonsIsCustom){ + let tmp = new CustomizationOptions(this.draftCustomizationOptions.identity.mainColor, this.draftCustomizationOptions.identity.secondaryColor); + this.resetBackgroundsAndButtonsTo(tmp); } - if (colorOptions.color) { - style = style.concat('; color:' + colorOptions.color); - } - if (colorOptions.backgroundColor) { - style = style.concat( '; background-color:' + colorOptions.backgroundColor); - } - if (colorOptions.borderColor) { - style = style.concat('; border-color:' + colorOptions.borderColor); - } - if (borderOptions.borderStyle) { - style = style.concat('; border-style:' + borderOptions.borderStyle); - } - if (borderOptions.borderWidth) { - style = style.concat( '; border-width:' + borderOptions.borderWidth + 'px'); - } - if (borderOptions.borderRadius) { - style = style.concat('; border-radius:' + borderOptions.borderRadius + 'px'); - } - - return this.sanitizer.bypassSecurityTrustStyle(style); } - - - changeFontsStyle(options, color = null) { - let style = ''; - - - if (options.family) { - style = style.concat('; font-family:' + options.family); - } - - if (options.size) { - style = style.concat('; font-size:' + options.size + 'px'); - } - - if (options.weight) { - style = style.concat('; font-weight:' + options.weight); - } - - if (color) { - style = style.concat('; color:' + color); - } - - return this.sanitizer.bypassSecurityTrustStyle(style); - } - getCommunityUrlSatinized(layout: string) { return this.sanitizer.bypassSecurityTrustResourceUrl(this.getCommunityUrlNewLayout(layout)); } getCommunityUrl() { +/* if(this.properties.environment == "development") { + return 'http://spitoo.di.uoa.gr:4200'; + }*/ return 'https://'+ (this.properties.environment == 'production'?'':'beta.')+this.communityId+'.openaire.eu'; } getCommunityUrlNewLayout(layout: string) { this.previewCustomization = layout; - return this.getCommunityUrl()+'/?' + 'layout=' + StringUtils.URIEncode(layout); + return this.getCommunityUrl()+'/preview/?' + 'layout=' + StringUtils.URIEncode(layout); } copyObject(obj) { return JSON.parse(JSON.stringify(obj)); } - back() { - if (JSON.stringify(this.draftCustomizationOptions) == JSON.stringify(this.publishedCustomizationOptions) || - JSON.stringify(this.draftCustomizationOptions) == JSON.stringify(this.appliedCustomizationOptions)) { - this.menuSelected = 'main'; - } else { - this.backAlert.okButtonText = 'Yes'; - this.backAlert.cancelButtonText = 'No'; - this.backAlert.alertTitle = ''; - this.backAlert.okButtonLeft = true; - this.backAlert.open(); - } - - } - - resetToAppliedOptions() { - this.draftCustomizationOptions = this.copyObject(this.appliedCustomizationOptions); - this.menuSelected = 'main'; - } - - exit() { - if (JSON.stringify(this.appliedCustomizationOptions) == JSON.stringify(this.publishedCustomizationOptions)) { - this.exitCustomization(); - } else { - this.exitAlert.okButtonText = 'Yes'; - this.exitAlert.cancelButtonText = 'No'; - this.exitAlert.alertTitle = ''; - this.exitAlert.okButtonLeft = true; - this.exitAlert.open(); - } - - } - - exitCustomization() { - this._router.navigate(['/dashboard'], { - queryParams: {'communityId': this.communityId} - }); - } - downloadCustomization(){ - this.errorMessage = ""; - let options= JSON.parse(JSON.stringify(this.publishedCustomizationOptions)); - delete options['_id']; - console.info("Here!" +JSON.stringify(options)); - if(typeof document !== 'undefined') { - let dataStr = JSON.stringify(options); - let dataUri = 'data:application/json;charset=utf-8,' + encodeURIComponent(dataStr); - - let exportFileDefaultName = 'layoutOptions.json'; - - let linkElement = document.createElement('a'); - linkElement.setAttribute('href', dataUri); - linkElement.setAttribute('download', exportFileDefaultName); - linkElement.click(); - } - } - fileChangeEvent(fileInput: any) { - this.errorMessage = ""; - let filesToUpload = >fileInput.target.files; - - - if (filesToUpload.length == 0) { - this.errorMessage = "There is no selected file to upload."; - return; - } else { - if (filesToUpload[0].name.indexOf(".json") == -1 || - (filesToUpload[0].type != "application/json" )) { - this.errorMessage = "No valid file type. The required type is json "+filesToUpload[0].type; - return; - } - } - - this.makeFileRequest(this.properties.utilsService + '/upload?type=json', [], filesToUpload).then((result) => { - let layout:CustomizationOptions = JSON.parse(result.toString()); - if( layout && layout.panel && layout.links && layout.buttons && layout.box){ - this.draftCustomizationOptions = layout; - //put the same id to not have any difference - if(this.publishedCustomizationOptions['_id']){ - this.draftCustomizationOptions['_id'] = this.publishedCustomizationOptions['_id']; - } - }else{ - this.errorMessage = "No valid file"; - } - - }, (error) => { - this.errorMessage = "No valid file"; - }); - } - - - makeFileRequest(url: string, params: Array, files: Array) { - return new Promise((resolve, reject) => { - const formData: any = new FormData(); - const xhr = new XMLHttpRequest(); - for (let i = 0; i < files.length; i++) { - formData.append("uploads[]", files[i], files[i].name); - } - xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (xhr.status == 200) { - resolve(xhr.response); - } else { - reject(xhr.response); - } - } - } - xhr.open("POST", url, true); - xhr.send(formData); - }); - } - - - - } diff --git a/src/app/pages/customization/customization.module.ts b/src/app/pages/customization/customization.module.ts index 67ca774..d194e90 100644 --- a/src/app/pages/customization/customization.module.ts +++ b/src/app/pages/customization/customization.module.ts @@ -12,15 +12,24 @@ import {ColorComponent} from './Color.component'; import {BorderComponent} from './Border.component'; import {LayoutService} from '../../openaireLibrary/services/layout.service'; import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; +import {PageContentModule} from '../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; +import {QuickLookComponent} from './quickLook.component'; +import {QuickLookBackgroundsComponent} from './quickLook-backgrounds.component'; +import {QuickLookButtonsComponent} from './quickLook-buttons.component'; +import {MatFormFieldModule, MatSelectModule, MatSlideToggleModule} from '@angular/material'; +import {CustomizeButtonsComponent} from './customize-buttons.component'; +import {IconsModule} from '../../openaireLibrary/utils/icons/icons.module'; +import {IconsService} from '../../openaireLibrary/utils/icons/icons.service'; +import {refresh, reset} from '../../openaireLibrary/utils/icons/icons'; +import {BackgroundComponent} from './background.component'; +import {InputModule} from '../../openaireLibrary/sharedComponents/input/input.module'; -// import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -// import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; @NgModule({ imports: [ - CustomizationRoutingModule, CommonModule, FormsModule, RouterModule, ColorPickerModule, AlertModalModule + CustomizationRoutingModule, CommonModule, FormsModule, RouterModule, ColorPickerModule, AlertModalModule, PageContentModule, MatFormFieldModule, MatSelectModule, MatSlideToggleModule, IconsModule, InputModule ], declarations: [ - CustomizationComponent, FontSizeComponent, ColorComponent, BorderComponent + CustomizationComponent, FontSizeComponent, ColorComponent, BorderComponent, QuickLookComponent, QuickLookBackgroundsComponent, QuickLookButtonsComponent, CustomizeButtonsComponent, BackgroundComponent ], providers: [ LayoutService @@ -30,4 +39,7 @@ import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.mod ] }) export class CustomizationModule { + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([reset, refresh]); + } } diff --git a/src/app/pages/customization/customize-buttons.component.ts b/src/app/pages/customization/customize-buttons.component.ts new file mode 100644 index 0000000..5f74e86 --- /dev/null +++ b/src/app/pages/customization/customize-buttons.component.ts @@ -0,0 +1,62 @@ +import {Component, Input} from '@angular/core'; +import {ButtonsCustomization} from '../../openaireLibrary/connect/community/CustomizationOptions'; + + +@Component({ + selector: 'customize-buttons', + template: ` + +
+ +
+
+
Colors
+ + + +
+
+
Colors on hover
+
+ + + +
+
+
+
+ + +`, + styles:[` `] + +}) + +export class CustomizeButtonsComponent { + @Input() buttons:ButtonsCustomization; + @Input() light:boolean; + constructor() { + } + +} diff --git a/src/app/pages/customization/quickLook-backgrounds.component.ts b/src/app/pages/customization/quickLook-backgrounds.component.ts new file mode 100644 index 0000000..46022dd --- /dev/null +++ b/src/app/pages/customization/quickLook-backgrounds.component.ts @@ -0,0 +1,63 @@ +import {Component, HostBinding, Input} from '@angular/core'; +import {DomSanitizer} from '@angular/platform-browser'; +import {ButtonsCustomization} from '../../openaireLibrary/connect/community/CustomizationOptions'; + + +@Component({ + selector: 'quick-look-backgrounds', + template: ` +
Dark background
+ +
+
+

Heading

+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mollis velit ornare, auctor lectus at, rutrum magna. Aenean vehicula elementum lacinia.
+ Link + +
+
+ +
+ +
Light background
+
+
+

Heading

+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mollis velit ornare, auctor lectus at, rutrum magna. Aenean vehicula elementum lacinia.
+ Link +
+ +
+
+
+ `, + styles:[` + .darkBackground{ + background-color: var(--background-dark-color); + } + .lightBackground{ + background-color: var(--background-low-color); + } + `] + +}) + +export class QuickLookBackgroundsComponent { + @Input() primaryColor; + @Input() secondaryColor; + @Input() darkBackgroundColor; + @Input() lightBackgroundColor; + @Input() buttonsOnDark:ButtonsCustomization; + @Input() buttonsOnLight:ButtonsCustomization; + constructor( private sanitizer: DomSanitizer) { + } + + @HostBinding("attr.style") + public get valueAsStyle(): any { + return this.sanitizer.bypassSecurityTrustStyle(`--portal-main-color: ${this.primaryColor}; --portal-dark-color: ${this.secondaryColor}; + --background-dark-color: ${this.darkBackgroundColor}; --background-low-color: ${this.lightBackgroundColor};`); + } +} diff --git a/src/app/pages/customization/quickLook-buttons.component.ts b/src/app/pages/customization/quickLook-buttons.component.ts new file mode 100644 index 0000000..5fa2e82 --- /dev/null +++ b/src/app/pages/customization/quickLook-buttons.component.ts @@ -0,0 +1,58 @@ +import {Component, HostBinding, Input} from '@angular/core'; +import {DomSanitizer} from '@angular/platform-browser'; +import {ButtonsCustomization} from '../../openaireLibrary/connect/community/CustomizationOptions'; + + +@Component({ + selector: 'quick-look-buttons', + template: ` + +
+ Button +
+ + +`, + styles:[` + .preview-button { + color: var(--color); + background-color: var(--background-color); + border-color: var(--border-color); + border-style: var(--border-style); + border-width: var(--border-width); + border-radius: var(--border-radius); + } + .preview-button:hover { + color: var(--color-hover); + background-color: var(--background-color-hover); + border-color: var(--border-color-hover); + + } + + `] + +}) + +export class QuickLookButtonsComponent { + @Input() buttons:ButtonsCustomization; + + @HostBinding("attr.style") + public get valueAsStyle(): any { + return this.sanitizer.bypassSecurityTrustStyle(` + --color: ${this.buttons.color}; + --background-color: ${this.buttons.backgroundColor}; + --border-color: ${this.buttons.borderColor}; + --border-style: ${this.buttons.borderStyle}; + --border-width: ${this.buttons.borderWidth + 'px'}; + --border-radius: ${this.buttons.borderRadius + 'px'}; + --color-hover: ${this.buttons.onHover.color}; + --background-color-hover: ${this.buttons.onHover.backgroundColor}; + --border-color-hover: ${this.buttons.onHover.borderColor}; + `); + } + constructor( private sanitizer: DomSanitizer) { + } + + + +} diff --git a/src/app/pages/customization/quickLook.component.ts b/src/app/pages/customization/quickLook.component.ts new file mode 100644 index 0000000..d32bbaa --- /dev/null +++ b/src/app/pages/customization/quickLook.component.ts @@ -0,0 +1,88 @@ +import {Component, HostBinding, Input} from '@angular/core'; +import {DomSanitizer} from '@angular/platform-browser'; + + +@Component({ + selector: 'quick-look', + template: ` +
+ +
+ +
Text in primary + color +
+
Text in secondary + color +
+
+ Link 1 +
+
+ Link 2 +
+
+ + + `, + styles:[` + /*Override inside this component*/ +/* :host { + --portal-main-color: #fe3c52; + --portal-dark-color: #b40238; + --new:#fe3c52; + + }*/ + /* + overrides root + ::ng-deep :root { + --portal-main-color: #fe3c52; + --portal-dark-color: #b40238; + --new:#fe3c52; + }*/ + .uk-pagination li a.uk-active{ + background-color: var(--portal-main-color); + color:white; + } + .uk-pagination li a, .uk-tab li a{ + text-decoration: none; + } + a.link1{ + color: var(--portal-main-color); + } + a.link1:hover{ + color: var(--portal-dark-color); + } + .uk-tab li.uk-active a{ + color: var(--portal-main-color) !important; + border-color:var(--portal-main-color) !important; + } + + `] + +}) + +export class QuickLookComponent { + @Input() primaryColor; + @Input() secondaryColor; + @Input() preview :"identity"|"backgrounds"|"buttons" = "identity"; + + constructor( private sanitizer: DomSanitizer) { + } + + @HostBinding("attr.style") + public get valueAsStyle(): any { + return this.sanitizer.bypassSecurityTrustStyle(`--portal-main-color: ${this.primaryColor}; --portal-dark-color: ${this.secondaryColor};`); + } + +} diff --git a/src/app/pages/dashboard/dashboard-routing.module.ts b/src/app/pages/dashboard/dashboard-routing.module.ts deleted file mode 100644 index 57b5c37..0000000 --- a/src/app/pages/dashboard/dashboard-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {DashboardComponent} from './dashboard.component'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: DashboardComponent} - ]) - ] -}) -export class DashboardRoutingModule { } diff --git a/src/app/pages/dashboard/dashboard.component.html b/src/app/pages/dashboard/dashboard.component.html deleted file mode 100644 index 9a4d0c7..0000000 --- a/src/app/pages/dashboard/dashboard.component.html +++ /dev/null @@ -1,117 +0,0 @@ -
-
- -
-
-
-

- - Profile -

-
- Edit community information, change logo url, add community managers or organizations related to - community and customize css layout. -
- -
-
-

- - Content -

-
- Manage projects, content providers{{(communityType && communityType != 'ri')?', subjects':''}} and zenodo communities that are related to the research community. -
- -
-
-

- - Statistics & Charts -

-
- Manage statistical numbers & charts that will be displayed in the community overview and graph analysis views. -
- -
-
-

- - Links -

-
- Manage user claims related to the research community. -
-
- Links -
-
-
-

- - Help texts -

-
- Add or edit help text in research community pages. -
- -
-
-

- - Text mining rules -

-
- Manage text mining rules, test the rules and see the results, save and load mining profiles. -
- -
-
-

- - Users -

-
- Invite more users to subscribe, manage community subscribers, your personal info and notification settings. -
- -
-
-
-
-
diff --git a/src/app/pages/dashboard/dashboard.component.ts b/src/app/pages/dashboard/dashboard.component.ts deleted file mode 100644 index ec2e9db..0000000 --- a/src/app/pages/dashboard/dashboard.component.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Created by stefania on 3/21/16. - */ - -import {Component, ElementRef, OnInit} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; -import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Title} from '@angular/platform-browser'; -import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper"; - -@Component({ - selector: 'dashboard', - templateUrl: 'dashboard.component.html', -}) -export class DashboardComponent implements OnInit { - communityId: string = null; - communityType = null; - properties: EnvProperties; - - constructor( private element: ElementRef, - private route: ActivatedRoute, - private title: Title, - private _communityService: CommunityService) {} - - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.title.setTitle('Administration Dashboard | Overview'); - this.properties = data.envSpecific; - this.route.queryParams.subscribe(data => { - HelperFunctions.scroll(); - this.communityId = ((data['communityId']) ? data['communityId'] : data['community']); - ConnectHelper.setPortalTypeFromPid(this.communityId); - - this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe ( - community => { - this.communityType = community.type; - }, - error => { - console.error('Server responded: ' + error); - } - ); - }); - }); - - } -} diff --git a/src/app/pages/dashboard/dashboard.module.ts b/src/app/pages/dashboard/dashboard.module.ts deleted file mode 100644 index 116f115..0000000 --- a/src/app/pages/dashboard/dashboard.module.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { NgModule } from '@angular/core'; -import {DashboardRoutingModule} from './dashboard-routing.module'; -import {RouterModule} from '@angular/router'; -import {DashboardComponent} from './dashboard.component'; -import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; - -@NgModule({ - imports: [ - CommonModule, DashboardRoutingModule, RouterModule - ], - declarations: [DashboardComponent], - providers: [IsCommunity, ConnectAdminLoginGuard], - exports: [DashboardComponent] -}) -export class DashboardModule { } diff --git a/src/app/pages/divId/divId-form.component.html b/src/app/pages/divId/divId-form.component.html deleted file mode 100644 index c04acc9..0000000 --- a/src/app/pages/divId/divId-form.component.html +++ /dev/null @@ -1,68 +0,0 @@ -
-
- - -
- -
- - - - -
If portal changes, selected pages will be lost
-
- -
- -
-
{{page.name}}, 
- - - - - - - - - -
- - - - - - - - {{page.name}} - -
-
-
-
- -
diff --git a/src/app/pages/divId/divId-form.component.ts b/src/app/pages/divId/divId-form.component.ts deleted file mode 100644 index 1575159..0000000 --- a/src/app/pages/divId/divId-form.component.ts +++ /dev/null @@ -1,235 +0,0 @@ -import {Component, OnInit, Input} from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import {FormGroup, FormArray, FormBuilder, Validators, FormControl} from "@angular/forms"; -import { HelpContentService } from "../../services/help-content.service"; -import { Page } from "../../domain/page"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {Subscription} from "rxjs"; - -@Component({ - selector: 'divId-form', - templateUrl: './divId-form.component.html', -}) - -export class DivIdFormComponent implements OnInit{ - @Input('group') - myForm: FormGroup; - @Input('pageId') - pageId: string; - @Input('formPages') - formPages: Page[] = []; - - public allPages : Page[] = []; - public allPagesFiltered: Map = new Map(); - private gotPages: boolean = false; - - public properties:EnvProperties = null; - - public showLoading: boolean = false; - public errorMessage: string = ''; - selectedCommunityPid = null; - - private sub: Subscription = null; - - constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, private _helpContentService: HelpContentService){} - - ngOnInit(): void { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - // this.route.queryParams.subscribe(params => { - // this.selectedCommunityPid = params['communityId']; - // }); - }); - - this. sub = this.myForm.get('portalType').valueChanges.subscribe(portalType => { - let pages = this.myForm.get('pages').value; - //pages = pages.filter(page => page.portalType == portalType); - //this.setPages(pages); - - pages.forEach((page, i) => { - if(page.portalType != portalType) { - this.pages.removeAt(i); - } - }); - - this.allPagesFiltered.clear(); - this.allPages.filter(page => page.portalType == portalType).forEach(page => { - this.allPagesFiltered.set(page, false); - }) - //this.myForm.value.pages = []; - }); - } - - ngOnDestroy() { - if(this.sub) { - this.sub.unsubscribe(); - } - } - - public getKeys( map) { - return Array.from(map.keys()); - } - - getPages(includedPages: Set) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.showLoading = true; - this.errorMessage = ""; - - this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe( - pages => { - this.allPages = pages; - let self = this; - pages = pages.filter(page => page.portalType == self.myForm.get('portalType').value); - for(let page of pages) { - if(includedPages.has(page._id)) { - this.allPagesFiltered.set(page, true); - } else { - this.allPagesFiltered.set(page, false); - } - } - this.showLoading = false; - }, - error => this.handleError('System error retrieving pages', error) - ); - } - } - - public toggle() { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.myForm.value.isCollapsed = !this.myForm.value.isCollapsed; - /////// - if(!this.myForm.value.isCollapsed) { - let includedPages: Set = new Set(); - for(let pageName of this.myForm.value.pages) { - includedPages.add(pageName._id); - } - - let allPages = this.allPagesFiltered; - - let self = this; - allPages.forEach(function (status, page, map) { - if(includedPages.has(page._id)) { - self.allPagesFiltered.set(page, true); - } else { - self.allPagesFiltered.set(page, false); - } - }); - - - if(!this.gotPages) { - this.gotPages = true; - this.getPages(includedPages); - } - } - } -///// - } - - public get form() { - return this._fb.group({ - _id: '', - name : ['', Validators.required], - pages: this._fb.array([], Validators.required), - portalType: ['', Validators.required], - isCollapsed: [true] - }); - } - - public reset() { - this.myForm.patchValue({ - _id : '', - name : '', - portalType: '', - pages: [], - isCollapsed: [true] - }); - - this.formPages = []; - } - - public get pages(): FormArray { - return this.myForm.get('pages') as FormArray; - }; - - setPages(pages: Page[]) { - //const pageFormArray = this._fb.array(pages); - //this.myForm.setControl('pages', pageFormArray); - - //const pageFGs = pages.map(page => this._fb.group(page)); - //if(pages && pages.length > 0) { - // const pageCtrls = pages.map(page => this._fb.control(page)); - // const pageFormArray = this._fb.array(pageCtrls); - // this.myForm.setControl('pages', pageFormArray); - //} - - while (this.pages.length !== 0) { - this.pages.removeAt(0) - } - pages.forEach(page => { - //array.push(new FormControl(page)); - this.pages.push(this._fb.control(page)); - }); - } - - indexOfPageInForm(pageId: string): number { - let index: number = -1; - for(let i=0; i= 0) { - this.formPages.splice(index, 1); - this.myForm.value.pages.splice(index, 1); - } - }*/ - - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - let index: number = -1; - for(let i=0; i= 0) { - this.pages.removeAt(index); - } - } - } - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } -} diff --git a/src/app/pages/divId/divIds-routing.module.ts b/src/app/pages/divId/divIds-routing.module.ts deleted file mode 100644 index 1a9ef38..0000000 --- a/src/app/pages/divId/divIds-routing.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {DivIdsComponent} from './divIds.component'; -import {AdminLoginGuard} from "../../openaireLibrary/login/adminLoginGuard.guard"; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [AdminLoginGuard], component: DivIdsComponent} - ]) - ] -}) -export class DivIdsRoutingModule { } diff --git a/src/app/pages/divId/divIds.component.html b/src/app/pages/divId/divIds.component.html deleted file mode 100644 index 0a8fa77..0000000 --- a/src/app/pages/divId/divIds.component.html +++ /dev/null @@ -1,131 +0,0 @@ -
- - -
-
-
- - - -
-
-
- -
- -
-
-
-
- -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - -
NamePagePortal TypeActions
- -
{{check.divId.name}}
-
- -
- {{page.name}}, -
-
-
{{check.divId.portalType}}
-
-
- - -
-
- -
-
No classes found
-
-
-
-
-
-
-
-
- - -
- - - - - - - - - - - - - - diff --git a/src/app/pages/divId/divIds.component.ts b/src/app/pages/divId/divIds.component.ts deleted file mode 100644 index 1b154cf..0000000 --- a/src/app/pages/divId/divIds.component.ts +++ /dev/null @@ -1,292 +0,0 @@ -import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import { HelpContentService } from "../../services/help-content.service"; -import { FormGroup } from "@angular/forms"; -import { DivIdFormComponent } from "./divId-form.component"; -import { CheckDivId, DivId } from "../../domain/divId"; -//import { Community } from "../../domain/community"; -import { Page } from "../../domain/page"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Title} from '@angular/platform-browser'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'divIds', - templateUrl: './divIds.component.html', -}) - -export class DivIdsComponent implements OnInit { - - // @ViewChild(ModalFormComponent) - // @ViewChild('saveModal') - // public modal:ModalFormComponent; - // - // @ViewChild('updateModal') - // public updateModal:ModalFormComponent; - - // @ViewChild('deleteConfirmationModal') - // public deleteConfirmationModal : DeleteConfirmationDialogComponent; - @ViewChild('AlertModalSaveDivId') alertModalSaveDivId; - @ViewChild('AlertModalUpdateDivId') alertModalUpdateDivId; - @ViewChild('AlertModalDeleteDivIds') alertModalDeleteDivIds; - private selectedDivIds: string[] = []; - - @ViewChild(DivIdFormComponent) - public formComponent : DivIdFormComponent; - - public checkboxes : CheckDivId[] = []; - - public divIds : DivId[] = []; - - //public errorMessage: string; - - public formGroup : FormGroup; - - private searchText : RegExp = new RegExp(''); - public keyword: string = ""; - - public pages: Page[] = []; - public properties:EnvProperties = null; - public formPages: Page[] = []; - - public showLoading: boolean = true; - public errorMessage: string = ''; - public updateErrorMessage: string = ''; - public modalErrorMessage: string = ''; - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | Classes'); - this.properties = data.envSpecific; - this.formGroup = this.formComponent.form; - - this.getDivIds(); - }); - } - - constructor(private element: ElementRef, private route: ActivatedRoute, - private _router: Router, private title: Title, - private _helpContentService: HelpContentService, - private _clearCacheService: ClearCacheService) {} - - getDivIds() { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ""; - this.errorMessage = ""; - - this._helpContentService.getAllDivIdsFull(this.properties.adminToolsAPIURL).subscribe( - divIds => { - this.divIds = divIds; - this.checkboxes = []; - - let self = this; - divIds.forEach(_ => { - self.checkboxes.push({divId : _, checked : false}); - }); - - this.showLoading = false; - }, - error => this.handleError('System error retrieving classes', error)); - } - } - - // public showModal():void { - // this.modal.showModal(); - // } - - public toggleCheckBoxes(event) { - this.checkboxes.forEach(_ => _.checked = event.target.checked); - } - - public applyCheck(flag : boolean) { - this.checkboxes.forEach(_ => _.checked = flag); - } - - public getSelectedDivIds() : string[] { - return this.checkboxes.filter(divId => divId.checked == true).map(checkedDivId => checkedDivId.divId).map(res => res._id); - } - - private deleteDivIdsFromArray(ids : string[]) : void { - for(let id of ids) { - let i = this.checkboxes.findIndex(_ => _.divId._id == id); - this.checkboxes.splice(i, 1); - } - } - - public confirmDeleteDivId(id : string) { - //this.deleteConfirmationModal.ids = [id]; - //this.deleteConfirmationModal.showModal(); - this.selectedDivIds = [id]; - this.confirmModalOpen(); - } - - public confirmDeleteSelectedDivIds() { - //this.deleteConfirmationModal.ids = this.getSelectedDivIds(); - //this.deleteConfirmationModal.showModal(); - this.selectedDivIds = this.getSelectedDivIds(); - this.confirmModalOpen(); - } - - private confirmModalOpen() { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.alertModalDeleteDivIds.cancelButton = true; - this.alertModalDeleteDivIds.okButton = true; - this.alertModalDeleteDivIds.alertTitle = "Delete Confirmation"; - this.alertModalDeleteDivIds.message = "Are you sure you want to delete the selected class(es)?"; - this.alertModalDeleteDivIds.okButtonText = "Yes"; - this.alertModalDeleteDivIds.open(); - } - } - - public confirmedDeleteDivIds(data: any) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ""; - - this._helpContentService.deleteDivIds(this.selectedDivIds, this.properties.adminToolsAPIURL).subscribe( - _ => { - this.deleteDivIdsFromArray(this.selectedDivIds); - this.showLoading = false; - this._clearCacheService.clearCache("classes deleted"); - }, - error => this.handleUpdateError('System error deleting the selected classes', error) - ); - } - } - - public editDivId(i : number) { - let divId : DivId = this.checkboxes[i].divId; - this.formPages = divId.pages; - - /*let pageIds: string[] = []; - let index = 0; - for(let page of divId.pages) { - pageIds[index] = page._id; - index++; - }*/ - - this.formGroup.patchValue(divId); - this.formComponent.setPages(divId.pages as Page[]);//pageIds); - this.formGroup.controls['portalType'].disable(); - - //this.updateModal.showModal(); - this.divIdsModalOpen(this.alertModalUpdateDivId, "Update", "Update Class"); - } - - public newDivId() { - this.formGroup.controls['portalType'].enable(); - this.formComponent.reset(); - this.modalErrorMessage = ""; - this.divIdsModalOpen(this.alertModalSaveDivId, "Save", "Add a new Class"); - } - - private divIdsModalOpen(modal: any, title: string, yesBtn: string) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - modal.cancelButton = true; - modal.okButton = true; - modal.alertTitle = title; - modal.okButtonText = yesBtn; - modal.open(); - } - } - - public divIdSaveConfirmed(data: any) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - if(!this.formGroup.valid) { - this.divIdsModalOpen(this.alertModalSaveDivId, "Save", "Add a new Class"); - this.modalErrorMessage = "Please fill in all required fields marked with *"; - } else { - this.modalErrorMessage = ""; - this._helpContentService.saveDivId( this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( - divId => { - this.divIdSavedSuccessfully(divId); - this._clearCacheService.clearCache("class saved"); - }, - error => this.handleUpdateError("System error creating class", error) - ); - } - } - } - - public divIdUpdateConfirmed(data: any) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - if(!this.formGroup.valid) { - this.divIdsModalOpen(this.alertModalUpdateDivId, "Update", "Update Class"); - this.modalErrorMessage = "Please fill in all required fields marked with *"; - } else { - this.formGroup.controls['portalType'].enable(); - this._helpContentService.updateDivId( this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( - divId => { - this.divIdUpdatedSuccessfully(divId); - this._clearCacheService.clearCache("class updated"); - }, - error => this.handleUpdateError("System error updating class", error) - ); - } - } - } - - public divIdSavedSuccessfully(divId: DivId) { - this.checkboxes.push({divId : divId, checked : false}); - this.applyCheck(false); - } - - public divIdUpdatedSuccessfully(divId : DivId) { - this.checkboxes.find(checkItem => checkItem.divId._id==divId._id).divId = divId; - this.applyCheck(false); - } - - public filterBySearch(text : string) { - this.searchText = new RegExp(text,'i'); - this.applyFilter(); - } - - public applyFilter() { - this.checkboxes = []; - this.divIds.filter(item => this.filterDivIds(item)).forEach( - _ => this.checkboxes.push({divId: _, checked: false}) - ); - } - - public filterDivIds(divId : DivId) : boolean { - let textFlag = this.searchText.toString() == '' || (divId.name + ' ' + divId.portalType).match(this.searchText) != null; - return textFlag; - } - - handleUpdateError(message: string, error) { - if(error == null) { - this.formComponent.reset(); - } else { - this.updateErrorMessage = message; - console.log('Server responded: ' +error); - } - - this.showLoading = false; - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } -} diff --git a/src/app/pages/divId/divIds.module.ts b/src/app/pages/divId/divIds.module.ts deleted file mode 100644 index 209c876..0000000 --- a/src/app/pages/divId/divIds.module.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {FABModule} from '../../utils/fabModule.module'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {DivIdsComponent} from './divIds.component'; -import {DivIdFormComponent} from './divId-form.component'; -import {DivIdsRoutingModule} from './divIds-routing.module'; -import {AdminLoginGuard} from "../../openaireLibrary/login/adminLoginGuard.guard"; - -@NgModule({ - imports: [ - CommonModule, RouterModule, FormsModule, FABModule, - AlertModalModule, ReactiveFormsModule, DivIdsRoutingModule - ], - declarations: [DivIdsComponent, DivIdFormComponent], - providers: [AdminLoginGuard], - exports: [DivIdsComponent] -}) -export class DivIdsModule { } diff --git a/src/app/pages/divhelpcontent/div-help-content-form.component.html b/src/app/pages/divhelpcontent/div-help-content-form.component.html deleted file mode 100644 index c70d31b..0000000 --- a/src/app/pages/divhelpcontent/div-help-content-form.component.html +++ /dev/null @@ -1,56 +0,0 @@ - - - -
- - Create or edit help text -
- Select the class to be displayed, add the content and click active to make it visible to dashboard -
- -
-
-
-
Class content displayed in page(s): {{page.name}},
- -
- - -
- -
- - -
- -
-
- -
- - - -
-
-
- - -
- -
- diff --git a/src/app/pages/divhelpcontent/div-help-content-form.component.ts b/src/app/pages/divhelpcontent/div-help-content-form.component.ts deleted file mode 100644 index 3513f71..0000000 --- a/src/app/pages/divhelpcontent/div-help-content-form.component.ts +++ /dev/null @@ -1,161 +0,0 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import { FormGroup, FormBuilder, Validators } from "@angular/forms"; -import { Page } from "../../domain/page"; -import { DivId } from "../../domain/divId"; -import { HelpContentService } from "../../services/help-content.service"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; - -@Component({ - selector: 'div-content-form', - templateUrl: './div-help-content-form.component.html', -}) - -export class DivContentFormComponent implements OnInit{ - - @Input('group') - myForm: FormGroup; - @Input('communityPid') - communityPid: string; - @Input('pageId') - pageId: string; - @Input('editMode') - editMode: boolean = false; - - //public divIdName: string = ''; - - private communityId: string = ''; - - showPageSelect: boolean = true; - selectedDiv: DivId; - - private availablePages : Page[] = []; - private availableDivs : DivId[] = []; - - private ckeditorContent : string; - - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - @Input() updateErrorMessage: string = ''; - - constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService){} - - ngOnInit() { - this.myForm = this.form; - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe(params => { - - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - if(this.pageId) { - this.showPageSelect = false; - this.getDivs(this.pageId); - } else { - if(!this.editMode) { - this._helpContentService.getCommunityPagesWithDivId(this.communityPid, this.properties.adminToolsAPIURL).subscribe( - pages => { - this.availablePages = pages; - this.showLoading = false; - }, - error => this.handleError('System error retrieving pages', error)); - } - } - - this.getCommunity(this.communityPid); - } - }); - }); - - } - - public pageSelected(event) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.getDivs(event.target.value); - } - } - - public divIdSelected(div: DivId) { - this.selectedDiv = div; - } - - public getCommunity(communityPid: string) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.showLoading = true; - this.errorMessage = ''; - - this._helpContentService.getCommunity(this.communityPid, this.properties.adminToolsAPIURL).subscribe( - community => { - this.communityId = community._id; - - this.myForm.patchValue({ - community: this.communityId - }); - this.showLoading = false; - }, - error => this.handleError('System error retrieving community', error) - ); - } - } - - public getDivs(pageId: string) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - //this.showLoading = true; - this.errorMessage = ''; - - this._helpContentService.getDivIdsFullByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - divs => { - this.availableDivs = divs; - this.pageId = pageId; - - this.showLoading = false; - }, - error => this.handleError('System error retrieving pages', error)); - } - } - - // public selectedDiv(event) { - // console.info(event.target.value); - // } - - public get form() { - return this._fb.group({ - divId: ['', Validators.required], - content: ['', Validators.required], - isActive: true, - portal: this.communityPid, - _id : '', - }); - } - - public reset() { - this.myForm.patchValue({ - divId: '', - content: '', - isActive: true, - portal: this.communityPid, - _id : '' - }); - this.myForm.markAsPristine(); - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } -} diff --git a/src/app/pages/divhelpcontent/div-help-content-form.module.ts b/src/app/pages/divhelpcontent/div-help-content-form.module.ts deleted file mode 100644 index 7cc9bd6..0000000 --- a/src/app/pages/divhelpcontent/div-help-content-form.module.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { NgModule } from '@angular/core'; -import {CommonModule} from '@angular/common'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {FABModule} from '../../utils/fabModule.module'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {SafeHtmlPipeModule} from '../../openaireLibrary/utils/pipes/safeHTMLPipe.module'; -import {DivContentFormComponent} from './div-help-content-form.component'; -import {CKEditorModule} from 'ng2-ckeditor'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - FABModule, SafeHtmlPipeModule, CKEditorModule, - AlertModalModule, ReactiveFormsModule - ], - declarations: [ - DivContentFormComponent - ], - exports: [DivContentFormComponent] -}) -export class DivHelpContentFormModule { } diff --git a/src/app/pages/divhelpcontent/div-help-contents-routing.module.ts b/src/app/pages/divhelpcontent/div-help-contents-routing.module.ts deleted file mode 100644 index 7a62003..0000000 --- a/src/app/pages/divhelpcontent/div-help-contents-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {DivHelpContentsComponent} from './div-help-contents.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: DivHelpContentsComponent} - ]) - ] -}) -export class DivHelpContentsRoutingModule { } diff --git a/src/app/pages/divhelpcontent/div-help-contents.component.html b/src/app/pages/divhelpcontent/div-help-contents.component.html deleted file mode 100644 index aded876..0000000 --- a/src/app/pages/divhelpcontent/div-help-contents.component.html +++ /dev/null @@ -1,155 +0,0 @@ -
- - - -
-
-
- - - -
-
-
-
- - -
- - Enable or disable help text to show or hide it from the dashboard - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
PageClassContentChange statusActions
- - -
- {{page.name}}, -
-
-
{{check.divHelpContent.divId.name}}
-
- -
{{check.divHelpContent.content}}
-
- - -
- - -
-
- -
-
No class help texts found
-
-
-
-
- Go back to {{page.type}} pages -
-
-
-
- -
- - - diff --git a/src/app/pages/divhelpcontent/div-help-contents.component.ts b/src/app/pages/divhelpcontent/div-help-contents.component.ts deleted file mode 100644 index 18d92b7..0000000 --- a/src/app/pages/divhelpcontent/div-help-contents.component.ts +++ /dev/null @@ -1,368 +0,0 @@ -import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; -import { Router, ActivatedRoute } from "@angular/router"; -import { FormGroup } from "@angular/forms"; -import { HelpContentService } from "../../services/help-content.service"; -import { DivHelpContent, CheckDivHelpContent, DivHelpContentFilterOptions } from "../../domain/div-help-content"; -import { Page } from "../../domain/page"; -import { Portal } from "../../domain/portal"; -import { DivId } from "../../domain/divId"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; -import {SafeHtmlPipe} from '../../openaireLibrary/utils/pipes/safeHTML.pipe'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {PageHelpContent} from "../../domain/page-help-content"; -import {Title} from '@angular/platform-browser'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'div-help-contents', - templateUrl: './div-help-contents.component.html', -}) - -export class DivHelpContentsComponent implements OnInit { - // @ViewChild('deleteConfirmationModal') - // public deleteConfirmationModal : DeleteConfirmationDialogComponent; - @ViewChild('AlertModalDeleteDivHelpContents') alertModalDeleteDivHelpContents; - private selectedDivContents: string[] = []; - - public checkboxes : CheckDivHelpContent[] = []; - - public divHelpContents : DivHelpContent[] = []; - - //public errorMessage: string; - - public formGroup : FormGroup; - - public pages: Page[]; - - public checkboxAll : boolean = false; - - public filters : DivHelpContentFilterOptions = {id : '', active : null, text : new RegExp('')}; - public keyword: string = ""; - - public counter = {all : 0, active : 0, inactive : 0}; - - public communities: Portal[] = []; - - public selectedCommunityPid: string; - - public selectedPageId: string; - - public community: Portal; - - public page: Page; - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - public updateErrorMessage: string = ''; - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - - this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | Class Help Texts'); - this.selectedCommunityPid = params['communityId']; - this.selectedPageId = params['pageId']; - - if(this.selectedCommunityPid && this.selectedPageId) { - this.getPage(this.selectedPageId); - } else if(this.selectedCommunityPid){ - this.selectedPageId = ""; - this.getPages(this.selectedCommunityPid); - } - }); - }); - } - - constructor(private element: ElementRef, private route: ActivatedRoute, - private title: Title, - private _helpService: HelpContentService, private router : Router, - private _clearCacheService: ClearCacheService) {} - - getPage(pageId: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ""; - this.errorMessage = ""; - this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( - page => { - // if( (this.selectedCommunityPid == 'openaire' && !page.openaire) - // || (this.selectedCommunityPid == 'connect' && !page.connect) - // || (this.selectedCommunityPid != 'openaire' && this.selectedCommunityPid != 'connect' && !page.communities)) { - if(this.properties.adminToolsPortalType != page.portalType) { - this.router.navigate(['/classContents'], { queryParams: { "communityId": this.selectedCommunityPid} }); - } else { - this.page = page; - this.getDivHelpContents(this.selectedCommunityPid); - } - }, - error => this.handleError('System error retrieving page', error)); - } - } - - getPages(community_pid: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ""; - this.errorMessage = ""; - - this._helpService.getCommunityPagesWithDivId(community_pid, this.properties.adminToolsAPIURL).subscribe( - //this._helpService.getPagesWithDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe( - pages => { - this.pages = pages; - this.getDivHelpContents(this.selectedCommunityPid); - }, - error => this.handleError('System error retrieving pages', error)); - } - } - - public countDivHelpContents() { - this.counter = {all : 0, active : 0, inactive : 0}; - let filter = Object.assign({},this.filters); - filter.active = null; - this.divHelpContents.forEach(_ => { - if(this.filterDivHelpContent(_,filter)){ - if (_.isActive==true) this.counter.active++; - else this.counter.inactive++ - } - }); - this.counter.all = this.counter.active + this.counter.inactive; - } - - getDivHelpContents(community_pid: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this._helpService.getCommunityDivHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe( - divHelpContents => { - this.divHelpContents = divHelpContents as Array; - this.counter.all = this.divHelpContents.length; - this.checkboxes = []; - - for (let i = this.divHelpContents.length - 1; i >= 0; i -= 1) { - //for (let i = 0; i < this.divHelpContents.length; i++) { - let divId: DivId = this.divHelpContents[i].divId as DivId; - let pages: Page[] = divId.pages as Page[]; - const pageIds = pages.map(x => x._id); - - if(!this.selectedPageId || pageIds.includes(this.selectedPageId)) { - this.cutContent(this.divHelpContents[i]); - this.checkboxes.unshift({divHelpContent : this.divHelpContents[i], checked : false}); - } else { - this.divHelpContents.splice(i, 1); - } - } - - this.countDivHelpContents(); - - this.showLoading = false; - }, - error => this.handleError('System error retrieving page contents', error)); - } - } - - public toggleCheckBoxes(event) { - this.checkboxes.forEach(_ => _.checked = event.target.checked); - this.checkboxAll = event.target.checked; - } - - public applyCheck(flag : boolean) { - this.checkboxes.forEach(_ => _.checked = flag); - this.checkboxAll = false; - } - - public getSelectedDivHelpContents() : string[] { - return this.checkboxes.filter(divHelpContent => divHelpContent.checked == true) - .map(checkedDivHelpContent => checkedDivHelpContent.divHelpContent).map(res => res._id); - } - - public confirmDeleteDivHelpContent(id : string) { - //this.deleteConfirmationModal.ids = [id]; - //this.deleteConfirmationModal.showModal(); - this.selectedDivContents = [id]; - this.confirmModalOpen(); - } - - public confirmDeleteSelectedDivHelpContents() { - //this.deleteConfirmationModal.ids = this.getSelectedDivHelpContents(); - //this.deleteConfirmationModal.showModal(); - this.selectedDivContents = this.getSelectedDivHelpContents(); - this.confirmModalOpen(); - } - - private confirmModalOpen() { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.alertModalDeleteDivHelpContents.cancelButton = true; - this.alertModalDeleteDivHelpContents.okButton = true; - this.alertModalDeleteDivHelpContents.alertTitle = "Delete Confirmation"; - this.alertModalDeleteDivHelpContents.message = "Are you sure you want to delete the help text(s)?"; - this.alertModalDeleteDivHelpContents.okButtonText = "Yes"; - this.alertModalDeleteDivHelpContents.open(); - } - } - - public confirmedDeleteDivHelpContents(data: any) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ""; - - this._helpService.deleteDivHelpContents(this.selectedDivContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( - _ => { - this.deleteDivHelpContentsFromArray(this.selectedDivContents); - this.showLoading = false; - this._clearCacheService.clearCache("class help contents deleted"); - }, - error => this.handleUpdateError('System error deleting the selected class content(s)', error) - ); - } - } - - private deleteDivHelpContentsFromArray(ids : string[]) : void { - for(let id of ids) { - let iqc = this.checkboxes.findIndex(_ => _.divHelpContent._id == id); - let iq = this.divHelpContents.findIndex(_ => _._id == id); - this.checkboxes.splice(iqc, 1); - this.divHelpContents.splice(iqc, 1); - } - this.countDivHelpContents(); - } - - public editDivHelpContent(id : string) { - //this.router.navigate(['/pageContents/edit/', _id]); - if(this.selectedPageId) { - this.router.navigate( ['/classContents/edit/'], { queryParams: { "classContentId": id, "communityId": this.selectedCommunityPid, "pageId": this.selectedPageId } } ); - } else { - this.router.navigate( ['/classContents/edit/'], { queryParams: { "classContentId": id, "communityId": this.selectedCommunityPid } } ); - } - } - - public toggleDivHelpContents(status : boolean, ids : string[]) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.updateErrorMessage = ""; - - this._helpService.toggleDivHelpContents(ids,status, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( - () => { - for(let id of ids) { - let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id); - this.checkboxes[i].divHelpContent.isActive=status; - } - this.countDivHelpContents(); - this.applyCheck(false); - this._clearCacheService.clearCache("class help contents toggled (status: "+status+")"); - }, - error => this.handleUpdateError('System error changing the status of the selected page content(s)', error) - ); - } - } - - public divHelpContentSavedSuccessfully(divHelpContent: DivHelpContent) { - this.cutContent(divHelpContent); - this.checkboxes.push({divHelpContent : divHelpContent, checked : false}); - this.divHelpContents.push(divHelpContent); - this.applyCheck(false); - this.countDivHelpContents(); - } - - public divHelpContentUpdatedSuccessfully(divHelpContent : DivHelpContent) { - this.checkboxes.find(checkItem => checkItem.divHelpContent._id==divHelpContent._id).divHelpContent = divHelpContent; - let index = this.divHelpContents.findIndex(checkItem => checkItem._id==divHelpContent._id); - this.divHelpContents[index] = divHelpContent; - this.applyCheck(false); - this.countDivHelpContents(); - } - - - public filterDivHelpContent(divHelpContent : DivHelpContent, filters : DivHelpContentFilterOptions) : boolean { - let divId: DivId = divHelpContent.divId as DivId; - let pages: Page[] = divId.pages; - let pageIds: string[] = pages.map(x => x._id); - - let idFlag = filters.id == '' || /*(divId.pages)._id == filters.id*/ pageIds.includes(filters.id); - let activeFlag = filters.active == null || divHelpContent.isActive == filters.active; - let textFlag = filters.text.toString() == '' || (divHelpContent.content).match(filters.text) != null - || ((divHelpContent.divId).name).match(filters.text) != null; - return idFlag && activeFlag && textFlag; - } - - public cutContent(divHelpContent: DivHelpContent) { - divHelpContent.content = divHelpContent.content.replace(/<[^>]*>/g, ''); - divHelpContent.content = divHelpContent.content.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm," "); - if(divHelpContent.content.length > 200) { - divHelpContent.content = divHelpContent.content.substr(0, 200) + "..."; - } - } - - public applyFilter() { - this.checkboxes = []; - this.divHelpContents.filter(item => this.filterDivHelpContent(item,this.filters)).forEach( - _ => { - this.cutContent(_); - this.checkboxes.push({divHelpContent: _, checked: false}) - } - ); - this.countDivHelpContents(); - } - - public filterByPage(event: any) { - this.filters.id = event.target.value; - this.applyFilter(); - } - - public displayAllDivHelpContents() { - this.filters.active = null; - this.applyFilter(); - } - - public displayActiveDivHelpContents() { - this.filters.active = true; - this.applyFilter(); - } - - public filterBySearch(text : string) { - this.filters.text = new RegExp(text, "i"); - this.applyFilter(); - } - - public displayInactiveDivHelpContents() { - this.filters.active = false; - this.applyFilter(); - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } - - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; - console.log('Server responded: ' +error); - - this.showLoading = false; - } - - public newClassContent() { - if(this.selectedPageId) { - this.router.navigate( ['/classContents/new'], { queryParams: {communityId: this.selectedCommunityPid, pageId: this.selectedPageId} } ); - } else { - this.router.navigate( ['/classContents/new'], { queryParams: {communityId: this.selectedCommunityPid} } ); - } - } -} diff --git a/src/app/pages/divhelpcontent/div-help-contents.module.ts b/src/app/pages/divhelpcontent/div-help-contents.module.ts deleted file mode 100644 index 95d62f1..0000000 --- a/src/app/pages/divhelpcontent/div-help-contents.module.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {FABModule} from '../../utils/fabModule.module'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {DivHelpContentsRoutingModule} from './div-help-contents-routing.module'; -import {SafeHtmlPipeModule} from '../../openaireLibrary/utils/pipes/safeHTMLPipe.module'; -import {DivHelpContentsComponent} from './div-help-contents.component'; -import {MatSlideToggleModule} from '@angular/material'; - -@NgModule({ - imports: [ - CommonModule, RouterModule, FormsModule, FABModule, SafeHtmlPipeModule, - AlertModalModule, ReactiveFormsModule, DivHelpContentsRoutingModule, MatSlideToggleModule - ], - declarations: [ - DivHelpContentsComponent - ], - providers: [IsCommunity, ConnectAdminLoginGuard], - exports: [DivHelpContentsComponent] -}) -export class DivHelpContentsModule { } diff --git a/src/app/pages/divhelpcontent/edit-div-help-content-routing.module.ts b/src/app/pages/divhelpcontent/edit-div-help-content-routing.module.ts deleted file mode 100644 index e73fef5..0000000 --- a/src/app/pages/divhelpcontent/edit-div-help-content-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {EditDivHelpContentComponent} from './edit-div-help-content.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: EditDivHelpContentComponent} - ]) - ] -}) -export class EditDivHelpContentRoutingModule { } diff --git a/src/app/pages/divhelpcontent/edit-div-help-content.component.html b/src/app/pages/divhelpcontent/edit-div-help-content.component.html deleted file mode 100644 index daf6773..0000000 --- a/src/app/pages/divhelpcontent/edit-div-help-content.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
- - -
- -
- - - - - - -
-
-
-
diff --git a/src/app/pages/divhelpcontent/edit-div-help-content.component.ts b/src/app/pages/divhelpcontent/edit-div-help-content.component.ts deleted file mode 100644 index cd0def3..0000000 --- a/src/app/pages/divhelpcontent/edit-div-help-content.component.ts +++ /dev/null @@ -1,188 +0,0 @@ -import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core'; -import { DivContentFormComponent } from "./div-help-content-form.component"; -import { Subscription } from "rxjs"; -import { HelpContentService } from "../../services/help-content.service"; -import { DivHelpContent } from "../../domain/div-help-content"; -import { ActivatedRoute, Router } from "@angular/router"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Page} from "../../domain/page"; -import {Title} from '@angular/platform-browser'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'edit-div-help-content', - templateUrl: 'edit-div-help-content.component.html', -}) - -export class EditDivHelpContentComponent implements OnInit, OnDestroy{ - - @ViewChild(DivContentFormComponent) - public formComponent : DivContentFormComponent; - - public communityPid: string; - public pageId: string; - public page: Page; - - private sub: Subscription; - - private divHelpContent: DivHelpContent; - - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - public updateErrorMessage: string = ''; - - constructor( - private element: ElementRef, - private route: ActivatedRoute, - private router: Router, - private title: Title, - private _helpContentService: HelpContentService, - private _clearCacheService: ClearCacheService) {} - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.sub = this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - - //let id = params['id']; - let divContentId = params['classContentId']; - this.communityPid = params['communityId']; - this.pageId = params['pageId']; - this.title.setTitle('Administration Dashboard | Edit Class Help Text'); - if(!divContentId) { - this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} }); - } - - this.getDivHelpContent(divContentId); - }); - }); - } - ngOnDestroy() { - this.sub.unsubscribe(); - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } - - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } - - private getPage(pageId: string) { - this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( - page => { - // if( (this.communityPid == 'openaire' && !page.openaire) - // || (this.communityPid == 'connect' && !page.connect) - // || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { - if(this.properties.adminToolsPortalType != page.portalType) { - this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} }); - } else { - this.page = page; - this.showLoading = false; - } - }, - error => this.handleError('System error retrieving page with id: '+pageId, error) - ); - } - - private getDivHelpContent(divContentId: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - this.errorMessage = ""; - this.updateErrorMessage = ""; - - this._helpContentService.getDivHelpContent(divContentId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - divHelpContent => { - if(this.pageId) { - this.getPage(this.pageId); - } - this.updateForm(divHelpContent); - this.showLoading = false; - }, - error => this.handleError('System error retrieving class help content', error)); - } - } - - getDivId(divId: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - - this._helpContentService.getDivIdFull(divId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - div => { - this.formComponent.selectedDiv = div; - - if(!this.pageId) { - this.formComponent.getDivs(""); - } - - this.showLoading = false; - }, - error => this.handleError('System error retrieving class', error) - ); - } - } - - private updateForm(divHelpContent : DivHelpContent) { - this.divHelpContent = divHelpContent; - - this.getDivId(divHelpContent.divId as string); - - this.formComponent.myForm.patchValue((divHelpContent)); - } - - public saveCustom() { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - if(this.formComponent.myForm.valid) { - this.showLoading = true; - this.updateErrorMessage = ""; - - let divHelpContent : DivHelpContent = this.formComponent.myForm.value; - - this._helpContentService.updateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - _ => { - if(this.pageId) { - this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); - } else { - this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); - } - this.showLoading = false; - this._clearCacheService.clearCache("class help content updated"); - }, - err => this.handleUpdateError('System error updating class content', err) - ); - } else { - this.errorMessage = "Please fill all required fields"; - } - } - } - - public cancelCustom() { - this.errorMessage = ""; - this.updateErrorMessage = ""; - - if(this.pageId) { - this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); - } else { - this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); - } - } -} diff --git a/src/app/pages/divhelpcontent/edit-div-help-content.module.ts b/src/app/pages/divhelpcontent/edit-div-help-content.module.ts deleted file mode 100644 index a7d006c..0000000 --- a/src/app/pages/divhelpcontent/edit-div-help-content.module.ts +++ /dev/null @@ -1,21 +0,0 @@ -import {NgModule} from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {EditDivHelpContentRoutingModule} from './edit-div-help-content-routing.module'; -import {EditDivHelpContentComponent} from './edit-div-help-content.component'; -import {DivHelpContentFormModule} from './div-help-content-form.module'; - -@NgModule({ - imports: [ - CommonModule, RouterModule, - DivHelpContentFormModule, EditDivHelpContentRoutingModule - ], - declarations: [ - EditDivHelpContentComponent - ], - providers: [IsCommunity, ConnectAdminLoginGuard], - exports: [EditDivHelpContentComponent] -}) -export class EditDivHelpContentModule { } diff --git a/src/app/pages/divhelpcontent/new-div-help-content-routing.module.ts b/src/app/pages/divhelpcontent/new-div-help-content-routing.module.ts deleted file mode 100644 index cfd65c3..0000000 --- a/src/app/pages/divhelpcontent/new-div-help-content-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {NewDivHelpContentComponent} from './new-div-help-content.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: NewDivHelpContentComponent} - ]) - ] -}) -export class NewDivHelpContentRoutingModule { } diff --git a/src/app/pages/divhelpcontent/new-div-help-content.component.html b/src/app/pages/divhelpcontent/new-div-help-content.component.html deleted file mode 100644 index 954b59b..0000000 --- a/src/app/pages/divhelpcontent/new-div-help-content.component.html +++ /dev/null @@ -1,23 +0,0 @@ -
-
- - -
- -
- - - - - - -
-
-
-
diff --git a/src/app/pages/divhelpcontent/new-div-help-content.component.ts b/src/app/pages/divhelpcontent/new-div-help-content.component.ts deleted file mode 100644 index 2b729b6..0000000 --- a/src/app/pages/divhelpcontent/new-div-help-content.component.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { Component, ViewChild, ElementRef } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import { DivContentFormComponent } from "./div-help-content-form.component"; -import { DivHelpContent } from "../../domain/div-help-content"; -import { HelpContentService } from "../../services/help-content.service"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Page} from "../../domain/page"; -import {Title} from '@angular/platform-browser'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'new-div-help-content', - templateUrl: 'new-div-help-content.component.html', -}) - -export class NewDivHelpContentComponent { - - @ViewChild(DivContentFormComponent) - public formComponent : DivContentFormComponent; - - //private errorMessage : string = null; - - public communityPid: string; - - public pageId: string; - public page: Page; - - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - public updateErrorMessage: string = ''; - - constructor( - private element: ElementRef, - private route: ActivatedRoute, - private router: Router, - private title: Title, - private _helpContentService: HelpContentService, - private _clearCacheService: ClearCacheService) {} - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | New Class Help Text'); - this.communityPid = params['communityId']; - this.pageId = params['pageId']; - - - if(this.pageId) { - this.getPage(this.pageId); - } else { - this.showLoading = false; - } - }); - }); - } - - private getPage(pageId: string) { - this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( - page => { - // if( (this.communityPid == 'openaire' && !page.openaire) - // || (this.communityPid == 'connect' && !page.connect) - // || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { - if(this.properties.adminToolsPortalType != page.portalType) { - this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} }); - } else { - this.page = page; - this.showLoading = false; - console.info(this.page); - } - }, - error => this.handleError('System error retrieving page with id: '+pageId, error) - ); - } - - public saveCustom() { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - if(this.formComponent.myForm.valid) { - this.showLoading = true; - this.updateErrorMessage = ""; - - let divHelpContent : DivHelpContent = this.formComponent.myForm.value; - - this._helpContentService.saveDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - _ => { - if(this.pageId) { - this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); - } else { - this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); - } - this.showLoading = false; - this._clearCacheService.clearCache("class help content saved"); - }, - err => this.handleUpdateError('System error saving page content', err) - ); - } else { - this.errorMessage = "Please fill all required fields"; - } - } - } - - public cancelCustom() { - if(this.pageId) { - this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); - } else { - this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); - } - } - - handleUpdateError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } -} diff --git a/src/app/pages/divhelpcontent/new-div-help-content.module.ts b/src/app/pages/divhelpcontent/new-div-help-content.module.ts deleted file mode 100644 index d3ecabd..0000000 --- a/src/app/pages/divhelpcontent/new-div-help-content.module.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {NewDivHelpContentRoutingModule} from './new-div-help-content-routing.module'; -import {NewDivHelpContentComponent} from './new-div-help-content.component'; -import {DivHelpContentFormModule} from './div-help-content-form.module'; - -@NgModule({ - imports: [ - CommonModule, RouterModule, - DivHelpContentFormModule, NewDivHelpContentRoutingModule - ], - declarations: [ - NewDivHelpContentComponent - ], - providers: [IsCommunity, ConnectAdminLoginGuard], - exports: [NewDivHelpContentComponent] -}) -export class NewDivHelpContentModule { } diff --git a/src/app/pages/entity/entities-routing.module.ts b/src/app/pages/entity/entities-routing.module.ts deleted file mode 100644 index da2247d..0000000 --- a/src/app/pages/entity/entities-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {EntitiesComponent} from './entities.component'; -import {IsCommunityOrAdmin} from '../../openaireLibrary/connect/communityGuard/isCommunityOrAdmin'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunityOrAdmin, ConnectAdminLoginGuard], component: EntitiesComponent} - ]) - ] -}) -export class EntitiesRoutingModule { } diff --git a/src/app/pages/entity/entities.component.html b/src/app/pages/entity/entities.component.html deleted file mode 100644 index 2487eb1..0000000 --- a/src/app/pages/entity/entities.component.html +++ /dev/null @@ -1,123 +0,0 @@ -
- - - -
-
-
-
-
- - Disable an entity to hide it from community dashboard portal.
-
If an entity is disabled, all related search and advanced search pages will be hidden from the community dashborad and a message "Can't find that page" will appear in case the url of that page is loaded. If the related page belongs to the menu the link will be removed from menu, too.
- -
- - - - -
-
-
-
- - - - - - - - - - - - - - - - - -
NameChange statusActions
- -
{{check.entity.name}}
-
- - -
- - -
-
- -
-
No entities found
-
-
-
-
-
-
-
-
- - -
- - - - - - - - - - - - - - - diff --git a/src/app/pages/entity/entities.component.ts b/src/app/pages/entity/entities.component.ts deleted file mode 100644 index 12b2ef7..0000000 --- a/src/app/pages/entity/entities.component.ts +++ /dev/null @@ -1,349 +0,0 @@ -import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { HelpContentService } from '../../services/help-content.service'; -import { FormGroup } from '@angular/forms'; -import { EntityFormComponent } from './entity-form.component'; -import { CheckEntity, Entity } from '../../domain/entity'; -import { Portal } from '../../domain/portal'; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; -import {Title} from '@angular/platform-browser'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'entities', - templateUrl: './entities.component.html', -}) - -export class EntitiesComponent implements OnInit { - - // @ViewChild(ModalFormComponent) - // @ViewChild('saveModal') - // public modal:ModalFormComponent; - // - // @ViewChild('updateModal') - // public updateModal:ModalFormComponent; - @ViewChild('AlertModalSaveEntity') alertModalSaveEntity; - @ViewChild('AlertModalUpdateEntity') alertModalUpdateEntity; - @ViewChild('AlertModalDeleteEntities') alertModalDeleteEntities; - private selectedEntities: string[] = []; - - @ViewChild(EntityFormComponent) - public formComponent: EntityFormComponent; - - public checkboxes: CheckEntity[] = []; - - public entities: Entity[] = []; - - public formGroup: FormGroup; - - private searchText: RegExp = new RegExp(''); - public keyword = ''; - - public communities: Portal[] = []; - public selectedCommunityPid: string; - - @ViewChild('AlertModalRelatedPages') alertModalRelatedPages; - - public toggleIds: string[]; - public toggleStatus: boolean; - public properties: EnvProperties = null; - - public showLoading = true; - public errorMessage = ''; - public updateErrorMessage = ''; - public modalErrorMessage = ''; - public isPortalAdministrator = null; - - constructor(private element: ElementRef, private route: ActivatedRoute, - private _router: Router, private title: Title, - private _helpContentService: HelpContentService, - private userManagementService: UserManagementService, - private _clearCacheService: ClearCacheService) {} - - ngOnInit() { - this.formGroup = this.formComponent.form; - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.title.setTitle('Administration Dashboard | Entities'); - this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - this.userManagementService.getUserInfo().subscribe( user => { - this.selectedCommunityPid = params['communityId']; - this.applyCommunityFilter(this.selectedCommunityPid); - this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.selectedCommunityPid; - }); - }); - }); - - } - - getEntities(community_pid: string) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ''; - this.errorMessage = ''; - if(community_pid) { - this._helpContentService.getCommunityEntities(community_pid, this.properties.adminToolsAPIURL).subscribe( - entities => { - this.entities = entities; - this.checkboxes = []; - - let self = this; - entities.forEach(_ => { - self.checkboxes.push({entity: _, checked: false}); - }); - - this.showLoading = false; - }, - error => this.handleError('System error retrieving entities', error)); - } else { - this._helpContentService.getEntities(this.properties.adminToolsAPIURL).subscribe( - entities => { - this.entities = entities; - this.checkboxes = []; - - let self = this; - entities.forEach(_ => { - self.checkboxes.push({entity: _, checked: false}); - }); - this.showLoading = false; - }, - error => this.handleError('System error retrieving community entities', error)); - } - } - } - - public toggleCheckBoxes(event) { - this.checkboxes.forEach(_ => _.checked = event.target.checked); - } - - public applyCheck(flag: boolean) { - this.checkboxes.forEach(_ => _.checked = flag); - } - - public getSelectedEntities(): string[] { - return this.checkboxes.filter(entity => entity.checked === true).map(checkedEntity => checkedEntity.entity).map(res => res._id); - } - - private deleteEntitiesFromArray(ids: string[]): void { - for (let id of ids) { - const i = this.checkboxes.findIndex(_ => _.entity._id === id); - this.checkboxes.splice(i, 1); - } - } - - public confirmDeleteEntity(id: string) { - // this.deleteConfirmationModal.ids = [id]; - // this.deleteConfirmationModal.showModal(); - this.selectedEntities = [id]; - this.confirmDeleteEntitiesModalOpen(); - } - - public confirmDeleteSelectedEntities() { - // this.deleteConfirmationModal.ids = this.getSelectedEntities(); - // this.deleteConfirmationModal.showModal(); - this.selectedEntities = this.getSelectedEntities(); - this.confirmDeleteEntitiesModalOpen(); - } - - private confirmDeleteEntitiesModalOpen() { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - this.alertModalDeleteEntities.cancelButton = true; - this.alertModalDeleteEntities.okButton = true; - this.alertModalDeleteEntities.alertTitle = 'Delete Confirmation'; - this.alertModalDeleteEntities.message = 'Are you sure you want to delete the selected entity(-ies)?'; - this.alertModalDeleteEntities.okButtonText = 'Yes'; - this.alertModalDeleteEntities.open(); - } - } - - public confirmedDeleteEntities(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ''; - - this._helpContentService.deleteEntities(this.selectedEntities, this.properties.adminToolsAPIURL).subscribe( - _ => { - this.deleteEntitiesFromArray(this.selectedEntities); - this.showLoading = false; - this._clearCacheService.clearCache("entities deleted"); - }, - error => this.handleUpdateError('System error deleting the selected entities', error) - ); - } - } - - public editEntity(i: number) { - const entity: Entity = this.checkboxes[i].entity; - this.formGroup.patchValue(entity); - // this.updateModal.showModal(); - this.modalErrorMessage = ''; - this.entitiesModalOpen(this.alertModalUpdateEntity, 'Update', 'Update Entity'); - } - - public newEntity() { - this.formComponent.reset(); - this.modalErrorMessage = ''; - this.entitiesModalOpen(this.alertModalSaveEntity, 'Save', 'Add a new Entity'); - } - - private entitiesModalOpen(modal: any, title: string, yesBtn: string) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - modal.cancelButton = true; - modal.okButton = true; - modal.alertTitle = title; - modal.okButtonText = yesBtn; - modal.open(); - } - } - - public entitySaveConfirmed(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if (!this.formGroup.valid) { - this.entitiesModalOpen(this.alertModalSaveEntity, 'Save', 'Add a new Entity'); - this.modalErrorMessage = 'Please fill in all required fields marked with *'; - } else { - this.modalErrorMessage = ''; - this._helpContentService.saveEntity( this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( - entity => { - this.entitySavedSuccessfully(entity); - this._clearCacheService.clearCache("entity saved"); - }, - error => this.handleUpdateError('System error creating entity', error) - ); - } - } - } - - public entityUpdateConfirmed(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if(!this.formGroup.valid) { - this.entitiesModalOpen(this.alertModalUpdateEntity, 'Update', 'Update Entity'); - this.modalErrorMessage = 'Please fill in all required fields marked with *'; - } else { - this._helpContentService.updateEntity( - this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( - entity => { - this.entityUpdatedSuccessfully(entity); - this._clearCacheService.clearCache("entity updated"); - }, - error => this.handleUpdateError('System error updating entity', error) - ); - } - } - } - - public entitySavedSuccessfully(entity: Entity) { - this.checkboxes.push({entity : entity, checked : false}); - this.applyCheck(false); - } - - public entityUpdatedSuccessfully(entity: Entity) { - this.checkboxes.find(checkItem => checkItem.entity._id === entity._id).entity = entity; - this.applyCheck(false); - } - - public filterBySearch(text: string) { - this.searchText = new RegExp(text, 'i'); - this.applyFilter(); - } - - public applyFilter() { - this.checkboxes = []; - this.entities.filter(item => this.filterEntities(item)).forEach( - _ => this.checkboxes.push({entity: _, checked: false}) - ); - } - - public filterEntities(entity: Entity): boolean { - const textFlag = this.searchText.toString() === '' || (entity.name).match(this.searchText) != null; - return textFlag; - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } - - handleUpdateError(message: string, error) { - if (error == null) { - this.formComponent.reset(); - } else { - this.updateErrorMessage = message; - console.log('Server responded: ' + error); - } - - this.showLoading = false; - } - - public applyCommunityFilter(community_pid: string) { - this.getEntities(community_pid); - } - - public toggleEntities(status: boolean, ids: string[]) { - // this.okModal.showModal(); - this.toggleIds = ids; - this.toggleStatus = status; - this.confirmRelatedPagesModalOpen(); - } - - private confirmRelatedPagesModalOpen() { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - this.alertModalRelatedPages.cancelButton = true; - this.alertModalRelatedPages.okButton = true; - this.alertModalRelatedPages.alertTitle = 'Warning'; - this.alertModalRelatedPages.message = "This action will affect all search pages related to this entity! Pages' status will change to entity's status! Do you want to continue?"; - this.alertModalRelatedPages.okButtonText = 'Yes'; - this.alertModalRelatedPages.open(); - } - } - - public continueToggling(event: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - this.updateErrorMessage = ''; - this._helpContentService.toggleEntities( - this.selectedCommunityPid, this.toggleIds, this.toggleStatus, this.properties.adminToolsAPIURL).subscribe( - () => { - for (let id of this.toggleIds) { - const i = this.checkboxes.findIndex(_ => _.entity._id === id); - this.checkboxes[i].entity.isEnabled = this.toggleStatus; - } - this.applyCheck(false); - this._clearCacheService.clearCache("entities toggled (status: "+this.toggleStatus+")"); - }, - error => this.handleUpdateError('System error changing the status of the selected entity(-ies)', error) - ); - } - } - } diff --git a/src/app/pages/entity/entities.module.ts b/src/app/pages/entity/entities.module.ts deleted file mode 100644 index 24a2fc0..0000000 --- a/src/app/pages/entity/entities.module.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {EntitiesComponent} from './entities.component'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {FABModule} from '../../utils/fabModule.module'; -import {EntityFormComponent} from './entity-form.component'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {EntitiesRoutingModule} from './entities-routing.module'; -import {MatSlideToggleModule} from '@angular/material'; -import {IsCommunityOrAdmin} from '../../openaireLibrary/connect/communityGuard/isCommunityOrAdmin'; - -@NgModule({ - imports: [ - CommonModule, RouterModule, FormsModule, FABModule, - AlertModalModule, ReactiveFormsModule, EntitiesRoutingModule, MatSlideToggleModule - ], - declarations: [EntitiesComponent, EntityFormComponent], - providers: [IsCommunityOrAdmin, ConnectAdminLoginGuard], - exports: [EntitiesComponent] -}) -export class EntitiesModule { } diff --git a/src/app/pages/entity/entity-form.component.html b/src/app/pages/entity/entity-form.component.html deleted file mode 100644 index 755f540..0000000 --- a/src/app/pages/entity/entity-form.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
- - -
-
- - -
- -
diff --git a/src/app/pages/entity/entity-form.component.ts b/src/app/pages/entity/entity-form.component.ts deleted file mode 100644 index 963cc50..0000000 --- a/src/app/pages/entity/entity-form.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {Component, OnInit, Input} from '@angular/core'; -import {FormGroup, FormBuilder, Validators} from "@angular/forms"; - - -@Component({ - selector: 'entity-form', - templateUrl: './entity-form.component.html', -}) - -export class EntityFormComponent implements OnInit{ - - @Input('group') - myForm: FormGroup; - - constructor(private _fb: FormBuilder){} - - ngOnInit(): void { - } - - public get form() { - return this._fb.group({ - pid: ['', Validators.required], - name : ['', Validators.required], - isEnabled: '', - _id : '' - }); - } - - public reset() { - this.myForm.patchValue({ - pid: '', - name : '', - isEnabled: '', - _id : '' - }); - } - -} diff --git a/src/app/pages/error/errorPage.component.ts b/src/app/pages/error/errorPage.component.ts index 789d55c..6db8884 100644 --- a/src/app/pages/error/errorPage.component.ts +++ b/src/app/pages/error/errorPage.component.ts @@ -1,10 +1,12 @@ -import { Component} from '@angular/core'; +import {Component} from '@angular/core'; @Component({ - selector: 'openaire-error', - template: ` - - ` + selector: 'openaire-error', + template: ` +
+ +
+ ` }) export class AdminErrorPageComponent { diff --git a/src/app/pages/helpcontent/edit-page-help-content-routing.module.ts b/src/app/pages/helpcontent/edit-page-help-content-routing.module.ts deleted file mode 100644 index 5906590..0000000 --- a/src/app/pages/helpcontent/edit-page-help-content-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {EditPageHelpContentComponent} from './edit-page-help-content.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: EditPageHelpContentComponent} - ]) - ] -}) -export class EditPageHelpContentRoutingModule { } diff --git a/src/app/pages/helpcontent/edit-page-help-content.component.html b/src/app/pages/helpcontent/edit-page-help-content.component.html deleted file mode 100644 index 8b8ca71..0000000 --- a/src/app/pages/helpcontent/edit-page-help-content.component.html +++ /dev/null @@ -1,23 +0,0 @@ -
-
- - -
- -
- - - - - - -
-
-
-
diff --git a/src/app/pages/helpcontent/edit-page-help-content.component.ts b/src/app/pages/helpcontent/edit-page-help-content.component.ts deleted file mode 100644 index 6b0e8cb..0000000 --- a/src/app/pages/helpcontent/edit-page-help-content.component.ts +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Created by stefania on 7/14/17. - */ -import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core'; -import { PageContentFormComponent } from "./page-help-content-form.component"; -import { Subscription } from "rxjs"; -import { HelpContentService } from "../../services/help-content.service"; -import { PageHelpContent } from "../../domain/page-help-content"; -import { ActivatedRoute, Router } from "@angular/router"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Page} from "../../domain/page"; -import {Title} from '@angular/platform-browser'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'edit-page-help-content', - templateUrl: 'edit-page-help-content.component.html', -}) - -export class EditPageHelpContentComponent implements OnInit, OnDestroy{ - - @ViewChild(PageContentFormComponent) - public formComponent : PageContentFormComponent; - - public communityPid: string; - - public pageId: string; - public page: Page; - - private sub: Subscription; - - private pageHelpContent: PageHelpContent; - - //private errorMessage : string = null; - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - public updateErrorMessage: string = ''; - - constructor( - private element: ElementRef, - private route: ActivatedRoute, - private router: Router, - private title: Title, - private _helpContentService: HelpContentService, - private _clearCacheService: ClearCacheService) {} - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.sub = this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - - let pageContentId = params['pageContentId']; - this.communityPid = params['communityId']; - this.pageId = params['pageId']; - this.title.setTitle('Administration Dashboard | Edit Page Help Text'); - if(!pageContentId) { - this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); - } - - this.getPageHelpContent(pageContentId); - }); - }); - } - ngOnDestroy() { - this.sub.unsubscribe(); - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } - - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } - - private getPage(pageId: string) { - this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( - page => { - // if( (this.communityPid == 'openaire' && !page.openaire) - // || (this.communityPid == 'connect' && !page.connect) - // || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { - if(this.properties.adminToolsPortalType != page.portalType) { - this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); - } else { - this.page = page; - this.formComponent.setPlacements(this.page); - this.showLoading = false; - } - }, - error => this.handleError('System error retrieving page with id: '+pageId, error) - ); - } - - private getPageHelpContent(pageContentId: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - this.errorMessage = ""; - this.updateErrorMessage = ""; - - this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - pageHelpContent => { - if(this.pageId && this.pageId != pageHelpContent.page) { - this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); - } else if(this.pageId) { - this.getPage(this.pageId); - } else { - this.getPage(pageHelpContent.page); - } - this.updateForm(pageHelpContent); - //this.showLoading = false; - }, - error => this.handleError('System error retrieving page help content', error)); - } - } - - private updateForm(pageHelpContent : PageHelpContent) { - this.pageHelpContent = pageHelpContent; - this.formComponent.myForm.patchValue((pageHelpContent)); - // console.log("patching",pageHelpContent); - } - - public saveCustom() { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - if(this.formComponent.myForm.valid) { - this.showLoading = true; - this.updateErrorMessage = ""; - - let pageHelpContent : PageHelpContent = this.formComponent.myForm.value; - this._helpContentService.updatePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - _ => { - if(this.pageId) { - this.router.navigate( ['/pageContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); - } else { - this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} } ); - } - this.showLoading = false; - this._clearCacheService.clearCache("page help content updated"); - }, - err => this.handleUpdateError('System error updating page content', err) - ); - } else { - this.errorMessage = "Please fill all required fields"; - } - } - } - - public cancelCustom() { - this.errorMessage = ""; - this.updateErrorMessage = ""; - - if(this.pageId) { - this.router.navigate( ['/pageContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); - } else { - this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} } ); - } - } -} diff --git a/src/app/pages/helpcontent/edit-page-help-content.module.ts b/src/app/pages/helpcontent/edit-page-help-content.module.ts deleted file mode 100644 index 7322594..0000000 --- a/src/app/pages/helpcontent/edit-page-help-content.module.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {EditPageHelpContentRoutingModule} from './edit-page-help-content-routing.module'; -import {EditPageHelpContentComponent} from './edit-page-help-content.component'; -import {PageHelpContentFormModule} from './page-help-content-form.module'; - -@NgModule({ - imports: [ - CommonModule, RouterModule, - PageHelpContentFormModule, EditPageHelpContentRoutingModule - ], - declarations: [ - EditPageHelpContentComponent - ], - providers: [IsCommunity, ConnectAdminLoginGuard], - exports: [EditPageHelpContentComponent] -}) -export class EditPageHelpContentModule { } diff --git a/src/app/pages/helpcontent/new-page-help-content-routing.module.ts b/src/app/pages/helpcontent/new-page-help-content-routing.module.ts deleted file mode 100644 index 7fb748c..0000000 --- a/src/app/pages/helpcontent/new-page-help-content-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {NewPageHelpContentComponent} from './new-page-help-content.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: NewPageHelpContentComponent} - ]) - ] -}) -export class NewPageHelpContentRoutingModule { } diff --git a/src/app/pages/helpcontent/new-page-help-content.component.html b/src/app/pages/helpcontent/new-page-help-content.component.html deleted file mode 100644 index 93cadd3..0000000 --- a/src/app/pages/helpcontent/new-page-help-content.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
- - -
- -
- - - - - - - -
-
-
-
diff --git a/src/app/pages/helpcontent/new-page-help-content.component.ts b/src/app/pages/helpcontent/new-page-help-content.component.ts deleted file mode 100644 index b0575e6..0000000 --- a/src/app/pages/helpcontent/new-page-help-content.component.ts +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Created by stefania on 7/13/17. - */ -import { Component, ViewChild, ElementRef } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import { PageContentFormComponent } from "./page-help-content-form.component"; -import { PageHelpContent } from "../../domain/page-help-content"; -import { HelpContentService } from "../../services/help-content.service"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Page} from "../../domain/page"; -import {Title} from '@angular/platform-browser'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'new-page-help-content', - templateUrl: 'new-page-help-content.component.html', -}) - -export class NewPageHelpContentComponent { - - @ViewChild(PageContentFormComponent) - public formComponent : PageContentFormComponent; - - //private errorMessage : string = null; - - public communityPid: string; - - public pageId: string; - public page: Page; - - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - public updateErrorMessage: string = ''; - - constructor( - private element: ElementRef, - private route: ActivatedRoute, - private router: Router, - private title: Title, - private _helpContentService: HelpContentService, - private _clearCacheService: ClearCacheService) {} - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | New Page Help Text'); - this.communityPid = params['communityId']; - this.pageId = params['pageId']; - - if(this.pageId) { - this.getPage(this.pageId); - } else { - this.showLoading = false; - } - }); - }); - } - - private getPage(pageId: string) { - this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( - page => { - // if( (this.communityPid == 'openaire' && !page.openaire) - // || (this.communityPid == 'connect' && !page.connect) - // || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { - if(this.properties.adminToolsPortalType != page.portalType) { - this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); - } else { - this.page = page; - this.formComponent.setPlacements(this.page); - this.showLoading = false; - console.info(this.page); - } - }, - error => this.handleError('System error retrieving page with id: '+pageId, error) - ); - } - - public saveCustom() { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - //this.errorMessage = null; - - if(this.formComponent.myForm.valid) { - this.showLoading = true; - this.updateErrorMessage = ""; - - let pageHelpContent : PageHelpContent = this.formComponent.myForm.value; - - this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - _ => { - if(this.pageId) { - this.router.navigate( ['/pageContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); - } else { - this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); - } - this.showLoading = false; - this._clearCacheService.clearCache("page help content saved"); - }, - err => this.handleUpdateError('System error saving page content', err) - ); - } else { - this.errorMessage = "Please fill all required fields"; - } - } - } - - public cancelCustom() { - if(this.pageId) { - this.router.navigate( ['/pageContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); - } else { - this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} } ); - } - } - - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } -} diff --git a/src/app/pages/helpcontent/new-page-help-content.module.ts b/src/app/pages/helpcontent/new-page-help-content.module.ts deleted file mode 100644 index 1c6c57f..0000000 --- a/src/app/pages/helpcontent/new-page-help-content.module.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {NewPageHelpContentComponent} from './new-page-help-content.component'; -import {NewPageHelpContentRoutingModule} from './new-page-help-content-routing.module'; -import {PageHelpContentFormModule} from './page-help-content-form.module'; - -@NgModule({ - imports: [ - CommonModule, RouterModule, - PageHelpContentFormModule, NewPageHelpContentRoutingModule - ], - declarations: [ - NewPageHelpContentComponent - ], - providers: [IsCommunity, ConnectAdminLoginGuard], - exports: [NewPageHelpContentComponent] -}) -export class NewPageHelpContentModule { } diff --git a/src/app/pages/helpcontent/page-help-content-form.component.html b/src/app/pages/helpcontent/page-help-content-form.component.html deleted file mode 100644 index 3513bad..0000000 --- a/src/app/pages/helpcontent/page-help-content-form.component.html +++ /dev/null @@ -1,81 +0,0 @@ - - - -
- - Create or edit help text -
- Select the page to be displayed, select position of the page -
- -
-
-
- - -
-
- - -
-
- -
- - - - - - - - - - - - -
- - -
-
- - -
- -
- - -
- -
- - - - diff --git a/src/app/pages/helpcontent/page-help-content-form.component.ts b/src/app/pages/helpcontent/page-help-content-form.component.ts deleted file mode 100644 index 7bef64c..0000000 --- a/src/app/pages/helpcontent/page-help-content-form.component.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import { FormGroup, FormBuilder, Validators } from "@angular/forms"; -import { Page } from "../../domain/page"; -import { HelpContentService } from "../../services/help-content.service"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; - -@Component({ - selector: 'page-content-form', - templateUrl: './page-help-content-form.component.html', -}) - -export class PageContentFormComponent implements OnInit{ - - @Input('group') - myForm: FormGroup; - @Input('communityPid') - communityPid: string; - @Input('pageId') - pageId: string; - @Input('page') - page: Page; - placements = {"top": false, "bottom": false, "left": false, "right": false} - - private availablePages : Page[] = []; - //private errorMessage: string; - - private ckeditorContent : string; - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - @Input() updateErrorMessage: string = ''; - - constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService){} - - ngOnInit() { - this.myForm = this.form; - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - if(!this.pageId) { - this.myForm.valueChanges.subscribe(value => { - let pageId = value.page; - this._helpContentService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(page => { - this.setPlacements(page); - }); - }); - } - this._helpContentService.getCommunityPagesWithPositions(this.communityPid, this.properties.adminToolsAPIURL).subscribe( - pages => { - this.availablePages = pages; - this.showLoading = false; - }, - error => this.handleError('System error retrieving pages', error)); - } - }); - } - - public setPlacements(page: Page) { - this.placements.top = page.top; - this.placements.bottom = page.bottom; - this.placements.left = page.left; - this.placements.right = page.right; - } - - public get form() { - return this._fb.group({ - page : [this.pageId, Validators.required], - portal : this.communityPid, - placement : ['', Validators.required], - content : ['', Validators.required], - order : [1, Validators.required], - isActive : true, - //isPriorTo : false, - _id : '', - }); - } - - public reset() { - this.myForm.patchValue({ - page : '', - portal : this.communityPid, - placement : '', - content : [''], - order : 1, - isActive : true, - //isPriorTo : false, - _id : '' - }); - this.myForm.markAsPristine(); - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } -} diff --git a/src/app/pages/helpcontent/page-help-content-form.module.ts b/src/app/pages/helpcontent/page-help-content-form.module.ts deleted file mode 100644 index feeb967..0000000 --- a/src/app/pages/helpcontent/page-help-content-form.module.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { NgModule } from '@angular/core'; -import {CommonModule} from '@angular/common'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {FABModule} from '../../utils/fabModule.module'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {SafeHtmlPipeModule} from '../../openaireLibrary/utils/pipes/safeHTMLPipe.module'; -import {CKEditorModule} from 'ng2-ckeditor'; -import {PageContentFormComponent} from './page-help-content-form.component'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - FABModule, SafeHtmlPipeModule, CKEditorModule, - AlertModalModule, ReactiveFormsModule - ], - declarations: [ - PageContentFormComponent - ], - exports: [PageContentFormComponent] -}) -export class PageHelpContentFormModule { } diff --git a/src/app/pages/helpcontent/page-help-contents-routing.module.ts b/src/app/pages/helpcontent/page-help-contents-routing.module.ts deleted file mode 100644 index 1e490b0..0000000 --- a/src/app/pages/helpcontent/page-help-contents-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {PageHelpContentsComponent} from './page-help-contents.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: PageHelpContentsComponent} - ]) - ] -}) -export class PageHelpContentsRoutingModule { } diff --git a/src/app/pages/helpcontent/page-help-contents.component.html b/src/app/pages/helpcontent/page-help-contents.component.html deleted file mode 100644 index e916256..0000000 --- a/src/app/pages/helpcontent/page-help-contents.component.html +++ /dev/null @@ -1,154 +0,0 @@ -
- - -
-
-
- - - - - -
-
-
-
- - -
- - Enable or disable help text to show or hide it from the dashboard - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PageCommunityContentPlacementOrderChange statusActions
- -
{{check.pageHelpContent.page.name}}
-
-
{{check.pageHelpContent.portal.name}}
-
- -
{{check.pageHelpContent.content}}
-
-
{{check.pageHelpContent.placement}}
-
-
{{check.pageHelpContent.order}} -
-
- - -
- - -
-
- -
-
No page contents found
-
-
-
-
- Go back to {{page.type}} pages -
-
-
-
- -
- - - diff --git a/src/app/pages/helpcontent/page-help-contents.component.ts b/src/app/pages/helpcontent/page-help-contents.component.ts deleted file mode 100644 index cd58cf6..0000000 --- a/src/app/pages/helpcontent/page-help-contents.component.ts +++ /dev/null @@ -1,379 +0,0 @@ -/** - * Created by stefania on 7/13/17. - */ -import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; -import { FormGroup } from "@angular/forms"; -import { ActivatedRoute, Router } from "@angular/router"; -import { HelpContentService } from "../../services/help-content.service"; -import { PageHelpContent, CheckPageHelpContent, PageHelpContentFilterOptions } from "../../domain/page-help-content"; -import { Page } from "../../domain/page"; -import { Portal } from "../../domain/portal"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; -import {SafeHtmlPipe} from '../../openaireLibrary/utils/pipes/safeHTML.pipe'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Title} from '@angular/platform-browser'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'page-help-contents', - templateUrl: './page-help-contents.component.html', -}) - -export class PageHelpContentsComponent implements OnInit { - - // @ViewChild(ModalFormComponent) - // @ViewChild('saveModal') - // public modal:ModalFormComponent; - // - // @ViewChild('updateModal') - // public updateModal:ModalFormComponent; - // - // @ViewChild(PageHelpContentsFormComponent) - // public formComponent : PageHelpContentsFormComponent; - - // @ViewChild('deleteConfirmationModal') - // public deleteConfirmationModal : DeleteConfirmationDialogComponent; - @ViewChild('AlertModalDeletePageHelpContents') alertModalDeletePageHelpContents; - private selectedPageContents: string[] = []; - - public checkboxes : CheckPageHelpContent[] = []; - - public pageHelpContents : PageHelpContent[] = []; - - //public errorMessage: string; - - public formGroup : FormGroup; - - public pages: Page[]; - - public checkboxAll : boolean = false; - - public filters : PageHelpContentFilterOptions = {id : '', active : null, text : new RegExp('')}; - public keyword: string = ""; - - public counter = {all : 0, active : 0, inactive : 0}; - - public communities: Portal[] = []; - - public selectedCommunityPid: string; - - public selectedPageId: string; - - public community: Portal; - - public page: Page; - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - public updateErrorMessage: string = ''; - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | Page Help Texts'); - this.selectedCommunityPid = params['communityId']; - this.selectedPageId = params['pageId']; - - if(this.selectedCommunityPid && this.selectedPageId) { - this.getPage(this.selectedPageId); - } else if(this.selectedCommunityPid) { - this.selectedPageId = ""; - this.getPages(this.selectedCommunityPid); - } - }); - }); - // this.formGroup = this.formComponent.form; - } - - constructor(private element: ElementRef, private route: ActivatedRoute, - private title: Title, - private router : Router, private _helpService: HelpContentService, - private _clearCacheService: ClearCacheService) {} - - getPage(pageId: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ""; - this.errorMessage = ""; - - this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( - page => { - // if( (this.selectedCommunityPid == 'openaire' && !page.openaire) - // || (this.selectedCommunityPid == 'connect' && !page.connect) - // || (this.selectedCommunityPid != 'openaire' && this.selectedCommunityPid != 'connect' && !page.communities)) { - if(this.properties.adminToolsPortalType != page.portalType) { - this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.selectedCommunityPid} }); - } else { - this.page = page; - this.getPageHelpContents(this.selectedCommunityPid); - } - }, - error => this.handleError('System error retrieving page', error)); - } - } - - getPages(community_pid: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ""; - this.errorMessage = ""; - - //this._helpService.getCommunityPages(community_pid, "", this.properties.adminToolsAPIURL).subscribe( - this._helpService.getCommunityPagesWithPositions(community_pid, this.properties.adminToolsAPIURL).subscribe( - pages => { - this.pages = pages; - this.getPageHelpContents(this.selectedCommunityPid); - }, - error => this.handleError('System error retrieving pages', error)); - } - } - - public countPageHelpContents() { - this.counter = {all : 0, active : 0, inactive : 0}; - let filter = Object.assign({},this.filters); - filter.active = null; - this.pageHelpContents.forEach(_ => { - if(this.filterPageHelpContent(_,filter)){ - if (_.isActive==true) this.counter.active++; - else this.counter.inactive++ - } - }); - this.counter.all = this.counter.active + this.counter.inactive; - } - - getPageHelpContents(community_pid: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this._helpService.getCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe( - pageHelpContents => { - this.pageHelpContents = pageHelpContents as Array; - this.counter.all = this.pageHelpContents.length; - this.checkboxes = []; - - for (let i = this.pageHelpContents.length - 1; i >= 0; i -= 1) { - //for (let i = 0; i < this.pageHelpContents.length; i++) { - let page: Page = this.pageHelpContents[i].page as Page; - if(!this.selectedPageId || (page._id == this.selectedPageId)) { - this.cutContent(this.pageHelpContents[i]); - this.checkboxes.unshift({pageHelpContent : this.pageHelpContents[i], checked : false}); - } else { - this.pageHelpContents.splice(i, 1); - } - } - - this.countPageHelpContents(); - - this.showLoading = false; - }, - error => this.handleError('System error retrieving page contents', error)); - } - } - - // public showModal():void { - // this.modal.showModal(); - // } - - public toggleCheckBoxes(event) { - this.checkboxes.forEach(_ => _.checked = event.target.checked); - this.checkboxAll = event.target.checked; - } - - public applyCheck(flag : boolean) { - this.checkboxes.forEach(_ => _.checked = flag); - this.checkboxAll = false; - } - - public getSelectedPageHelpContents() : string[] { - return this.checkboxes.filter(pageHelpContent => pageHelpContent.checked == true) - .map(checkedPageHelpContent => checkedPageHelpContent.pageHelpContent).map(res => res._id); - } - - public confirmDeletePageHelpContent(id : string) { - //this.deleteConfirmationModal.ids = [id]; - //this.deleteConfirmationModal.showModal(); - this.selectedPageContents = [id]; - this.confirmModalOpen(); - } - - public confirmDeleteSelectedPageHelpContents() { - //this.deleteConfirmationModal.ids = this.getSelectedPageHelpContents(); - //this.deleteConfirmationModal.showModal(); - this.selectedPageContents = this.getSelectedPageHelpContents(); - this.confirmModalOpen(); - } - - private confirmModalOpen() { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.alertModalDeletePageHelpContents.cancelButton = true; - this.alertModalDeletePageHelpContents.okButton = true; - this.alertModalDeletePageHelpContents.alertTitle = "Delete Confirmation"; - this.alertModalDeletePageHelpContents.message = "Are you sure you want to delete the selected page content(s)?"; - this.alertModalDeletePageHelpContents.okButtonText = "Yes"; - this.alertModalDeletePageHelpContents.open(); - } - } - - public confirmedDeletePageHelpContents(data: any) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - this.updateErrorMessage = ""; - - this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( - _ => { - this.deletePageHelpContentsFromArray(this.selectedPageContents); - this.showLoading = false; - this._clearCacheService.clearCache("page help contents deleted"); - }, - error => this.handleUpdateError('System error deleting the selected page content(s)', error) - ); - } - } - - private deletePageHelpContentsFromArray(ids : string[]) : void { - for(let id of ids) { - let iqc = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id); - let iq = this.pageHelpContents.findIndex(_ => _._id == id); - this.checkboxes.splice(iqc, 1); - this.pageHelpContents.splice(iqc, 1); - } - this.countPageHelpContents(); - } - - public editPageHelpContent(id : string) { - //this.router.navigate(['/pageContents/edit/', _id]); - if(this.selectedPageId) { - this.router.navigate( ['/pageContents/edit/'], { queryParams: { "pageContentId": id, "communityId": this.selectedCommunityPid, "pageId": this.selectedPageId } } ); - } else { - this.router.navigate( ['/pageContents/edit/'], { queryParams: { "pageContentId": id, "communityId": this.selectedCommunityPid } } ); - } - } - - public togglePageHelpContents(status : boolean, ids : string[]) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.updateErrorMessage = ""; - - this._helpService.togglePageHelpContents(ids,status, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( - () => { - for(let id of ids) { - let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id); - this.checkboxes[i].pageHelpContent.isActive=status; - } - this.countPageHelpContents(); - this.applyCheck(false); - this._clearCacheService.clearCache("page help contents toggled (status: "+status+")"); - }, - error => this.handleUpdateError('System error changing the status of the selected page content(s)', error) - ); - } - } - - public pageHelpContentSavedSuccessfully(pageHelpContent: PageHelpContent) { - this.cutContent(pageHelpContent); - this.checkboxes.push({pageHelpContent : pageHelpContent, checked : false}); - this.pageHelpContents.push(pageHelpContent); - this.applyCheck(false); - this.countPageHelpContents(); - } - - public pageHelpContentUpdatedSuccessfully(pageHelpContent : PageHelpContent) { - this.checkboxes.find(checkItem => checkItem.pageHelpContent._id==pageHelpContent._id).pageHelpContent = pageHelpContent; - let index = this.pageHelpContents.findIndex(checkItem => checkItem._id==pageHelpContent._id); - this.pageHelpContents[index] = pageHelpContent; - this.applyCheck(false); - this.countPageHelpContents(); - } - - - public filterPageHelpContent(pageHelpContent : PageHelpContent, filters : PageHelpContentFilterOptions) : boolean { - let idFlag = filters.id == '' || (pageHelpContent.page)._id == filters.id; - let activeFlag = filters.active == null || pageHelpContent.isActive == filters.active; - let textFlag = filters.text.toString() == '' || (pageHelpContent.content).match(filters.text) != null - || ((pageHelpContent.page).name).match(filters.text) != null; - return idFlag && activeFlag && textFlag; - } - - public cutContent(pageHelpContent: PageHelpContent) { - pageHelpContent.content = pageHelpContent.content.replace(/<[^>]*>/g, ''); - pageHelpContent.content = pageHelpContent.content.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm," "); - - if(pageHelpContent.content.length > 200) { - pageHelpContent.content = pageHelpContent.content.substr(0, 200) + "..."; - } - } - - public applyFilter() { - this.checkboxes = []; - this.pageHelpContents.filter(item => this.filterPageHelpContent(item,this.filters)).forEach( - _ => { - this.cutContent(_); - this.checkboxes.push({pageHelpContent: _, checked: false}) - } - ); - this.countPageHelpContents(); - } - - public filterByPage(event: any) { - this.filters.id = event.target.value; - this.applyFilter(); - } - - public displayAllPageHelpContents() { - this.filters.active = null; - this.applyFilter(); - } - - public displayActivePageHelpContents() { - this.filters.active = true; - this.applyFilter(); - } - - public filterBySearch(text : string) { - this.filters.text = new RegExp(text, "i"); - this.applyFilter(); - } - - public displayInactivePageHelpContents() { - this.filters.active = false; - this.applyFilter(); - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } - - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; - console.log('Server responded: ' +error); - - this.showLoading = false; - } - - public newPageContent() { - if(this.selectedPageId) { - this.router.navigate( ['/pageContents/new'], { queryParams: {communityId: this.selectedCommunityPid, pageId: this.selectedPageId} } ); - } else { - this.router.navigate( ['/pageContents/new'], { queryParams: {communityId: this.selectedCommunityPid} } ); - } - } -} diff --git a/src/app/pages/helpcontent/page-help-contents.module.ts b/src/app/pages/helpcontent/page-help-contents.module.ts deleted file mode 100644 index 7559a32..0000000 --- a/src/app/pages/helpcontent/page-help-contents.module.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {FABModule} from '../../utils/fabModule.module'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {PageHelpContentsRoutingModule} from './page-help-contents-routing.module'; -import {PageHelpContentsComponent} from './page-help-contents.component'; -import {SafeHtmlPipeModule} from '../../openaireLibrary/utils/pipes/safeHTMLPipe.module'; -import {MatSlideToggleModule} from '@angular/material'; - -@NgModule({ - imports: [ - CommonModule, RouterModule, FormsModule, FABModule, SafeHtmlPipeModule, - AlertModalModule, ReactiveFormsModule, PageHelpContentsRoutingModule, MatSlideToggleModule - ], - declarations: [ - PageHelpContentsComponent - ], - providers: [IsCommunity, ConnectAdminLoginGuard], - exports: [PageHelpContentsComponent] -}) -export class PageHelpContentsModule { } diff --git a/src/app/pages/htmlpagecontent/edit-html-page-content-routing.module.ts b/src/app/pages/htmlpagecontent/edit-html-page-content-routing.module.ts deleted file mode 100644 index 0cd2d05..0000000 --- a/src/app/pages/htmlpagecontent/edit-html-page-content-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {EditHtmlPageContentComponent} from './edit-htmlpage-content.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: EditHtmlPageContentComponent} - ]) - ] -}) -export class EditHtmlPageContentRoutingModule { } diff --git a/src/app/pages/htmlpagecontent/edit-html-page-content.module.ts b/src/app/pages/htmlpagecontent/edit-html-page-content.module.ts deleted file mode 100644 index b28fd78..0000000 --- a/src/app/pages/htmlpagecontent/edit-html-page-content.module.ts +++ /dev/null @@ -1,41 +0,0 @@ -import {NgModule} from '@angular/core'; -import {HttpClientModule} from '@angular/common/http'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {RouterModule} from '@angular/router'; - - -import {ErrorMessagesModule} from '../../openaireLibrary/utils/errorMessages.module'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {SafeHtmlPipeModule} from '../../openaireLibrary/utils/pipes/safeHTMLPipe.module'; - -import {HtmlPageContentFormComponent} from './html-page-content-form.component'; -import {EditHtmlPageContentComponent} from './edit-htmlpage-content.component'; -import {HtmlPageContentService} from './html-page-content.service'; -import {EditHtmlPageContentRoutingModule} from './edit-html-page-content-routing.module'; -import {CommonModule} from '@angular/common'; -import {CKEditorModule} from 'ng2-ckeditor'; - -@NgModule({ - imports: [ - CommonModule, - HttpClientModule, - FormsModule, - ReactiveFormsModule, - RouterModule, - CKEditorModule, - ErrorMessagesModule, - AlertModalModule, - SafeHtmlPipeModule, - EditHtmlPageContentRoutingModule - ], - declarations: [ - HtmlPageContentFormComponent, - EditHtmlPageContentComponent, - ], - providers: [ - HtmlPageContentService - ], - exports: [EditHtmlPageContentComponent] -}) - -export class EditHtmlPageContentModule { } diff --git a/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.html b/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.html deleted file mode 100644 index ccca5b2..0000000 --- a/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
- - -
- -
- - - - - - - -
-
-
-
diff --git a/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts b/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts deleted file mode 100644 index b4ecd21..0000000 --- a/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts +++ /dev/null @@ -1,164 +0,0 @@ -import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; -import { FormGroup } from "@angular/forms"; -import { ActivatedRoute, Router } from "@angular/router"; -//import { Location } from "@angular/common"; -import { HelpContentService } from "../../services/help-content.service"; -import { HtmlPageContentService } from "./html-page-content.service"; -import { HtmlPageContent, CheckHtmlPageContent } from "../../domain/html-page-content"; -import { HtmlPageContentFormComponent } from "./html-page-content-form.component"; - -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; -import { Subscription } from "rxjs"; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Title} from '@angular/platform-browser'; -declare var UIkit: any; - -@Component({ - selector: 'edit-htmlpage-content', - templateUrl: './edit-htmlpage-content.component.html', -}) - -export class EditHtmlPageContentComponent implements OnInit { - @ViewChild(HtmlPageContentFormComponent) - public formComponent : HtmlPageContentFormComponent; - - communityPid: string; - pageId: string; - pageName: string = ""; - //public mode: string = "edit"; - - private sub: Subscription; - - private htmlPageContent: HtmlPageContent; - - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - public updateErrorMessage: string = ''; - - constructor( - private element: ElementRef, - private route: ActivatedRoute, - private router: Router, - private title: Title, - private _helpContentService: HelpContentService, - private _htmlContentService: HtmlPageContentService) { - this.router.routeReuseStrategy.shouldReuseRoute = function(){ - return false; - } - } - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.sub = this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | Edit HTML page'); - this.communityPid = params['communityId']; - this.pageId = params['pageId']; - - this.getPage(this.communityPid, this.pageId); - }); - }); - } - ngOnDestroy() { - this.sub.unsubscribe(); - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } - - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } - - private getPage(communityId: string, pageId: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this._helpContentService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - page => { - this.pageName = page.name; - this.getHtmlPageContent(communityId, page.route); - }, - error => this.handleError('System error retrieving page', error)); - } - } - - private getHtmlPageContent(communityId: string, pageRoute: string) { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.showLoading = true; - this.errorMessage = ""; - this.updateErrorMessage = ""; - - this._htmlContentService.getHtmlPageContent(communityId, pageRoute, this.properties.adminToolsAPIURL).subscribe( - htmlPageContent => { - if(htmlPageContent.length > 0) { - this.updateForm(htmlPageContent[0]); - } - this.showLoading = false; - }, - error => this.handleError('System error retrieving page help content', error)); - } - } - - private updateForm(htmlPageContent : HtmlPageContent) { - this.htmlPageContent = htmlPageContent; - this.formComponent.myForm.patchValue((htmlPageContent)); - } - - saveCustom() { - if(!Session.isLoggedIn()){ - this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); - } else { - this.formComponent.myForm.value.content = this.formComponent.myeditor.instance.getData(); - if(this.formComponent.myForm.valid) { - this.showLoading = true; - this.updateErrorMessage = ""; - //this.mode = ""; - - let htmlPageContent : HtmlPageContent = this.formComponent.myForm.value; - this._htmlContentService.updateHtmlPageContent(htmlPageContent, this.properties.adminToolsAPIURL).subscribe( - _ => { - //this.mode = "preview"; - UIkit.tab('#html-tab').show(1); - UIkit.switcher('#html-tab-content').show(1); - this.showLoading = false; - }, - err => { - //this.mode = "edit"; - UIkit.tab('#html-tab').show(0); - UIkit.switcher('#html-tab-content').show(0); - this.handleUpdateError('System error updating page content', err); - } - ); - } else { - //this.mode = "edit"; - UIkit.tab('#html-tab').show(0); - UIkit.switcher('#html-tab-content').show(0); - this.errorMessage = "Please fill all required fields"; - } - } - } - - cancelCustom() { - this.errorMessage = ""; - this.updateErrorMessage = ""; - this.router.navigate(['/pages'], { queryParams: { "type": "html", "communityId": this.communityPid}}); - //this.location.back(); - //this.router.navigated = false; - //this.router.navigate( ['/htmlPageContent/edit'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); - } -} diff --git a/src/app/pages/htmlpagecontent/html-page-content-form.component.html b/src/app/pages/htmlpagecontent/html-page-content-form.component.html deleted file mode 100644 index 270633c..0000000 --- a/src/app/pages/htmlpagecontent/html-page-content-form.component.html +++ /dev/null @@ -1,37 +0,0 @@ - - - -
- - Edit html page content -
-
-
- - -
    - -
  • - - -
  • - -
  • -
    
    -          
  • -
-
- -
diff --git a/src/app/pages/htmlpagecontent/html-page-content-form.component.ts b/src/app/pages/htmlpagecontent/html-page-content-form.component.ts deleted file mode 100644 index ab9782e..0000000 --- a/src/app/pages/htmlpagecontent/html-page-content-form.component.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Component, OnInit, Input, ViewChild } from '@angular/core'; -import { ActivatedRoute } from "@angular/router"; -import { FormGroup, FormBuilder, Validators } from "@angular/forms"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; -import { SafeHtmlPipe } from '../../openaireLibrary/utils/pipes/safeHTML.pipe'; - -@Component({ - selector: 'html-page-content-form', - templateUrl: './html-page-content-form.component.html', -}) - -export class HtmlPageContentFormComponent implements OnInit{ - - @Input('group') - myForm: FormGroup; - @Input('communityPid') - communityPid: string; - @Input('pageId') - pageId: string; - //@Input('mode') - //mode: string; - @ViewChild('myeditor') public myeditor; - - public properties:EnvProperties = null; - - public errorMessage: string = ''; - @Input() updateErrorMessage: string = ''; - - constructor(private route: ActivatedRoute,private _fb: FormBuilder){} - - ngOnInit() { - this.myForm = this.form; - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - }); - } - - public get form() { - return this._fb.group({ - page : [this.pageId,Validators.required], - community : this.communityPid, - content : ['', Validators.required], - _id : '', - }); - } - - public reset() { - this.myForm.patchValue({ - page : '', - community : this.communityPid, - content : '', - _id : '' - }); - this.myForm.markAsPristine(); - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - } -} diff --git a/src/app/pages/htmlpagecontent/html-page-content.service.ts b/src/app/pages/htmlpagecontent/html-page-content.service.ts deleted file mode 100644 index caa5919..0000000 --- a/src/app/pages/htmlpagecontent/html-page-content.service.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Injectable } from '@angular/core'; -import {HttpClient, HttpErrorResponse} from '@angular/common/http'; -import { Observable } from 'rxjs'; -import {COOKIE} from "../../openaireLibrary/login/utils/helper.class" -import { HtmlPageContent } from "../../domain/html-page-content"; -import { CustomOptions } from '../../openaireLibrary/services/servicesUtils/customOptions.class'; -import {catchError} from "rxjs/operators"; - -@Injectable() -export class HtmlPageContentService { - - constructor(private http:HttpClient) { - } - - static removeNulls(obj){ - var isArray = obj instanceof Array; - for (var k in obj){ - if (obj[k]===null || obj[k]==='') isArray ? obj.splice(k,1) : delete obj[k]; - else if (typeof obj[k]=="object") HtmlPageContentService.removeNulls(obj[k]); - } - } - - getHtmlPageContent(community : string, page: string, adminToolsAPIURL:string) { - return this.http.get>(adminToolsAPIURL + 'htmlpagecontent?community=' + community + "&page="+page) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } - - updateHtmlPageContent(htmlPageContent: HtmlPageContent, adminToolsAPIURL:string) { - //let headers = new Headers({'Content-Type': 'application/json'}); - //let options = new RequestOptions({headers: headers}); - - HtmlPageContentService.removeNulls(htmlPageContent); - - return this.http.post(adminToolsAPIURL + 'htmlpagecontent/update', JSON.stringify(htmlPageContent), CustomOptions.getAuthOptionsWithBody()) - //return this.http.post(adminToolsAPIURL + 'htmlpagecontent/update', JSON.stringify(htmlPageContent), options) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } - - private handleError(error: HttpErrorResponse) { - // in a real world app, we may send the error to some remote logging infrastructure - // instead of just logging it to the console - console.error(error); - return Observable.throw(error.error || 'Server error'); - } - -} diff --git a/src/app/pages/manage-communities/manage-communities-routing.module.ts b/src/app/pages/manage-communities/manage-communities-routing.module.ts new file mode 100644 index 0000000..72e8ecb --- /dev/null +++ b/src/app/pages/manage-communities/manage-communities-routing.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import {RouterModule} from '@angular/router'; +import {ManageCommunitiesComponent} from './manage-communities.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: ManageCommunitiesComponent} + ]) + ] +}) +export class ManageCommunitiesRoutingModule { } diff --git a/src/app/pages/manage-communities/manage-communities.component.css b/src/app/pages/manage-communities/manage-communities.component.css new file mode 100644 index 0000000..41f6241 --- /dev/null +++ b/src/app/pages/manage-communities/manage-communities.component.css @@ -0,0 +1,21 @@ +.uk-card { + min-height: 230px; +} + +.uk-card-body { + padding-top: 75px; +} + +.uk-card-default .name { + margin-left: auto; + margin-right: auto; +} + +.uk-card-default .uk-card-title .logo { + display: inline-block; + max-width: 80%; +} + +.uk-card-default .uk-card-title .logo > img { + max-height: 60px; +} diff --git a/src/app/pages/manage-communities/manage-communities.component.ts b/src/app/pages/manage-communities/manage-communities.component.ts new file mode 100644 index 0000000..d445255 --- /dev/null +++ b/src/app/pages/manage-communities/manage-communities.component.ts @@ -0,0 +1,154 @@ +import {Component, OnDestroy, OnInit} from '@angular/core'; +import {Session, User} from '../../openaireLibrary/login/utils/helper.class'; +import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {ActivatedRoute} from '@angular/router'; +import {CommunitiesService} from '../../openaireLibrary/connect/communities/communities.service'; +import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; +import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; +import {Title} from '@angular/platform-browser'; +import {properties} from "../../../environments/environment"; +import {Subscription} from "rxjs"; + +type Tab = 'all' | 'communities' | 'ris'; + +@Component({ + selector: 'manage-communities', + template: ` +
+ +
+
+ +
+
+
+
Research Communities
+
+ + + +
+
+
+

+ No communities to manage yet +

+
+
+
Research Initiatives
+
+ + + +
+
+
+
+
+ + + + `, + styleUrls: ['manage-communities.component.css'] +}) +export class ManageCommunitiesComponent implements OnInit, OnDestroy { + public properties: EnvProperties = properties; + public communities: CommunityInfo[] = []; + public ris: CommunityInfo[] = []; + public loading: boolean; + public user: User; + public tab: Tab = "all"; + private subscriptions: any[] = []; + + constructor(private route: ActivatedRoute, + private communitiesService: CommunitiesService, + private title: Title, + private userManagementService: UserManagementService) { + } + + ngOnInit() { + this.loading = true; + this.title.setTitle('Administrator Dashboard | Manage Communities'); + this.subscriptions.push(this.route.fragment.subscribe((fragment: Tab) => { + if (this.isTab(fragment)) { + this.tab = fragment; + } else { + this.tab = 'all'; + } + })); + this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { + this.user = user; + if (this.user) { + this.subscriptions.push(this.communitiesService.getCommunities(this.properties, this.properties.communityAPI + 'communities').subscribe( + communities => { + this.communities = []; + this.ris = []; + communities.forEach(community => { + if (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || Session.isManager('community', community.communityId, this.user)) { + if (community.type === 'community') { + this.communities.push(community); + } else { + this.ris.push(community); + } + } + }) + this.loading = false; + })); + } + })); + } + + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }); + } + + public get noResults(): boolean { + return (this.tab === "all" && this.communities.length === 0 && this.ris.length === 0) || + (this.tab === "communities" && this.communities.length === 0) || + (this.tab === "ris" && this.ris.length === 0); + } + + private isTab(tab: Tab): boolean { + switch (tab) { + case "all": + return true; + case "communities": + return true; + case "ris": + return true; + default: + return false; + } + } +} diff --git a/src/app/pages/manage-communities/manage-communities.module.ts b/src/app/pages/manage-communities/manage-communities.module.ts new file mode 100644 index 0000000..84f4fc4 --- /dev/null +++ b/src/app/pages/manage-communities/manage-communities.module.ts @@ -0,0 +1,27 @@ +import {NgModule} from '@angular/core'; +import {ManageCommunitiesComponent} from './manage-communities.component'; +import {ManageCommunitiesRoutingModule} from './manage-communities-routing.module'; +import {RouterModule} from '@angular/router'; +import {CommonModule} from '@angular/common'; +import {LoginGuard} from '../../openaireLibrary/login/loginGuard.guard'; +import {PageContentModule} from '../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; +import {LoadingModule} from '../../openaireLibrary/utils/loading/loading.module'; +import {UrlPrefixModule} from '../../openaireLibrary/utils/pipes/url-prefix.module'; +import {CommunitiesService} from '../../openaireLibrary/connect/communities/communities.service'; +import {IconsModule} from '../../openaireLibrary/utils/icons/icons.module'; +import {IconsService} from '../../openaireLibrary/utils/icons/icons.service'; +import {earth, group, lock} from '../../openaireLibrary/utils/icons/icons'; + +@NgModule({ + imports: [ + CommonModule, ManageCommunitiesRoutingModule, RouterModule, PageContentModule, LoadingModule, UrlPrefixModule, IconsModule + ], + declarations: [ManageCommunitiesComponent], + providers: [LoginGuard, CommunitiesService], + exports: [ManageCommunitiesComponent] +}) +export class ManageCommunitiesModule { + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([group, lock, earth]); + } +} diff --git a/src/app/pages/mining/mining-routing.module.ts b/src/app/pages/mining/mining-routing.module.ts new file mode 100644 index 0000000..1e840cf --- /dev/null +++ b/src/app/pages/mining/mining-routing.module.ts @@ -0,0 +1,9 @@ +import {NgModule} from "@angular/core"; +import {InteractiveMiningModule, InteractiveMiningRoutingModule} from "interactiveminingv3"; + +@NgModule({ + imports: [InteractiveMiningRoutingModule, InteractiveMiningModule] +}) +export class MiningRoutingModule { + +} diff --git a/src/app/pages/mining/mining.component.ts b/src/app/pages/mining/mining.component.ts new file mode 100644 index 0000000..0e64cca --- /dev/null +++ b/src/app/pages/mining/mining.component.ts @@ -0,0 +1,36 @@ +import {Component, OnDestroy, OnInit} from "@angular/core"; +import {ActivatedRoute} from "@angular/router"; +import {Title} from "@angular/platform-browser"; +import {Subscription} from "rxjs"; + +@Component({ + selector: 'mining', + template: ` +
+
+ +
+
+ ` +}) +export class MiningComponent implements OnInit, OnDestroy{ + private subs: any[] = []; + + constructor(private title: Title, + private route: ActivatedRoute) { + } + + ngOnInit() { + this.subs.push(this.route.params.subscribe(params => { + this.title.setTitle(params['community'].toUpperCase() + ' | Mining'); + })); + } + + ngOnDestroy() { + this.subs.forEach(subscription => { + if(subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }); + } +} diff --git a/src/app/pages/mining/mining.module.ts b/src/app/pages/mining/mining.module.ts index 15e7266..81cde1d 100644 --- a/src/app/pages/mining/mining.module.ts +++ b/src/app/pages/mining/mining.module.ts @@ -1,9 +1,23 @@ -import { NgModule } from '@angular/core'; -import { InteractiveMiningModule, InteractiveMiningRoutingModule} from 'interactiveminingv3'; +import {NgModule} from '@angular/core'; +import {RouterModule} from "@angular/router"; +import {CommonModule} from "@angular/common"; +import {MiningComponent} from "./mining.component"; +import {PageContentModule} from "../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; + @NgModule({ imports: [ - InteractiveMiningModule, - InteractiveMiningRoutingModule - ] + CommonModule, + RouterModule.forChild([ + { + path: '', component: MiningComponent, children: [ + {path: '', loadChildren: './mining-routing.module#MiningRoutingModule'} + ] + } + ]), + PageContentModule, + ], + declarations: [MiningComponent], + exports: [MiningComponent] }) -export class MiningModule { } +export class MiningModule { +} diff --git a/src/app/pages/page/page-form.component.html b/src/app/pages/page/page-form.component.html deleted file mode 100644 index d638274..0000000 --- a/src/app/pages/page/page-form.component.html +++ /dev/null @@ -1,106 +0,0 @@ -
-
- - -
-
- - -
-
- - -
- -
- -
-
{{entity.name}}, 
- - - - - - - -
- - - - - - - - {{entity.name}} - -
-
-
-
- -
- - - - - - -
- -
- - - - -
- - - - - - - - - - - - - -
diff --git a/src/app/pages/page/page-form.component.ts b/src/app/pages/page/page-form.component.ts deleted file mode 100644 index 1109a2d..0000000 --- a/src/app/pages/page/page-form.component.ts +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Created by stefania on 7/13/17. - */ -import {Component, OnInit, Input} from '@angular/core'; -import { ActivatedRoute, Router } from "@angular/router"; -import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms"; -import {Entity} from '../../domain/entity'; -import { HelpContentService } from "../../services/help-content.service"; -import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; - -@Component({ - selector: 'page-form', - templateUrl: './page-form.component.html', -}) - -export class PageFormComponent implements OnInit{ - - @Input('group') - myForm: FormGroup; - @Input('type') - public type: string; - - //public errorMessage: string; - - public allEntities: Map = new Map(); - private gotEntities: boolean = false; - public properties:EnvProperties = null; - - public showLoading: boolean = false; - public errorMessage: string = ''; - - constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, private _helpContentService: HelpContentService){} - - ngOnInit(): void { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - }); - } - - public toggle() { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.myForm.value.isCollapsed = !this.myForm.value.isCollapsed; - - if(!this.myForm.value.isCollapsed) { - let includedEntities: Set = new Set(); - for(let entityName of this.myForm.value.entities) { - includedEntities.add(entityName._id); - } - - let allEntities = this.allEntities; - - let self = this; - allEntities.forEach(function (status, entity, map) { - if(includedEntities.has(entity._id)) { - self.allEntities.set(entity, true); - } else { - self.allEntities.set(entity, false); - } - }); - - - if(!this.gotEntities) { - this.gotEntities = true; - this.getEntities(includedEntities); - } - } - } - } - - public getEntities(includedEntities: Set) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.showLoading = true; - this.errorMessage = ""; - - this._helpContentService.getEntities(this.properties.adminToolsAPIURL).subscribe( - entities => { - for(let entity of entities) { - if(includedEntities.has(entity._id)) { - this.allEntities.set(entity, true); - } else { - this.allEntities.set(entity, false); - } - } - this.showLoading = false; - }, - error => this.handleError('System error retrieving community entities', error)); - } - } - - public getKeys( map) { - return Array.from(map.keys()); - } - - public get form() { - return this._fb.group({ - route : ['', Validators.required], - name : ['', Validators.required], - isEnabled: '', - portalType: ['', Validators.required], - top: true, - bottom: true, - left: true, - right: true, - type: ['', Validators.required], - entities: this._fb.array([]), - _id : '', - isCollapsed: [true] - }); - } - - public reset() { - this.myForm.patchValue({ - route : '', - name : '', - type: '', - isEnabled: '', - portalType: '', - top: true, - bottom: true, - left: true, - right: true, - _id : '', - isCollapsed: [true] - }); - - this.setEntities([]); - } - - public get entities(): FormArray { - return this.myForm.get('entities') as FormArray; - }; - - setEntities(entities: Entity[]) { - const entityFGs = entities.map(entity => this._fb.group(entity)); - const entityFormArray = this._fb.array(entityFGs); - this.myForm.setControl('entities', entityFormArray); - } - - public toggleEntity(status : boolean, id : string, entity: Entity) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - let index: number = -1; - for(let i=0; i= 0) { - this.myForm.value.entities.splice(index, 1); - } - } - } - } - - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } - -} diff --git a/src/app/pages/page/pages-routing.module.ts b/src/app/pages/page/pages-routing.module.ts deleted file mode 100644 index c4179e0..0000000 --- a/src/app/pages/page/pages-routing.module.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {PagesComponent} from './pages.component'; -import {IsCommunityOrAdmin} from '../../openaireLibrary/connect/communityGuard/isCommunityOrAdmin'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunityOrAdmin, ConnectAdminLoginGuard], component: PagesComponent} - ]) - ] -}) -export class PagesRoutingModule { } diff --git a/src/app/pages/page/pages.component.html b/src/app/pages/page/pages.component.html deleted file mode 100644 index 8479624..0000000 --- a/src/app/pages/page/pages.component.html +++ /dev/null @@ -1,155 +0,0 @@ -
- - -
-
-
- - -
-
- - Disable a page to hide it from community dashboard portal.
-
If the page is disabled, a message "Can't find that page" will appear in case the url of that page is loaded. If the disabled page belongs to the menu, the link will be removed from menu, too.
- -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameChange statusTypeRelated EntitiesRoutePortal TypeActionsPage help textsClass help texts
- -
{{check.page.name}}
-
- - -
{{check.page.type}}
-
-
- {{entity.name}}, -
-
-
{{check.page.route}}
-
-
{{check.page.portalType}}
-
-
- - -
-
- - add page contents - - - - - add class contents - - -
- -
-
No pages found
-
-
-
-
-
-
-
-
- - -
- - - - - - - - - - - - - - - - diff --git a/src/app/pages/page/pages.component.ts b/src/app/pages/page/pages.component.ts deleted file mode 100644 index 3f0b985..0000000 --- a/src/app/pages/page/pages.component.ts +++ /dev/null @@ -1,385 +0,0 @@ -/** - * Created by stefania on 7/13/17. - */ -import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; -import {ActivatedRoute, Router} from '@angular/router'; -import {HelpContentService} from '../../services/help-content.service'; -import {FormGroup} from '@angular/forms'; -import {PageFormComponent} from './page-form.component'; -import {CheckPage, Page} from '../../domain/page'; -import {Portal} from '../../domain/portal'; -import {Entity} from '../../domain/entity'; -import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class'; -import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; -import {Title} from '@angular/platform-browser'; -import {StringUtils} from '../../openaireLibrary/utils/string-utils.class'; -import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; - -@Component({ - selector: 'pages', - templateUrl: './pages.component.html', -}) - -export class PagesComponent implements OnInit { - - @ViewChild('AlertModalSavePage') alertModalSavePage; - @ViewChild('AlertModalUpdatePage') alertModalUpdatePage; - @ViewChild('AlertModalDeletePages') alertModalDeletePages; - private selectedPages: string[] = []; - - @ViewChild(PageFormComponent) - public formComponent: PageFormComponent; - - public checkboxes: CheckPage[] = []; - - public pages: Page[] = []; - public pageWithDivIds: string[] = []; - - //public errorMessage: string; - - public formGroup: FormGroup; - - private searchText: RegExp = new RegExp(''); - public keyword: string = ''; - - public communities: Portal[] = []; - - public selectedCommunityPid: string; - - public pagesType: string; - public properties: EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - public updateErrorMessage: string = ''; - public modalErrorMessage: string = ''; - public isPortalAdministrator = null; - - constructor(private element: ElementRef, private route: ActivatedRoute, - private title: Title, - private _router: Router, private _helpContentService: HelpContentService, - private userManagementService: UserManagementService, - private _clearCacheService: ClearCacheService) { - } - - ngOnInit() { - this.formGroup = this.formComponent.form; - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - - this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | Pages'); - this.pagesType = ''; - if (params['type']) { - this.pagesType = params['type']; - this.title.setTitle('Administration Dashboard | ' + StringUtils.capitalize(this.pagesType) + ' Pages'); - } - - this.keyword = ''; - this.userManagementService.getUserInfo().subscribe( user => { - this.selectedCommunityPid = params['communityId']; - this.applyCommunityFilter(this.selectedCommunityPid); - this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.selectedCommunityPid; - }); - //this.getCommunities(); - }); - }); - } - - getPages(community_pid: string) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); - } else { - this.showLoading = true; - this.updateErrorMessage = ''; - this.errorMessage = ''; - - this.pageWithDivIds = []; - - let parameters = ''; - if (this.pagesType) { - parameters = '?page_type=' + this.pagesType; - } - if (community_pid) { - this._helpContentService.getCommunityPagesByType(community_pid, this.pagesType, this.properties.adminToolsAPIURL).subscribe( - pages => { - this.pagesReturned(pages); - //if(!this.pagesType || this.pagesType == "link") { - this.getPagesWithDivIds(community_pid); - //} else { - //this.showLoading = false; - //} - }, - error => this.handleError('System error retrieving pages', error) - ); - } else { - this._helpContentService.getAllPagesFull(this.properties.adminToolsAPIURL).subscribe( - pages => { - this.pagesReturned(pages); - this.showLoading = false; - }, - error => this.handleError('System error retrieving pages', error) - ); - } - } - } - - getPagesWithDivIds(community_pid: string) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); - } else { - this._helpContentService.getPageIdsFromDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe( - pages => { - this.pageWithDivIds = pages; - this.showLoading = false; - }, - error => this.handleError('System error retrieving information about pages\' classes', error)); - } - } - - pagesReturned(pages: Page[]) { - this.pages = pages; - this.checkboxes = []; - - if (pages) { - pages.forEach(_ => { - this.checkboxes.push({page: _, checked: false}); - }); - } - } - - /* - getCommunities() { - this._helpContentService.getCommunities(this.properties.adminToolsAPIURL).subscribe( - communities => { - this.communities = communities; - this.selectedCommunityPid = this.communities[0].pid; - this.getPages(this.selectedCommunityPid); - this.getPagesWithDivIds(this.selectedCommunityPid); - }, - error => this.handleError('System error retrieving communities', error)); - } - */ - - public toggleCheckBoxes(event) { - this.checkboxes.forEach(_ => _.checked = event.target.checked); - } - - public applyCheck(flag: boolean) { - this.checkboxes.forEach(_ => _.checked = flag); - } - - public getSelectedPages(): string[] { - return this.checkboxes.filter(page => page.checked == true).map(checkedPage => checkedPage.page).map(res => res._id); - } - - private deletePagesFromArray(ids: string[]): void { - for (let id of ids) { - let i = this.checkboxes.findIndex(_ => _.page._id == id); - this.checkboxes.splice(i, 1); - } - } - - public confirmDeletePage(id: string) { - //this.deleteConfirmationModal.ids = [id]; - //this.deleteConfirmationModal.showModal(); - this.selectedPages = [id]; - this.confirmModalOpen(); - } - - public confirmDeleteSelectedPages() { - //this.deleteConfirmationModal.ids = this.getSelectedPages(); - //this.deleteConfirmationModal.showModal(); - this.selectedPages = this.getSelectedPages(); - this.confirmModalOpen(); - } - - private confirmModalOpen() { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); - } else { - this.alertModalDeletePages.cancelButton = true; - this.alertModalDeletePages.okButton = true; - this.alertModalDeletePages.alertTitle = 'Delete Confirmation'; - this.alertModalDeletePages.message = 'Are you sure you want to delete the selected page(s)?'; - this.alertModalDeletePages.okButtonText = 'Yes'; - this.alertModalDeletePages.open(); - } - } - - public confirmedDeletePages(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); - } else { - this.showLoading = true; - this.updateErrorMessage = ''; - - this._helpContentService.deletePages(this.selectedPages, this.properties.adminToolsAPIURL).subscribe( - _ => { - this.deletePagesFromArray(this.selectedPages); - this.showLoading = false; - this._clearCacheService.clearCache("pages deleted"); - }, - error => this.handleUpdateError('System error deleting the selected pages', error) - ); - } - } - - public editPage(i: number) { - let page: Page = this.checkboxes[i].page; - this.formGroup.patchValue(page); - this.formComponent.setEntities(page.entities as Entity[]); - this.formGroup.controls['portalType'].disable(); - - //console.info(this.formGroup.value); - //this.updateModal.showModal(); - this.modalErrorMessage = ''; - this.pagesModalOpen(this.alertModalUpdatePage, 'Update', 'Update Page'); - } - - public newPage() { - this.formGroup.controls['portalType'].enable(); - this.formComponent.reset(); - this.modalErrorMessage = ''; - this.pagesModalOpen(this.alertModalSavePage, 'Save', 'Add a new Page'); - } - - private pagesModalOpen(modal: any, title: string, yesBtn: string) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); - } else { - modal.cancelButton = true; - modal.okButton = true; - modal.alertTitle = title; - modal.okButtonText = yesBtn; - modal.open(); - } - } - - public pageSaveConfirmed(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); - } else { - if (!this.formGroup.valid) { - this.pagesModalOpen(this.alertModalSavePage, 'Save', 'Add a new Page'); - this.modalErrorMessage = 'Please fill in all required fields marked with *'; - } else { - this.modalErrorMessage = ''; - this._helpContentService.savePage(this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( - page => { - this.pageSavedSuccessfully(page); - this._clearCacheService.clearCache("page saved"); - }, - error => this.handleUpdateError('System error creating page', error) - ); - } - } - } - - public pageUpdateConfirmed(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); - } else { - if (!this.formGroup.valid) { - this.pagesModalOpen(this.alertModalUpdatePage, 'Update', 'Update Page'); - this.modalErrorMessage = 'Please fill in all required fields marked with *'; - } else { - this.formGroup.controls['portalType'].enable(); - this._helpContentService.updatePage(this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( - page => { - this.pageUpdatedSuccessfully(page); - this._clearCacheService.clearCache("page updated"); - }, - error => this.handleUpdateError('System error updating page', error) - ); - } - } - } - - public pageSavedSuccessfully(page: Page) { - this.checkboxes.push({page: page, checked: false}); - this.applyCheck(false); - } - - public pageUpdatedSuccessfully(page: Page) { - this.checkboxes.find(checkItem => checkItem.page._id == page._id).page = page; - this.applyCheck(false); - } - - public filterBySearch(text: string) { - this.searchText = new RegExp(text, 'i'); - this.applyFilter(); - } - - public applyFilter() { - this.checkboxes = []; - this.pages.filter(item => this.filterPages(item)).forEach( - _ => this.checkboxes.push({page: _, checked: false}) - ); - } - - public filterPages(page: Page): boolean { - let textFlag = this.searchText.toString() == '' || (page.route + ' ' + page.name + ' ' + page.type + ' ' + page.portalType).match(this.searchText) != null; - return textFlag; - } - - handleError(message: string, error) { - // if(error == null) { - // this.formComponent.reset(); - // } else { - this.errorMessage = message;// + ' (Server responded: ' + error + ')'; - console.log('Server responded: ' + error); - //} - - this.showLoading = false; - } - - handleUpdateError(message: string, error) { - if (error == null) { - this.formComponent.reset(); - } else { - this.updateErrorMessage = message;// + ' (Server responded: ' + error + ')'; - console.log('Server responded: ' + error); - } - - this.showLoading = false; - } - - // public filterByCommunity(event: any) { - // this.selectedCommunityPid = event.target.value; - // this.applyCommunityFilter(this.selectedCommunityPid); - // } - - public applyCommunityFilter(community_pid: string) { - this.getPages(community_pid); - } - - public togglePages(status: boolean, ids: string[]) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); - } else { - this.updateErrorMessage = ''; - - this._helpContentService.togglePages(this.selectedCommunityPid, ids, status, this.properties.adminToolsAPIURL).subscribe( - () => { - for (let id of ids) { - let i = this.checkboxes.findIndex(_ => _.page._id == id); - this.checkboxes[i].page.isEnabled = status; - } - this.applyCheck(false); - this._clearCacheService.clearCache("pages toggled (status: "+status+")"); - }, - error => this.handleUpdateError('System error changing the status of the selected page(s)', error) - ); - } - } - - public capitalizeFirstLetter(str: string) { - return str.charAt(0).toUpperCase() + str.slice(1); - } -} diff --git a/src/app/pages/page/pages.module.ts b/src/app/pages/page/pages.module.ts deleted file mode 100644 index 896e369..0000000 --- a/src/app/pages/page/pages.module.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {FABModule} from '../../utils/fabModule.module'; -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {PagesComponent} from './pages.component'; -import {PageFormComponent} from './page-form.component'; -import {PagesRoutingModule} from './pages-routing.module'; -import {MatSlideToggleModule} from '@angular/material'; -import {IsCommunityOrAdmin} from '../../openaireLibrary/connect/communityGuard/isCommunityOrAdmin'; - -@NgModule({ - imports: [ - CommonModule, RouterModule, FormsModule, FABModule, - AlertModalModule, ReactiveFormsModule, PagesRoutingModule, MatSlideToggleModule - ], - declarations: [PagesComponent, PageFormComponent], - providers: [IsCommunityOrAdmin, ConnectAdminLoginGuard], - exports: [PagesComponent] -}) -export class PagesModule { } diff --git a/src/app/pages/projects/add-projects.component.html b/src/app/pages/projects/add-projects.component.html new file mode 100644 index 0000000..b531824 --- /dev/null +++ b/src/app/pages/projects/add-projects.component.html @@ -0,0 +1,110 @@ +
+
+
+ Filter by: +
+
+
+
+
+
+
+
+
+
+ + +
+
+ +
+
+
+
No OpenAIRE projects available
+
+ If you wish to suggest a new funder to include or report a missing project, please contact us via + + feedback@openaire.eu. +
+ +
An Error Occurred. No OpenAIRE projects found
+
Service temporarily unavailable. Please try again later.
+
No OpenAIRE projects found
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/app/pages/projects/add-projects.component.ts b/src/app/pages/projects/add-projects.component.ts new file mode 100644 index 0000000..cdfa9fe --- /dev/null +++ b/src/app/pages/projects/add-projects.component.ts @@ -0,0 +1,342 @@ +import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; +import {ActivatedRoute, Router} from "@angular/router"; +import {SearchResult} from '../../openaireLibrary/utils/entities/searchResult'; +import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; +import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; +import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {SearchProjectsService} from '../../openaireLibrary/services/searchProjects.service'; +import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class'; +import {StringUtils} from '../../openaireLibrary/utils/string-utils.class'; +import {ManageCommunityProjectsService} from '../../services/manageProjects.service'; + +import {Session} from '../../openaireLibrary/login/utils/helper.class'; +import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; +import {properties} from "../../../environments/environment"; +import {Subscriber} from "rxjs"; +import {FormBuilder, FormGroup} from "@angular/forms"; +import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; +import {debounceTime, distinctUntilChanged} from "rxjs/operators"; +import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview"; +import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component"; + +declare var UIkit; + +@Component({ + selector: 'add-projects', + templateUrl: './add-projects.component.html', +}) + +export class AddProjectsComponent implements OnInit { + private subscriptions: any[] = []; + public subResults: any; + + private community: string = ''; + + public routerHelper: RouterHelper = new RouterHelper(); + public properties: EnvProperties = properties; + public errorCodes: ErrorCodes; + public openaireSearchUtils: SearchUtilsClass = new SearchUtilsClass(); + @Output() communityProjectsChanged = new EventEmitter(); + @Input() communityProjects = []; + public openaireProjects = []; + public queryParameters: string = ""; + + // public pagingLimit: number = properties.pagingLimit; + public resultsPerPage: number = properties.resultsPerPage; + public selectedFunderId: string = ""; + + filterForm: FormGroup; + allOptions: Option[] = []; + @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; + + private projectUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject; + public body: string = "Send from page"; + + @Output() toggleView: EventEmitter = new EventEmitter(); + + constructor(private route: ActivatedRoute, private _router: Router, private _searchProjectsService: SearchProjectsService, + private _manageCommunityProjectsService: ManageCommunityProjectsService, + private _fb: FormBuilder) { + this.errorCodes = new ErrorCodes(); + this.openaireSearchUtils.status = this.errorCodes.LOADING; + } + + ngOnInit() { + this.subscriptions.push(this.route.params.subscribe(params => { + this.openaireSearchUtils.status = this.errorCodes.LOADING; + + this.community = params['community']; + // this.projectUrl = "https://" + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "") + // + this.community + ".openaire.eu" + this.properties.searchLinkToProject; + + this.getFunders(); + this._getOpenaireProjects("", 1, this.resultsPerPage); + + this.body = "[Please write your message here]"; + this.body = StringUtils.URIEncode(this.body); + })); + + this.openaireSearchUtils.keyword = ""; + + this.filterForm = this._fb.group({ + keyword: [''], + funder: [] + }); + + this.subscriptions.push(this.filterForm.get('keyword').valueChanges + .pipe(debounceTime(1000), distinctUntilChanged()) + .subscribe(value => { + this.keywordChanged(value); + })); + + this.subscriptions.push(this.filterForm.get('funder').valueChanges + .pipe(debounceTime(1000), distinctUntilChanged()) + .subscribe(value => { + // console.log("value: ",value); + if (value == null) { + // console.log("will be called funder changed: null"); + this.funderChanged("", ""); + } else if (value && value.id != undefined && value.id != this.selectedFunderId) { + // console.log("will be called funder changed: name="+value.label+", id="+value.id); + this.funderChanged(value.id, value.label); + } + })); + } + + public ngOnDestroy() { + this.subscriptions.forEach(sub => { + if (sub instanceof Subscriber) { + sub.unsubscribe(); + } + }); + + if (this.subResults) { + this.subResults.unsubscribe(); + } + } + + public addProject(project: SearchResult) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.subscriptions.push(this._manageCommunityProjectsService.addProject(this.properties, this.community, project).subscribe( + data => { + this.communityProjects.push(data); + UIkit.notification('Project successfully added!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.communityProjectsChanged.emit({ + value: this.communityProjects, + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.error(err.status); + } + )); + } + } + + public removeProject(project: any) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + let communityProject = this.getCommunityProject(project); + let projectId: string = communityProject['id']; + this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community, projectId).subscribe( + data => { + let index = this.communityProjects.indexOf(communityProject); + this.communityProjects.splice(index, 1); + UIkit.notification('Project successfully removed!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.communityProjectsChanged.emit({ + value: this.communityProjects, + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.error(err); + } + )); + } + } + + public getCommunityProject(project: any): string { + let index: number = 0; + for (let communityProject of this.communityProjects) { + if (communityProject.openaireId == project.id || + (project.code == communityProject.grantId && project.funderShortname == communityProject.funder)) { + return communityProject; + } + index++; + } + return ""; + } + + getFunders() { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.subscriptions.push(this._searchProjectsService.getFunders(this.properties).subscribe( + data => { + let funders = data[1]; + this.allOptions = []; + let i; + for (i = 0; i < funders.length; i++) { + let funder = funders[i]; + if (funder && funder['id']) { + this.allOptions.push({label: funder['name'], value: {id: funder['id'], label: funder['name']}}); + } + } + }, + err => console.error("Server error fetching funders: ", err) + )); + } + } + + public getResultPreview(result: SearchResult): ResultPreview { + return ResultPreview.searchResultConvert(result, "project"); + } + + private _getOpenaireProjects(parameters: string, page: number, size: number) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + // if (page > this.pagingLimit) { + // size = 0; + // } + + if (this.openaireSearchUtils.status == this.errorCodes.LOADING) { + this.openaireSearchUtils.status = this.errorCodes.LOADING; + + this.openaireProjects = []; + this.openaireSearchUtils.totalResults = 0; + + if (this.subResults) { + this.subResults.unsubscribe(); + } + this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, [], this.properties).subscribe( + data => { + this.openaireSearchUtils.totalResults = data[0]; + this.openaireProjects = data[1]; + + //this.searchPage.checkSelectedFilters(this.filters); + this.openaireSearchUtils.status = this.errorCodes.DONE; + if (this.openaireSearchUtils.totalResults == 0) { + this.openaireSearchUtils.status = this.errorCodes.NONE; + } + + // if (this.openaireSearchUtils.status == this.errorCodes.DONE) { + // // Page out of limit!!! + // let totalPages: any = this.openaireSearchUtils.totalResults / (this.openaireSearchUtils.size); + // if (!(Number.isInteger(totalPages))) { + // totalPages = (parseInt(totalPages, 10) + 1); + // } + // if (totalPages < page) { + // this.openaireSearchUtils.totalResults = 0; + // this.openaireSearchUtils.status = this.errorCodes.OUT_OF_BOUND; + // } + // } + }, + err => { + console.error(err); + //TODO check erros (service not available, bad request) + if (err.status == '404') { + this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND; + } else if (err.status == '500') { + this.openaireSearchUtils.status = this.errorCodes.ERROR; + } else { + this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + } + ); + } + } + } + + totalPages(): number { + let totalPages: any = this.openaireSearchUtils.totalResults / (this.resultsPerPage); + if (!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + return totalPages; + } + + keywordChanged(keyword) { + this.openaireSearchUtils.keyword = keyword; + this.buildQueryParameters(); + this.goTo(1); + } + + funderChanged(funderId: string, funderName: string) { + this.selectedFunderId = funderId; + + this.buildQueryParameters(); + this.goTo(1); + } + + buildQueryParameters() { + this.queryParameters = ""; + + if (this.openaireSearchUtils.keyword) { + this.queryParameters = "q=" + StringUtils.URIEncode(this.openaireSearchUtils.keyword); + } + + if (this.selectedFunderId) { + this.queryParameters += this.queryParameters ? "&" : ""; + this.queryParameters += "fq=funder exact " + '"' + StringUtils.URIEncode(this.selectedFunderId) + '"'; + } + } + + goTo(page: number = 1) { + this.openaireSearchUtils.page = page; + this.openaireSearchUtils.status = this.errorCodes.LOADING; + this._getOpenaireProjects(this.queryParameters, page, this.resultsPerPage); + } + + back() { + this.toggleView.emit(null); + } + + public onSearchClose() { + this.openaireSearchUtils.keyword = this.filterForm.get('keyword').value; + } + + public resetInput() { + this.openaireSearchUtils.keyword = null; + this.searchInputComponent.reset() + } + + handleError(message: string) { + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + } +} diff --git a/src/app/pages/projects/communityProjects.module.ts b/src/app/pages/projects/communityProjects.module.ts new file mode 100644 index 0000000..9596c63 --- /dev/null +++ b/src/app/pages/projects/communityProjects.module.ts @@ -0,0 +1,66 @@ +import {NgModule} from '@angular/core'; +import {HttpClientModule} from '@angular/common/http'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {RouterModule} from '@angular/router'; +import {ManageProjectsComponent} from './manage-projects.component'; +import {ManageCommunityProjectsService} from '../../services/manageProjects.service'; +import {SearchProjectsServiceModule} from '../../openaireLibrary/connect/projects/searchProjectsService.module'; + +import {RemoveProjectsComponent} from './remove-projects.component'; +import {AddProjectsComponent} from './add-projects.component'; +import {SearchProjectsService} from '../../openaireLibrary/services/searchProjects.service'; +import {PagingModule} from '../../openaireLibrary/utils/paging.module'; +import {SearchPagingModule} from '../../openaireLibrary/searchPages/searchUtils/searchPaging.module'; +import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; +import {CommonModule} from '@angular/common'; +import {PageContentModule} from "../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; +import {CommunityInfoModule} from "../community-info/community-info.module"; +import {InputModule} from "../../openaireLibrary/sharedComponents/input/input.module"; +import {SearchInputModule} from "../../openaireLibrary/sharedComponents/search-input/search-input.module"; +import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; +import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"; +import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; +import {IconsService} from "../../openaireLibrary/utils/icons/icons.service"; +import {add, arrow_left, close, remove_circle_outline} from "../../openaireLibrary/utils/icons/icons"; +import {FullScreenModalModule} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module"; +import {ResultPreviewModule} from "../../openaireLibrary/utils/result-preview/result-preview.module"; +import {ErrorMessagesModule} from "../../openaireLibrary/utils/errorMessages.module"; + +@NgModule({ + imports: [ + CommonModule, + HttpClientModule, + FormsModule, + ReactiveFormsModule, + RouterModule, + PagingModule, SearchPagingModule, + ErrorMessagesModule, + AlertModalModule, + SearchProjectsServiceModule, + PageContentModule, + CommunityInfoModule, + InputModule, + SearchInputModule, + RouterModule.forChild([ + { + path: '', component: ManageProjectsComponent + } + ]), + NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule + ], + declarations: [ + ManageProjectsComponent, + RemoveProjectsComponent, + AddProjectsComponent + ], + providers: [ + ManageCommunityProjectsService, + SearchProjectsService + ], + exports: [ManageProjectsComponent] +}) +export class CommunityProjectsModule { + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([remove_circle_outline, add, close, arrow_left]); + } +} diff --git a/src/app/pages/projects/manage-projects.component.ts b/src/app/pages/projects/manage-projects.component.ts new file mode 100644 index 0000000..fe368fe --- /dev/null +++ b/src/app/pages/projects/manage-projects.component.ts @@ -0,0 +1,111 @@ +import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core'; +import {ActivatedRoute, Router} from "@angular/router"; + +import {RemoveProjectsComponent} from './remove-projects.component'; + +import {Session} from '../../openaireLibrary/login/utils/helper.class'; +import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; +import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; +import {Title} from '@angular/platform-browser'; +import {FullScreenModalComponent} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component"; +import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; +import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties"; +import {properties} from "../../../environments/environment"; +import {Subscriber} from "rxjs"; + +@Component({ + selector: 'manage-projects', + template: ` + + + +
+ +
+
+ If you cannot find a funder that is relevant for your community, please contact us + ({{properties.feedbackmailForMissingEntities}}) + and we will try to get the funder on board! +
+
+
+ + +
+ ` +}) + +export class ManageProjectsComponent implements OnInit { + @Input() communityProjects = []; + @ViewChild(RemoveProjectsComponent) removeProjectsComponent: RemoveProjectsComponent; + @ViewChild('fsModal') fullscreen: FullScreenModalComponent; + + public toggle: boolean = false; + + private subscriptions: any[] = []; + + public showLoadingInRemove: boolean = true; + + public body: string = "Send from page"; + public properties: EnvProperties = properties; + public communityId: string = ""; + + constructor(private element: ElementRef, + private title: Title, + private route: ActivatedRoute, private _router: Router) { + } + + ngOnInit() { + this.subscriptions.push(this.route.params.subscribe(params => { + this.communityId = params['community']; + + if (this.communityId) { + this.title.setTitle(this.communityId.toUpperCase() + ' | Projects'); + this.body = "[Please write your message here]"; + this.body = StringUtils.URIEncode(this.body); + } + })); + + this.fullscreen.title = "Search and Add Projects"; + this.fullscreen.okButtonText = "Done"; + this.fullscreen.okButton = true; + } + + public ngOnDestroy() { + this.subscriptions.forEach(sub => { + if (sub instanceof Subscriber) { + sub.unsubscribe(); + } + }); + } + + public toggleAction() { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} + }); + } else { + HelperFunctions.scroll(); + + this.toggle = !this.toggle; + if (this.toggle) { + this.fullscreen.open(); + } + } + } + + public communityProjectsChanged($event) { + this.communityProjects = $event.value; + this.showLoadingInRemove = false; + + if (this.toggle) { + this.removeProjectsComponent.applyFilters(); + this.removeProjectsComponent.createFunderFilter(); + } + } +} diff --git a/src/app/pages/projects/remove-projects.component.html b/src/app/pages/projects/remove-projects.component.html new file mode 100644 index 0000000..1aa8e88 --- /dev/null +++ b/src/app/pages/projects/remove-projects.component.html @@ -0,0 +1,116 @@ +
+ +
+
+ +
+ +
+
+
+
+ Filter by: +
+
+
+
+
+ Sort by: +
+
+
+
+
+ + +
+
+
No projects for {{name}}
+
+
+
+
+
+
+ + {{item.name}} + ({{item.acronym}}) + [no title available] + + + + {{item.name}} + ({{item.acronym}}) + [no title available] + +
+
+ Grant ID: + {{item.grantId}} +
+
+ Funder: + {{item.funder}} +
+
+
+ +
+
+
+ + +
+
+ + +
+
diff --git a/src/app/pages/projects/remove-projects.component.ts b/src/app/pages/projects/remove-projects.component.ts new file mode 100644 index 0000000..d4224eb --- /dev/null +++ b/src/app/pages/projects/remove-projects.component.ts @@ -0,0 +1,370 @@ +import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; +import {ActivatedRoute, Router} from "@angular/router"; +import {Subscriber} from 'rxjs'; + +import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; +import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; +import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {ManageCommunityProjectsService} from '../../services/manageProjects.service'; +import {SearchCommunityProjectsService} from '../../openaireLibrary/connect/projects/searchProjects.service'; +import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class'; + +import {Session} from '../../openaireLibrary/login/utils/helper.class'; +import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; +import {FormArray, FormBuilder, FormGroup} from "@angular/forms"; +import {properties} from "../../../environments/environment"; +import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; +import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; +import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component"; + +declare var UIkit; + +@Component({ + selector: 'remove-projects', + templateUrl: './remove-projects.component.html' +}) + +export class RemoveProjectsComponent implements OnInit { + public portal: string; + public name: string; + + private subscriptions: any[] = []; + + public routerHelper: RouterHelper = new RouterHelper(); + private projectUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject.split("?")[0]; + + @Input() public showLoading: boolean = true; + + @Output() communityProjectsChanged = new EventEmitter(); + @Input() public communityProjects = []; + public previewCommunityProjects = []; + public communitySearchUtils: SearchUtilsClass = new SearchUtilsClass(); + public errorCodes: ErrorCodes; + properties: EnvProperties = properties; + + private selectedCommunityProject: any; + @ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity; + + /* Paging */ + page: number = 1; + resultsPerPage: number = properties.resultsPerPage; + + /* Search */ + @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; + filterForm: FormGroup; + public fundersCtrl: FormArray; + private searchText: RegExp = new RegExp(''); + public keyword: string = ''; + allOptions: Option[] = []; + sortOptions: Option[] = [ + //{label:"Title (desc) ", value:{ sort: "title",descending: true }}, + {label: "Title ", value: {sort: "title", descending: false}}, + //{label:"Grant ID (desc) ", value:{ sort: "grant",descending: true }}, + {label: "Grant ID ", value: {sort: "grant", descending: false}}, + //{label:"Funder (desc) ", value:{ sort: "funder",descending: true }}, + {label: "Funder ", value: {sort: "funder", descending: false}} + ]; + + @Output() toggleView: EventEmitter = new EventEmitter(); + @Input() public toggle: boolean = true; + + constructor(private route: ActivatedRoute, private _router: Router, + private _fb: FormBuilder, + private communityService: CommunityService, + private _manageCommunityProjectsService: ManageCommunityProjectsService, + private _searchCommunityProjectsService: SearchCommunityProjectsService) { + this.errorCodes = new ErrorCodes(); + this.communitySearchUtils.status = this.errorCodes.LOADING; + } + + ngOnInit() { + this.communitySearchUtils.keyword = ""; + + this.fundersCtrl = this._fb.array([]); + this.filterForm = this._fb.group({ + keyword: [''], + funder: this.fundersCtrl, + sort: this._fb.control(this.sortOptions[0].value) + }); + + this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => { + this.searchText = new RegExp(value, 'i'); + this.page = 1; + this.applyFilters(); + })); + + this.subscriptions.push(this.filterForm.get('funder').valueChanges.subscribe(value => { + this.page = 1; + this.applyFilters(); + })); + + this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => { + this.page = 1; + this.sort(); + })); + + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { + if (community) { + this.portal = community.communityId; + this.name = community.shortTitle; + this.projectUrl = "https://" + + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "") + + this.portal + ".openaire.eu" + this.properties.searchLinkToProject.split("?")[0]; + + this.keyword = ''; + this._getCommunityProjects(); + } + })); + } + + public ngOnDestroy() { + this.subscriptions.forEach(sub => { + if (sub instanceof Subscriber) { + sub.unsubscribe(); + } + }); + } + + public inCommunity(result: any): any { + let found = false; + for (let project of this.communityProjects) { + if (project.opeaireId == result.id) { + return true; + } else if (result['title'].name.search("(" + project.grantId + ")") != -1 && result.funderShortname == project.funder) { + return true; + } + } + return found; + + } + + totalPages(): number { + let totalPages: any = this.communitySearchUtils.totalResults / (this.resultsPerPage); + if (!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + return totalPages; + } + + public confirmedDeleteProject(data: any) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.portal, this.selectedCommunityProject.id).subscribe( + data => { + let index = this.communityProjects.indexOf(this.selectedCommunityProject); + this.communityProjects.splice(index, 1); + + this.applyFilters(); + + UIkit.notification('Project successfully removed!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + + this.communityProjectsChanged.emit({ + value: this.communityProjects, + }); + + this.communitySearchUtils.totalResults--; + this.communitySearchUtils.page = 1; + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.error(err); + } + )); + } + } + + public removeProject(communityProject: any) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.selectedCommunityProject = communityProject; + this.alertModalDeleteCommunity.cancelButton = true; + this.alertModalDeleteCommunity.okButton = true; + this.alertModalDeleteCommunity.alertTitle = "Remove project?"; + let title = ""; + if (communityProject.name) { + title = communityProject.name; + } + if (communityProject.name && communityProject.acronym) { + title += " ("; + } + if (communityProject.acronym) { + title += communityProject.acronym; + } + if (communityProject.name && communityProject.acronym) { + title += ")"; + } + this.alertModalDeleteCommunity.message = "Project"; + if (title) { + this.alertModalDeleteCommunity.message += " '" + title + "' "; + } + this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?"; + this.alertModalDeleteCommunity.okButtonText = "Yes"; + this.alertModalDeleteCommunity.open(); + } + } + + public _getCommunityProjects() { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.communitySearchUtils.status = this.errorCodes.LOADING; + this.communityProjects = []; + this.communitySearchUtils.totalResults = 0; + this.communitySearchUtils.page = 1; + this.communitySearchUtils.keyword = ""; + + this.subscriptions.push(this._searchCommunityProjectsService.searchProjects(this.properties, this.portal).subscribe( + data => { + this.communityProjects = data; + this.previewCommunityProjects = this.communityProjects; + this.sort(); + + this.communitySearchUtils.totalResults = data.length; + this.communitySearchUtils.status = this.errorCodes.DONE; + + this.communityProjectsChanged.emit({ + value: this.communityProjects, + }); + + this.createFunderFilter(); + + this.showLoading = false; + }, + err => { + console.error(err); + //TODO check erros (service not available, bad request) + + if (err.status == '404') { + this.communitySearchUtils.status = this.errorCodes.NOT_FOUND; + } else if (err.status == '500') { + this.communitySearchUtils.status = this.errorCodes.ERROR; + } else { + this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + + this.showLoading = false; + } + )); + } + } + + public createFunderFilter(): void { + let funders: Set = new Set(); + this.allOptions = []; + let i; + for (i = 0; i < this.communityProjects.length; i++) { + let funder = this.communityProjects[i].funder; + if (funder && !funders.has(funder)) { + funders.add(funder); + this.allOptions.push({label: funder, value: {id: funder, label: funder}}); + } + } + } + + public updatePage($event) { + this.page = $event.value; + } + + addNew() { + this.toggleView.emit(null); + } + + public applyFilters() { + this.previewCommunityProjects = this.communityProjects.filter(project => { + let return_value: boolean = (this.filterCommunityProjectByKeyword(project) && this.filterCommunityProjectByFunder(project)); + return return_value; + }); + + // check paging here!!! + if (this.previewCommunityProjects.slice((this.page - 1) * this.resultsPerPage, this.page * this.resultsPerPage).length == 0) { + this.page = 1; + } + + this.sort(); + } + + public filterCommunityProjectByKeyword(project): boolean { + const textFlag = this.searchText.toString() === '' + || ((project.name + " " + project.acronym + " " + project.grantId + " " + project.funder)).match(this.searchText) != null; + + return textFlag; + } + + public filterCommunityProjectByFunder(project): boolean { + if (this.fundersCtrl.getRawValue().length == 0) { + return true; + } + for (let funder of this.fundersCtrl.getRawValue()) { + if (project.funder.toLowerCase().indexOf(funder.label.toLowerCase()) != -1) { + return true; + } + } + return false; + } + + private sort() { + let sortOption: { sort: string, descending: boolean } = this.filterForm.get('sort').value; + + this.previewCommunityProjects.sort((left, right): number => { + if (sortOption.sort == "title") { + if ((left.name + left.acronym) > (right.name + right.acronym)) { + return sortOption.descending ? -1 : 1; + } else if ((left.name + left.acronym) < (right.name + right.acronym)) { + return sortOption.descending ? 1 : -1; + } + } else if (sortOption.sort == "grant") { + if (left.grantId > right.grantId) { + return sortOption.descending ? -1 : 1; + } else if (left.grantId < right.grantId) { + return sortOption.descending ? 1 : -1; + } + } else if (sortOption.sort == "funder") { + if (left.funder > right.funder) { + return sortOption.descending ? -1 : 1; + } else if (left.funder < right.funder) { + return sortOption.descending ? 1 : -1; + } + } + + return 0; + }); + } + + public onSearchClose() { + this.communitySearchUtils.keyword = this.filterForm.get('keyword').value; + } + + public resetInput() { + this.communitySearchUtils.keyword = null; + this.searchInputComponent.reset() + } + + handleError(message: string) { + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + } +} diff --git a/src/app/pages/stats/stats-routing.module.ts b/src/app/pages/stats/stats-routing.module.ts index 78e7fe1..d8ac4f1 100644 --- a/src/app/pages/stats/stats-routing.module.ts +++ b/src/app/pages/stats/stats-routing.module.ts @@ -1,13 +1,11 @@ -import { NgModule } from '@angular/core'; +import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; import {StatsComponent} from './stats.component'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: StatsComponent} + { path: '',component: StatsComponent} ]) ] }) diff --git a/src/app/pages/stats/stats.component.html b/src/app/pages/stats/stats.component.html index e912ded..213dbf7 100644 --- a/src/app/pages/stats/stats.component.html +++ b/src/app/pages/stats/stats.component.html @@ -33,7 +33,7 @@
-
+
diff --git a/src/app/pages/stats/stats.component.ts b/src/app/pages/stats/stats.component.ts index 7a44592..73ed26e 100644 --- a/src/app/pages/stats/stats.component.ts +++ b/src/app/pages/stats/stats.component.ts @@ -12,6 +12,7 @@ import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {CommunityCharts} from '../../openaireLibrary/connect/statistics/communityCharts'; +import {properties} from '../../../environments/environment'; @Component({ selector: 'stats', @@ -58,19 +59,16 @@ export class StatsComponent implements OnInit { private titleCase: TitleCasePipe) {} ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe( - params => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | Statistics'); - this.communityId = params['communityId']; - this.getStatistics(); - }); - }, - error => console.log(`E R R O R!!`) - ); + + this.properties = properties; + this.route.params.subscribe( + params => { + HelperFunctions.scroll(); + this.title.setTitle('Administration Dashboard | Statistics'); + this.communityId = params['community']; + this.getStatistics(); + }); + } getStatistics() { @@ -92,6 +90,8 @@ export class StatsComponent implements OnInit { if(stats["other"]){ //hack because in stats API the entity name is "other" while in admin API is "orp". This component uses also "orp" name this.statisticsSum["orp"]=stats["other"]; } + }else{ + console.debug("Aaaa") } }, error => { @@ -133,10 +133,13 @@ export class StatsComponent implements OnInit { this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); } else { //console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`); - this.configService.getCommunityInformation(this.properties, this.communityId).subscribe( + this.configService.communityInformationState.subscribe( res => { + console.debug(res); + if(res) { this.communityInfo = res; this.communityName = this.communityInfo.name; + } }, error => this.handleError('Failed to retrieve information for the chosen community!', error),//console.log(error), () => { diff --git a/src/app/pages/stats/stats.module.ts b/src/app/pages/stats/stats.module.ts index 5214f44..8cc4c7b 100644 --- a/src/app/pages/stats/stats.module.ts +++ b/src/app/pages/stats/stats.module.ts @@ -1,8 +1,6 @@ -import { NgModule } from '@angular/core'; +import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; import {StatsComponent} from './stats.component'; import {StatsRoutingModule} from './stats-routing.module'; import {MatSlideToggleModule} from '@angular/material'; @@ -12,7 +10,6 @@ import {MatSlideToggleModule} from '@angular/material'; CommonModule, StatsRoutingModule, RouterModule, MatSlideToggleModule ], declarations: [StatsComponent], - providers: [IsCommunity, ConnectAdminLoginGuard], exports: [StatsComponent] }) export class StatsModule { } diff --git a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form-routing.module.ts b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form-routing.module.ts index 4b58550..5f86a90 100644 --- a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form-routing.module.ts +++ b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form-routing.module.ts @@ -1,14 +1,11 @@ -import { NgModule } from '@angular/core'; +import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; import {SubjectsEditFormComponent} from './subjects-edit-form.component'; -import {IsCommunity} from '../../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {ConnectCommunityGuard} from '../../../openaireLibrary/connect/communityGuard/connectCommunityGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard, ConnectCommunityGuard], component: SubjectsEditFormComponent} + { path: '', component: SubjectsEditFormComponent} ]) ] }) diff --git a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.html b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.html index 3c678e7..a32a06f 100644 --- a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.html +++ b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.html @@ -1,43 +1,106 @@ -
-
Manage subjects
-
+
+
+ +
+ +
+
- - All the research results associated to the subjects specified here will be automatically linked to the community dashboard. + + + +
-
-
- - -
- - - - - - -
- -
-
- - - - - -
- - - -
- -
- - - -
+
+
+
+ +
+
+
+
No subjects found
+
+
+ + + +
+
+ +
+
+
+
+
+ + + +
+
+ +
+
+
+ + diff --git a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.ts b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.ts index 75ba3c1..452ed08 100644 --- a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.ts +++ b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.ts @@ -1,331 +1,355 @@ -import {Component, OnInit, Input, ElementRef} from '@angular/core'; -import {FormGroup, FormBuilder, Validators} from '@angular/forms'; +import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; +import {FormArray, FormBuilder, FormControl} from '@angular/forms'; import {ActivatedRoute, Router} from '@angular/router'; -import {HelpContentService} from '../../../services/help-content.service'; import {CommunityService} from '../../../openaireLibrary/connect/community/community.service'; import {SubjectsService} from '../subjects.service'; import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; import {Session} from '../../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class'; -import { concat } from 'rxjs/observable/concat'; -import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class"; +import {concat} from 'rxjs/observable/concat'; import {Title} from '@angular/platform-browser'; +import {properties} from '../../../../environments/environment'; +import {AlertModal} from '../../../openaireLibrary/utils/modal/alert'; +import {SearchInputComponent} from '../../../openaireLibrary/sharedComponents/search-input/search-input.component'; +import {Subscription} from 'rxjs'; +import {CommunityInfo} from '../../../openaireLibrary/connect/community/communityInfo'; + +declare var UIkit; + @Component({ - selector: 'subjects-edit-form', - templateUrl: './subjects-edit-form.component.html', + selector: 'subjects-edit-form', + templateUrl: './subjects-edit-form.component.html', }) export class SubjectsEditFormComponent implements OnInit { - - @Input('group') - myForm: FormGroup; - - public showLoading = true; - public errorMessage = ''; - public updateErrorMessage = ''; - - public successfulSaveMessage = ''; - public successfulResetMessage = ''; - - public hasChanged = false; - - public res = []; - - params: any; - - public communityId = null; - public community = null; - public properties: EnvProperties = null; - public newsubject = ''; - public edit = null; - public editSubjectOriginalValue = null; - public originalSubjects = []; - - constructor (private element: ElementRef, - private route: ActivatedRoute, - private _router: Router, - public _fb: FormBuilder, - private title: Title, - private _helpContentService: HelpContentService, - private _communityService: CommunityService, - private _subjectsService: SubjectsService) { } - - - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe( - communityId => { - HelperFunctions.scroll(); - this.title.setTitle('Administration Dashboard | Subjects'); - this.communityId = communityId['communityId']; - - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if (this.communityId != null && this.communityId !== '') { - this.showLoading = true; - this.updateErrorMessage = ''; - this.errorMessage = ''; - - this._communityService.getCommunity(this.properties, - this.properties.communityAPI + this.communityId).subscribe ( - community => { - this.community = community; - this.params = {community: encodeURIComponent( - '"' + community.queryId + '"')}; - this.originalSubjects = []; - for (let i = 0; i < this.community.subjects.length; i++) { - this.originalSubjects.push(this.community.subjects[i]); - } - if (this.community.subjects.length === 0) { - this.community.subjects.push(''); - } - this.showLoading = false; - }, - error => this.handleError('System error retrieving community profile', error) - ); - } - } - }); - }); - } - - - - public addSubject() { - if (!Session.isLoggedIn()) { - this._router.navigate( - ['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - this.community.subjects.push(''); - } + myForm = new FormArray([new FormControl({subject: ''})]); + public showLoading = true; + public res = []; + params: any; + public communityId: string = null; + public community: CommunityInfo = null; + public properties: EnvProperties = properties; + public edit = null; + public originalSubjects = []; + @ViewChild('editModal') editModal: AlertModal; + @ViewChild('deleteModal') deleteModal: AlertModal; + page = 1; + size = 10; + selectedSubjects = []; + isEditModal: boolean = false; + public selectedKeyword: string; + @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; + public filterForm: FormControl; + private subscriptions: any[] = []; + /*//Check again functionality to enable page + subjectsPage; + @ViewChild('enablePageModal') enablePageModal: AlertModal;*/ + constructor(private element: ElementRef, + private route: ActivatedRoute, + private _router: Router, + public _fb: FormBuilder, + private title: Title, + // private _helpContentService: HelpContentService, + private _communityService: CommunityService, + private _subjectsService: SubjectsService, + ) { } + + + ngOnInit() { + this.filterForm = this._fb.control(''); + this.subscriptions.push(this.filterForm.valueChanges.subscribe(value => { + this.page = 1; + this.community.subjects = this.originalSubjects.filter(subject => { + return subject.toLowerCase().indexOf(value.toLowerCase()) != -1 + }); + })); + this.subscriptions.push(this.route.params.subscribe( + params => { + this.communityId = params['community']; + this.title.setTitle(this.communityId.toUpperCase() + ' | Subjects'); + this.showLoading = true; + this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe( + community => { + this.community = community; + this.params = { + community: encodeURIComponent( + '"' + community.queryId + '"') + }; + this.community.subjects.sort((n1,n2)=> { + if (n1.toLowerCase() > n2.toLowerCase()) { + return 1; + } + if (n1.toLowerCase() < n2.toLowerCase()) { + return -1; + } + return 0; + }); - public removeSubject(i: any) { + this.originalSubjects = []; + for (let i = 0; i < this.community.subjects.length; i++) { + this.originalSubjects.push(this.community.subjects[i]); + } + if (this.community.subjects.length === 0) { + this.community.subjects.push(''); + } + this.showLoading = false; + }, + error => this.handleUpdateError('System error retrieving community profile', error) + )); + // this.getSubjectsPageStatus(); + })); + + } + + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }); + } + + private removeModalOpen(subject: string, i: any) { if (!Session.isLoggedIn()) { this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); } else { - this.community.subjects.splice(i, 1); + this.selectedSubjects = [subject]; + this.reset(['']); + this.deleteModal.cancelButton = true; + this.deleteModal.okButton = true; + this.deleteModal.alertTitle = 'Delete Confirmation'; + this.deleteModal.message = 'Are you sure you want to delete this subject?'; + this.deleteModal.okButtonText = 'Yes'; + this.deleteModal.cancelButtonText = 'No'; + this.deleteModal.open(); } } - - public resetForm(communityId: string) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if (communityId != null && communityId !== '') { - this.showLoading = true; - this.updateErrorMessage = ''; - this.errorMessage = ''; - - this._communityService.getCommunity(this.properties, - this.properties.communityAPI + communityId).subscribe ( - community => { - this.community = community; - this.params = {community: encodeURIComponent('"' + community.queryId + '"')}; - this.showLoading = false; - this.handleSuccessfulReset('Form reset!'); - }, - error => this.handleError('System error retrieving community profile', error) - ); + + + public getSubjectsExistOnlyInFirst(firstArray: string[], secondArray: string[]): string[] { + const difference = []; + for (let i = 0; i < firstArray.length; i++) { + if (secondArray.indexOf(firstArray[i]) === -1) { + difference.push(firstArray[i]); } - this.resetChange(); + } + return difference; } - - public getSubjectsExistOnlyInFirst(firstArray: string[], secondArray: string[]): string[] { - - const difference = []; - for (let i = 0; i < firstArray.length; i++) { - if (secondArray.indexOf(firstArray[i]) === -1) { - difference.push(firstArray[i]); - } - - } - return difference; - - } - - public updateSubjects() { + + public saveSubjects() { if (!Session.isLoggedIn()) { this._router.navigate(['/user-info'], - { queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); + {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); } else { if (this.communityId != null && this.communityId !== '') { - this.showLoading = true; - const subjectsToDeleteAr = this.getSubjectsExistOnlyInFirst(this.originalSubjects, this.community.subjects); - const subjectsToAddAr = this.getSubjectsExistOnlyInFirst(this.community.subjects, this.originalSubjects); - const subjectsToDelete = this.parseUpdatedSubjects(subjectsToDeleteAr); - const subjectsToAdd = this.parseUpdatedSubjects(subjectsToAddAr); - if (subjectsToAddAr.length > 0 && subjectsToDeleteAr.length > 0) { - const obs = concat(this._subjectsService.addSubjects( - this.properties.communityAPI + this.communityId + '/subjects', subjectsToAdd), + this.showLoading = true; + const subjectsToDeleteAr = this.getSubjectsExistOnlyInFirst(this.selectedSubjects, this.myForm.getRawValue()); + const subjectsToAddAr = this.getSubjectsExistOnlyInFirst(this.myForm.getRawValue(), this.selectedSubjects); + const subjectsToDelete = this.getNonEmptyItems(subjectsToDeleteAr); + const subjectsToAdd = this.getNonEmptyItems(subjectsToAddAr); + if (subjectsToAdd.length > 0 && subjectsToDelete.length > 0) { + const obs = concat(this._subjectsService.addSubjects( + this.properties.communityAPI + this.communityId + '/subjects', subjectsToAdd), this._subjectsService.removeSubjects( - this.properties.communityAPI + this.communityId + '/subjects', subjectsToDelete)); - obs.subscribe(res => { - if (res['method'] === 'delete') { - this.afterUpdateActions(res); - } - }, - error => this.handleUpdateError('System error updating subjects', error) - ); - } else if (subjectsToAddAr.length > 0) { - this._subjectsService.addSubjects( - this.properties.communityAPI + this.communityId + '/subjects', subjectsToAdd). - subscribe(res => { - this.afterUpdateActions(res); - }, - error => this.handleUpdateError('System error updating subjects', error) - ); - } else if (subjectsToDeleteAr.length > 0) { - this._subjectsService.removeSubjects( - this.properties.communityAPI + this.communityId + '/subjects', subjectsToDelete). - subscribe(res => { - this.afterUpdateActions(res); - }, - error => this.handleUpdateError('System error updating subjects', error) - ); - } - // this._router.navigate(['/manage-subjects'], {queryParams: { "communityId": this.communityId}}); + this.properties.communityAPI + this.communityId + '/subjects', subjectsToDelete)); + this.subscriptions.push(obs.subscribe(res => { + if (res['method'] === 'delete') { + this.afterUpdateActions(res, "updated"); + } + }, + error => this.handleUpdateError('System error updating subjects', error) + )); + } else if (subjectsToAdd.length > 0) { + this.subscriptions.push(this._subjectsService.addSubjects( + this.properties.communityAPI + this.communityId + '/subjects', subjectsToAdd).subscribe(res => { + this.afterUpdateActions(res, "added"); + }, + error => this.handleUpdateError('System error updating subjects', error) + )); + } else if (subjectsToDelete.length > 0) { + this.subscriptions.push(this._subjectsService.removeSubjects( + this.properties.communityAPI + this.communityId + '/subjects', subjectsToDelete).subscribe(res => { + this.afterUpdateActions(res, "deleted"); + }, + error => this.handleUpdateError('System error updating subjects', error) + )); + } +/* if(!this.subjectsEnabled) { + this.curatorsEnabledOpen(); + }*/ } - this.resetChange(); } } - - afterUpdateActions(res) { + + handleUpdateError(message: string, error) { + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + this.showLoading = false; + } + + afterUpdateActions(res, message: string) { + this._communityService.setCommunity(this._communityService.parseCommunity(res)); this.community.subjects = res['subjects']; this.originalSubjects = []; for (let i = 0; i < this.community.subjects.length; i++) { - this.originalSubjects.push(this.community.subjects[i]); + this.originalSubjects.push(this.community.subjects[i]); } - if (this.community.subjects.length === 0) { - this.community.subjects.push(''); - } - this.handleSuccessfulSave('Subjects updated!'); + this.originalSubjects.sort((n1,n2)=> { + if (n1.toLowerCase() > n2.toLowerCase()) { + return 1; + } + if (n1.toLowerCase() < n2.toLowerCase()) { + return -1; + } + return 0; + }); + this.page = 1; + this.community.subjects = this.originalSubjects.filter(subject => { + return subject.toLowerCase().indexOf(this.filterForm.value.toLowerCase()) != -1 + }).sort(); + UIkit.notification('Subjects successfully ' + message + '!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; } - - private parseUpdatedSubjects(subjects): {} { - const parsedSubjects = this.getNonEmptyItems(subjects); - return parsedSubjects; - } - - - + + private getNonEmptyItems(data: string[]): string[] { - const length = data.length; - const arrayNonEmpty = new Array(); - let j = 0; - for (let i = 0; i < length; i++) { - if (this.isEmpty(data[i])) { - } else if (this.isNonEmpty(data[i])) { - arrayNonEmpty[j] = data[i]; - j++; - } + const length = data.length; + const arrayNonEmpty = new Array(); + let j = 0; + for (let i = 0; i < length; i++) { + if (this.isEmpty(data[i])) { + } else if (this.isNonEmpty(data[i])) { + arrayNonEmpty[j] = data[i]; + j++; } - return arrayNonEmpty; + } + return arrayNonEmpty; } - - private hasFilled(data: any): boolean { - if (this.isNonEmpty(data) && !this.isEmpty(data)) { - return true; - } - return false; - } - + + private isEmpty(data: string): boolean { - if (data !== undefined && !data.replace(/\s/g, '').length) { - return true; - } else { - return false; - } - } - - private isNonEmpty(data: string): boolean { - if (data !== undefined && data != null) { - return true; - } else { - return false; - } - } - - private hasValidEmail(data: any): boolean { - const length = data['managers'].length; - - for (let i = 0; i < length; i++) { - if (!this.emailValidator(data['managers'][i])) { - // TODO remove console message after final testing - // console.log("INVALID EMAIL"); - return false; - } - } - // TODO remove console message after final testing - // console.log("ALL EMAILS ARE VALID"); + if (data !== undefined && !data.replace(/\s/g, '').length) { return true; + } else { + return false; + } } - - private emailValidator(email: any): boolean { - if (email.match('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$')) { - return true; - } else { - return false; - } + + private isNonEmpty(data: string): boolean { + if (data !== undefined && data != null) { + return true; + } else { + return false; + } } - - private change() { - this.hasChanged = true; - this.successfulSaveMessage = ''; - this.successfulResetMessage = ''; + + public addSubjectInForm() { + this.myForm.push(new FormControl('')); } - - private resetChange() { - this.hasChanged = false; + + public removeSubjectInForm(i: number) { + this.myForm.removeAt(i); } - - public get form() { - return this._fb.group({ - _id : '', - name : ['', Validators.required] + + public reset(subjects: string[]) { + this.myForm = new FormArray([]); + for (let subject in subjects) { + this.myForm.push(new FormControl('')); + } + this.myForm.patchValue(subjects); + } + + newSubject() { + this.isEditModal = false; + this.selectedSubjects = []; + this.reset([""]); + this.formModalOpen('Add Subject', 'Save'); + } + + public editSubject(subject: string) { + this.isEditModal = true; + this.selectedSubjects = [subject]; + this.reset([subject]); + this.formModalOpen('Edit Subject', 'Save'); + } + + + private formModalOpen(title: string, yesBtn: string) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } }); + } else { + this.editModal.okButtonLeft = false; + this.editModal.cancelButton = true; + this.editModal.okButton = true; + this.editModal.alertTitle = title; + this.editModal.okButtonText = yesBtn; + this.editModal.open(); + } + } + + public onSearchClose() { + this.selectedKeyword = this.filterForm.value; + } + + public resetInput() { + this.selectedKeyword = null; + this.searchInputComponent.reset() + } + /* + //Check again functionality to enable page + private getSubjectsPageStatus() { + this._helpContentService.getCommunityPagesByRoute(this.communityId, '/subjects', this.properties.adminToolsAPIURL).subscribe((page) => { + this.subjectsPage = page; + }); } - public reset() { - this.myForm.patchValue({ - name : '', - _id : '' + public get subjectsEnabled(): boolean { + return !this.subjectsPage || this.subjectsPage.isEnabled; + } + enablePage() { + this._helpContentService.togglePages(this.communityId, [this.subjectsPage._id], true, this.properties.adminToolsAPIURL).subscribe(() => { + this.subjectsPage.isEnabled = true; + UIkit.notification('Curators Page has been enabled successfully', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' }); + },error => { + this.subjectsPage.isEnabled = false; + UIkit.notification('An error occured', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + }); } - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; - console.log('Server responded: ' + error); - this.showLoading = false; - } + private curatorsEnabledOpen() { + this.enablePageModal.okButtonLeft = false; + this.enablePageModal.alertTitle = 'Enable Subjects Page'; + this.enablePageModal.okButtonText = 'Yes'; + this.enablePageModal.cancelButtonText = 'No'; + this.enablePageModal.open(); + }*/ - handleError(message: string, error) { - this.errorMessage = message; - console.log('Server responded: ' + error); - - this.showLoading = false; - } - - handleSuccessfulSave(message) { - this.showLoading = false; - this.successfulSaveMessage = message; - } - - handleSuccessfulReset(message) { - this.showLoading = false; - this.successfulResetMessage = message; - } - - trackByFn(index: any, item: any) { - return index; - } } diff --git a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.module.ts b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.module.ts index 8ab3e7d..308efcf 100644 --- a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.module.ts +++ b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.module.ts @@ -7,22 +7,33 @@ import {SubjectsEditFormComponent} from './subjects-edit-form.component'; import {SubjectsService} from '../subjects.service'; import {SubjectsEditFormRoutingModule} from './subjects-edit-form-routing.module'; -import {IsCommunity} from '../../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; -import {ConnectCommunityGuard} from '../../../openaireLibrary/connect/communityGuard/connectCommunityGuard.guard'; +import {PageContentModule} from '../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; +import {IconsModule} from '../../../openaireLibrary/utils/icons/icons.module'; +import {IconsService} from '../../../openaireLibrary/utils/icons/icons.service'; +import {add, check_circle_outlined, close, edit, remove} from '../../../openaireLibrary/utils/icons/icons'; +import {AlertModalModule} from '../../../openaireLibrary/utils/modal/alertModal.module'; +import {NoLoadPaging} from '../../../openaireLibrary/searchPages/searchUtils/no-load-paging.module'; +import {LoadingModule} from '../../../openaireLibrary/utils/loading/loading.module'; +import {InputModule} from '../../../openaireLibrary/sharedComponents/input/input.module'; +import {CommunityInfoModule} from '../../community-info/community-info.module'; +import {SearchInputModule} from '../../../openaireLibrary/sharedComponents/search-input/search-input.module'; @NgModule({ imports: [ - SubjectsEditFormRoutingModule, CommonModule, FormsModule, RouterModule, + SubjectsEditFormRoutingModule, CommonModule, FormsModule, RouterModule, PageContentModule, IconsModule, AlertModalModule, NoLoadPaging, LoadingModule, InputModule, CommunityInfoModule, SearchInputModule ], declarations: [ SubjectsEditFormComponent ], providers: [ - SubjectsService, IsCommunity, ConnectAdminLoginGuard, ConnectCommunityGuard + SubjectsService ], exports: [ SubjectsEditFormComponent ] }) -export class SubjectsEditFormModule { } +export class SubjectsEditFormModule { + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([add, edit, remove, close]) + } +} diff --git a/src/app/pages/subscribers/manage-subscribers-routing.module.ts b/src/app/pages/subscribers/manage-subscribers-routing.module.ts deleted file mode 100644 index 1d41090..0000000 --- a/src/app/pages/subscribers/manage-subscribers-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {ManageSubscribersComponent} from './manage-subscribers.component'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: ManageSubscribersComponent} - ]) - ] -}) -export class ManageSubscribersRoutingModule { } diff --git a/src/app/pages/subscribers/manage-subscribers.component.html b/src/app/pages/subscribers/manage-subscribers.component.html deleted file mode 100644 index dce7d75..0000000 --- a/src/app/pages/subscribers/manage-subscribers.component.html +++ /dev/null @@ -1,62 +0,0 @@ -
-
Manage subscribers
-
-
- - -
-
- -
-
- - {{subscribersSearchUtils.totalResults | number}} subscribers, page {{subscribersSearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
- -
-
- - - - - - - - - - - - - -
EmailAction
- {{item.email}} - - - -
-
-
- -
-
- - {{subscribersSearchUtils.totalResults | number}} subscribers, page {{subscribersSearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
- -
- - diff --git a/src/app/pages/subscribers/manage-subscribers.component.ts b/src/app/pages/subscribers/manage-subscribers.component.ts deleted file mode 100644 index c10d654..0000000 --- a/src/app/pages/subscribers/manage-subscribers.component.ts +++ /dev/null @@ -1,308 +0,0 @@ -import {Component, ViewChild, OnInit, Input, Output, ElementRef} from '@angular/core'; -import {ViewEncapsulation, EventEmitter} from '@angular/core'; -import {SimpleChanges, OnChanges} from '@angular/core'; -import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms'; -import {ActivatedRoute, Router} from '@angular/router'; -import {Subject} from 'rxjs'; -import {DataTableDirective} from 'angular-datatables'; - -import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; -import {SubscribeService} from '../../openaireLibrary/utils/subscribe/subscribe.service'; -import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class'; - -import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; -import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; - -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; -import {Title} from '@angular/platform-browser'; - -@Component({ - selector: 'manage-subscribers', - templateUrl: './manage-subscribers.component.html', - styles: [` - #dpTable_info, #dpTable_paginate, #dpTable_length, #dpTable_filter{ - display: none; - } - `], - encapsulation: ViewEncapsulation.None // this used in order styles to work -}) - -export class ManageSubscribersComponent implements OnInit { - public routerHelper:RouterHelper = new RouterHelper(); - - private errorCodes: ErrorCodes; - - @Output() commmunitySubscribersChanged = new EventEmitter(); - public communitySubscribers = []; - public subscribersSearchUtils: SearchUtilsClass = new SearchUtilsClass(); - - public sub: any; public subResults: any; subRemove: any; - public properties: EnvProperties; - - public disableForms: boolean = false; - - dtOptions: DataTables.Settings = {}; - showTable = false; filteringAdded = false; - @ViewChild(DataTableDirective) datatableElement: DataTableDirective; - dtTrigger: Subject = new Subject(); //necessary - - public rowsOnPage:number = 10; - - public queryParameters: string = ""; - - public query = ''; - public selectedSubscribersEmail=[]; - public elementRef; - - public subscribers:string[]; - private triggered: boolean = false; - - private selectedSubscriberEmail: any; - - public communityId = null; - - @ViewChild('AlertModalDeleteSubscriber') alertModalDeleteSubscriber; - - constructor (private element: ElementRef, - private route: ActivatedRoute, - private title: Title, - private _router: Router, - public _fb: FormBuilder, - private _subscribeService: SubscribeService) { - - this.errorCodes = new ErrorCodes(); - this.subscribersSearchUtils.status = this.errorCodes.LOADING; - } - - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe( - - communityId => { - HelperFunctions.scroll(); - - this.communityId = communityId['communityId']; - this.title.setTitle('Administration Dashboard | Subscribers'); - if (this.communityId != null && this.communityId != '') { - this._getCommunitySubscribers(); - } - }); - }); - - this.dtOptions = { - "pageLength": this.rowsOnPage, - "language": { - "search": "", - "searchPlaceholder": "Search subscribers..." - } - }; - - this.subscribersSearchUtils.keyword = ""; - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults) { - this.subResults.unsubscribe(); - } - if(this.subRemove) { - this.subRemove.unsubscribe(); - } - - $.fn['dataTable'].ext.search.pop(); - } - - rerender(): void { - this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => { - // Destroy the table first - dtInstance.destroy(); - - // Call the dtTrigger to rerender again - this.dtTrigger.next(); - }); - } - - ngAfterViewInit(): void { - $.fn['dataTable'].ext.search.push((settings, data, dataIndex) => { - - if (this.filterData(data, this.subscribersSearchUtils.keyword)) { - return true; - } - return false; - }); - - //console.info("ngAfterViewInit"); - } - - filterData(row: any, query: string) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - let returnValue: boolean = false; - - if(query) { - for(var i = 0; i < 2; i++) { - var r= this.filterQuery(row[i], query); - if(r) { - returnValue = true; - break; - } - } - - if(!returnValue) { - return false; - } - } - return true; - } - } - - filterQuery(data, query){ - if(data.toLowerCase().indexOf(query.toLowerCase()) > -1) { - return true; - } else { - return false; - } - } - - /* - Trigger a table draw in order to get the initial filtering - */ - triggerInitialLoad(){ - this.triggered = true; - //console.info("triggerInitialLoad"); - setTimeout(function() { - var table = ($('#dpTable')).DataTable(); - table.page( 0 ).draw( false ); - }, 500); - this.dtTrigger.next(); - } - - public goTo(page:number = 1) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subscribersSearchUtils.page=page; - - var table = $('#dpTable').DataTable(); - table.page( page - 1 ).draw( false ); - - var info = table.page.info(); - this.subscribersSearchUtils.totalResults = info.recordsDisplay; - } - } - - totalPages(): number { - let totalPages:any = this.subscribersSearchUtils.totalResults/(this.rowsOnPage); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - return totalPages; - } - - public removeSubscriber(email:string) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.selectedSubscriberEmail = email; - this.alertModalDeleteSubscriber.cancelButton = true; - this.alertModalDeleteSubscriber.okButton = true; - this.alertModalDeleteSubscriber.alertTitle = "Remove subscriber?"; - - this.alertModalDeleteSubscriber.message = "Subscriber with email "; - if (email) { - this.alertModalDeleteSubscriber.message += " '"+email+"' "; - } - - this.alertModalDeleteSubscriber.message += "will be removed from your community. Are you sure?"; - this.alertModalDeleteSubscriber.okButtonText = "Yes"; - this.alertModalDeleteSubscriber.open(); - } - } - - public confirmedDeleteSubscriber() { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subRemove = this._subscribeService.unSubscribeToCommunityByEmail(this.properties, this.communityId, this.selectedSubscriberEmail).subscribe( - result => { - this.communitySubscribers = result; - }, - err => { - console.log(err); - }, - () => { - this.subscribersSearchUtils.totalResults--; - this.subscribersSearchUtils.page=1; - - this.rerender(); - } - ) - } - } - - public _getCommunitySubscribers(){ - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.subscribersSearchUtils.status = this.errorCodes.LOADING; - this.disableForms = true; - this.communitySubscribers = []; - this.subscribersSearchUtils.totalResults = 0; - this.subscribersSearchUtils.page=1; - this.subscribersSearchUtils.keyword = ""; - - this.subResults = this._subscribeService.getCommunitySubscribers(this.properties, this.communityId).subscribe( - - res => { - //console.info("search Subscribers [total communitySubscribers:"+res.subscribers.length+"]"); - this.communitySubscribers = res; - - this.subscribersSearchUtils.totalResults = res.subscribers.length; - this.subscribersSearchUtils.status = this.errorCodes.DONE; - - this.disableForms = false; - if(!this.triggered) { - this.triggerInitialLoad(); - } else { - var table = $('#dpTable').DataTable(); - table.clear(); - - this.rerender(); - } - - this.commmunitySubscribersChanged.emit({ - value: this.communitySubscribers, - }); - }, - err => { - console.log(err); - //TODO check erros (service not available, bad request) - - if(err.status == '404') { - this.subscribersSearchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.subscribersSearchUtils.status = this.errorCodes.ERROR; - } else { - this.subscribersSearchUtils.status = this.errorCodes.NOT_AVAILABLE; - } - - this.disableForms = false; - if(!this.triggered) { - this.triggerInitialLoad(); - } else { - var table = $('#dpTable').DataTable(); - table.clear(); - - this.rerender(); - } - } - ); - } - } -} diff --git a/src/app/pages/subscribers/manage-subscribers.module.ts b/src/app/pages/subscribers/manage-subscribers.module.ts deleted file mode 100644 index 25f339c..0000000 --- a/src/app/pages/subscribers/manage-subscribers.module.ts +++ /dev/null @@ -1,30 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; -import {FormsModule} from '@angular/forms'; -import {RouterModule} from '@angular/router'; -import {DataTablesModule} from 'angular-datatables'; - -import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; -import {PagingModule} from '../../openaireLibrary/utils/paging.module'; -import {ManageSubscribersComponent} from './manage-subscribers.component'; -import {ManageSubscribersRoutingModule} from './manage-subscribers-routing.module'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; - -@NgModule({ - imports: [ - ManageSubscribersRoutingModule, CommonModule, FormsModule, RouterModule, - PagingModule, DataTablesModule, AlertModalModule - ], - declarations: [ - ManageSubscribersComponent - ], - providers: [ - IsCommunity, ConnectAdminLoginGuard - ], - exports: [ - ManageSubscribersComponent - ] -}) - -export class ManageSubscribersModule { } diff --git a/src/app/pages/usernotifications/manage-user-notifications-routing.module.ts b/src/app/pages/usernotifications/manage-user-notifications-routing.module.ts index 15427a5..07795ff 100644 --- a/src/app/pages/usernotifications/manage-user-notifications-routing.module.ts +++ b/src/app/pages/usernotifications/manage-user-notifications-routing.module.ts @@ -1,14 +1,13 @@ -import { NgModule } from '@angular/core'; +import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; import {ManageUserNotificationsComponent} from './manage-user-notifications.component'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: ManageUserNotificationsComponent} + { path: '', component: ManageUserNotificationsComponent} ]) ] }) -export class ManageUserNotificationsRoutingModule { } +export class ManageUserNotificationsRoutingModule { +} diff --git a/src/app/pages/usernotifications/manage-user-notifications.component.html b/src/app/pages/usernotifications/manage-user-notifications.component.html index b121222..309c5f4 100644 --- a/src/app/pages/usernotifications/manage-user-notifications.component.html +++ b/src/app/pages/usernotifications/manage-user-notifications.component.html @@ -1,96 +1,75 @@ -
-
Manage notification settings
+
+
+
-
- - - - - -
- -
-
- -
Notify for manager changes:
-
- - - - -
+
+ +
+
+ + +
Notifications settings
-
-
Notify for new subscribers:
-
- - - - -
-
- -
-
- - +
Manage Notifications
+
+
+
+ Notifications for manager list changes {{userNotifications.notifyForNewManagers ? '(Enabled)' : '(Disabled)'}}
+ + +
+
+
Notifications for new + subscribers {{userNotifications.notifyForNewSubscribers ? '(Enabled)' : '(Disabled)'}}
+ + +
+
+
+
+
Notify for + links + {{notification.notify ? '(Enabled)' : '(Disabled)'}}
+ + +
+
+
+ + + {{fr.label}} + +
- - --> - - - -
- - - +
+
+
+
+
+ +
+
+
+
diff --git a/src/app/pages/usernotifications/manage-user-notifications.component.ts b/src/app/pages/usernotifications/manage-user-notifications.component.ts index 9ccb4be..6e42463 100644 --- a/src/app/pages/usernotifications/manage-user-notifications.component.ts +++ b/src/app/pages/usernotifications/manage-user-notifications.component.ts @@ -1,21 +1,20 @@ -import {Component, OnInit, Input, ViewChild, ElementRef} from '@angular/core'; -import {FormGroup, FormBuilder} from '@angular/forms'; +import {Component, ElementRef, Input, OnInit} from '@angular/core'; +import {FormBuilder, FormGroup} from '@angular/forms'; import {ActivatedRoute, Router} from '@angular/router'; - import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; - import {Session, User} from '../../openaireLibrary/login/utils/helper.class'; - import {ManageUserNotificationsService} from './manage-user-notifications.service'; - import {UserNotificationsRights} from './userNotificationsRights'; - -import {MailPrefsComponent} from '../../openaireLibrary/connect/userEmailPreferences/mailPrefs.component'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class'; import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; import {Title} from '@angular/platform-browser'; +import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; +import {properties} from '../../../environments/environment'; +import { Subscriber} from 'rxjs'; +import {MailPrefsService} from '../../openaireLibrary/connect/userEmailPreferences/mailPrefs.service'; +declare var UIkit; @Component({ selector: 'manage-user-notifications', templateUrl: './manage-user-notifications.component.html', @@ -27,86 +26,102 @@ export class ManageUserNotificationsComponent implements OnInit { myForm: FormGroup; public properties: EnvProperties = null; - public communityId = null; - public userNotifications = null; - public initialUserNotifications = null; + public communityId; + public userNotifications:UserNotificationsRights = null; + public initialUserNotifications:UserNotificationsRights = null; + public notifications = null; + public initialNotifications = []; public userEmail = null; public showLoading = true; - public errorMessage = ''; - public updateErrorMessage = ''; - - public successfulSaveMessage = ''; - public successfulResetMessage = ''; - public hasChanged = false; public user: User; + private subscriptions = []; - @ViewChild(MailPrefsComponent) mailPrefs: MailPrefsComponent; - + frequencyOptions = [{label:"Daily", value: 24}, {label:"Every two days", value: 48}, {label:"Weekly", value: 168}] constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, private title: Title, private _manageUserNotificationsService: ManageUserNotificationsService, - private element: ElementRef, private userManagementService: UserManagementService) { + private element: ElementRef, private userManagementService: UserManagementService, private communityService: CommunityService, private _mailPrefsService: MailPrefsService,) { } ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe( - communityId => { - HelperFunctions.scroll(); - this.communityId = communityId['communityId']; - if (this.communityId != null && this.communityId !== '') { - this.title.setTitle('Administration Dashboard | User Notifications'); - this.showLoading = true; - this.updateErrorMessage = ''; - this.errorMessage = ''; - this.successfulSaveMessage = ''; - this.userManagementService.getUserInfo().subscribe(user => { - this.user = user; - if (this.user) { - this.userEmail = this.user.email; - this._manageUserNotificationsService.getUserNotifications(this.properties, this.communityId, this.userEmail).subscribe( - userNotifications => { - this.initialUserNotifications = userNotifications; - if (this.initialUserNotifications['notifyForNewManagers'] == null || - this.initialUserNotifications['notifyForNewSubscribers'] == null) { - this.initialUserNotifications = this.initiateUserNotifications(); - } - this.userNotifications = JSON.parse(JSON.stringify(this.initialUserNotifications)); - - // TODO remove after final testing - this.showLoading = false; - }, - error => { - if (error.status === 404) { - this.initialUserNotifications = this.initiateUserNotifications(); - this.userNotifications = JSON.parse(JSON.stringify(this.initialUserNotifications)); - } else { - this.handleError('System error retrieving user notifications', error); - } - this.showLoading = false; - } - ); + this.properties = properties; + HelperFunctions.scroll(); + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { + if(community) { + this.communityId =community.communityId; + this.title.setTitle( this.communityId.toUpperCase() + ' | User Notifications'); + this.showLoading = true; + this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { + this.user = user; + if (this.user) { + this.userEmail = this.user.email; + this.subscriptions.push(this._manageUserNotificationsService.getUserNotifications(this.properties, this.communityId).subscribe( + userNotifications => { + this.initialUserNotifications = userNotifications; + if (this.initialUserNotifications['notifyForNewManagers'] == null || + this.initialUserNotifications['notifyForNewSubscribers'] == null) { + if(Session.isManager("community",this.communityId, this.user)) { + this.initialUserNotifications = new UserNotificationsRights(true, true, ""); + }else{ + this.initialUserNotifications = new UserNotificationsRights(false, false, ""); + } } - }); - } + + this.userNotifications = JSON.parse(JSON.stringify(this.initialUserNotifications)); + this.getClaimsNotifications(); + }, + error => { + if (error.status === 404) { + if(Session.isManager("community",this.communityId, this.user)) { + this.initialUserNotifications = new UserNotificationsRights(true, true, ""); + }else{ + this.initialUserNotifications = new UserNotificationsRights(false, false, ""); + } + this.userNotifications = JSON.parse(JSON.stringify(this.initialUserNotifications)); + } else { + this.handleError('System error retrieving user notifications', error); + } + this.getClaimsNotifications(); + } + )); } - ); + })); + } + })); + } + getClaimsNotifications(){ + this.subscriptions.push(this._mailPrefsService.getUserEmailPreferencesForCommunity(this.communityId, this.properties.claimsAPIURL).subscribe( + data => { + this.initialNotifications = data.data; + this.notifications = JSON.parse(JSON.stringify( this.initialNotifications )); + this.showLoading = false; + }, + err => { + if(err.status === 404) { + if(Session.isManager("community",this.communityId, this.user)) { + this.initialNotifications = [{notify: true, frequency:24, openaireId: this.communityId}]; + }else{ + this.initialNotifications = [{notify: false, frequency:24, openaireId: this.communityId}]; + } + this.notifications = JSON.parse(JSON.stringify( this.initialNotifications )); + }else{ + this.handleError("Error getting user email preferences for community with id: "+this.communityId, err); + } + this.showLoading = false; + } + )); + } + ngOnDestroy() { + this.subscriptions.forEach(value => { + if (value instanceof Subscriber) { + value.unsubscribe(); + } }); } - public initiateUserNotifications(): UserNotificationsRights { - const notificationRights: UserNotificationsRights = new UserNotificationsRights(); - - notificationRights['notifyForNewManagers'] = true; - notificationRights['notifyForNewSubscribers'] = true; - notificationRights['managerEmail'] = this.userEmail; - - return notificationRights; - } public updateUserNotifications() { if (!Session.isLoggedIn()) { @@ -114,18 +129,28 @@ export class ManageUserNotificationsComponent implements OnInit { {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); } else { if (this.communityId != null && this.communityId !== '') { - this.mailPrefs.saveNotification(0); + // this.mailPrefs.saveNotification(0); - this.successfulSaveMessage = ''; + // this.successfulSaveMessage = ''; this.showLoading = true; const userNotifications = this.parseUpdatedUserNotifications(); - this._manageUserNotificationsService.updateUserNotifications(this.properties, this.communityId, userNotifications).subscribe( + this.subscriptions.push(this._manageUserNotificationsService.updateUserNotifications(this.properties, this.communityId, userNotifications).subscribe( userNotifications => { this.initialUserNotifications = JSON.parse(JSON.stringify(this.userNotifications)); this.handleSuccessfulSave('Notification settings saved!'); }, error => this.handleUpdateError('System error updating user notifications', error) - ); + )); + this.subscriptions.push(this._mailPrefsService.saveUserEmailPreferences(this.notifications[0], this.properties.claimsAPIURL).subscribe( + data => { + this.initialNotifications[0] = JSON.parse(JSON.stringify( this.notifications[0] )); + this.handleSuccessfulSave('Claims notification settings saved!'); + }, + err => { + //console.log(err); + this.handleError("Error saving user email preferences: "+JSON.stringify(this.notifications[0]), err); + } + )); } this.resetChange(); } @@ -139,11 +164,12 @@ export class ManageUserNotificationsComponent implements OnInit { if (this.userNotifications.managerEmail) { userNotifications['managerEmail'] = this.userNotifications.managerEmail; - } else { - if (this.user) { - userNotifications['managerEmail'] = this.user.email; - } } + // else { + // if (this.user) { + // userNotifications['managerEmail'] = this.user.email; + // } + // } return userNotifications; } @@ -153,9 +179,11 @@ export class ManageUserNotificationsComponent implements OnInit { queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); } else { - this.mailPrefs.restoreNotification(0); + // this.mailPrefs.restoreNotification(0); + this.notifications[0] = JSON.parse(JSON.stringify( this.initialNotifications[0] )); + if (this.userNotifications && this.initialUserNotifications) { - this.successfulSaveMessage = ''; + // this.successfulSaveMessage = ''; this.showLoading = true; this.userNotifications = JSON.parse(JSON.stringify(this.initialUserNotifications)); this.showLoading = false; @@ -188,45 +216,50 @@ export class ManageUserNotificationsComponent implements OnInit { private change() { this.hasChanged = true; - this.successfulSaveMessage = ''; - this.successfulResetMessage = ''; + // this.successfulSaveMessage = ''; + // this.successfulResetMessage = ''; } private resetChange() { this.hasChanged = false; } - public mailPrefsChanged(): boolean { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} - }); - } else { - return this.mailPrefs.prefsChanged['0']; - } - } - handleUpdateError(message: string, error) { - this.updateErrorMessage = message; + // this.updateErrorMessage = message; console.log('Server responded: ' + error); this.showLoading = false; } handleError(message: string, error) { - this.errorMessage = message; + // this.errorMessage = message; console.log('Server responded: ' + error); - + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; } handleSuccessfulSave(message) { this.showLoading = false; - this.successfulSaveMessage = message; + // this.successfulSaveMessage = message; + UIkit.notification(message, { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); } - handleSuccessfulReset(message) { - this.showLoading = false; - this.successfulResetMessage = message; + changeNotify(notification: any, checked: boolean, index: number) { + notification.notify = checked; + this.change(); } + + changeFrequency() { + this.change(); + } + + } diff --git a/src/app/pages/usernotifications/manage-user-notifications.module.ts b/src/app/pages/usernotifications/manage-user-notifications.module.ts index 293b471..a0f9ece 100644 --- a/src/app/pages/usernotifications/manage-user-notifications.module.ts +++ b/src/app/pages/usernotifications/manage-user-notifications.module.ts @@ -7,18 +7,21 @@ import {ManageUserNotificationsComponent} from './manage-user-notifications.comp import {ManageUserNotificationsService} from './manage-user-notifications.service'; import {MailPrefsModule} from '../../openaireLibrary/connect/userEmailPreferences/mailsPrefs.module'; import {ManageUserNotificationsRoutingModule} from './manage-user-notifications-routing.module'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; +import {UsersTabsModule} from '../users/users-tabs.module'; +import {PageContentModule} from '../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; +import {MatSelectModule, MatSlideToggleModule} from '@angular/material'; +import {LoadingModule} from '../../openaireLibrary/utils/loading/loading.module'; +import {SharedModule} from '../../openaireLibrary/shared/shared.module'; @NgModule({ imports: [ - ManageUserNotificationsRoutingModule, RouterModule, CommonModule, FormsModule, MailPrefsModule + ManageUserNotificationsRoutingModule, RouterModule, CommonModule, FormsModule, MailPrefsModule, UsersTabsModule, PageContentModule, MatSlideToggleModule, LoadingModule, SharedModule, MatSelectModule ], declarations: [ ManageUserNotificationsComponent ], providers: [ - ManageUserNotificationsService, IsCommunity, ConnectAdminLoginGuard + ManageUserNotificationsService ], exports: [ ManageUserNotificationsComponent diff --git a/src/app/pages/usernotifications/manage-user-notifications.service.ts b/src/app/pages/usernotifications/manage-user-notifications.service.ts index c604c6d..127e863 100644 --- a/src/app/pages/usernotifications/manage-user-notifications.service.ts +++ b/src/app/pages/usernotifications/manage-user-notifications.service.ts @@ -12,10 +12,9 @@ export class ManageUserNotificationsService { constructor(private http: HttpClient) { } - getUserNotifications(properties: EnvProperties, pid: string, email: string) { + getUserNotifications(properties: EnvProperties, pid: string) { let url: string = properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+ pid + '/notifications'; - return this.http.get(url)//.map(res => res.json()) - .pipe(map(res => this.parseUserNotifications(res, email))); + return this.http.get(url, CustomOptions.registryOptions()); } updateUserNotifications(properties: EnvProperties, pid: string, userNotificationsRights: any) { @@ -23,7 +22,7 @@ export class ManageUserNotificationsService { //let options = new RequestOptions({headers: headers}); let body = JSON.stringify(userNotificationsRights); let url: string = properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/notifications'; - return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody()); + return this.http.post(url, body, CustomOptions.registryOptions()); //.do(request => console.log("Insert Response:"+request.status)); } diff --git a/src/app/pages/usernotifications/userNotificationsRights.ts b/src/app/pages/usernotifications/userNotificationsRights.ts index 15328b0..8f84a64 100644 --- a/src/app/pages/usernotifications/userNotificationsRights.ts +++ b/src/app/pages/usernotifications/userNotificationsRights.ts @@ -2,4 +2,9 @@ export class UserNotificationsRights { notifyForNewManagers: boolean; notifyForNewSubscribers: boolean; managerEmail: string; + constructor (notifyForNewManagers: boolean = true, notifyForNewSubscribers: boolean = true, managerEmail: string = null ){ + this.notifyForNewManagers = notifyForNewManagers; + this.notifyForNewSubscribers = notifyForNewSubscribers; + this.managerEmail = managerEmail; + } } diff --git a/src/app/pages/users/personal-info/personal-info.component.css b/src/app/pages/users/personal-info/personal-info.component.css new file mode 100644 index 0000000..d97c500 --- /dev/null +++ b/src/app/pages/users/personal-info/personal-info.component.css @@ -0,0 +1,30 @@ +form { + font-family: "Roboto", sans-serif; +} + +form .connected { + color: rgba(var(--text-color-rgb), 0.5); +} + +form .image { + position: relative; + width: 120px; + height: 120px; +} + +form .image icon { + position: absolute; + top: 100%; + left: 50%; + transform: translate(-50%, -50%); +} + +form .image img { + box-shadow: 0 3px 6px #00000029; + border-radius: 50%; + margin-bottom: 10px; + width: 120px; + height: 120px; + object-fit: cover; +} + diff --git a/src/app/pages/users/personal-info/personal-info.component.ts b/src/app/pages/users/personal-info/personal-info.component.ts new file mode 100644 index 0000000..ca32351 --- /dev/null +++ b/src/app/pages/users/personal-info/personal-info.component.ts @@ -0,0 +1,479 @@ +import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {Title} from '@angular/platform-browser'; +import {AlertModal} from "../../../openaireLibrary/utils/modal/alert"; +import {CuratorService} from "../../../openaireLibrary/connect/curators/curator.service"; +import {UtilitiesService} from "../../../openaireLibrary/services/utilities.service"; +import {UserManagementService} from "../../../openaireLibrary/services/user-management.service"; +import {FormArray, FormBuilder, FormGroup, Validators} from "@angular/forms"; +import {Subscriber} from "rxjs"; +import {EnvProperties} from "../../../openaireLibrary/utils/properties/env-properties"; +import {properties} from "../../../../environments/environment"; +import {User} from "../../../openaireLibrary/login/utils/helper.class"; +import {Affiliation, Curator} from "../../../openaireLibrary/utils/entities/CuratorInfo"; +import {HelpContentService} from "../../../services/help-content.service"; +import {Page} from "../../../domain/page"; +import {CommunityService} from "../../../openaireLibrary/connect/community/community.service"; +import {StringUtils} from "../../../openaireLibrary/utils/string-utils.class"; + +declare var UIkit; + +@Component({ + selector: 'personal-info', + template: ` +
+
+ +
+
+
+
+
+
+ Personal Info & Affiliations + (unsaved changes) +
+
+
+ + +
+
+
+
+
+
+
+
+
+ +
+
+
{{user.firstname + ' ' + user.lastname}}
+ +
+
+
+
+
+
My Affiliations
+ +
+
+
+
+
+ +
+
+
{{affiliation.value.name}}
+ URL: {{affiliation.value.website_url}} +
+
+ +
+
+
+
+
+ Your personal info will be visible in the Curators page of your Community Gateway. + Read privacy policy statement. +
+
+
+
+
+ +
+
+
+
+ +
+ Your personal data and photo are processed by OpenAIRE in conformity with personal data protection legal + framework. + They will be stored safely in our system for as long as OpenAIRE exists. Since you press the "save" button, + you give us the consent to make them public in your Community Gateway to let users know who is + configuring the platform. You always have the right to exercise your rights and ask for access, + rectification, erasure and restriction of your data. Please contact rcd-helpdesk@openaire.eu + if you have any inquiries. +
+
+ +
+
+
+
+
+
+
+
+ + + +
+ Your personal information has been successfully saved.

+ This information will be visible in Curators page of Research Community Dashboard, which is disabled. + Do you want to enable it now? +
+
+ `, + styleUrls: ['personal-info.component.css'] +}) +export class PersonalInfoComponent implements OnInit, OnDestroy { + /** Curator information */ + public loading = false; + public user: User; + public curator: Curator; + public curatorFb: FormGroup; + public properties: EnvProperties = properties; + public curatorsPage: Page; + public newCurator = false; + public communityId: string; + /** Photo */ + public photo: any = null; + private photoChanged: boolean = false; + public file: File = null; + private maxsize: number = 200 * 1024; + private deletePhoto = false; + private subs: any[] = []; + /** Affiliations */ + public affiliationFb: FormGroup; + public index: number = -1; + @ViewChild('fileInput') fileInput: ElementRef; + @ViewChild('privacyStatement') privacyStatement: AlertModal; + @ViewChild('affiliationModal') affiliationModal: AlertModal; + @ViewChild('removeAffiliationModal') removeAffiliationModal: AlertModal; + @ViewChild('enableCuratorsModal') enableCuratorsModal: AlertModal; + + constructor(private route: ActivatedRoute, + private title: Title, + private fb: FormBuilder, + private curatorService: CuratorService, + private utilitiesService: UtilitiesService, + private helpContentService: HelpContentService, + private communityService: CommunityService, + private userManagementService: UserManagementService) { + } + + + ngOnInit() { + this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => { + this.communityId = community.communityId; + this.subs.push(this.userManagementService.getUserInfo().subscribe(user => { + this.user = user; + if (this.user) { + this.title.setTitle(community.communityId.toUpperCase() + " | Personal Info"); + this.loading = true; + this.subs.push(this.curatorService.getCurator(properties).subscribe(curator => { + this.initCurator(curator); + this.reset(); + this.loading = false; + }, error => { + if (error.status === 404) { + this.initCurator(null); + this.reset(); + } else { + console.error(error); + } + this.loading = false; + })); + } + })); + })); + } + + ngOnDestroy() { + this.subs.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }) + } + + hide(element: any) { + UIkit.dropdown(element).hide(); + } + + initCurator(curator: Curator) { + if (curator) { + this.curator = curator; + this.curator.email = this.user.email; + } else { + this.newCurator = true; + this.curator = new Curator(); + this.curator._id = this.user.id; + this.curator.email = this.user.email; + this.curator.name = this.user.fullname; + this.curator.affiliations = []; + this.curator.bio = ''; + this.curator.photo = null; + } + this.curatorsPageStatus(); + } + + reset() { + this.photoChanged = false; + this.file = null; + if (this.fileInput) { + this.fileInput.nativeElement.value = null; + } + let affiliations: FormArray = this.fb.array([]); + this.curator.affiliations.forEach(affiliation => { + affiliations.push(this.fb.group({ + id: this.fb.control(affiliation.id), + name: this.fb.control(affiliation.name, Validators.required), + logo_url: this.fb.control(affiliation.logo_url, [Validators.required, StringUtils.urlValidator()]), + website_url: this.fb.control(affiliation.website_url, [Validators.required, StringUtils.urlValidator()]), + })); + }); + this.curatorFb = this.fb.group({ + _id: this.fb.control(this.curator._id), + name: this.fb.control(this.curator.name, Validators.required), + bio: this.fb.control(this.curator.bio), + email: this.fb.control(this.curator.email), + photo: this.fb.control(this.curator.photo), + affiliations: affiliations + }); + if (this.curator.photo) { + this.photo = this.properties.utilsService + '/download/' + this.curator.photo; + } else { + this.photo = 'assets/common-assets/curator-default.png'; + } + } + + get affiliations(): FormArray { + return this.curatorFb.get('affiliations') as FormArray; + } + + saveCurator() { + this.curatorService.updateCurator(this.properties, this.curatorFb.value).subscribe((curator) => { + if (curator) { + UIkit.notification('Your data has been saved successfully', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.newCurator = false; + this.deletePhoto = false; + this.initCurator(curator); + this.reset(); + if(!this.curatorsEnabled) { + this.curatorsEnabledOpen(); + } + this.loading = false; + } + }, + error => { + this.handleUpdateError('An error has occurred. Try again later!'); + this.reset(); + }); + } + + + updateCurator() { + if (this.curatorFb.valid) { + this.loading = true; + if (this.file) { + this.utilitiesService.uploadPhoto(this.properties.utilsService + '/upload/' + this.curator._id, this.file).subscribe((res) => { + if (this.curator.photo) { + this.utilitiesService.deletePhoto(this.properties.utilsService + '/delete/' + this.curator.photo).subscribe(); + } + this.curatorFb.get('photo').setValue(res.filename); + this.saveCurator(); + }, error => { + this.handleUpdateError('An error has occurred during photo uploading.'); + } + ); + } else { + if (this.deletePhoto && this.curator.photo) { + this.utilitiesService.deletePhoto(this.properties.utilsService + '/delete/' + this.curator.photo).subscribe(); + this.curatorFb.get('photo').setValue(null); + } + this.saveCurator(); + } + } + } + + private curatorsPageStatus() { + this.helpContentService.getCommunityPagesByRoute(this.communityId, '/curators', this.properties.adminToolsAPIURL).subscribe((page) => { + this.curatorsPage = page; + }); + } + + public get curatorsEnabled(): boolean { + return !this.curatorsPage || this.curatorsPage.isEnabled; + } + + fileChangeEvent(event) { + this.loading = true; + if (event.target.files && event.target.files[0]) { + this.file = event.target.files[0]; + if (this.file.type !== 'image/png' && this.file.type !== 'image/jpeg') { + this.handleUpdateError('You must choose a file with type: image/png or image/jpeg!'); + this.file = null; + } else if (this.file.size > this.maxsize) { + this.handleUpdateError('File exceeds size\'s limit! Maximum size 200KB.'); + this.file = null; + } else { + const reader = new FileReader(); + reader.readAsDataURL(this.file); + reader.onload = () => { + this.photo = reader.result; + this.photoChanged = true; + this.loading = false; + }; + } + } else { + this.loading = false; + } + } + + removePhoto() { + this.deletePhoto = true; + this.file = null; + this.fileInput.nativeElement.value = null; + this.photoChanged = !!this.curator.photo; + this.photo = 'assets/common-assets/curator-default.png'; + } + + handleUpdateError(message: string) { + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + this.loading = false; + } + + privacy() { + this.privacyStatement.cancelButton = false; + this.privacyStatement.okButtonText = 'Close'; + this.privacyStatement.alertTitle = 'Privacy policy statement'; + this.privacyStatement.open(); + } + + uploadPhoto(fileInput: HTMLInputElement) { + if (!this.curator.photo && !this.file) { + fileInput.click(); + } + } + + get hasChanged(): boolean { + return (this.curatorFb && this.curatorFb.dirty) || this.newCurator || this.photoChanged; + } + + editAffiliationOpen(index = -1) { + this.index = index; + let affiliation: Affiliation = new Affiliation(); + if(index === -1) { + this.affiliationModal.alertTitle = 'Add Affiliation'; + this.affiliationModal.okButtonText = 'Add'; + } else { + this.affiliationModal.alertTitle = 'Edit Affiliation'; + this.affiliationModal.okButtonText = 'Update'; + affiliation = this.affiliations.at(index).value; + } + this.affiliationFb = this.fb.group({ + id: this.fb.control(affiliation.id), + name: this.fb.control(affiliation.name, Validators.required), + logo_url: this.fb.control(affiliation.logo_url, [Validators.required, StringUtils.urlValidator()]), + website_url: this.fb.control(affiliation.website_url, [Validators.required, StringUtils.urlValidator()]) + }); + this.affiliationModal.okButtonLeft = false; + this.affiliationModal.cancelButtonText = 'Cancel'; + this.affiliationModal.open(); + } + + deleteAffiliationOpen(index: number) { + this.index = index; + let affiliation: Affiliation = this.affiliations.at(index).value; + this.removeAffiliationModal.alertTitle = 'Delete Affiliation'; + this.removeAffiliationModal.message = 'Do you want to remove ' + + affiliation.name + ' from your Affiliations?'; + this.removeAffiliationModal.okButtonText = 'Yes'; + this.removeAffiliationModal.cancelButtonText = 'No'; + this.removeAffiliationModal.open(); + } + + editAffiliation() { + if(this.index === -1) { + this.affiliations.push(this.affiliationFb); + } else { + this.affiliations.at(this.index).setValue(this.affiliationFb.value); + } + this.curatorFb.markAsDirty(); + } + + removeAffiliation() { + this.affiliations.removeAt(this.index); + this.curatorFb.markAsDirty(); + } + + private curatorsEnabledOpen() { + this.enableCuratorsModal.okButtonLeft = false; + this.enableCuratorsModal.alertTitle = 'Enable Curators Page'; + this.enableCuratorsModal.okButtonText = 'Yes'; + this.enableCuratorsModal.cancelButtonText = 'No'; + this.enableCuratorsModal.open(); + } + + enableCurators() { + this.helpContentService.togglePages(this.communityId, [this.curatorsPage._id], true, this.properties.adminToolsAPIURL).subscribe(() => { + this.curatorsPage.isEnabled = true; + UIkit.notification('Curators Page has been enabled successfully', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + },error => { + this.handleUpdateError('An error has occurred. Try again later!'); + }); + } +} diff --git a/src/app/pages/users/personal-info/personal-info.module.ts b/src/app/pages/users/personal-info/personal-info.module.ts new file mode 100644 index 0000000..5910ab5 --- /dev/null +++ b/src/app/pages/users/personal-info/personal-info.module.ts @@ -0,0 +1,41 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {RouterModule} from '@angular/router'; +import {PersonalInfoComponent} from './personal-info.component'; +import {AlertModalModule} from "../../../openaireLibrary/utils/modal/alertModal.module"; +import {CuratorService} from "../../../openaireLibrary/connect/curators/curator.service"; +import {UtilitiesService} from "../../../openaireLibrary/services/utilities.service"; +import {PageContentModule} from "../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; +import {UsersTabsModule} from "../users-tabs.module"; +import {LoadingModule} from "../../../openaireLibrary/utils/loading/loading.module"; +import {InputModule} from "../../../openaireLibrary/sharedComponents/input/input.module"; +import {IconsModule} from "../../../openaireLibrary/utils/icons/icons.module"; +import {IconsService} from "../../../openaireLibrary/utils/icons/icons.service"; +import {add, edit, photo, remove} from "../../../openaireLibrary/utils/icons/icons"; +import {UrlPrefixModule} from "../../../openaireLibrary/utils/pipes/url-prefix.module"; +import {HelpContentService} from "../../../services/help-content.service"; + +@NgModule({ + imports: [ + CommonModule, FormsModule, RouterModule.forChild([ + {path: '', component: PersonalInfoComponent} + ]), + AlertModalModule, PageContentModule, UsersTabsModule, LoadingModule, ReactiveFormsModule, InputModule, IconsModule, UrlPrefixModule + ], + declarations: [ + PersonalInfoComponent + ], + providers: [ + CuratorService, UtilitiesService, HelpContentService + ], + exports: [ + PersonalInfoComponent + ] +}) + +export class PersonalInfoModule { + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([photo, edit, remove, add]) + } +} diff --git a/src/app/pages/users/users-managers/users-managers.component.ts b/src/app/pages/users/users-managers/users-managers.component.ts new file mode 100644 index 0000000..f7af221 --- /dev/null +++ b/src/app/pages/users/users-managers/users-managers.component.ts @@ -0,0 +1,67 @@ +import {Component, OnInit} from "@angular/core"; +import {Title} from "@angular/platform-browser"; +import {ActivatedRoute} from "@angular/router"; +import {CommunityService} from "../../../openaireLibrary/connect/community/community.service"; +import {Subscriber} from "rxjs"; +import {Email} from "../../../openaireLibrary/utils/email/email"; +import {Composer} from "../../../openaireLibrary/utils/email/composer"; +import {properties} from "../../../../environments/environment"; + +@Component({ + selector: 'users-managers', + template: ` + + + + ` +}) +export class UsersManagersComponent implements OnInit { + public communityId: string; + public name: string; + public type: string; + public link: string; + public loading: boolean; + public message: string; + public inviteDisableMessage: string; + public emailComposer: Function = (name, recipient, role):Email => { + return Composer.composeEmailForCommunityDashboard(name, recipient); + } + private subscriptions: any[] = []; + + constructor(private communityService: CommunityService, + private route: ActivatedRoute, + private title: Title) { + } + + ngOnInit() { + this.loading = true; + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { + if(community) { + this.communityId = community.communityId; + this.name = community.shortTitle; + this.title.setTitle(this.communityId.toUpperCase() + " | Managers"); + this.type = 'community'; + this.link = this.getURL(this.communityId); + this.message = 'A manager has the right to access the administration part of Research Community Dashboard, ' + + 'where he is able to customize and manage the content, invite other users as managers or to subscribe.'; + if(community.status === "hidden") { + this.inviteDisableMessage = "
Community's status is Hidden and invitation to manage the Research community dashboard is disabled. Update the community status to enable invitations.
" + } + this.loading = false; + } + })); + } + + ngOnDestroy() { + this.subscriptions.forEach(value => { + if (value instanceof Subscriber) { + value.unsubscribe(); + } + }); + } + + private getURL(id: string): string { + return 'https://' + (properties.environment !== "production"?'beta.':'') + id + ".openaire.eu?verify="; + } +} diff --git a/src/app/pages/users/users-managers/users-managers.module.ts b/src/app/pages/users/users-managers/users-managers.module.ts new file mode 100644 index 0000000..4f6b423 --- /dev/null +++ b/src/app/pages/users/users-managers/users-managers.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from "@angular/core"; +import {UsersManagersComponent} from "./users-managers.component"; +import {CommonModule} from "@angular/common"; +import {LoadingModule} from "../../../openaireLibrary/utils/loading/loading.module"; +import {RouterModule} from "@angular/router"; +import {RoleUsersModule} from "../../../openaireLibrary/dashboard/users/role-users/role-users.module"; +import {UsersTabsModule} from '../users-tabs.module'; + +@NgModule({ + imports: [CommonModule, LoadingModule, RoleUsersModule, RouterModule.forChild([ + {path: '', component: UsersManagersComponent} + ]), UsersTabsModule], + declarations: [UsersManagersComponent], + exports: [UsersManagersComponent] +}) +export class UsersManagersModule {} diff --git a/src/app/pages/users/users-routing.module.ts b/src/app/pages/users/users-routing.module.ts new file mode 100644 index 0000000..5039e4f --- /dev/null +++ b/src/app/pages/users/users-routing.module.ts @@ -0,0 +1,20 @@ +import {NgModule} from '@angular/core'; +import {RouterModule} from '@angular/router'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + {path: '', redirectTo: 'managers', pathMatch: 'full'}, + {path: 'managers', loadChildren: './users-managers/users-managers.module#UsersManagersModule'}, + {path: 'subscribers', loadChildren: './users-subscribers/users-subscribers.module#UsersSubscribersModule'}, + { + path: 'notifications', + loadChildren: '../usernotifications/manage-user-notifications.module#ManageUserNotificationsModule' + }, + {path: 'claims', loadChildren: '../claims/claims.module#ClaimsModule'}, + {path: 'personal', loadChildren: './personal-info/personal-info.module#PersonalInfoModule'} + ]) + ] +}) +export class UsersRoutingModule { +} diff --git a/src/app/pages/users/users-subscribers/users-subscribers.component.ts b/src/app/pages/users/users-subscribers/users-subscribers.component.ts new file mode 100644 index 0000000..9a96fc0 --- /dev/null +++ b/src/app/pages/users/users-subscribers/users-subscribers.component.ts @@ -0,0 +1,51 @@ +import {Component, OnInit} from "@angular/core"; +import {Title} from "@angular/platform-browser"; +import {ActivatedRoute} from "@angular/router"; +import {CommunityService} from "../../../openaireLibrary/connect/community/community.service"; +import {Subscriber} from "rxjs"; + +@Component({ + selector: 'users-subscribers', + template: ` + + + + ` +}) +export class UsersSubscribersComponent implements OnInit { + public communityId: string; + public name: string; + public type: string; + public loading: boolean; + public inviteDisableMessage: string; + private subscriptions: any[] = []; + + constructor(private communityService: CommunityService, + private route: ActivatedRoute, + private title: Title) { + } + + ngOnInit() { + this.loading = true; + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { + if(community) { + this.communityId = community.communityId; + this.name = community.shortTitle; + this.title.setTitle(this.communityId.toUpperCase() + " | Subscribers"); + this.type = 'community'; + if(community.status !== "all") { + this.inviteDisableMessage = "
Community's status is " + (community.status === 'manager'?'Visible to managers':'Hidden') + " and invitation to subscribe to the Research community dashboard is disabled. Update the community status to enable invitations.
" + } + this.loading = false; + } + })); + } + + ngOnDestroy() { + this.subscriptions.forEach(value => { + if (value instanceof Subscriber) { + value.unsubscribe(); + } + }); + } +} diff --git a/src/app/pages/users/users-subscribers/users-subscribers.module.ts b/src/app/pages/users/users-subscribers/users-subscribers.module.ts new file mode 100644 index 0000000..7865cfe --- /dev/null +++ b/src/app/pages/users/users-subscribers/users-subscribers.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from "@angular/core"; +import {UsersSubscribersComponent} from "./users-subscribers.component"; +import {CommonModule} from "@angular/common"; +import {LoadingModule} from "../../../openaireLibrary/utils/loading/loading.module"; +import {RouterModule} from "@angular/router"; +import {SubscribersModule} from "../../../openaireLibrary/dashboard/users/subscribers/subscribers.module"; +import {UsersTabsModule} from '../users-tabs.module'; + +@NgModule({ + imports: [CommonModule, LoadingModule, RouterModule.forChild([ + {path: '', component: UsersSubscribersComponent} + ]), SubscribersModule, UsersTabsModule], + declarations: [UsersSubscribersComponent], + exports: [UsersSubscribersComponent] +}) +export class UsersSubscribersModule {} diff --git a/src/app/pages/users/users-tabs.component.ts b/src/app/pages/users/users-tabs.component.ts new file mode 100644 index 0000000..a2ddf80 --- /dev/null +++ b/src/app/pages/users/users-tabs.component.ts @@ -0,0 +1,51 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {Session} from '../../openaireLibrary/login/utils/helper.class'; +import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; +import {Subscriber} from 'rxjs'; +import {ActivatedRoute} from '@angular/router'; + +@Component({ + selector: 'users-tabs', + template: ` + + ` +}) +export class UsersTabsComponent implements OnInit { + @Input() + public type: string; + @Input() + public tab: "managers"| "members" | "notifications" | "claims" | "personal" = 'managers'; + private subscriptions = []; + isAManager: boolean = false; + canManageNotifications: boolean = false; + constructor(private userManagementService: UserManagementService, private route: ActivatedRoute) { + } + + ngOnInit() { + this.route.params.subscribe(params => { + if (params && params['community']) { + let communityPid = params['community']; + this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { + this.isAManager = Session.isManager("community", communityPid, user); + this.canManageNotifications = Session.isManager("community", communityPid, user)// || Session.isCommunityCurator(user); + })); + } + }); + } + + ngOnDestroy() { + this.subscriptions.forEach(value => { + if (value instanceof Subscriber) { + value.unsubscribe(); + } + }); + } +} diff --git a/src/app/pages/users/users-tabs.module.ts b/src/app/pages/users/users-tabs.module.ts new file mode 100644 index 0000000..cc556be --- /dev/null +++ b/src/app/pages/users/users-tabs.module.ts @@ -0,0 +1,14 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {UsersTabsComponent} from "./users-tabs.component"; +import {RouterModule} from "@angular/router"; + +@NgModule({ + declarations: [UsersTabsComponent], + imports: [ + CommonModule, RouterModule + ], + exports:[UsersTabsComponent] +}) +export class UsersTabsModule { +} diff --git a/src/app/pages/wellcome/wellcome-routing.module.ts b/src/app/pages/wellcome/wellcome-routing.module.ts deleted file mode 100644 index a5ddec9..0000000 --- a/src/app/pages/wellcome/wellcome-routing.module.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { NgModule } from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {WellcomeComponent} from './wellcome.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', component: WellcomeComponent} - ]) - ] -}) -export class WellcomeRoutingModule { } diff --git a/src/app/pages/wellcome/wellcome.component.ts b/src/app/pages/wellcome/wellcome.component.ts deleted file mode 100644 index f508cae..0000000 --- a/src/app/pages/wellcome/wellcome.component.ts +++ /dev/null @@ -1,137 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {Session, User} from '../../openaireLibrary/login/utils/helper.class'; -import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; -import {ActivatedRoute} from '@angular/router'; -import {EnvironmentSpecificService} from '../../openaireLibrary/utils/properties/environment-specific.service'; -import {CommunitiesService} from '../../openaireLibrary/connect/communities/communities.service'; -import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; -import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class'; -import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; -import {Title} from '@angular/platform-browser'; - -@Component({ - selector: 'wellcome', - template: ` -
-
- -
-
-
Build an Open Research Gateway for your Community
-

Turn Open Science into practice

-
Share and link your research results.
- Across organizations, across borders.
Customized to your needs. -
-
- -
- -
-
- ` -}) - -export class WellcomeComponent implements OnInit { - properties: EnvProperties = null; - public communities: CommunityInfo[] = []; - showLoading: boolean; - private user: User; - - constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService, private _communitiesService: CommunitiesService, - private title: Title, - private userManagementService: UserManagementService) { - } - - ngOnInit() { - this.showLoading = true; - this.title.setTitle('Administration Dashboard | OpenAIRE-Connect'); - this.propertiesService.loadEnvironment().then(es => { - this.propertiesService.setEnvProperties(es); - this.properties = this.propertiesService.envSpecific; - HelperFunctions.scroll(); - this.userManagementService.getUserInfo().subscribe(user => { - this.user = user; - this._communitiesService.getCommunitiesState().subscribe( - communities => { - this.communities = []; - if (!communities || communities.length === 0) { - return; - } - var countCommunities = 0; - var index_managerOfCommunity = null; - for (var i = 0; i < communities.length; i++) { - var com = communities[i]; - if (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user)) { - this.communities.push(communities[i]); - } else { - for (var manager of com.managers) { - if (this.user && manager == this.user.email) { - countCommunities++; - index_managerOfCommunity = i; - this.communities.push(communities[i]); - break; - } - } - } - } - this.showLoading = false; - }); - }); - }); - } -} diff --git a/src/app/pages/wellcome/wellcome.module.ts b/src/app/pages/wellcome/wellcome.module.ts deleted file mode 100644 index a545955..0000000 --- a/src/app/pages/wellcome/wellcome.module.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { NgModule } from '@angular/core'; -import {WellcomeComponent} from './wellcome.component'; -import {WellcomeRoutingModule} from './wellcome-routing.module'; -import {RouterModule} from '@angular/router'; -import {CommunitiesService} from '../../openaireLibrary/connect/communities/communities.service'; -//import { EnvironmentSpecificResolver} from '../../openaireLibrary/utils/properties/environmentSpecificResolver'; -import { EnvironmentSpecificService} from '../../openaireLibrary/utils/properties/environment-specific.service'; -import { CommonModule } from '@angular/common'; - -@NgModule({ - imports: [ - CommonModule, WellcomeRoutingModule, RouterModule - ], - declarations: [WellcomeComponent], - providers: [EnvironmentSpecificService], - exports: [WellcomeComponent] -}) -export class WellcomeModule { } diff --git a/src/app/pages/zenodo-communities/add-zenodo-communities.component.html b/src/app/pages/zenodo-communities/add-zenodo-communities.component.html index 1543579..e723504 100644 --- a/src/app/pages/zenodo-communities/add-zenodo-communities.component.html +++ b/src/app/pages/zenodo-communities/add-zenodo-communities.component.html @@ -1,85 +1,64 @@ -
-
-
- - -
-
-
- - Newly added Zenodo communities will be linked to your community on the next run of our algorithms. -
- - -
-
- - {{zenodoCommunitySearchUtils.totalResults | number}} zenodo communities, page {{zenodoCommunitySearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
- - - - -
-
- - {{zenodoCommunitySearchUtils.totalResults | number}} zenodo communities, page {{zenodoCommunitySearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
+
+
+
+ +
+
+
No zenodo communities found +
+
+
+ + +
    +
  • +
    +
    + +
    + +
    +
    +
    +
    + Master zenodo community +
    + +
    + +
    + Add community +
    +
    +
    +
    + + + + Remove community +
    +
    +
    +
    +
    + +
    +
  • +
+ + +
diff --git a/src/app/pages/zenodo-communities/add-zenodo-communities.component.ts b/src/app/pages/zenodo-communities/add-zenodo-communities.component.ts index 78c0042..0f00c58 100644 --- a/src/app/pages/zenodo-communities/add-zenodo-communities.component.ts +++ b/src/app/pages/zenodo-communities/add-zenodo-communities.component.ts @@ -1,192 +1,256 @@ -import {Component, OnInit, Input} from '@angular/core'; -import {SimpleChanges, OnChanges} from '@angular/core'; -import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms'; -import {ActivatedRoute, Router} from '@angular/router'; - -import {HelpContentService} from '../../services/help-content.service'; -import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; - -import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; -import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; +import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {FormBuilder, FormControl} from '@angular/forms'; +import {ActivatedRoute, Router} from '@angular/router'; +import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; +import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; -import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo'; - import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import{ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; +import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; +import {SearchInputComponent} from '../../openaireLibrary/sharedComponents/search-input/search-input.component'; +import {Subject, Subscription} from 'rxjs'; +import {debounceTime, distinctUntilChanged} from 'rxjs/operators'; + +declare var UIkit; + @Component({ - selector: 'add-zenodo-communities', - templateUrl: './add-zenodo-communities.component.html', + selector: 'add-zenodo-communities', + templateUrl: './add-zenodo-communities.component.html', }) - export class AddZenodoCommunitiesComponent implements OnInit { - - public zenodoCommunities = null; // zenodo search API results - public totalZenodoCommunities = null; - @Input() properties:EnvProperties = null; - @Input() communityId = null; - - public zenodoCommunitySearchUtils:SearchUtilsClass = new SearchUtilsClass(); - - errorCodes: ErrorCodes; - public rowsOnPage = 10; - @Input() masterCommunity = null; - @Input() selectedCommunities = []; - newlySelectedCommunities = []; - constructor (private route: ActivatedRoute, - private _router: Router, - public _fb: FormBuilder, - private _helpContentService: HelpContentService, - private _zenodoCommunitieService: ZenodoCommunitiesService, - private _manageZenodoCommunitiesService: ManageZenodoCommunitiesService) { - - this.errorCodes = new ErrorCodes(); - this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; - } - - ngOnInit() { - this.zenodoCommunitySearchUtils.keyword = ""; - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; - this.newlySelectedCommunities = []; - if (this.communityId != null && this.communityId != '') { - this._zenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities+"?page="+this.zenodoCommunitySearchUtils.page+"&size="+this.rowsOnPage).subscribe( - result => { - this.zenodoCommunities = result[0]; - this.totalZenodoCommunities = result[1]; - this.zenodoCommunitySearchUtils.totalResults = result[1]; - this.zenodoCommunitySearchUtils.page = 1; - this.zenodoCommunitySearchUtils.size =this.rowsOnPage; - if(this.totalZenodoCommunities == 0){ - this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE; - }else{ - this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE; - } - - }, - error => { - this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR; - } - ); + + public zenodoCommunities = null; // zenodo search API results + public totalZenodoCommunities = null; + @Input() properties: EnvProperties = null; + @Input() communityId = null; + @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; + public filterForm: FormControl; + private subscriptions: any[] = []; + public subResults: any; + public zenodoCommunitySearchUtils: SearchUtilsClass = new SearchUtilsClass(); + public searchTermStream = new Subject(); + errorCodes: ErrorCodes; + public rowsOnPage = 10; + @Input() masterCommunity = null; + @Input() selectedCommunities = []; + + constructor(private route: ActivatedRoute, + private _router: Router, + public _fb: FormBuilder, + private _zenodoCommunitieService: ZenodoCommunitiesService, + private _manageZenodoCommunitiesService: ManageZenodoCommunitiesService) { + + this.errorCodes = new ErrorCodes(); + this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; + } + + ngOnInit() { + this.filterForm = this._fb.control(''); + this.subscriptions.push(this.filterForm.valueChanges.subscribe(value => { + this.searchTermStream.next(value); + })); + this.subscriptions.push(this.searchTermStream + .pipe(debounceTime(1000), distinctUntilChanged()) + .subscribe((term: string) => { + this.zenodoCommunitySearchUtils.keyword = term; + this.goTo(1); + })); + + this.zenodoCommunitySearchUtils.keyword = ""; + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url } - } - - } - - public goTo(page:number = 1) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.zenodoCommunitySearchUtils.page=page; - this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; - this._zenodoCommunitieService.getZenodoCommunities(this.properties, - this.properties.zenodoCommunities+"?page="+this.zenodoCommunitySearchUtils.page - +"&size="+this.rowsOnPage - +((this.zenodoCommunitySearchUtils.keyword)?("&q="+this.zenodoCommunitySearchUtils.keyword):"") - ).subscribe( - result => { - this.zenodoCommunities = result[0]; - this.totalZenodoCommunities = result[1]; - this.zenodoCommunitySearchUtils.totalResults = result[1]; - this.zenodoCommunitySearchUtils.size =this.rowsOnPage; - if(this.totalZenodoCommunities == 0){ - this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE; - }else{ - this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE; - } - - }, - error => { - this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR; - } - ); - } - } - - totalPages(): number { - let totalPages:any = this.zenodoCommunitySearchUtils.totalResults/(this.rowsOnPage); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - return totalPages; - } - - - public addCommunity(community) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this._manageZenodoCommunitiesService.addZCommunity(this.properties, this.communityId, community.id ).subscribe( - data => { - // this.undo[project.id] = data.id; - community["openaireId"]=data.id; - this.selectedCommunities.push(community); - this.newlySelectedCommunities.push(community) + }); + } else { + this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; + if (this.communityId != null && this.communityId != '') { + this._zenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page + "&size=" + this.rowsOnPage).subscribe( + result => { + this.zenodoCommunities = result[0]; + this.totalZenodoCommunities = result[1]; + this.zenodoCommunitySearchUtils.totalResults = result[1]; + this.zenodoCommunitySearchUtils.page = 1; + this.zenodoCommunitySearchUtils.size = this.rowsOnPage; + if (this.totalZenodoCommunities == 0) { + this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE; + } else { + this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE; + } + }, - err => { - console.log(err.status); - }/*, + error => { + this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR; + } + ); + } + } + + } + + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }); + if(this.subResults){ + this.subResults.unsubscribe(); + } + } + + public goTo(page: number = 1) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.zenodoCommunitySearchUtils.page = page; + this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; + if(this.subResults){ + this.subResults.unsubscribe(); + } + this.subResults = this._zenodoCommunitieService.getZenodoCommunities(this.properties, + this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page + + "&size=" + this.rowsOnPage + + ((this.zenodoCommunitySearchUtils.keyword) ? ("&q=" + this.zenodoCommunitySearchUtils.keyword) : "") + ).subscribe( + result => { + this.zenodoCommunities = result[0]; + this.totalZenodoCommunities = result[1]; + this.zenodoCommunitySearchUtils.totalResults = result[1]; + this.zenodoCommunitySearchUtils.size = this.rowsOnPage; + if (this.totalZenodoCommunities == 0) { + this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE; + } else { + this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE; + } + + }, + error => { + this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR; + } + ); + } + } + + totalPages(): number { + let totalPages: any = this.zenodoCommunitySearchUtils.totalResults / (this.rowsOnPage); + if (!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + return totalPages; + } + + + public addCommunity(community) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.subscriptions.push(this._manageZenodoCommunitiesService.addZCommunity(this.properties, this.communityId, community.id).subscribe( + data => { + community["openaireId"] = data.id; + this.selectedCommunities.push(community); + UIkit.notification('Community successfully added!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.log(err.status); + }/*, () => { console.info("completed ADD"); }*/ - ) - } + )); } - - public removeCommunity( comm) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - var openaireId = this.getOpenaireId(comm); - this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.communityId,openaireId, ).subscribe( - data => { - var pos = -1; - for(var i=0; i< this.selectedCommunities.length;i++) { - if( this.selectedCommunities[i].id == comm.id) { - pos= i; - break; - } + } + + public removeCommunity(comm) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + var openaireId = this.getOpenaireId(comm); + this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.communityId, openaireId,).subscribe( + data => { + var pos = -1; + for (var i = 0; i < this.selectedCommunities.length; i++) { + if (this.selectedCommunities[i].id == comm.id) { + pos = i; + break; } - if(pos != -1){ - this.selectedCommunities.splice(pos, 1); - } - for(var i=0; i< this.newlySelectedCommunities.length;i++) { - if( this.newlySelectedCommunities[i].id == comm.id) { - pos= i; - break; - } - } - if(pos != -1){ - this.newlySelectedCommunities.splice(pos, 1); - } - - }, - err => { - console.log(err.status); - }/*, + } + if (pos != -1) { + this.selectedCommunities.splice(pos, 1); + } + + UIkit.notification('Community successfully removed!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.log(err.status); + }/*, () => { console.info("completed remove"); }*/ - ) + )); + } + } + + public inThelist(community: any, list): any { + for (let com of list) { + if (com.id == community.id) { + return true; } } - - public inThelist(community: any, list): any { - for(let com of list) { - if(com.id == community.id) { - return true; - } + return false; + } + + public getOpenaireId(community: any): string { + for (let com of this.selectedCommunities) { + if (com.id == community.id) { + return com.openaireId; } - return false; } - public getOpenaireId(community: any): string { - for(let com of this.selectedCommunities) { - if(com.id == community.id) { - return com.openaireId; - } - } - return null; - } + return null; + } + + public onSearchClose() { + this.zenodoCommunitySearchUtils.keyword = this.filterForm.value; + } + + public resetInput() { + this.zenodoCommunitySearchUtils.keyword = null; + this.searchInputComponent.reset() + } + + handleError(message: string) { + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + } } diff --git a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html index 0f615f8..934a3ca 100644 --- a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html +++ b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html @@ -1,101 +1,72 @@ -
-
-
Master Zenodo community
-
- -
- - - -
-
-

- - {{masterCommunity.title}} - [no name available] - - -
- {{masterCommunity.title}} - [no name available] -
-

-
- last update: {{masterCommunity.date | date:'yyyy/MM/dd'}} -
- -
-
-
-

{{masterCommunity.description}}

+
+ -
-
- - -
-
-
- - All the research results belonging to the Zenodo communities specified here will be automatically linked to your community dashboard. +
+
+
- -
-
- - {{searchUtils.totalResults | number}} zenodo communities, page {{searchUtils.page | number}} of {{(totalPages()) | number}} - - - - +
+
+
Main Zenodo community
+
-
+
+
No zenodo communities found +
+
+
+ + +
- +
diff --git a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts index fdd4d9a..a88ad09 100644 --- a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts +++ b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts @@ -1,239 +1,189 @@ -import {Component, OnInit, Input, ViewChild, ViewEncapsulation} from '@angular/core'; -import {SimpleChanges, OnChanges} from '@angular/core'; -import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms'; -import {ActivatedRoute, Router} from '@angular/router'; -import { Subject } from 'rxjs'; - -import { DataTableDirective } from 'angular-datatables'; - -import {HelpContentService} from '../../services/help-content.service'; -import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; - -import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; -import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; -import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; -import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo'; - +import { + Component, + EventEmitter, + Input, + OnChanges, + OnDestroy, + OnInit, + Output, SimpleChanges, + ViewChild, + ViewEncapsulation +} from '@angular/core'; +import {FormBuilder, FormControl} from '@angular/forms'; +import {ActivatedRoute, Router} from '@angular/router'; +import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; +import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; -import{ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; +import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; +import {SearchInputComponent} from '../../openaireLibrary/sharedComponents/search-input/search-input.component'; +import {Subscription} from 'rxjs'; + +declare var UIkit; @Component({ - selector: 'manage-zenodo-communities', - templateUrl: './manage-zenodo-communities.component.html', - styles: [` - #dpTable_info, #dpTable_paginate, #dpTable_length, #dpTable_filter{ - display: none; - } - - `], - encapsulation: ViewEncapsulation.None // this used in order styles to work + selector: 'manage-zenodo-communities', + templateUrl: './manage-zenodo-communities.component.html', + encapsulation: ViewEncapsulation.None // this used in order styles to work }) -export class ManageZenodoCommunitiesComponent implements OnInit { - @Input() properties:EnvProperties = null; - @Input() communityId = null; - - @Input() searchUtils:SearchUtilsClass = null; - - errorCodes: ErrorCodes; - public rowsOnPage = 10; - @Input() masterCommunity = null; - @Input() selectedCommunities = []; - - @ViewChild(DataTableDirective) datatableElement: DataTableDirective; - dtTrigger: Subject = new Subject(); //necessary - dtOptions: DataTables.Settings = {}; - private triggered: boolean = false; - - @ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity; - selectedToDelete = null; - constructor (private route: ActivatedRoute, - private _router: Router, - public _fb: FormBuilder, - private _helpContentService: HelpContentService, - private _ΖenodoCommunitieService: ZenodoCommunitiesService, - private _manageZenodoCommunitiesService: ManageZenodoCommunitiesService) { - - this.errorCodes = new ErrorCodes(); - +export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy { + @Input() properties: EnvProperties = null; + @Input() communityId = null; + + @Input() searchUtils: SearchUtilsClass = null; + + errorCodes: ErrorCodes; + public rowsOnPage = 10; + @Input() masterCommunity = null; + @Input() selectedCommunities = []; + previewCommunities = []; + + @ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity; + selectedToDelete = null; + @Output() toggleView: EventEmitter = new EventEmitter(); + page = 1; + size = 10; + @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; + public filterForm: FormControl; + private subscriptions: any[] = []; + + constructor(private route: ActivatedRoute, + private _router: Router, + public _fb: FormBuilder, + private _manageZenodoCommunitiesService: ManageZenodoCommunitiesService) { + + this.errorCodes = new ErrorCodes(); + + } + + ngOnInit() { + this.init(); + } + + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }); + } + + private init() { + this.filterForm = this._fb.control(''); + this.filterPreviewCommunities(""); + this.subscriptions.push(this.filterForm.valueChanges.subscribe(value => { + this.page = 1; + this.filterPreviewCommunities(value); + })); + this.searchUtils.keyword = ""; + this.searchUtils.totalResults = this.selectedCommunities.length; + } + + public filterPreviewCommunities(value: string) { + this.previewCommunities = this.selectedCommunities.filter(community => { + return community.title.toLowerCase().indexOf(value.toLowerCase()) != -1 + }); + if (this.previewCommunities.slice((this.page - 1) * this.rowsOnPage, this.page * this.rowsOnPage).length == 0) { + this.page = 1; } - - ngOnInit() { - - - this.searchUtils.keyword = ""; - this.dtOptions = { - // "paging": true, - // "searching": true, - // "lengthChange": false, - "pageLength": this.rowsOnPage, - "language": { - "search": "", - "searchPlaceholder": "Search projects..." - } - - }; - if(!this.triggered) { - this.triggerInitialLoad(); - } else { - var table = $('#dpTable').DataTable(); - table.clear(); - - this.rerender(); + } + + public confirmedDeleteCommunity(data: any) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url } - - this.searchUtils.totalResults = this.selectedCommunities.length; - } - - public ngOnDestroy() { - - $.fn['dataTable'].ext.search.pop(); - } - rerender(): void { - if(this.datatableElement.dtInstance){ - this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => { - // Destroy the table first - dtInstance.destroy(); - - // Call the dtTrigger to rerender again - this.dtTrigger.next(); - }); - } - } - - ngAfterViewInit(): void { - $.fn['dataTable'].ext.search.push((settings, data, dataIndex) => { - - if (this.filterData(data, this.searchUtils.keyword )) { - return true; + }); + } else { + this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.communityId, this.selectedToDelete.openaireId).subscribe( + data => { + var pos = -1; + for (var i = 0; i < this.selectedCommunities.length; i++) { + if (this.selectedCommunities[i].id == this.selectedToDelete.id) { + pos = i; + break; + } } - return false; - }); - - //console.info("ngAfterViewInit"); - this.searchUtils.totalResults = this.selectedCommunities.length; - - } - - filterData(row: any, query: string) { - let returnValue: boolean = false; - - if(query) { - for(var i=0; i <3; i++){ - var r= this.filterQuery(row[i], query); - if(r) { - returnValue = true; - break; - } - } - - if(!returnValue) { - return false; - } - } - - return true; - } - - filterQuery(data, query){ - if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){ - return true; - }else{ - return false; - } - } - - - /* - Trigger a table draw in order to get the initial filtering - */ - triggerInitialLoad(){ - this.triggered = true; - //console.info("triggerInitialLoad"); - setTimeout(function(){ - var table = ($('#dpTable')).DataTable(); - table.page( 0 ).draw( false ); - }, 500); - this.dtTrigger.next(); - } - - goTo(page:number = 1){ - this.searchUtils.page=page; - - var table = $('#dpTable').DataTable(); - table.page( page - 1 ).draw( false ); - - var info = table.page.info(); - this.searchUtils.totalResults = info.recordsDisplay; - } - - public confirmedDeleteCommunity(data : any) { - - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.communityId,this.selectedToDelete.openaireId ).subscribe( - data => { - var pos = -1; - for(var i=0; i< this.selectedCommunities.length;i++) { - if( this.selectedCommunities[i].id == this.selectedToDelete.id) { - pos= i; - break; - } - } - if(pos != -1){ - this.selectedCommunities.splice(pos, 1); - this.searchUtils.totalResults = this.selectedCommunities.length; - } + if (pos != -1) { + this.selectedCommunities.splice(pos, 1); this.searchUtils.totalResults = this.selectedCommunities.length; - var table = $('#dpTable').DataTable(); - table.clear(); - this.rerender(); - - }, - err => { - console.log(err.status); - }/*, - () => { - console.info("completed remove"); - }*/ - ) + } + this.searchUtils.totalResults = this.selectedCommunities.length; + this.filterPreviewCommunities(this.filterForm.value); + UIkit.notification('Community has been successfully removed!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.log(err.status); + } + )); + } + } + + public removeCommunity(comm) { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + this.selectedToDelete = comm; + this.alertModalDeleteCommunity.cancelButton = true; + this.alertModalDeleteCommunity.okButton = true; + this.alertModalDeleteCommunity.alertTitle = "Remove zenodo community?"; + let title = ""; + if (comm.title) { + title = comm.title; } - } - - public removeCommunity( comm) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.selectedToDelete = comm; - this.alertModalDeleteCommunity.cancelButton = true; - this.alertModalDeleteCommunity.okButton = true; - this.alertModalDeleteCommunity.alertTitle = "Remove zenodo community?"; - let title = ""; - if(comm.title) { - title = comm.title; - } - - - this.alertModalDeleteCommunity.message = "Zenodo community"; - if(title) { - this.alertModalDeleteCommunity.message += " '"+title+"' "; - } - this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?"; - this.alertModalDeleteCommunity.okButtonText = "Yes"; - this.alertModalDeleteCommunity.open(); + + + this.alertModalDeleteCommunity.message = "Zenodo community"; + if (title) { + this.alertModalDeleteCommunity.message += " '" + title + "' "; } + this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?"; + this.alertModalDeleteCommunity.okButtonText = "Yes"; + this.alertModalDeleteCommunity.open(); } - - - totalPages(): number { - let totalPages:any = this.searchUtils.totalResults/(this.rowsOnPage); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - return totalPages; + } + + + totalPages(): number { + let totalPages: any = this.searchUtils.totalResults / (this.rowsOnPage); + if (!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); } - - + return totalPages; + } + + addNew() { + this.toggleView.emit(null); + } + + public onSearchClose() { + this.searchUtils.keyword = this.filterForm.value; + } + + public resetInput() { + this.searchUtils.keyword = null; + this.searchInputComponent.reset() + } + + handleError(message: string) { + UIkit.notification(message, { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); + } } diff --git a/src/app/pages/zenodo-communities/preview-z-community.component.ts b/src/app/pages/zenodo-communities/preview-z-community.component.ts new file mode 100644 index 0000000..ce68049 --- /dev/null +++ b/src/app/pages/zenodo-communities/preview-z-community.component.ts @@ -0,0 +1,32 @@ +import {Component, Input} from '@angular/core'; + +@Component({ + selector: 'preview-zenodo-community', + template: ` +
+ + + +
+ + {{item.title}} + [no name available] + + +
+ last update: {{item.date | date:'yyyy/MM/dd'}} +
+
+
+ +
+

{{item.description|htmlToString}}

+
+ + ` +}) + +export class PreviewZenodoCommunityComponent { + @Input() item; + } diff --git a/src/app/pages/zenodo-communities/zenodo-communities-routing.module.ts b/src/app/pages/zenodo-communities/zenodo-communities-routing.module.ts index 3ec54da..b0f3aef 100644 --- a/src/app/pages/zenodo-communities/zenodo-communities-routing.module.ts +++ b/src/app/pages/zenodo-communities/zenodo-communities-routing.module.ts @@ -1,13 +1,11 @@ -import { NgModule } from '@angular/core'; +import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; import {ZenodoCommunitiesComponent} from './zenodo-communities.component'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: ZenodoCommunitiesComponent} + { path: '', component: ZenodoCommunitiesComponent} ]) ] }) diff --git a/src/app/pages/zenodo-communities/zenodo-communities.component.ts b/src/app/pages/zenodo-communities/zenodo-communities.component.ts index 5543e58..cae9f16 100644 --- a/src/app/pages/zenodo-communities/zenodo-communities.component.ts +++ b/src/app/pages/zenodo-communities/zenodo-communities.component.ts @@ -1,208 +1,183 @@ -import {Component, ViewChild, OnInit, Input, ElementRef, OnDestroy} from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; - -import {ManageZenodoCommunitiesComponent} from './manage-zenodo-communities.component'; -import {AddZenodoCommunitiesComponent} from './add-zenodo-communities.component'; +import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; -import { SearchZenodoCommunitiesService } from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service'; +import {SearchZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service'; import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo'; import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; -import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; +import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class'; import {Title} from '@angular/platform-browser'; +import {properties} from '../../../environments/environment'; +import {Subscription} from 'rxjs'; +import {FullScreenModalComponent} from '../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component'; +import {ManageZenodoCommunitiesComponent} from './manage-zenodo-communities.component'; @Component({ - selector: 'zenodo-communities', - template: ` -
- - -
- - - - - -
-
- + selector: 'zenodo-communities', + template: ` +
+
+ +
+
+
+
- ` +
+ + + + + + + ` }) - export class ZenodoCommunitiesComponent implements OnInit, OnDestroy { - private communityId: string = null; + public communityId: string = null; private community: CommunityInfo = null; - - @Input() communityProjects = []; - @ViewChild (ManageZenodoCommunitiesComponent) manageZenodoCommunitiesComponent: ManageZenodoCommunitiesComponent ; - @ViewChild (AddZenodoCommunitiesComponent) addZenodoCommunitiesComponent: AddZenodoCommunitiesComponent ; - - public warningMessage = ''; - public infoMessage = ''; - - public toggle = true; + public toggle = false; public updateCommunityProjectsOnToggle = false; public pageTitle = 'Manage zenodo communities'; - public toggleLinkMessage = 'Manage zenodo communities'; - masterZenodoCommunityId = null; masterZenodoCommunity = null; public properties: EnvProperties = null; - selectedCommunityIds = null; - // ["ecfunded", "zenodo", "lory_hslu", "cs19", "", - // "hbp","dighl", "wind_energy", "lory", "fp7-bmc","fp7postgrantoapilotoutputs","cernopenlab"]; selectedCommunities = []; - zenodocommunitiesloadedCount = 0; zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass(); - private errorCodes: ErrorCodes = new ErrorCodes(); - + public errorCodes: ErrorCodes = new ErrorCodes(); + subscriptions = []; + @ViewChild('fsModal') fullscreen: FullScreenModalComponent; + @ViewChild('manage') manage: ManageZenodoCommunitiesComponent; + constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, - private _ΖenodoCommunitieService: ZenodoCommunitiesService, private title: Title, + private _zenodoCommunitieService: ZenodoCommunitiesService, private title: Title, private _communityService: CommunityService, - private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {} - - ngOnInit() { - this.zenodoSearchUtils.status = this.errorCodes.LOADING; - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - - if (params['communityId']) { - this.communityId = params['communityId']; - this.title.setTitle('Administration Dashboard | Zenodo Communities'); - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); - } else { - if (this.communityId != null && this.communityId !== '') { - - this._communityService.getCommunity(this.properties, - this.properties.communityAPI + this.communityId).subscribe ( - community => { - this.community = community; - this.masterZenodoCommunityId = this.community.zenodoCommunity; - if (this.masterZenodoCommunityId) { - this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, - this.properties.zenodoCommunities + this.masterZenodoCommunityId, - null).subscribe( - result => { - this.masterZenodoCommunity = result; - - }, - error => { - const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo(); - emptyCommunity.id = this.masterZenodoCommunityId; - emptyCommunity.title = this.masterZenodoCommunityId; - this.masterZenodoCommunity = emptyCommunity; - // console.log("Master Zenodo community'"+this.masterZenodoCommunityId+"' couldn't be loaded"); - } - ); - } - this.zenodoSearchUtils.status = this.errorCodes.LOADING; - this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe ( - result => { - this.selectedCommunityIds = result; - this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length; - if (this.selectedCommunityIds.length === 0) { - this.zenodoSearchUtils.status = this.errorCodes.NONE; - } - for (let i = 0; i < this.selectedCommunityIds.length; i++) { - this.getZenodoCommunityById( - this.selectedCommunityIds[i]['zenodoid'], - this.selectedCommunityIds[i]['id']); - } - - }, - error => { - console.log('list of zenodo communities couldn\'t be loaded'); - this.zenodoSearchUtils.status = this.errorCodes.ERROR; - } // this.handleError('System error retrieving community profile', error) - ); - - }, - error => { - console.log('Community couldn\'t be loaded'); - this.zenodoSearchUtils.status = this.errorCodes.ERROR; - } - ); - - - } + private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) { + } + + ngOnInit() { + this.zenodoSearchUtils.status = this.errorCodes.LOADING; + this.properties = properties; + this.route.params.subscribe(params => { + this.communityId = params['community']; + if (this.communityId) { + this.title.setTitle(this.communityId.toUpperCase() + ' | Zenodo Communities'); + if (this.communityId != null && this.communityId !== '') { + this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe( + community => { + this.community = community; + this.masterZenodoCommunityId = this.community.zenodoCommunity; + if (this.masterZenodoCommunityId) { + this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, + this.properties.zenodoCommunities + this.masterZenodoCommunityId, + null).subscribe( + result => { + this.masterZenodoCommunity = result; + }, + error => { + const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo(); + emptyCommunity.id = this.masterZenodoCommunityId; + emptyCommunity.title = this.masterZenodoCommunityId; + this.masterZenodoCommunity = emptyCommunity; + // console.log("Master Zenodo community'"+this.masterZenodoCommunityId+"' couldn't be loaded"); + } + )); } - - - } - }); - }); -} - - - - public ngOnDestroy() {} - + this.zenodoSearchUtils.status = this.errorCodes.LOADING; + this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe( + result => { + this.selectedCommunityIds = result; + this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length; + if (this.selectedCommunityIds.length === 0) { + this.zenodoSearchUtils.status = this.errorCodes.NONE; + } + for (let i = 0; i < this.selectedCommunityIds.length; i++) { + this.getZenodoCommunityById( + this.selectedCommunityIds[i]['zenodoid'], + this.selectedCommunityIds[i]['id']); + } + + }, + error => { + console.log('list of zenodo communities couldn\'t be loaded'); + this.zenodoSearchUtils.status = this.errorCodes.DONE; + } // this.handleError('System error retrieving community profile', error) + ); + })); + } + } + }); + this.fullscreen.title = "Search and Add Zenodo Communities"; + this.fullscreen.okButtonText = "Done"; + this.fullscreen.okButton = true; + + + } + + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }); + } + public toggleAction() { if (!Session.isLoggedIn()) { this._router.navigate(['/user-info'], { - queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); + queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} + }); } else { HelperFunctions.scroll(); - + this.toggle = !this.toggle; if (this.toggle) { + this.fullscreen.open(); this.pageTitle = 'Manage zenodo communities'; - } else { + this.manage.filterPreviewCommunities(this.manage.filterForm.value); this.updateCommunityProjectsOnToggle = false; this.pageTitle = 'Search zenodo communities'; } } } - + getZenodoCommunityById(zenodoid, openaireId) { - this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, - this.properties.zenodoCommunities + zenodoid, openaireId).subscribe( - result => { - this.selectedCommunities.push(result); - this.zenodocommunitiesloadedCount++; - if (this.zenodocommunitiesloadedCount >= this.selectedCommunityIds.length) { - this.zenodoSearchUtils.status = this.errorCodes.DONE; - } - - - }, - error => { - const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo(); - emptyCommunity.id = zenodoid; - emptyCommunity.openaireId = openaireId; - emptyCommunity.title = zenodoid; - this.selectedCommunities.push(emptyCommunity); - this.zenodocommunitiesloadedCount++; - if (this.zenodocommunitiesloadedCount >= this.selectedCommunityIds.length) { - this.zenodoSearchUtils.status = this.errorCodes.DONE; + this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, + this.properties.zenodoCommunities + zenodoid, openaireId).subscribe( + result => { + this.selectedCommunities.push(result); + this.zenodocommunitiesloadedCount++; + if (this.zenodocommunitiesloadedCount >= this.selectedCommunityIds.length) { + this.zenodoSearchUtils.status = this.errorCodes.DONE; + } + + + }, + error => { + const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo(); + emptyCommunity.id = zenodoid; + emptyCommunity.openaireId = openaireId; + emptyCommunity.title = zenodoid; + this.selectedCommunities.push(emptyCommunity); + this.zenodocommunitiesloadedCount++; + if (this.zenodocommunitiesloadedCount >= this.selectedCommunityIds.length) { + this.zenodoSearchUtils.status = this.errorCodes.DONE; + } + console.log('Zenodo community\'' + zenodoid + '\' couldn\'t be loaded'); } - console.log('Zenodo community\'' + zenodoid + '\' couldn\'t be loaded'); - } - ); + )); } } diff --git a/src/app/pages/zenodo-communities/zenodo-communities.module.ts b/src/app/pages/zenodo-communities/zenodo-communities.module.ts index d5d26b2..ce96c76 100644 --- a/src/app/pages/zenodo-communities/zenodo-communities.module.ts +++ b/src/app/pages/zenodo-communities/zenodo-communities.module.ts @@ -2,35 +2,44 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {FormsModule} from '@angular/forms'; import {RouterModule} from '@angular/router'; -import {PagingModule} from '../../openaireLibrary/utils/paging.module'; import {ManageZenodoCommunitiesComponent} from './manage-zenodo-communities.component'; import {AddZenodoCommunitiesComponent} from './add-zenodo-communities.component'; import {ZenodoCommunitiesComponent} from './zenodo-communities.component'; -import {FABModule} from '../../utils/fabModule.module'; -import { DataTablesModule } from 'angular-datatables'; -import {SearchZenodoCommunitiesServiceModule } from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module'; +import {SearchZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module'; import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module'; import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; import {ZenodoCommunitiesRoutingModule} from './zenodo-communities-routing.module'; -import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; +import {CommunityInfoModule} from '../community-info/community-info.module'; +import {SearchInputModule} from '../../openaireLibrary/sharedComponents/search-input/search-input.module'; +import {IconsModule} from '../../openaireLibrary/utils/icons/icons.module'; +import {IconsService} from '../../openaireLibrary/utils/icons/icons.service'; +import {add, arrow_left, remove_circle_outline} from '../../openaireLibrary/utils/icons/icons'; +import {NoLoadPaging} from '../../openaireLibrary/searchPages/searchUtils/no-load-paging.module'; +import {LoadingModule} from '../../openaireLibrary/utils/loading/loading.module'; +import {PreviewZenodoCommunityComponent} from './preview-z-community.component'; +import {PageContentModule} from '../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; +import {FullScreenModalModule} from '../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module'; +import {HTMLToStringPipeModule} from '../../openaireLibrary/utils/pipes/HTMLToStringPipe.module'; @NgModule({ imports: [ - CommonModule, FormsModule, RouterModule, - PagingModule, FABModule, DataTablesModule, SearchZenodoCommunitiesServiceModule, ZenodoCommunitiesServiceModule, - AlertModalModule, ZenodoCommunitiesRoutingModule + CommonModule, FormsModule, RouterModule, SearchZenodoCommunitiesServiceModule, ZenodoCommunitiesServiceModule, + AlertModalModule, ZenodoCommunitiesRoutingModule, CommunityInfoModule, PageContentModule, SearchInputModule, IconsModule, NoLoadPaging, LoadingModule, FullScreenModalModule, HTMLToStringPipeModule ], declarations: [ - ManageZenodoCommunitiesComponent, ZenodoCommunitiesComponent, AddZenodoCommunitiesComponent + ManageZenodoCommunitiesComponent, ZenodoCommunitiesComponent, AddZenodoCommunitiesComponent, PreviewZenodoCommunityComponent ], providers: [ - ManageZenodoCommunitiesService, IsCommunity, ConnectAdminLoginGuard + ManageZenodoCommunitiesService ], exports: [ ZenodoCommunitiesComponent ] }) -export class ZenodoCommunitiesModule { } +export class ZenodoCommunitiesModule { + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([add, arrow_left, remove_circle_outline ]) + } +} diff --git a/src/app/services/help-content.service.ts b/src/app/services/help-content.service.ts index d5cc46c..e413e6d 100644 --- a/src/app/services/help-content.service.ts +++ b/src/app/services/help-content.service.ts @@ -281,12 +281,17 @@ export class HelpContentService { // //.map(res => > res.json()) // .pipe(catchError(this.handleError)); // } - + + getCommunityPagesByRoute(pid: string, route: string, helpContentUrl:string) { + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages' + + (route ? '?page_route='+route : '')) + .pipe(map(pages => (pages.length>0?pages[0]:null)), catchError(this.handleError)); + } + // Replacing getCommunityPages getCommunityPagesByType(pid: string, type: string, helpContentUrl:string) { return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages' + (type ? '?page_type='+type : '')) - //.map(res => > res.json()) .pipe(catchError(this.handleError)); } // End of replacing getCommunityPages diff --git a/src/app/utils/fab.component.ts b/src/app/utils/fab.component.ts deleted file mode 100644 index d7020c6..0000000 --- a/src/app/utils/fab.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Component, EventEmitter, Output } from '@angular/core'; - -@Component({ - selector: 'fab', - template: ` - - ` -}) - -export class FABComponent { - @Output() public clicked:EventEmitter = new EventEmitter(); - - constructor () {} - - public ngOnInit() {} - - public onClick() { - this.clicked.emit(true); - } - -} diff --git a/src/app/utils/fabModule.module.ts b/src/app/utils/fabModule.module.ts deleted file mode 100644 index 5d2b8f6..0000000 --- a/src/app/utils/fabModule.module.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule} from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import {FABComponent} from './fab.component'; - -@NgModule({ - imports: [ - CommonModule, - FormsModule - ], - declarations: [ - FABComponent - ], - exports: [ - FABComponent - ] -}) - -export class FABModule { } diff --git a/src/assets/css/connect-custom.css b/src/assets/css/connect-custom.css index 3395519..5a33499 100644 --- a/src/assets/css/connect-custom.css +++ b/src/assets/css/connect-custom.css @@ -1,40 +1,29 @@ :root { - ---portal-main-color: #222080; -/* --portal-main-contrast: #2E2E2E; */ ---portal-main-contrast: white; ---portal-dark-color: #4687E6; - ---openaire-main-color: #313179; - ---explore-portal-color: #D95F2D; ---provide-portal-color: #37C7E9; ---monitor-portal-color: #9ABB55; ---connect-portal-color: #EBB13E; ---develop-portal-color: #DA65AB; - ---explore-portal-lower-tone: #a0462c; ---provide-portal-lower-tone: #3A8FA3; ---monitor-portal-lower-tone: #7c9144; ---connect-portal-lower-tone: #b48536; ---develop-portal-lower-tone: #9f4e7e; + --portal-main-color: #FECA1D; + --portal-main-contrast: #FFFFFF; + --portal-dark-color: #b48536; + --primary-color: var(--theme-secondary-color); + --secondary-color: var(--theme-secondary-color); } + .tm-toolbar .uk-subnav-line .custom-connect-li, .tm-toolbar .uk-subnav-line .custom-connect-admin-li { - display: block; - background:#DEAF50 !important; color:#fff !important; + display: block; + background: #DEAF50 !important; + color: #fff !important; } -.custom-connect-toolbar ul.uk-subnav.uk-subnav-line, .custom-connect-admin-toolbar ul.uk-subnav.uk-subnav-line{ + +.custom-connect-toolbar ul.uk-subnav.uk-subnav-line, .custom-connect-admin-toolbar ul.uk-subnav.uk-subnav-line { background-color: #FFC700 !important; - } +} - .custom-connect-toolbar .inner, .custom-connect-admin-toolbar .inner { - background-color: #FFC700 !important; - } +.custom-connect-toolbar .inner, .custom-connect-admin-toolbar .inner { + background-color: #FFC700 !important; +} -.custom-connect-toolbar,.custom-connect-admin-toolbar{ - border-top-color:#FFC700 !important; - } +.custom-connect-toolbar, .custom-connect-admin-toolbar { + border-top-color: #FFC700 !important; +} .red_color { color: #FF3030; @@ -56,94 +45,77 @@ color: #767779 !important; } -.wellcomePage{ +.wellcomePage { background: transparent linear-gradient(0deg, #FAFAFA 0%, #E2EEFA 100%) 0 0 no-repeat padding-box; min-height: calc(100vh - 412.767px); } -.sidebar{ - background-color: #9C9C9C; -} -.uk-button-default:hover,.uk-button-default:focus,.btn:hover,.btn:focus { - background-color:#fff !important; - color:#5b5b5b !important; - box-shadow:0 6px 50px rgba(0,0,0,0.05) -} - - -.connect-admin-menu{ - background-color: var(--portal-main-color) !important; -} - -.connect-admin-menu.uk-navbar-transparent .uk-navbar-nav > li > a{ - color: white !important; -} - -.connect-admin-menu .uk-logo{ - background-color: white !important; - margin: 5px; -} - -.sidebar .uk-nav>li>a{ - font-weight: 400; - color: rgb(255,255,255); -} - -.uk-button:disabled, .uk-button:disabled:hover { - background-color: #f7f7fa; - color: #cbcbcb; - background-image: none; - box-shadow: none; - cursor: not-allowed; -} - .uk-pagination > .uk-active > span { - background-color: var(--portal-main-color) !important; - color: var(--portal-main-contrast) !important; - border-color:var(--portal-main-color) !important; - border-bottom-color: var(--portal-main-color) !important; - } - -.communitiesImageBox{ - width:107px; height:57px; -} - -.communityCard { - box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16); -} - -.font-41 { - font-size: 41px; -} - -.iframeContainer{ - overflow:hidden; +.iframeContainer { + overflow: hidden; } -.iframeContainer iframe{ +.iframeContainer iframe { - width:100%; - height:100%; - border:0; + width: 100%; + height: 100%; + border: 0; } /*Customization*/ -.customizationMenuPanel{ - background-color: #999999; +.customizationMenuPanel { + /*background-color: #999999;*/ } -.customizationMenuPanel .customizationMenuItems{ - background-color: white; - border: white solid 1px; - border-radius: 14px; +.customizationMenuPanel .customizationMenuItems { + background-color: white; + border: white solid 1px; + border-radius: 14px; +} +/*#colorPickerInput { + width: 15px; + height: 15px; + border: 1px solid #707070; + border-radius: 50%; + opacity: 1; + cursor:pointer; + +}*/ + +.colorPicker input { + width: 35px; + height: 15px; + border: 1px solid #707070; + border-radius: 2px; + opacity: 1; + cursor:pointer; } - -.colorPicker input{ - width:35px; - height: 15px; - border: 1px solid #707070; - border-radius: 2px; - opacity: 1; +/* NEW CSS*/ +.login circle { + fill: var(--primary-color); +} + +.login:hover circle { + fill: var(--secondary-color); +} + +#sidebar_main .sidebar_main_header .portal-logo { + background: url("/assets/common-assets/logo-large-connect.png") no-repeat; + background-size: contain; +} + +.sidebar_mini #sidebar_main .sidebar_main_header .portal-logo { + background: url("/assets/common-assets/logo-small-connect.png") no-repeat; + background-size: contain; +} + +#sidebar_main #sidebar_content { + border-right: 1px solid var(--portal-main-color); +} + +#sidebar_switcher_toggle { + border: 1px solid var(--portal-main-color); + border-left: 0; } diff --git a/src/assets/env-properties.json b/src/assets/env-properties.json deleted file mode 100644 index 6b2f905..0000000 --- a/src/assets/env-properties.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "environment":"development", - "adminToolsPortalType": "community", - "enablePiwikTrack" : false, - "useCache" : false, - "metricsAPIURL" : "https://beta.services.openaire.eu/usagestats/", - "framesAPIURL" : "https://beta.openaire.eu/stats3/", - "claimsAPIURL" : "http://dl170.madgik.di.uoa.gr:8180/dnet-claims-service-2.0.0-SNAPSHOT/rest/claimsService/", - "statisticsAPIURL" : "https://beta.services.openaire.eu/stats-api/", - "statisticsFrameAPIURL":"https://beta.openaire.eu/stats/", - "statisticsFrameNewAPIURL": "https://stats.madgik.di.uoa.gr/stats-api/", - "useNewStatistisTool":true, - "searchAPIURLLAst" : "https://beta.services.openaire.eu/search/v2/api/", - "searchResourcesAPIURL" : "https://beta.services.openaire.eu/search/v2/api/resources", - "openCitationsAPIURL" : "https://services.openaire.eu/opencitations/getCitations?id=", - "csvAPIURL" : "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/reports", - "searchCrossrefAPIURL" : "https://api.crossref.org/works", - "searchDataciteAPIURL" : "https://api.datacite.org/works", - "searchOrcidURL" : "https://pub.orcid.org/", - "orcidURL" : "https://orcid.org/", - "doiURL" : "https://dx.doi.org/", - "cordisURL" : "http://cordis.europa.eu/projects/", - "openDoarURL": "http://v2.sherpa.ac.uk/id/repository/", - "r3DataURL": "http://service.re3data.org/repository/", - "sherpaURL": "http://www.sherpa.ac.uk/romeo/search.php?issn=", - "zenodo" : "https://zenodo.org/", - "zenodoCommunities" : "https://zenodo.org/api/communities/", - "openAccess" : "https://www.openaire.eu/support/faq#article-id-234", - "openAccessRepo" : "https://www.openaire.eu/support/faq#article-id-310", - "fp7Guidlines" : "https://www.openaire.eu/open-access-in-fp7-seventh-research-framework-programme", - "h2020Guidlines" : "https://www.openaire.eu/oa-publications/h2020/open-access-in-horizon-2020", - "ercGuidlines" : "http://erc.europa.eu/sites/default/files/document/file/ERC_Open_Access_Guidelines-revised_2014.pdf", - "helpdesk" : "https://www.openaire.eu/support/helpdesk", - "helpdeskEmail": "helpdesk@openaire.eu", - "utilsService" : "http://mpagasas.di.uoa.gr:8000", - - "vocabulariesAPI" :"https://beta.services.openaire.eu/provision/mvc/vocabularies/", - - "piwikBaseUrl" :" https://analytics.openaire.eu/piwik.php?idsite=6", - "loginUrl" :"http://dl170.madgik.di.uoa.gr:8180/dnet-login/openid_connect_login", - - "userInfoUrl" : "http://dl170.madgik.di.uoa.gr:8180/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=", - "logoutUrl" :"https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=", - - "cookieDomain" :".di.uoa.gr", - - "feedbackmail" :"openaire.test@gmail.com", - "feedbackmailForMissingEntities" :"feedback@openaire.eu", - "cacheUrl" :"http://scoobydoo.di.uoa.gr:3000/get?url=", - - "adminToolsAPIURL" :"http://dl170.madgik.di.uoa.gr:8080/uoa-admin-tools/", - - "adminToolsCommunity" :"openaire", - "communityAPI": "https://dev-openaire.d4science.org/openaire/community/", - - "miningBackendURL": "https://beta.services.openaire.eu/interactive-mining", - - "csvLimit": 2000, - "pagingLimit": 20, - "resultsPerPage": 10, - - "baseLink" : "https://demo.openaire.eu", - "baseOpenaireLink" : "https://beta.explore.openaire.eu", - - "searchLinkToPublication" : "/search/publication?articleId=", - "searchLinkToProject" : "/search/project?projectId=", - "searchLinkToDataProvider" : "/search/dataprovider?datasourceId=", - "searchLinkToDataset" : "/search/dataset?datasetId=", - "searchLinkToOrganization" : "/search/organization?organizationId=", - - "searchLinkToPublications" : "/search/find/publications", - "searchLinkToDataProviders" : "/search/find/dataproviders", - "searchLinkToProjects" : "/search/find/projects", - "searchLinkToDatasets" : "/search/find/datasets", - "searchLinkToSoftware" : "/search/find/software", - "searchLinkToOrganizations" : "/search/find/organizations", - "searchLinkToCompatibleDataProviders" : "/search/content-providers", - "searchLinkToEntityRegistriesDataProviders" : "/search/entity-registries", - "searchLinkToEntityRegistriesDataProvidersTable" : "/search/entity-registries-table", - "searchLinkToJournals" : "/search/journals", - "searchLinkToJournalsTable" : "/search/journals-table", - - "searchLinkToAdvancedPublications" : "/search/advanced/publications", - "searchLinkToAdvancedProjects" : "/search/advanced/projects", - "searchLinkToAdvancedDatasets" : "/search/advanced/datasets", - "searchLinkToAdvancedSoftware" : "/search/advanced/software", - "searchLinkToAdvancedDataProviders" : "/search/advanced/dataproviders", - "searchLinkToAdvancedOrganizations" : "/search/advanced/organizations", - - "sendMailUrl": "http://duffy.di.uoa.gr:8080/uoa-admin-tools/sendMail", - "notifyForNewManagers": "http://duffy.di.uoa.gr:8080/uoa-admin-tools/notifyForNewManagers/", - "notifyForNewSubscribers": "http://duffy.di.uoa.gr:8080/uoa-admin-tools/notifyForNewSubscribers/", - - "lastIndexInformationLink" : "https://www.openaire.eu/aggregation-and-content-provision-workflows", - "showLastIndexInformationLink" : false, - - "widgetLink" : "https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId=", - "claimsInformationLink": "https://www.openaire.eu/linking-beta", - "lastIndexUpdate": "2019-05-16", - "indexInfoAPI": "http://beta.services.openaire.eu/openaire/info/", - "admins" : ["kostis30fylloy@gmail.com"], - "adminPortalURL": "https://beta.admin.connect.openaire.eu" -} diff --git a/src/assets/external-link.svg b/src/assets/external-link.svg deleted file mode 100644 index c291d7e..0000000 --- a/src/assets/external-link.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/imgs/add-icon.png b/src/assets/imgs/add-icon.png deleted file mode 100644 index bd93323..0000000 Binary files a/src/assets/imgs/add-icon.png and /dev/null differ diff --git a/src/assets/imgs/check-icon.png b/src/assets/imgs/check-icon.png deleted file mode 100644 index 40622e8..0000000 Binary files a/src/assets/imgs/check-icon.png and /dev/null differ diff --git a/src/assets/imgs/delete-icon.png b/src/assets/imgs/delete-icon.png deleted file mode 100644 index b64cc5f..0000000 Binary files a/src/assets/imgs/delete-icon.png and /dev/null differ diff --git a/src/assets/imgs/icn_edit.png b/src/assets/imgs/icn_edit.png deleted file mode 100644 index be8c68f..0000000 Binary files a/src/assets/imgs/icn_edit.png and /dev/null differ diff --git a/src/assets/imgs/icn_search.png b/src/assets/imgs/icn_search.png deleted file mode 100644 index f362e30..0000000 Binary files a/src/assets/imgs/icn_search.png and /dev/null differ diff --git a/src/assets/imgs/icn_trash.png b/src/assets/imgs/icn_trash.png deleted file mode 100644 index 675820f..0000000 Binary files a/src/assets/imgs/icn_trash.png and /dev/null differ diff --git a/src/assets/imgs/logo-large-connect-admin.png b/src/assets/imgs/logo-large-connect-admin.png deleted file mode 100644 index e3d95b8..0000000 Binary files a/src/assets/imgs/logo-large-connect-admin.png and /dev/null differ diff --git a/src/assets/imgs/logo-small-connect-admin.png b/src/assets/imgs/logo-small-connect-admin.png deleted file mode 100644 index 08fd7cd..0000000 Binary files a/src/assets/imgs/logo-small-connect-admin.png and /dev/null differ diff --git a/src/assets/imgs/wellcome.png b/src/assets/imgs/wellcome.png deleted file mode 100644 index 8ed6785..0000000 Binary files a/src/assets/imgs/wellcome.png and /dev/null differ diff --git a/src/assets/imgs/x-icon.png b/src/assets/imgs/x-icon.png deleted file mode 100644 index 6f7365a..0000000 Binary files a/src/assets/imgs/x-icon.png and /dev/null differ diff --git a/src/assets/loading.gif b/src/assets/loading.gif deleted file mode 100644 index b36a2b6..0000000 Binary files a/src/assets/loading.gif and /dev/null differ diff --git a/src/assets/styles.css b/src/assets/styles.css deleted file mode 100644 index 4a7c5d1..0000000 --- a/src/assets/styles.css +++ /dev/null @@ -1,1535 +0,0 @@ -@media (min-width: 768px) { - .form-inline .radio input[type="radio"], - .form-inline .checkbox input[type="checkbox"], - .form-group .checkbox input[type="checkbox"]{ - float: left; - margin-right: 5px; - } -} - -#sidebar-default { - /*background: #00b9b4 none repeat scroll 0 0;*/ - background: #00a0de none repeat scroll 0 0; - /*border-right: 1px solid #18aba6;*/ - border-right: 1px solid #008ec5; - position: fixed; - width: 260px; -} - -#sidebar-default .current-user { - background: #fff none repeat scroll 0 0; - color: #000; - margin-bottom: 40px; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); -} - -#sidebar-default .menu-section ul li a:hover, #sidebar-default .menu-section ul li a.toggled { - /*background: #18aba6 none repeat scroll 0 0;*/ - background: #008ec5 none repeat scroll 0 0; -} - -#sidebar-default .menu-section ul li a.active { - /*background: #ff6600 none repeat scroll 0 0;*/ - /*background: #003f3c none repeat scroll 0 0;*/ - /*background: #05007A none repeat scroll 0 0;*/ - background: #e2d442 none repeat scroll 0 0; -} - -#sidebar-default .menu-section h3 { - font-size: 14px; -} - -#sidebar-default .menu-section ul li a { - color: #fff; - font-weight: bold; -} - -#users #content form.search { - margin-left: 140px; -} - -#dashboard #content .menubar.fixed, -#newPageHelpContent #content .menubar.fixed, -#editPageHelpContent #content .menubar.fixed -{ - padding-left: 300px; -} - -.modal-header .close { - margin-top: 3px; -} - -.modal-dialog { - width: 500px; -} - -.dropdown-menu > li > a { - cursor: pointer; -} - -#faqQuestions #content .content-wrapper .page-controls .filters .links a, -#pageContents #content .content-wrapper .page-controls .filters .links a { - cursor: pointer; -} - -.bootstrap-switch-mySuccess { - background: #76b852; - color: #fff; -} -/*#dashboard #content .page-title {*/ - /*border-right: 1px solid #e6e6e6;*/ - /*bottom: 0;*/ - /*color: #7e7e7e;*/ - /*font-size: 16px;*/ - /*font-weight: 600;*/ - /*letter-spacing: 0.3px;*/ - /*padding: 20px 30px;*/ - /*position: absolute;*/ - /*text-transform: uppercase;*/ - /*top: 0;*/ -/*}*/ - -/*#form #content .menubar.fixed {*/ - /*padding-left: 270px;*/ -/*}*/ - -/*#form #content .form-horizontal .form-group .detail {*/ - /*margin-bottom: 0;*/ - /*margin-top: 0;*/ - /*padding-top: 7px;*/ -/*}*/ - -/*#users #content .page-title { - !*color: #ff6600;*! - color: #003f3c; - font-size: 17px; - font-weight: 700; -}*/ - - -/*To be moved to resource-type.component.css*/ - -/*#users #content .content-wrapper .users-list .headers .header label {*/ - /*height: auto;*/ -/*}*/ - -/*#users #content .content-wrapper .users-list .headers .header label span {*/ - /*background: #fff none repeat scroll 0 0;*/ - /*color: #333;*/ - /*display: block;*/ - /*font-weight: 600;*/ - /*text-decoration: none;*/ - /*transition: all 0.14s linear 0s;*/ -/*}*/ - -/***********************************************/ - -.btn-primary { - /*background-color: #00b9b4;*/ - background-color: #00a0de; - /*border-color: #18aba6;*/ - border-color: #008ec5; - color: #fff; -} - - - - -/*****************************************************************************************/ -/*****************************************************************************************/ - -/** Add css rules here for your application. */ - -*::before, *::after { - box-sizing: border-box; -} - -*::before, *::after { - box-sizing: border-box; -} - -* { - box-sizing: border-box; -} - - -body { - background: #fff none repeat scroll 0 0; - padding-top: 0px !important; - /*font: normal 13px/20px Open Sans !important;*/ - font: normal 13px/20px Source Sans Pro !important; - margin: 0; -} - -.loading { - position: relative; - min-height: 200px; -} - -.loading-medium { - position: relative; - min-height: 300px; -} - -.loading-big { - position: relative; - min-height: 600px; -} - -.loader { - background: url("assets/imgs/loader-small.gif") no-repeat center; - z-index: 10; - width: 100%; - height: 100%; - position: absolute; - top: 0; - left: 0; -} - -.loader-big { - background: url("assets/imgs/loader-big.gif") no-repeat center; - z-index: 10; - width: 100%; - height: 100%; - position: absolute; - top: 0; - left: 0; -} - -.whiteFilm { - background: #ffffff; - z-index: 5; - width: 100%; - height: 100%; - opacity: 0.7; - position: absolute; - top: 0; - left: 0; -} - -.inlineBlock { - display: inline-block; -} - -.marginLeftRight20 { - margin-left: 20px; - margin-right: 20px; -} - -.marginBottom20 { - margin-bottom: 20px; -} - -.pull-right { - float: right; -} - -.comment { - font-size: 12px; - color: #666; -} - -.fontItalic { - font-style: italic; -} - -.btn { - background-color: #fff !important; - background-image: none !important; - border-color: #ccc !important; - color: #333; - /*border-radius: 0px !important;*/ -} - -/*.btn-primary {*/ - /*background-color: #586175 !important;*/ - /*background-image: none !important;*/ -/*}*/ - -.btn-default { - background-color: #fff !important; - background-image: none !important; - border-color: #ccc !important; - color: #333; -} - -.btn-success { - background-color: #76b852 !important; - border: 1px solid #63a042 !important; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.14), 0 1px 0 rgba(255, 255, 255, 0.2) inset !important; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important; - transition: all 0.2s linear 0s !important; - color: #fff; -} - -.btn-info { - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.14), 0 1px 0 rgba(255, 255, 255, 0.3) inset !important; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important; - transition: all 0.2s linear 0s !important; - background-color: #5bc0de !important; - border-color: #46b8da !important; - color: #fff; -} - -.btn-danger { - - background-color: #d9534f !important; - border-color: #d43f3a !important; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.14), 0 1px 0 rgba(255, 255, 255, 0.3) inset !important; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important; - transition: all 0.2s linear 0s !important; - color: #fff; -} - - - -#signin .bg { - background: #3f4c5b url("./assets/imgs/fotoInteraWithOpacity.jpg") no-repeat fixed 50% 50% / 100% auto !important; - padding-top: 70px; -} - -#signin .logo { - display: block; - text-align: center; - text-decoration: none; -} - -#signin h3 { - color: #fff; - font-size: 24px; - margin-top: 35px; - text-align: center; -} - -#signin .content { - background: #fff none repeat scroll 0 0; - border-radius: 3px; - box-shadow: 0 1px 40px 0 rgba(0, 0, 0, 0.3); - margin: 40px auto 0; - max-width: 460px; - padding: 42px 48px; -} - -#signin .content .alert { - margin-bottom: 15px; -} - -#signin .content .fields { - margin-bottom: 10px; -} - -#signin .content .fields strong { - display: block; - margin-bottom: 10px; -} - -#signin .content .fields input[type="text"], #signin .content .fields input[type="password"] { - margin-bottom: 15px; -} -input.form-control[type="text"], input.form-control[type="email"], input.form-control[type="password"] { - box-shadow: none; -} - -.form-control { - background-color: #fff; - background-image: none; - border: 1px solid #ccc; - border-radius: 4px; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset; - color: #555; - display: block; - font-size: 14px; - height: 34px; - line-height: 1.42857; - padding: 6px 12px; - transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s; - width: 100%; -} - -#signin .content .actions { - margin-bottom: 10px; - margin-top: 30px; - text-align: center; -} - -#signin .content input { - height: 35px !important; -} - -.btn-lg, .btn-group-lg > .btn { - border-radius: 2px !important; - font-size: 17px !important; - line-height: 1.33 !important; - padding: 10px 20px !important; -} - -#signin .bottom-wrapper { - padding-bottom: 157px; -} - -#signin .bottom-wrapper .message { - border: 1px solid #8b9bc4; - border-radius: 4px; - color: #fff; - margin: 60px auto 0; - max-width: 360px; - padding: 18px; - text-align: center; -} - -#signin .bottom-wrapper .message a { - color: #fff; - margin-left: 6px; -} - - - - -modal-backdrop, .modal-backdrop.fade.in { - opacity: 0.35 !important; -} -/*.modal { - border-radius: 0px !important; -}*/ - -.modal.confirmationModal { - margin-left: -230px; - margin-top: 90px !important; - width: 500px !important; -} - -.confirmationModal .entriesInfo { - margin-bottom: 15px; -} - -.modal.formModal { - margin-left: -230px; - width: 500px !important; -} - -.confirmationModal .modal-header, -.formModal .modal-header { - padding: 15px 20px !important; -} - -.confirmationModal .modal-header h3, -.formModal .modal-header h3{ - font-size: 20px !important; - font-weight: 400 !important; -} - -.confirmationModal .modal-body, -.formModal .modal-body { - padding: 20px 25px; -} - -.confirmationModal .modal-footer, -.formModal .modal-footer { - padding: 19px 20px 20px !important; - margin-top: 15px; - background-color: #fff !important; - border-top: 1px solid #e5e5e5 !important; -} - -.confirmationModal .modal-footer .confirmationModalButtons .btn, -.formModal .modal-footer .confirmationModalButtons .btn { - margin-left: 10px; -} - -.formModal label { - display: inline-block; - font-weight: 700; - margin-bottom: 5px; -} - -.formModal input { - height: 35px !important; -} - -.formModal .input-xxlarge { - width: 450px; -} - -.formModal textarea { - height: 90px; -} - -.formModal form { - margin: 0px !important; -} - -.formModal fieldset.firstInlineFieldSet { - margin-right: 28px; -} - -.formModal .controls .span2 { - width: 202px; -} - - - - -/*#wrapper {*/ - /*margin: 0 auto;*/ - /*position: relative;*/ -/*}*/ - -/*#sidebar-default {*/ - /*background: #2a313a none repeat scroll 0 0;*/ - /*border-right: 1px solid #3c434d;*/ - /*left: 0;*/ - /*position: absolute;*/ - /*top: 0;*/ - /*width: 260px;*/ - /*z-index: 999;*/ -/*}*/ - -/*.main-sidebar {*/ - /*bottom: 0;*/ -/*}*/ - -/*#sidebar-default .current-user {*/ - /*background: linear-gradient(#3d4a5d, #3f4c5c) repeat scroll 0 0%, #686e78 none repeat scroll 0 0;*/ - /*color: #fff;*/ - /*height: 63px;*/ - /*margin-bottom: 20px;*/ - /*padding: 0 20px;*/ - /*position: relative;*/ -/*}*/ - -/*#sidebar-default .current-user .name {*/ - /*color: #f0f5fa;*/ - /*display: block;*/ - /*font-size: 15px;*/ - /*padding: 10px 0;*/ - /*position: relative;*/ - /*text-decoration: none;*/ - /*text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);*/ -/*}*/ - -/*#sidebar-default .current-user .name span {*/ - /*position: relative;*/ - /*top: 4px;*/ -/*}*/ - -/*#sidebar-default .current-user .name .avatar {*/ - /*border-radius: 50%;*/ - /*margin-right: 12px;*/ - /*max-width: 41px;*/ - /*position: relative;*/ - /*top: 2px;*/ - /*background-color: #dde1d4;*/ - /*padding: 3px;*/ -/*}*/ - -img { - vertical-align: middle; - border: 0 none; -} - -a { - background: rgba(0, 0, 0, 0) none repeat scroll 0 0; -} - -/*#sidebar-default .menu-section {*/ - /*margin-bottom: 25px;*/ -/*}*/ - -/*#sidebar-default .menu-section h3 {*/ - /*color: #fff;*/ - /*font-size: 11px;*/ - /*font-weight: bold;*/ - /*letter-spacing: 0.5px;*/ - /*margin-bottom: 0;*/ - /*margin-top: 0;*/ - /*padding-left: 23px;*/ - /*text-shadow: 1px 1px #000;*/ - /*text-transform: uppercase;*/ -/*}*/ - -/*#sidebar-default .menu-section ul {*/ - /*list-style-type: none;*/ - /*margin-bottom: 0;*/ - /*margin-left: 0;*/ - /*margin-right: 0;*/ - /*margin-top: 0;*/ - /*padding-left: 0;*/ -/*}*/ - -/*#sidebar-default .menu-section ul li {*/ - /*margin: 1px 0;*/ -/*}*/ - -/*#sidebar-default .menu-section ul li a {*/ - /*background: transparent none repeat scroll 0 0;*/ - /*color: #ecf6ff;*/ - /*display: inline-block;*/ - /*font-size: 14px;*/ - /*font-weight: 400;*/ - /*padding: 7px 10px 9px 23px;*/ - /*text-decoration: none;*/ - /*transition: background 0.13s linear 0s;*/ - /*width: 100%;*/ -/*}*/ - -/*#sidebar-default .menu-section ul li a.active {*/ - /*background: linear-gradient(#5b6479, #4c5566) repeat scroll 0 0%, #686e78 none repeat scroll 0 0;*/ - /*box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.16) inset;*/ - /*text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);*/ -/*}*/ - -/*#sidebar-default .menu-section ul li a i {*/ - /*font-size: 19px;*/ - /*margin-right: 9px;*/ - /*min-width: 17px;*/ - /*position: relative;*/ - /*text-align: center;*/ - /*top: 1px;*/ -/*}*/ - -#sidebar-default .bottom-menu { - bottom: 0; - position: fixed; - width: 260px; - z-index: 999; -} - -#sidebar-default .bottom-menu > ul { - list-style-type: none; - margin: 0; - padding: 0; -} - -#sidebar-default .bottom-menu > ul > li { - border-right: 1px solid #3e4e55; - border-top: 1px solid #3e4e55; - display: block; - float: left; - width: 33.333%; -} - -#sidebar-default .bottom-menu > ul > li > a { - background: #333d4b none repeat scroll 0 0; - display: block; - padding: 6px 0; - position: relative; - text-align: center; -} - -#sidebar-default .bottom-menu > ul > li > a i { - color: #cbd3db; - font-size: 19px; - transition: all 0.1s linear 0s; -} - -#sidebar-default .bottom-menu > ul > li > a .flag { - background: #9ed166 none repeat scroll 0 0; - border-radius: 25px; - display: block; - height: 7px; - position: absolute; - right: 25px; - top: 4px; - width: 7px; -} - -#sidebar-default .bottom-menu > ul > li .menu::after { - background-image: url("popover-arrow.png"); - background-size: 100% 100%; - bottom: -12px; - content: ""; - display: block; - height: 12px; - left: 49%; - margin-left: -18.5px; - position: absolute; - transform: rotateX(180deg); - width: 37px; -} - -#sidebar-default .bottom-menu > ul > li > a:hover + .menu { - opacity: 1; - transform: scale(1); -} - -#sidebar-default .bottom-menu > ul > li .menu { - background: #fff none repeat scroll 0 0; - border-radius: 3px; - bottom: 34px; - box-shadow: 1px 2px 8px rgba(0, 0, 0, 0.25); - left: 39px; - list-style-type: none; - opacity: 0; - padding: 7px 0; - position: absolute; - transform: scale(0); - transform-origin: 50% 100% 0; - transition: all 300ms cubic-bezier(0.34, 1.61, 0.7, 1) 0s; - width: 155px; - z-index: 999; -} - -#sidebar-default .bottom-menu > ul > li .menu li { - border-bottom: 1px solid #e6e6e6; - padding: 8px 0; - text-align: center; -} - -#sidebar-default .bottom-menu > ul > li .menu li:last-child { - border-bottom: 0 none; -} - -#sidebar-default .bottom-menu > ul > li .menu li a { - color: #54a0e2; - display: block; - font-weight: 600; - text-decoration: none; - transition: all 0.2s linear 0s; -} - - - - - - -#content { - background: #fff none repeat scroll 0 0; - margin-left: 260px; - min-height: 900px; - padding: 67px 40px 40px; - position: relative; - transition: all 0.3s ease-out 0s; -} - -/*#steps #content { - padding: 67px 0px 0px; -}*/ - -#content .menubar { - background: white none repeat scroll 0 0; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); - height: 63px; - left: 0; - padding: 20px 40px; - position: absolute; - top: 0; - width: 100%; - z-index: 99; -} - -#content .menubar.fixed { - padding-left: 260px; - position: fixed; -} - -#content .menubar .page-title { - color: #333; - float: left; - font-size: 17px; - line-height: 26px; - position: relative; -} - -#content .menubar .page-title small { - margin-left: 10px; -} - -#content .menubar .btn.pull-right { - font-weight: bold; - letter-spacing: 0.3px; - position: relative; - top: -5px; -} - -#users #content .page-title, -#roles #content .page-title, -#news #content .page-title, -#dataProviders #content .page-title, -#faqTopics #content .page-title, -#faqQuestions #content .page-title, -#pages #content .page-title, -#pageContents #content .page-title, -#entities #content .entity-title, -#communities #content .community-title { - border-right: 1px solid #e6e6e6; - bottom: 0; - color: #7e7e7e; - font-size: 16px; - font-weight: 600; - letter-spacing: 0.3px; - padding: 20px 35px; - position: absolute; - text-transform: uppercase; - top: 0; -} - - -#content .content-wrapper { - margin-top: 20px; -} - -#content .content-wrapper .contentPanel { - padding: 10px 15px; -} - -#steps #content .content-wrapper .contentPanel { - padding: 0px; -} - -#users #content .content-wrapper .contentPanel .alert, -#roles #content .content-wrapper .contentPanel .alert, -#news #content .content-wrapper .contentPanel .alert, -#faqTopics #content .content-wrapper .contentPanel .alert, -#faqQuestions #content .content-wrapper .contentPanel .alert, -#harvestHistory #content .content-wrapper .contentPanel .alert, -#pages #content .content-wrapper .contentPanel .alert, -#pageContents #content .content-wrapper .contentPanel .alert, -#entities #content .content-wrapper .contentPanel .alert, -#communities #content .content-wrapper .contentPanel .alert { - margin-left: -10px; - margin-right: -10px; -} - -#dataProviders #content .content-wrapper .contentPanel .alert { - margin-left: -25px; - margin-right: -25px; -} - -#dataProviders #content .content-wrapper .contentPanel .row .alert { - margin-left: 0px; - margin-right: 0px; -} - - - -/*.clearfix::before, .clearfix::after, .container::before, .container::after, .container-fluid::before, .container-fluid::after, .row::before, .row::after, .form-horizontal .form-group::before, .form-horizontal .form-group::after, .btn-toolbar::before, .btn-toolbar::after, .btn-group-vertical > .btn-group::before, .btn-group-vertical > .btn-group::after, .nav::before, .nav::after, .navbar::before, .navbar::after, .navbar-header::before, .navbar-header::after, .navbar-collapse::before, .navbar-collapse::after, .pager::before, .pager::after, .panel-body::before, .panel-body::after, .modal-footer::before, .modal-footer::after { - content: " "; - display: table; -} - -.clearfix::after, .container::after, .container-fluid::after, .row::after, .form-horizontal .form-group::after, .btn-toolbar::after, .btn-group-vertical > .btn-group::after, .nav::after, .navbar::after, .navbar-header::after, .navbar-collapse::after, .pager::after, .panel-body::after, .modal-footer::after { - clear: both; -} - -.clearfix::before, .clearfix::after, .container::before, .container::after, .container-fluid::before, .container-fluid::after, .row::before, .row::after, .form-horizontal .form-group::before, .form-horizontal .form-group::after, .btn-toolbar::before, .btn-toolbar::after, .btn-group-vertical > .btn-group::before, .btn-group-vertical > .btn-group::after, .nav::before, .nav::after, .navbar::before, .navbar::after, .navbar-header::before, .navbar-header::after, .navbar-collapse::before, .navbar-collapse::after, .pager::before, .pager::after, .panel-body::before, .panel-body::after, .modal-footer::before, .modal-footer::after { - content: " "; - display: table; -}*/ - - -#dashboard .metrics { - background: linear-gradient(#303d4f, #435266) repeat scroll 0 0%, #686e78 none repeat scroll 0 0; - border: 1px solid #000; - border-radius: 5px; - box-shadow: 0 1px rgba(255, 255, 255, 0.3) inset; - font-family: "Helvetica Neue",Arial; - margin-top: 30px; -} - -#dashboard .metrics .metric { - border-right: 1px solid #526075; - float: left; - padding: 23px 0; - text-align: center; - width: 25%; -} - -#dashboard .metrics .metric .field { - color: #f4f4f4; - display: inline-block; - font-size: 14px; - margin-bottom: 9px; -} - -#dashboard .metrics .metric .data { - color: #fff; - display: block; - font-size: 27px; - text-shadow: 1px 1px #000; -} - - - - - -#dashboard .chart { - background: #fff none repeat scroll 0 0; - border: 1px solid #dfe3eb; - border-radius: 5px; - box-shadow: 0 1px 0 #ededed inset; - margin: 40px 0 50px; - padding: 25px; -} - -#dashboard .requestsGraphPanel { - height: 400px; -} - -#dashboard .usersGraphPanel { - height: 400px; -} - -#dashboard .userSectorPiePanel { - height: 400px; - width: 48%; - display: inline-block; - /*float: left;*/ -} - -#dashboard .requestStatusDonutPanel { - height: 400px; - width: 48%; - display: inline-block; - margin-right: 4%; - /*float: left;*/ -} - -#dashboard .requestStatusDonutPanel.chart, #dashboard .userSectorPiePanel.chart { - margin-top: 0px; -} - -#dashboard .chart h3 { - font-size: 18px; - font-weight: 600; - margin-bottom: 25px; - margin-top: 0; -} - -#dashboard .chart #visitors-chart { - height: 230px; - position: relative; -} - -#dashboard .chart h3 .total { - color: #2d96be; - font-size: 14px; - left: -8px; - position: relative; - top: 6px; -} - -.pull-right { - float: right; -} - -#dashboard .chart h3 .total .change { - border-radius: 3px; - display: inline-block; - font-size: 13px; - margin-left: 7px; - padding: 2px 5px; -} - -#dashboard .chart h3 .total .change.up { - color: #3fb83f; -} - - - - - - - -#users #content form.search { - float: left; - margin-left: 170px; - position: relative; - top: -2px; - width: 260px; -} - -#roles #content form.search { - float: left; - margin-left: 200px; - position: relative; - top: -2px; - width: 260px; -} - -#news #content form.search { - float: left; - margin-left: 310px; - position: relative; - top: -2px; - width: 360px; -} - -#faqTopics #content form.search { - float: left; - margin-left: 170px; - position: relative; - top: -2px; - width: 360px; -} - -#faqQuestions #content form.search { - float: left; - margin-left: 200px; - position: relative; - top: -2px; - width: 360px; -} - -#pages #content form.search { - float: left; - margin-left: 150px; - position: relative; - top: -2px; - width: 360px; -} - -#pageContents #content form.search { - float: left; - margin-left: 250px; - position: relative; - top: -2px; - width: 360px; -} - -#entities #content form.search { - float: left; - margin-left: 150px; - position: relative; - top: -2px; - width: 360px; -} - -#communities #content form.search { - float: left; - margin-left: 150px; - position: relative; - top: -2px; - width: 360px; -} - -#dataProviders #content form.search { - float: left; - margin-left: 220px; - position: relative; - top: -2px; - width: 420px; -} - -#users #content form.search input[type="text"], -#roles #content form.search input[type="text"], -#news #content form.search input[type="text"], -#dataProviders #content form.search input[type="text"], -#faqTopics #content form.search input[type="text"], -#faqQuestions #content form.search input[type="text"], -#pages #content form.search input[type="text"], -#pageContents #content form.search input[type="text"], -#entities #content form.search input[type="text"], -#communities #content form.search input[type="text"] { - border: 0 none; - border-radius: 3px; - padding: 6px 15px 6px 37px; - width: 100%; - height: 35px !important; - box-shadow: none !important; - background-image: url("assets/imgs/icn_search.png"); - background-position: 2% 40%; - background-repeat: no-repeat; - background-size: 20px auto; -} - -#users #content form.search input[type="submit"], -#roles #content form.search input[type="submit"], -#news #content form.search input[type="submit"], -#dataProviders #content form.search input[type="submit"], -#faqTopics #content form.search input[type="submit"], -#faqQuestions #content form.search input[type="submit"], -#pages #content form.search input[type="submit"], -#pageContents #content form.search input[type="submit"], -#entities #content form.search input[type="submit"], -#communities #content form.search input[type="submit"] { - position: absolute; - visibility: hidden; -} - -#users #content .content-wrapper .page-controls, -#roles #content .content-wrapper .page-controls, -#news #content .content-wrapper .page-controls, -#faqTopics #content .content-wrapper .page-controls, -#harvestHistory #content .content-wrapper .page-controls, -#pages #content .content-wrapper .page-controls -{ - margin-top: 30px; -} - -#faqQuestions #content .content-wrapper .page-controls, -#pageContents #content .content-wrapper .page-controls -{ - margin-top: 10px; -} - -#users #content .content-wrapper .page-controls .filters .links, -#roles #content .content-wrapper .page-controls .filters .links, -#news #content .content-wrapper .page-controls .filters .links, -#faqTopics #content .content-wrapper .page-controls .filters .links, -#faqQuestions #content .content-wrapper .page-controls .filters .links, -#pages #content .content-wrapper .page-controls .filters .links, -#pageContents #content .content-wrapper .page-controls .filters .links, -#harvestHistory #content .content-wrapper .page-controls .filters .links, -#harvest #content .content-wrapper .page-controls .filters .links { - /*float: left; - margin-left: -5px;*/ -} - -#users #content .content-wrapper .page-controls .filters .links .filterLabel, -#roles #content .content-wrapper .page-controls .filters .links .filterLabel, -#news #content .content-wrapper .page-controls .filters .links .filterLabel, -#faqTopics #content .content-wrapper .page-controls .filters .links .filterLabel, -#faqQuestions #content .content-wrapper .page-controls .filters .links .filterLabel, -#pages #content .content-wrapper .page-controls .filters .links .filterLabel, -#pageContents #content .content-wrapper .page-controls .filters .links .filterLabel, -#harvestHistory #content .content-wrapper .page-controls .filters .links .filterLabel, -#harvest #content .content-wrapper .page-controls .filters .links .filterLabel { - font-size: 15px; - margin-right: 20px; - display: inline-block; - font-weight: 700; - margin-bottom: 5px; - display: inline-block; -} - -#harvestHistory #content .content-wrapper .page-controls .filters .links .input-xxlarge { - width: 380px !important; -} - - -#users #content .content-wrapper .page-controls .filters .links a, -#roles #content .content-wrapper .page-controls .filters .links a, -#news #content .content-wrapper .page-controls .filters .links a, -#faqQuestions #content .content-wrapper .page-controls .filters .links a, -#pageContents #content .content-wrapper .page-controls .filters .links a, -#harvest #content .content-wrapper .page-controls .filters .links a { - color: #666; - margin-right: 35px; - padding-bottom: 2px; - text-decoration: none; - transition: all 0.1s linear 0s; -} - -#users #content .content-wrapper .page-controls .filters .links a.active, -#roles #content .content-wrapper .page-controls .filters .links a.active, -#news #content .content-wrapper .page-controls .filters .links a.active, -#faqQuestions #content .content-wrapper .page-controls .filters .links a.active, -#pageContents #content .content-wrapper .page-controls .filters .links a.active, -#harvest #content .content-wrapper .page-controls .filters .links a.activ { - border-bottom: 1px solid #82bfe9; - color: #378fca; - font-weight: 600; -} - -#users #content .content-wrapper .page-controls .filters .show-options, -#roles #content .content-wrapper .page-controls .filters .show-options, -#news #content .content-wrapper .page-controls .filters .show-options, -#faqTopics #content .content-wrapper .page-controls .filters .show-options, -#faqQuestions #content .content-wrapper .page-controls .filters .show-options, -#pages #content .content-wrapper .page-controls .filters .show-options, -#pageContents #content .content-wrapper .page-controls .filters .show-options, -#harvestHistory #content .content-wrapper .page-controls .filters .show-options, -#harvest #content .content-wrapper .page-controls .filters .show-options { - float: right; -} - -#users #content .content-wrapper .page-controls .filters .show-options .btn, -#news #content .content-wrapper .page-controls .filters .show-options .btn, -#faqTopics #content .content-wrapper .page-controls .filters .show-options .btn, -#faqQuestions #content .content-wrapper .page-controls .filters .show-options .btn, -#pages #content .content-wrapper .page-controls .filters .show-options .btn, -#pageContents #content .content-wrapper .page-controls .filters .show-options .btn, -#harvestHistory #content .content-wrapper .page-controls .filters .show-options .btn, -#harvest #content .content-wrapper .page-controls .filters .show-options .btn { - display: inline-block; - margin-left: 20px; - position: relative; - top: -7px; -} - -.show-options .dropdown-menu { - right: 0; - margin: -5px 0 0 !important; - left: auto; -} - -.show-options .dropdown-menu > li > a:hover, .show-options .dropdown-menu > li > a:focus { - background-color: #f5f5f5 !important; - color: #262626 !important; - text-decoration: none !important; - background-image: none !important; -} - - - - - -#content .content-wrapper .users-list { - margin-bottom: 40px; - margin-top: 35px; - /*font-size: 12px;*/ -} - -#content .content-wrapper .dataProviders-list { - margin-bottom: 40px; - margin-top: 15px; -} - -.row { - margin-left: -15px; - margin-right: -15px; -} - -.dataProviders-list .row { - margin-left: -25px !important; - margin-right: -25px !important; -} - -.col-md-12 { - width: 100%; -} - -.col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { - float: left; -} - -.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, -.col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, -.col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, -.col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, -.col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, -.col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, -.col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, -.col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, -.col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, -.col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, -.col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, -.col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 { - min-height: 1px; - padding-left: 15px; - padding-right: 15px; - position: relative; - display: inline-block; -} - -#content .content-wrapper .users-list .headers, -#content .content-wrapper .dataProviders-list .headers { - min-height: 35px; - padding-bottom: 10px; -} - -#content .content-wrapper .users-list .headers .header label, -#content .content-wrapper .dataProviders-list .headers .header label { - color: #333; - font-weight: 600; - /*height: 100%;*/ - width: 100%; -} - -#content .content-wrapper .users-list .headers .header label a, -#content .content-wrapper .dataProviders-list .headers .header label a { - background: #fff none repeat scroll 0 0; - color: #333; - display: block; - font-weight: 600; - text-decoration: none; - transition: all 0.14s linear 0s; -} - -.col-sm-1 { - width: 8.33333%; -} - -.col-sm-2 { - width: 16.6667%; -} - -.col-sm-3 { - width: 25%; -} - -.col-sm-4 { - width: 33.3333%; -} - -.col-sm-5 { - width: 41.6667%; -} - -#content .content-wrapper .users-list .user:nth-child(2n), -#content .content-wrapper .dataProviders-list .user:nth-child(2n) { - background: #fafafc none repeat scroll 0 0; -} - -#content .content-wrapper .users-list .user, -#content .content-wrapper .dataProviders-list .user { - border-bottom: 1px solid #f0f0f0; - padding: 12px 0; -} - -#content .content-wrapper .users-list .user .avatar input[type="checkbox"], -#content .content-wrapper .dataProviders-list .user .avatar input[type="checkbox"] { - cursor: pointer; - margin-right: 15px; - margin-top: 0; -} - -#content .content-wrapper .users-list .user .name { - color: #333; - position: relative; - text-decoration: none; - /*top: 13px;*/ -} - -#content .content-wrapper .users-list .user .email { - font-size: 13px; - position: relative; - /*top: 13px;*/ -} - -#content .content-wrapper .users-list .user .alert { - margin-bottom: 0px !important; - margin-left: 0px !important; - margin-right: 0px !important; -} - -#content .content-wrapper .users-list .user .actions input { - margin-right: 10px !important; -} - -#content .content-wrapper .dataProviders-list .user .actions input { - margin-left: 10px !important; -} - -#content .content-wrapper .users-list .user .label, -#content .content-wrapper .dataProviders-list .user .label { - display: inline-block; - margin-left: 15px; - position: relative; - text-decoration: none !important; - padding: 3px 10px !important; -} - -.label-warning { - background-color: #f0ad4e !important; -} - - - - - -#steps .steps .step { - border-bottom: 1px solid #eee; - margin: 0; - padding: 35px 75px; -} - -#steps .steps .step:nth-child(2n+1) { - background: #f8f8fa none repeat scroll 0 0; -} - -/*#steps .steps .step.done { - background: #f8f8fa none repeat scroll 0 0; - margin: 0; - padding: 35px 75px; -}*/ - -#steps .steps .step .info { - float: left; - position: relative; -} - -#steps .steps .step.done .info { - top: -6px; -} - -#steps .steps .step .info .number { - font-size: 26px; - margin-right: 20px; - position: relative; - top: 2px; -} - -#steps .steps .step .btn { - margin-left: 10px; -} - - - -#harvest #content .content-wrapper .manualHarvest { - float: left; - height: 100%; - min-height: 800px; - /*padding: 30px 30px 80px;*/ - position: relative; - width: 30%; - margin-top: -30px; - margin-left: -35px; -} - -.manualHarvest input[type="text"] { - height: 30px !important; -} - -.manualHarvest .input-xlarge { - width: 98%; -} - -input.inputWithComment { - margin-bottom: 0px !important; -} - -.manualHarvest label { - display: inline-block; - font-weight: 700; - margin-bottom: 5px; -} - -.manualHarvestObjectTypes, .scheduledHarvestObjectTypes { - padding-left: 5px; - padding-right: 5px; -} - -.manualHarvestObjectTypes label, .scheduledHarvestObjectTypes label { - /*display: block;*/ - font-weight: 400; - margin-bottom: 7px; - width: 50%; -} - -.scheduledHarvestObjectTypes input { - height: 20px !important; - margin-top: 0 !important; -} - -label.selectAllObjectTypes { - display: block; - width: 100%; - background: rgba(0, 0, 0, 0) linear-gradient(#f7f8fc, #f8f9fc) repeat scroll 0 0; - border-bottom: 1px solid #dee3ea; - border-top: 1px solid #d4dbe4; - box-shadow: 0 1px rgba(255, 255, 255, 0.79) inset; - padding: 5px 10px; - margin-left: -5px; - margin-right: -5px; -} - -.selectAllObjectTypes input[type="checkbox"] { - margin-left: -4px !important; - margin-right: 6px; -} - -.selectAllObjectTypes span { - letter-spacing: 0.5px; -} - -.manualHarvest .actionButtons { - text-align: center; -} - -.manualHarvest .harvestNow { - font-weight: bold; - letter-spacing: 0.3px; -} - -#harvest #content .content-wrapper .scheduleHarvest { - border-left: 1px solid #e8ebf0; - bottom: 0; - position: absolute; - right: 0; - top: 67px; - width: 70%; -} - -#harvest .manualHarvest h3, -#harvest .scheduleHarvest h3 { - font-size: 17px !important; - font-weight: 400; - margin: 20px 0 25px; - padding: 0 20px; - text-align: center; -} - -#harvest .scheduleHarvest .row { - margin-left: 20px; - margin-right: 20px; -} - -#harvest #content .content-wrapper .page-controls { - margin-top: 15px; -} - -#harvest #content .content-wrapper .page-controls .filters .show-options { - margin-top: 7px; -} - -table.dataTable { - clear: both; - margin: 15px 30px; -} - -#harvest .content-wrapper .scheduleHarvest thead th::after { - bottom: -1px; - box-shadow: 0 1px 1px rgba(66, 85, 124, 0.14); - content: ""; - height: 1px; - left: 0; - position: absolute; - width: 100%; -} - -#harvest .content-wrapper .scheduleHarvest thead th { - background: rgba(0, 0, 0, 0) linear-gradient(#f7f8fc, #f8f9fc) repeat scroll 0 0; - border-bottom: 1px solid #dee3ea; - border-top: 1px solid #d4dbe4; - box-shadow: 0 1px rgba(255, 255, 255, 0.79) inset; - color: #444; - padding: 10px 18px 12px 20px; - position: relative; - text-shadow: 1px 1px #fff; -} - -table.dataTable tr.odd { - background-color: white; -} - -table.dataTable tr.even { - background-color: white; -} - -#harvest .content-wrapper .scheduleHarvest td { - padding: 11px 20px; - text-align: center; -} - -table.dataTable tr.odd td.selecting { - background-color: #fafbfd; -} - -table.dataTable tr.even td.selecting { - background-color: #fafbfd; -} - -table.dataTable td { - border-bottom: 1px solid #edf2f7; - padding: 11px 9px; -} - -table.dataTable td input.edit { - margin-right: 5px; -} - -.scheduleHarvestAlerts { - margin-left: 30px; - margin-right: 20px; -} - -#performanceIndicators #content .contentPanel { - font-size: 15px; - padding-left: 0; -} - -.form-group.required label:after { - content:"*"; - color:red; -} diff --git a/src/environments/environment.beta.ts b/src/environments/environment.beta.ts index 99e023a..dd2306a 100644 --- a/src/environments/environment.beta.ts +++ b/src/environments/environment.beta.ts @@ -2,6 +2,8 @@ import {EnvProperties} from '../app/openaireLibrary/utils/properties/env-propert export let properties: EnvProperties = { environment: "beta", + isDashboard: true, + adminToolsPortalType: "community", enablePiwikTrack: false, useCache: false, metricsAPIURL: "https://beta.services.openaire.eu/usagestats/", @@ -36,14 +38,15 @@ export let properties: EnvProperties = { utilsService: "https://demo.openaire.eu/utils-service", vocabulariesAPI: "https://beta.services.openaire.eu/provision/mvc/vocabularies/", piwikBaseUrl: " https://analytics.openaire.eu/piwik.php?idsite=6", + registryUrl: 'https://beta.services.openaire.eu/uoa-user-management/api/registry/', loginUrl: "https://beta.services.openaire.eu/connect-dashboard-login/openid_connect_login", userInfoUrl: "https://beta.services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=", - registryUrl: 'https://beta.services.openaire.eu/uoa-user-management/api/registry/', - logoutUrl: "https://services.openaire.eu/connect-dashboard-login/openid_logout", + logoutUrl: "https://beta.services.openaire.eu/connect-dashboard-login/openid_logout", cookieDomain: ".openaire.eu", feedbackmail: "feedback@openaire.eu", feedbackmailForMissingEntities: "feedback@openaire.eu", cacheUrl: "https://demo.openaire.eu/cache/get?url=", + deleteCacheUrl: 'https://demo.openaire.eu/cache/clear', adminToolsAPIURL: "https://beta.services.openaire.eu/uoa-admin-tools/", adminToolsCommunity: "openaire", communityAPI: "https://beta.services.openaire.eu/openaire/community/", @@ -82,6 +85,6 @@ export let properties: EnvProperties = { claimsInformationLink: "https://beta.openaire.eu/linking", lastIndexUpdate: "2020-05-06", indexInfoAPI: "http://beta.services.openaire.eu/openaire/info/", - adminPortalURL: "https://beta.admin.connect.openaire.eu", - admins: ["rcd-helpdesk@openaire.eu"] + admins: ["rcd-helpdesk@openaire.eu"], + adminPortalURL: "https://beta.admin.connect.openaire.eu" }; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 0e04c43..3783bf3 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -2,6 +2,7 @@ import {EnvProperties} from '../app/openaireLibrary/utils/properties/env-propert export let properties: EnvProperties = { environment:"production", + isDashboard: true, adminToolsPortalType: "community", enablePiwikTrack: false, useCache: false, @@ -35,44 +36,32 @@ export let properties: EnvProperties = { helpdesk: "https://www.openaire.eu/support/helpdesk", helpdeskEmail: "helpdesk@openaire.eu", utilsService: "https://explore.openaire.eu/utils-service", - vocabulariesAPI:"https://services.openaire.eu/provision/mvc/vocabularies/", - piwikBaseUrl:" https://analytics.openaire.eu/piwik.php?idsite=6", - loginUrl: "https://services.openaire.eu/connect-dashbaord-login/openid_connect_login", + loginUrl: "https://services.openaire.eu/connect-dashboard-login/openid_connect_login", userInfoUrl: " https://services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=", registryUrl: 'https://services.openaire.eu/uoa-user-management/api/registry/', - logoutUrl: "https://services.openaire.eu/connect-dashbaord-login/openid_logout", - + logoutUrl: "https://services.openaire.eu/connect-dashboard-login/openid_logout", cookieDomain:".openaire.eu", - feedbackmail:"openaire.test@gmail.com", feedbackmailForMissingEntities: "feedback@openaire.eu", - cacheUrl:"https://explore.openaire.eu/cache/get?url=", deleteCacheUrl: 'https://explore.openaire.eu/cache/clear', - adminToolsAPIURL:"https://services.openaire.eu/uoa-admin-tools/", - adminToolsCommunity:"openaire", communityAPI: "https://services.openaire.eu/openaire/community/", - miningBackendURL: "https://beta.services.openaire.eu/interactive-mining", - csvLimit: 2000, pagingLimit: 20, resultsPerPage: 10, - baseLink: "", domain: "https://admin.explore.openaire.eu/", baseOpenaireLink: "https://explore.openaire.eu", - searchLinkToPublication: "/search/publication?articleId=", searchLinkToProject: "/search/project?projectId=", searchLinkToDataProvider: "/search/dataprovider?datasourceId=", searchLinkToDataset: "/search/dataset?datasetId=", searchLinkToOrganization: "/search/organization?organizationId=", - searchLinkToPublications: "/search/find/publications", searchLinkToDataProviders: "/search/find/dataproviders", searchLinkToProjects: "/search/find/projects", @@ -84,7 +73,6 @@ export let properties: EnvProperties = { searchLinkToEntityRegistriesDataProvidersTable: "/search/entity-registries-table", searchLinkToJournals: "/search/journals", searchLinkToJournalsTable: "/search/journals-table", - searchLinkToAdvancedPublications: "/search/advanced/publications", searchLinkToAdvancedProjects: "/search/advanced/projects", searchLinkToAdvancedDatasets: "/search/advanced/datasets", @@ -93,11 +81,10 @@ export let properties: EnvProperties = { searchLinkToAdvancedOrganizations: "/search/advanced/organizations", lastIndexInformationLink: "https://www.openaire.eu/aggregation-and-content-provision-workflows", showLastIndexInformationLink: false, - widgetLink: "https://www.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId=", claimsInformationLink: "https://www.openaire.eu/linking", lastIndexUpdate: "2019-07-24", indexInfoAPI: "http://services.openaire.eu/openaire/info/", - adminPortalURL: "https://admin.connect.openaire.eu", - admins: ["rcd-helpdesk@openaire.eu"] + admins: ["rcd-helpdesk@openaire.eu"], + adminPortalURL: "https://admin.connect.openaire.eu" }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 43f25b9..e6ebb1e 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -7,12 +7,13 @@ import {EnvProperties} from '../app/openaireLibrary/utils/properties/env-propert export let properties: EnvProperties = { environment: 'development', + isDashboard: true, adminToolsPortalType: "community", enablePiwikTrack: false, useCache: false, metricsAPIURL: 'https://beta.services.openaire.eu/usagestats/', framesAPIURL: 'https://beta.openaire.eu/stats3/', - claimsAPIURL: 'http://dl170.madgik.di.uoa.gr:8180/dnet-claims-service-2.0.0-SNAPSHOT/rest/claimsService/', + claimsAPIURL: 'http://scoobydoo.di.uoa.gr:8080/dnet-claims-service-2.0.0-SNAPSHOT/rest/claimsService/', statisticsAPIURL: 'https://beta.services.openaire.eu/stats-api/', statisticsFrameAPIURL: 'https://beta.openaire.eu/stats/', statisticsFrameNewAPIURL: "https://stats.madgik.di.uoa.gr/stats-api/", @@ -40,42 +41,32 @@ export let properties: EnvProperties = { helpdesk: 'https://www.openaire.eu/support/helpdesk', helpdeskEmail: 'helpdesk@openaire.eu', utilsService: 'http://mpagasas.di.uoa.gr:8000', - vocabulariesAPI: 'https://beta.services.openaire.eu/provision/mvc/vocabularies/', - piwikBaseUrl: ' https://analytics.openaire.eu/piwik.php?idsite=6', registryUrl: 'http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/registry/', - loginUrl: "http://dl170.madgik.di.uoa.gr:8180/dnet-login/openid_connect_login", - userInfoUrl: "http://dl170.madgik.di.uoa.gr:8180/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=", - logoutUrl: "https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=", + loginUrl: "http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login", + userInfoUrl: "http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=", + logoutUrl: "http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_logout", cookieDomain: '.di.uoa.gr', - feedbackmail: 'openaire.test@gmail.com', feedbackmailForMissingEntities: 'feedback@openaire.eu', cacheUrl: 'http://scoobydoo.di.uoa.gr:3000/get?url=', deleteCacheUrl: 'http://duffy.di.uoa.gr:3000/clear', - adminToolsAPIURL: 'http://duffy.di.uoa.gr:8080/uoa-admin-tools/', - adminToolsCommunity: 'openaire', communityAPI: 'https://dev-openaire.d4science.org/openaire/community/', - miningBackendURL: 'https://beta.services.openaire.eu/interactive-mining', - csvLimit: 2000, pagingLimit: 20, resultsPerPage: 10, - baseLink: "", - domain:'https://demo.openaire.eu', + domain:'https://beta.admin.connect.openaire.eu', baseOpenaireLink: 'https://beta.explore.openaire.eu', - searchLinkToPublication: '/search/publication?articleId=', searchLinkToProject: '/search/project?projectId=', searchLinkToDataProvider: '/search/dataprovider?datasourceId=', searchLinkToDataset: '/search/dataset?datasetId=', searchLinkToOrganization: '/search/organization?organizationId=', - searchLinkToPublications: '/search/find/publications', searchLinkToDataProviders: '/search/find/dataproviders', searchLinkToProjects: '/search/find/projects', @@ -87,7 +78,6 @@ export let properties: EnvProperties = { searchLinkToEntityRegistriesDataProvidersTable: '/search/entity-registries-table', searchLinkToJournals: '/search/journals', searchLinkToJournalsTable: '/search/journals-table', - searchLinkToAdvancedPublications: '/search/advanced/publications', searchLinkToAdvancedProjects: '/search/advanced/projects', searchLinkToAdvancedDatasets: '/search/advanced/datasets', @@ -96,7 +86,6 @@ export let properties: EnvProperties = { searchLinkToAdvancedOrganizations: '/search/advanced/organizations', lastIndexInformationLink: 'https://www.openaire.eu/aggregation-and-content-provision-workflows', showLastIndexInformationLink: false, - widgetLink: 'https://beta.openaire.eu/index.php?option=com_openaire&view=widget&format=raw&projectId=', claimsInformationLink: 'https://www.openaire.eu/linking-beta', lastIndexUpdate: '2019-05-16', diff --git a/src/index.html b/src/index.html index aa85824..62500c7 100644 --- a/src/index.html +++ b/src/index.html @@ -1,39 +1,35 @@ - - - - Administration Dashboard | OpenAIRE-Connect + + + + Administration Dashboard | OpenAIRE-Connect - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/material.scss b/src/material.scss index 1957d96..b5fe85b 100644 --- a/src/material.scss +++ b/src/material.scss @@ -1,9 +1,23 @@ @import '~@angular/material/theming'; @include mat-core(); -$my-app-primary: mat-palette($mat-blue-grey); -$my-app-accent: mat-palette($mat-green); -$my-app-warn: mat-palette($mat-deep-orange); - -$my-app-theme: mat-light-theme($my-app-primary, $my-app-accent, $my-app-warn); +$primary-color: ( + 0: var(--primary-color), + contrast: ( + 50: var(--contrast-color) + ) +); +$secondary-color: ( + 0: var(--secondary-color), + contrast: ( + 50: var(--contrast-color) + ) +); +$my-app-primary: mat-palette($primary-color, 0); +$my-app-accent: mat-palette($secondary-color, 0); +$my-app-theme: mat-light-theme($my-app-primary, $my-app-accent); @include angular-material-theme($my-app-theme); + +.cdk-global-overlay-wrapper, .cdk-overlay-container { + z-index: 9999!important; +} diff --git a/src/styles.css b/src/styles.css index 8f4a2d9..200aa08 100644 --- a/src/styles.css +++ b/src/styles.css @@ -2,5 +2,6 @@ @import "assets/common-assets/common/theme.css"; @import "assets/common-assets/common/custom.css"; @import "assets/common-assets/library.css"; +@import "assets/dashboard-theme/main.css"; @import "assets/css/connect-custom.css";