Skip to content

Commit

Permalink
Restore lfooter
Browse files Browse the repository at this point in the history
Signed-off-by: Amol Sontakke <amols@proximabiz.com>
  • Loading branch information
amolsontakke3576 committed Dec 16, 2024
1 parent b1e45ef commit c4d8885
Show file tree
Hide file tree
Showing 19 changed files with 181 additions and 180 deletions.
5 changes: 4 additions & 1 deletion edge/security-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ function generateCSP(env, isDevServer) {
'https://api-gw.staging.platform.linuxfoundation.org/',
'https://api-gw.platform.linuxfoundation.org/',
'https://api.lfcla.staging.platform.linuxfoundation.org/',
'https://api.lfcla.dev.platform.linuxfoundation.org/'
'https://api.lfcla.dev.platform.linuxfoundation.org/',
'https://easycla.dev.communitybridge.org/',
'https://easycla.lfx.linuxfoundation.org/',
'https://contributor.easycla.lfx.linuxfoundation.org/'
];
let scriptSources = [SELF, UNSAFE_EVAL, UNSAFE_INLINE,
'https://cdn.dev.platform.linuxfoundation.org/lfx-header-v2.js',
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://www.linuxfoundation.org/"
},
"engines": {
"node": ">=16.0.0",
"node": ">=12.0.0",
"npm": ">=8.0.0"
},
"version": "1.0.0",
Expand Down Expand Up @@ -56,9 +56,10 @@
"@fortawesome/fontawesome-free": "^6.4.0",
"@ng-bootstrap/ng-bootstrap": "^6.1.0",
"@silvermine/serverless-plugin-cloudfront-lambda-edge": "^2.1.1",
"@linuxfoundation/lfx-ui-core": "^0.0.12",
"aws-sdk": "2.1558.0",
"@types/node": "^18.16.0",
"auth0-spa-js": "^1.6.5",
"aws-sdk": "2.1558.0",
"bootstrap": "^4.4.0",
"file-saver": "^2.0.5",
"query-string": "^6.13.8",
Expand Down
2 changes: 1 addition & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package:

provider:
name: aws
runtime: nodejs14.x
runtime: nodejs16.x
stage: ${opt:stage}
region: us-east-1 # Region can't be configurable, lambda@edge is us-east-1 only.
deploymentBucket:
Expand Down
1 change: 0 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
<app-alert></app-alert>
<router-outlet></router-outlet>
</div>

<lfx-footer></lfx-footer>
11 changes: 3 additions & 8 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/* Copyright The Linux Foundation and each contributor to CommunityBridge.
SPDX-License-Identifier: MIT */
.fix-header-margin {
transition: margin 0.3s;
margin-top: 25px;
padding: 25px 0;
min-height: calc(100vh - 167px);
&.expanded {
margin-top: 100px;
min-height: calc(100vh - 242px);
}
margin-top: 35px;
padding: 25px 0 0 0;
min-height: calc(100vh - 125px);
}
9 changes: 0 additions & 9 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// SPDX-License-Identifier: MIT

import { Component } from '@angular/core';
import { AppSettings } from './config/app-settings';
import { LfxHeaderService } from './shared/services/lfx-header.service';
import { EnvConfig } from './config/cla-env-utils';
import { environment } from 'src/environments/environment';

