Skip to content

Commit 2c3a0c7

Browse files
authored
Merge pull request #9 from in2workspace/feature/login
Feature/login
2 parents 0d72fb3 + 2db4c93 commit 2c3a0c7

File tree

132 files changed

+2275
-2678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+2275
-2678
lines changed

cypress/e2e/dashboard.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('/dashboard',{
1616
cy.getBySel('browseServices').should('not.be.disabled')
1717
cy.getBySel('mainText').should('exist')
1818
cy.getBySel('publishOff').should('exist')
19-
cy.getBySel('publishOff').should('have.attr', 'href', init_config.domeRegister)
19+
cy.getBySel('publishOff').should('have.attr', 'href', init_config.isbeRegister)
2020
cy.getBySel('vServices').should('exist')
2121
cy.getBySel('vServices').should('have.text', '1 verified services')
2222
cy.getBySel('rPublishers').should('exist')

cypress/support/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export const init_config = {
1818
'matomoId': '',
1919
'matomoUrl': '',
2020
'searchEnabled': false,
21-
'domeAbout': 'https://dome-marketplace.eu/about/',
22-
'domeRegister': 'https://dome-marketplace.github.io/onboarding/',
21+
'isbeAbout': 'https://dome-marketplace.eu/about/',
22+
'isbeRegister': 'https://dome-marketplace.github.io/onboarding/',
2323
'domePublish': 'https://knowledgebase.dome-marketplace.org/shelves/company-onboarding-process',
2424
'purchaseEnabled': false,
2525
'defaultId': 'urn:ngsi-ld:catalog:32828e1d-4652-4f4c-b13e-327450ce83c6'

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const config: Config = {
9696

9797
// Line to handle ES modules
9898
transformIgnorePatterns: [
99-
"node_modules/(?!@angular|@ngx-translate/core|@fortawesome/angular-fontawesome|ngx-markdown|@ctrl/ngx-emoji-mart|ngx-file-drop)"
99+
"node_modules/(?!@angular|@ngx-translate/core|@fortawesome/angular-fontawesome|ngx-markdown|@ctrl/ngx-emoji-mart|ngx-file-drop|angular-auth-oidc-client)"
100100
],
101101

102102
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@ngx-translate/core": "^15.0.0",
4040
"@ngx-translate/http-loader": "^8.0.0",
4141
"@types/tailwindcss": "^3.1.0",
42+
"angular-auth-oidc-client": "^19.0.2",
4243
"currencies.json": "^1.0.2",
4344
"fast-average-color": "^9.4.0",
4445
"flowbite": "^1.8.1",

src/app/app-config-factory.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { MatomoInitializerService } from 'ngx-matomo-client';
2-
import { AppInitService } from './services/app-init.service'; // Adjust path as necessary
3-
import { inject } from '@angular/core';
2+
import { environment } from 'src/environments/environment';
43

5-
export function appConfigFactory(appInitService: AppInitService, matomoInitializer: MatomoInitializerService): () => Promise<any> {
4+
export function appConfigFactory(matomoInitializer: MatomoInitializerService) {
65
return () => {
7-
return appInitService.init().then(conf => {
8-
const matomoConfigOptions = {
9-
siteId: conf.matomoId,
10-
trackerUrl: conf.matomoUrl
11-
}
12-
matomoInitializer.initializeTracker(matomoConfigOptions)
13-
});
14-
}
15-
}
6+
const siteId = environment.MATOMO_SITE_ID;
7+
const trackerUrl = environment.MATOMO_TRACKER_URL;
8+
9+
if (siteId && trackerUrl) {
10+
matomoInitializer.initializeTracker({
11+
siteId,
12+
trackerUrl
13+
});
14+
}
15+
};
16+
}

src/app/app.component.ts

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import {Component, OnInit} from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
22
import { initFlowbite } from 'flowbite';
33
import { TranslateService } from '@ngx-translate/core';
4-
import {LocalStorageService} from "./services/local-storage.service";
5-
import {EventMessageService} from "./services/event-message.service";
6-
import { NavigationEnd, Router, RouterOutlet } from '@angular/router';
7-
import { LoginInfo } from 'src/app/models/interfaces';
8-
import { RefreshLoginServiceService } from "src/app/services/refresh-login-service.service";
9-
import * as moment from 'moment';
4+
import { LocalStorageService } from './services/local-storage.service';
5+
import { Router, NavigationEnd, RouterOutlet } from '@angular/router';
106
import { FooterComponent } from './shared/footer/footer.component';
117
import { HeaderComponent } from './shared/header/header.component';
12-
8+
import { AuthService } from './guard/auth.service';
139

1410
@Component({
1511
selector: 'app-root',
@@ -22,59 +18,35 @@ export class AppComponent implements OnInit {
2218
title = 'ISBE Catalog';
2319
showPanel = false;
2420

25-
constructor(private readonly translate: TranslateService,
26-
private readonly localStorage: LocalStorageService,
27-
private readonly eventMessage: EventMessageService,
28-
private readonly router: Router,
29-
private readonly refreshApi: RefreshLoginServiceService) {
21+
constructor(
22+
private readonly translate: TranslateService,
23+
private readonly localStorage: LocalStorageService,
24+
private readonly router: Router,
25+
private readonly auth: AuthService
26+
) {
27+
// Idioma
3028
this.translate.addLangs(['en', 'es']);
3129
this.translate.setDefaultLang('es');
32-
let currLang = this.localStorage.getItem('current_language')
33-
if(!currLang || currLang == null) {
34-
this.localStorage.setItem('current_language', 'es');
35-
this.translate.use('es');
36-
} else {
37-
this.translate.use(currLang);
38-
}
39-
if(!this.localStorage.getObject('selected_categories'))
30+
const currLang = this.localStorage.getItem('current_language');
31+
this.translate.use(currLang ?? 'es');
32+
33+
if (!this.localStorage.getObject('selected_categories')) {
4034
this.localStorage.setObject('selected_categories', []);
35+
}
4136
}
4237

4338
ngOnInit(): void {
4439
initFlowbite();
45-
if(!this.localStorage.getObject('selected_categories'))
40+
if (!this.localStorage.getObject('selected_categories')) {
4641
this.localStorage.setObject('selected_categories', []);
47-
if(!this.localStorage.getObject('cart_items'))
48-
this.localStorage.setObject('cart_items', []);
49-
if(!this.localStorage.getObject('login_items'))
50-
this.localStorage.setObject('login_items', {});
51-
this.eventMessage.messages$.subscribe(ev => {
52-
if(ev.type === 'LoginProcess') {
53-
this.refreshApi.stopInterval();
54-
let info = ev.value as LoginInfo;
55-
56-
console.log('STARTING INTERVAL')
57-
console.log(info.expire)
58-
console.log(((info.expire - moment().unix()) - 4))
59-
60-
this.refreshApi.startInterval(((info.expire - moment().unix())-4)*1000, ev);
61-
}
62-
})
63-
let aux = this.localStorage.getObject('login_items') as LoginInfo;
64-
if(JSON.stringify(aux) === '{}'){
65-
//this.siopInfo.getSiopInfo().subscribe((data)=>{
66-
// environment.SIOP_INFO = data
67-
//})
6842
}
69-
else if (((aux.expire - moment().unix())-4) > 0) {
70-
this.refreshApi.stopInterval();
71-
this.refreshApi.startInterval(((aux.expire - moment().unix())-4)*1000, aux);
72-
console.log('token')
73-
console.log(aux.token)
43+
if (!this.localStorage.getObject('cart_items')) {
44+
this.localStorage.setObject('cart_items', []);
7445
}
46+
7547
this.router.events.subscribe(event => {
7648
if (event instanceof NavigationEnd) {
77-
window.scrollTo({ top: 0, behavior: 'smooth' }); // or just window.scrollTo(0, 0);
49+
window.scrollTo({ top: 0, behavior: 'smooth' });
7850
}
7951
});
8052
}

src/app/app.routes.ts

Lines changed: 86 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
import { NgModule } from '@angular/core';
12
import { RouterModule, Routes } from '@angular/router';
3+
24
import { DashboardComponent } from './pages/dashboard/dashboard.component';
3-
import { SearchComponent } from "./pages/search/search.component";
4-
import { ProductDetailsComponent } from "./pages/product-details/product-details.component";
5-
import { SearchCatalogComponent } from "./pages/search-catalog/search-catalog.component";
6-
import { CatalogsComponent } from "./pages/catalogs/catalogs.component";
7-
import { UserProfileComponent } from "./pages/user-profile/user-profile.component";
8-
import { SellerOfferingsComponent } from "./pages/seller-offerings/seller-offerings.component";
9-
import { AdminComponent } from "./pages/admin/admin.component";
10-
import { NgModule } from '@angular/core';
5+
import { SearchComponent } from './pages/search/search.component';
6+
import { ProductDetailsComponent } from './pages/product-details/product-details.component';
7+
import { SearchCatalogComponent } from './pages/search-catalog/search-catalog.component';
8+
import { CatalogsComponent } from './pages/catalogs/catalogs.component';
9+
import { UserProfileComponent } from './pages/user-profile/user-profile.component';
10+
import { SellerOfferingsComponent } from './pages/seller-offerings/seller-offerings.component';
11+
import { AdminComponent } from './pages/admin/admin.component';
1112
import { AboutDomeComponent } from './pages/about-dome/about-dome.component';
1213
import { CheckoutComponent } from './pages/checkout/checkout.component';
1314
import { ContactUsFormComponent } from './pages/contact-us/contact-us-form.component';
@@ -17,80 +18,90 @@ import { ProductInventoryComponent } from './pages/product-inventory/product-inv
1718
import { ProductOrdersComponent } from './pages/product-orders/product-orders.component';
1819
import { ShoppingCartComponent } from './pages/shopping-cart/shopping-cart.component';
1920
import { UsageSpecsComponent } from './pages/usage-specs/usage-specs.component';
21+
2022
import { environment } from 'src/environments/environment';
2123
import { AuthGuard } from './guard/auth.guard';
2224

23-
2425
export const routes: Routes = [
26+
{ path: 'dashboard', component: DashboardComponent },
27+
{ path: 'about', component: AboutDomeComponent ,
28+
canActivate: [AuthGuard],
29+
data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
30+
},
31+
{ path: 'search', component: SearchComponent },
32+
{ path: 'search/:id', component: ProductDetailsComponent },
33+
{ path: 'org-details/:id', component: OrganizationDetailsComponent },
34+
35+
{ path: 'search/catalogue/:id', component: SearchCatalogComponent ,
36+
canActivate: [AuthGuard],
37+
data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
38+
},
39+
{ path: 'catalogues',
40+
component: CatalogsComponent ,
41+
canActivate: [AuthGuard],
42+
data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
43+
},
2544
{
26-
path: 'dashboard',
27-
component: DashboardComponent
28-
},
29-
{
30-
path: 'about',
31-
component: AboutDomeComponent
32-
},
33-
{
34-
path: 'search',
35-
component: SearchComponent
36-
},
37-
{ path: 'search/:id',
38-
component: ProductDetailsComponent
39-
},
40-
{ path: 'org-details/:id',
41-
component: OrganizationDetailsComponent
42-
},
43-
{ path: 'search/catalogue/:id',
44-
component: SearchCatalogComponent
45-
},
46-
{ path: 'catalogues',
47-
component: CatalogsComponent
48-
},
49-
{ path: 'shopping-cart',
45+
path: 'shopping-cart',
5046
component: ShoppingCartComponent,
51-
canActivate: [AuthGuard], data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
52-
},
53-
{ path: 'checkout',
54-
component: CheckoutComponent,
55-
canActivate: [AuthGuard], data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
56-
},
57-
{ path: 'product-inventory',
47+
canActivate: [AuthGuard],
48+
data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
49+
},
50+
{
51+
path: 'checkout',
52+
component: CheckoutComponent,
53+
canActivate: [AuthGuard],
54+
data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
55+
},
56+
57+
{
58+
path: 'product-inventory',
5859
component: ProductInventoryComponent,
59-
//canActivate: [AuthGuard], data: { roles: [] }
60-
},
61-
{ path: 'product-inventory/:id',
62-
component: ProductInvDetailComponent
63-
},
64-
{ path: 'profile',
60+
canActivate: [AuthGuard],
61+
data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
62+
},
63+
{ path: 'product-inventory/:id', component: ProductInvDetailComponent,
64+
canActivate: [AuthGuard],
65+
data: { roles: [], is_isbe: environment.ISBE_CATALOGUE } },
66+
{
67+
path: 'profile',
6568
component: UserProfileComponent,
66-
//canActivate: [AuthGuard], data: { roles: ['individual','orgAdmin'] }
67-
},
68-
{ path: 'my-offerings',
69+
canActivate: [AuthGuard],
70+
data: { roles: ['individual', 'orgAdmin'] }
71+
},
72+
{
73+
path: 'my-offerings',
6974
component: SellerOfferingsComponent,
70-
////canActivate: [AuthGuard], data: { roles: ['seller'] }
71-
},
72-
{ path: 'admin',
75+
canActivate: [AuthGuard],
76+
data: { roles: ['seller'] }
77+
},
78+
{
79+
path: 'admin',
7380
component: AdminComponent,
74-
////canActivate: [AuthGuard], data: { roles: ['admin', 'certifier'] }
75-
},
76-
{ path: 'contact-us',
77-
component: ContactUsFormComponent
78-
},
79-
{ path: 'product-orders',
80-
component: ProductOrdersComponent,
81-
canActivate: [AuthGuard], data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
82-
},
83-
{ path: 'usage-spec',
84-
component: UsageSpecsComponent,
85-
canActivate: [AuthGuard], data: { roles: ['seller'], is_isbe: environment.ISBE_CATALOGUE }
86-
},
87-
{ path: '**', redirectTo: 'dashboard', pathMatch: 'full' },
88-
]
89-
90-
@NgModule({
91-
imports: [RouterModule.forRoot(routes)],
92-
exports: [RouterModule]
93-
})
94-
export class AppRoutingModule { }
95-
96-
81+
canActivate: [AuthGuard],
82+
data: { roles: ['admin', 'certifier'] }
83+
},
84+
{ path: 'contact-us', component: ContactUsFormComponent ,
85+
canActivate: [AuthGuard],
86+
data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
87+
},
88+
{
89+
path: 'product-orders',
90+
component: ProductOrdersComponent,
91+
canActivate: [AuthGuard],
92+
data: { roles: [], is_isbe: environment.ISBE_CATALOGUE }
93+
},
94+
{
95+
path: 'usage-spec',
96+
component: UsageSpecsComponent,
97+
canActivate: [AuthGuard],
98+
data: { roles: ['seller'], is_isbe: environment.ISBE_CATALOGUE }
99+
},
100+
{ path: '**', redirectTo: 'dashboard', pathMatch: 'full' },
101+
];
102+
103+
@NgModule({
104+
imports: [RouterModule.forRoot(routes, { scrollPositionRestoration: 'enabled' })],
105+
exports: [RouterModule],
106+
})
107+
export class AppRoutingModule {}

0 commit comments

Comments
 (0)