@Component({
Expand All @@ -26,7 +24,6 @@ export class AppComponent {
ngOnInit() {
this.mountHeader();
this.hasExpanded = true;
this.mountFooter();
}

private mountHeader(): void {
Expand All @@ -35,10 +32,4 @@ export class AppComponent {
script.setAttribute('async', 'true');
document.head.appendChild(script);
}

private mountFooter(): void {
const script = document.createElement('script');
script.setAttribute('src', EnvConfig.default[AppSettings.LFX_FOOTER]);
document.head.appendChild(script);
}
}
4 changes: 1 addition & 3 deletions src/app/config/scripts/prefetch-ssm.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// Copyright The Linux Foundation and each contributor to CommunityBridge.
// SPDX-License-Identifier: MIT

const fs = require('fs');
const RetrieveSSMValues = require('./read-ssm');
const configVarArray = ['auth0-clientId', 'auth0-domain', 'proj-console-link', 'corp-console-link', 'lfx-header', 'lfx-footer', 'corporate-v2-base', 'api-base', 'api-v4-base', 'admin-v2-base'];
const region = 'us-east-1';
const profile = process.env.AWS_PROFILE;
const stageEnv = process.env.STAGE_ENV;
const AWS_SSM_JSON_PATH = './src/app/config/cla-env-config.json';

async function prefetchSSM() {
console.log(`Start to fetch SSM values at ${stageEnv}...`);
const result = await RetrieveSSMValues(configVarArray, stageEnv, region, profile);
const result = await RetrieveSSMValues(configVarArray, stageEnv, region);
console.log('Fetching completed.');

//test for local
Expand Down
23 changes: 8 additions & 15 deletions src/app/config/scripts/read-ssm.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
// @ts-check

// Copyright The Linux Foundation and each contributor to CommunityBridge.
// SPDX-License-Identifier: MIT
const AWS = require('aws-sdk');

// @ts-check


/**
* @param {string[]} variables
* @param {string} stage
* @param {string} region
* @param {string} profile
* @returns {Promise<{ [key:string]: string}>}
*/
async function retrieveSSMValues(variables, stage, region, profile) {
async function retrieveSSMValues(variables, stage, region) {
const scopedVariables = variables.map((param) => `cla-${param}-${stage}`);
const result = await requestSSMParameters(scopedVariables, stage, region, profile);
const result = await requestSSMParameters(scopedVariables, stage, region);
const parameters = result.Parameters;
const error = result.$response.error;
if (error !== null) {
throw new Error(
`Couldn't retrieve SSM parameters for stage ${stage} in region ${region} using profile ${profile} - error ${error}`
`Couldn't retrieve SSM parameters for stage ${stage} in region ${region} - error ${error}`
);
}
const scopedParams = createParameterMap(parameters, stage);
const params = new Map();
Object.keys(scopedParams).forEach((key) => {
// console.log(`processing ${key}`);
const param = scopedParams[key];
key = key.replace('cla-', '');
key = key.replace(`-${stage}`, '');
Expand All @@ -34,7 +33,7 @@ async function retrieveSSMValues(variables, stage, region, profile) {
variables.forEach((variable) => {
if (params[variable] === undefined) {
throw new Error(
`Missing SSM parameter with name ${variable} for stage ${stage} in region ${region} using profile ${profile}`,
`Missing SSM parameter with name ${variable} for stage ${stage} in region ${region}`,
);
}
});
Expand All @@ -47,20 +46,14 @@ async function retrieveSSMValues(variables, stage, region, profile) {
* @param {string[]} variables
* @param {string} stage
* @param {string} region
* @param {string} profile
*/
async function requestSSMParameters(variables, stage, region, profile) {
console.log(`Loading AWS credentials from profile: ${profile}`)
AWS.config.credentials = new AWS.SharedIniFileCredentials({ profile });
async function requestSSMParameters(variables, stage, region) {
const ssm = new AWS.SSM({ region });
const ps = {
Names: variables,
WithDecryption: true
};
// console.log(AWS.config.credentials);
// console.log(`fetching ssm parameters: ${variables}`);
const response = await ssm.getParameters(ps).promise();
// console.log(response);
return response;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Copyright The Linux Foundation and each contributor to CommunityBridge.
SPDX-License-Identifier: MIT -->
<div class="container-fluid">
<div class="row justify-content-center align-items-center">
<div class="col-auto message">You are being redirected to the login page.</div>
</div>
<div class="container">
<div class="message">Welcome to Gerrit Window </div>
<div class="subtitle">wait ... We are trying to login LFX portal</div>
<div class="warning">If you are still viewing this screen, please <a class="link" (click)="login()">click here</a></div>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
/* Copyright The Linux Foundation and each contributor to CommunityBridge.
SPDX-License-Identifier: MIT -->*/
.row {
.message {
font-size: 18px;
text-align: center;
font-weight: bold;
}
.container {
.message {
margin-top: calc(100vh / 3);
font-size: 24px;
text-align: center;
font-weight: bold;
}

.subtitle {
font-size: 18px;
margin-top: 5px;
text-align: center;
font-weight: bold;
}

.warning {
font-size: 18px;
margin-top: 20px;
text-align: center;
}

.link {
color: #0099cc;
cursor: pointer;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
// Copyright The Linux Foundation and each contributor to CommunityBridge.
// SPDX-License-Identifier: MIT

import { Component, OnInit } from '@angular/core';
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { StorageService } from 'src/app/shared/services/storage.service';
import { AppSettings } from 'src/app/config/app-settings';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { AuthService } from 'src/app/shared/services/auth.service';
import { ClaContributorService } from 'src/app/core/services/cla-contributor.service';
import { ProjectModel } from 'src/app/core/models/project';
import { GerritUserModel } from 'src/app/core/models/gerrit';
import { AlertService } from 'src/app/shared/services/alert.service';
@Component({
selector: 'app-gerrit-dashboard',
templateUrl: './gerrit-dashboard.component.html',
styleUrls: ['./gerrit-dashboard.component.scss']
styleUrls: ['./gerrit-dashboard.component.scss'],
})
export class GerritDashboardComponent implements OnInit {
export class GerritDashboardComponent implements OnInit, AfterViewInit {
projectId: string;
contractType: string;
userId: string;

constructor(
private route: ActivatedRoute,
private storageService: StorageService,
private authService: AuthService
private authService: AuthService,
private claContributorService: ClaContributorService,
private router: Router,
private alertService: AlertService
) {
this.storageService.removeGithubItems();
}
Expand All @@ -31,7 +39,63 @@ export class GerritDashboardComponent implements OnInit {
this.storageService.setItem(AppSettings.HAS_GERRIT, true);
this.storageService.setItem(AppSettings.PROJECT_ID, this.projectId);
this.storageService.setItem(AppSettings.CONTRACT_TYPE, this.contractType);
}

ngAfterViewInit(): void {
this.authService.userProfile$.subscribe((data) => {
console.log(data);
if (data) {
this.getGerritProjectInfo();
this.getUserInfo();
} else {
this.authService.login();
}
});
}

login(){
this.authService.login();
}

getGerritProjectInfo() {
const projectId = JSON.parse(
this.storageService.getItem(AppSettings.PROJECT_ID)
);
this.claContributorService.getGerritProjectInfo(projectId).subscribe(
(response: ProjectModel) => {
this.storageService.setItem(
AppSettings.PROJECT_NAME,
response.project_name
);
this.storageService.setItem(AppSettings.PROJECT, response);
},
(exception) => {
this.alertService.error(exception);
}
);
}

getUserInfo() {
this.claContributorService.getGerritUserInfo().subscribe(
(response: GerritUserModel) => {
this.userId = response.user_id;
this.storageService.setItem(AppSettings.USER_ID, response.user_id);
this.storageService.setItem(AppSettings.USER, response);
this.redirectForGerritFlow();
},
(exception) => {
this.alertService.error(exception.error);
}
);
}

redirectForGerritFlow() {
if (this.contractType === 'individual') {
const url = '/individual-dashboard/' + this.projectId + '/' + this.userId;
this.router.navigate([url]);
} else if (this.contractType === 'corporate') {
const url = '/corporate-dashboard/' + this.projectId + '/' + this.userId;
this.router.navigate([url]);
}
}
}
Loading

0 comments on commit c4d8885

Please sign in to comment.