Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .dev.env
Binary file not shown.
2 changes: 0 additions & 2 deletions .github/workflows/CD-time-tracker-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
CLIENT_ID: ${{ secrets.client_id }}
CLIENT_URL: ${{ secrets.client_url }}
STACK_EXCHANGE_ID: ${{ secrets.stack_exchange_id }}
AUTH_URL: ${{ secrets.AUTH_URL }}
AUTH_APP_NAME: ${{ secrets.AUTH_APP_NAME }}
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }}
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }}
run: |
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/CI-time-tracker-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ jobs:
SCOPES: ${{ secrets.SCOPES }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_URL : ${{ secrets.CLIENT_URL }}
AUTH_URL: ${{ secrets.AUTH_URL }}
AUTH_APP_NAME: ${{ secrets.AUTH_APP_NAME }}
STACK_EXCHANGE_ID: ${{ secrets.STACK_EXCHANGE_ID }}
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }}
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/time-tracker-ui-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ jobs:
with:
ssh-private-key: ${{ secrets.INFRA_TERRAFORM_MODULES_SSH_PRIV_KEY }}

- name: Unlock DEV secrets
uses: sliteteam/[email protected]
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY_DEFAULT }}

- name: build docker
run: make build

- name: Running tests
run: |
chmod -R 777 ./$home
make test
- name: Generate coverage report
env:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cleanup: ## Delete image timetracker_ui

.PHONY: run
run: ## Execute timetracker_ui dev docker containe.
docker-compose --env-file=.dev.env up -d timetracker_ui
docker-compose --env-file=.dev.env up -d timetracker_ui

.PHONY: logs
logs: ## Show logs of timetracker_ui.
Expand All @@ -41,7 +41,7 @@ remove: ## Delete container timetracker_ui.
.PHONY: test
test: ## Run all tests on docker container timetracker_ui at the CLI.
docker-compose build timetracker_ui_test
docker-compose --env-file=.dev.env up -d timetracker_ui_test
docker-compose up -d timetracker_ui_test
docker logs -f timetracker_ui_test

.PHONY: testdev
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ In project path, open your favourite command line and run `npm install` in order

# Prepare your environment

### **Local DNS Configuration**

To test the application in a local environment please modify you `/etc/hosts` on Linux/Mac. In Windows `C:\Windows\System32\Drivers\etc\hosts` and add this line:
```text
127.0.0.1 timetracker-dev.ioet.com
```

### Set environment variables
**1**. Using GPG create your key by running this command in your favourite command shell: `gpg --generate-key`.

Expand Down
4 changes: 0 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ services:
timetracker_ui:
container_name: timetracker_ui
image: timetracker_ui
env_file:
- .dev.env
build:
context: .
dockerfile: ./Docker/Dockerfile.dev
Expand All @@ -16,8 +14,6 @@ services:
API_URL: ${API_URL}
CLIENT_ID: ${CLIENT_ID}
CLIENT_URL: ${CLIENT_URL}
AUTH_URL: ${AUTH_URL}
AUTH_APP_NAME: ${AUTH_APP_NAME}
SCOPES: ${SCOPES}
STACK_EXCHANGE_ID: ${STACK_EXCHANGE_ID}
STACK_EXCHANGE_ACCESS_TOKEN: ${STACK_EXCHANGE_ACCESS_TOKEN}
Expand Down
2 changes: 0 additions & 2 deletions scripts/populate-keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ echo "API_URL='$API_URL'" >> .env
echo "AUTHORITY='$AUTHORITY'" >> .env
echo "CLIENT_ID='$CLIENT_ID'" >> .env
echo "CLIENT_URL='$CLIENT_URL'" >> .env
echo "AUTH_URL='$AUTH_URL'" >> .env
echo "AUTH_APP_NAME='$AUTH_APP_NAME'" >> .env
echo "SCOPES='$SCOPES'" >> .env
echo "STACK_EXCHANGE_ID='$STACK_EXCHANGE_ID'" >> .env
echo "STACK_EXCHANGE_ACCESS_TOKEN='$STACK_EXCHANGE_ACCESS_TOKEN'" >> .env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ActivityService {
constructor(private http: HttpClient) {}

getActivities(): Observable<Activity[]> {
return this.http.get<Activity[]>(this.baseUrl, { withCredentials: true });
return this.http.get<Activity[]>(this.baseUrl);
}

createActivity(activityData): Observable<any> {
Expand All @@ -23,12 +23,12 @@ export class ActivityService {
tenant_id: '4225ab1e-1033-4a5f-8650-0dd4950f38c8',
};

return this.http.post(this.baseUrl, body, { withCredentials: true });
return this.http.post(this.baseUrl, body);
}

deleteActivity(acitivityId: string): Observable<any> {
const url = `${this.baseUrl}/${acitivityId}`;
return this.http.delete(url, { withCredentials: true });
return this.http.delete(url);
}

updateActivity(activityData): Observable<any> {
Expand All @@ -38,6 +38,6 @@ export class ActivityService {
...activityData,
};

return this.http.put(url, body, { withCredentials: true });
return this.http.put(url, body);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ export class ProjectTypeService {

getProjectTypes(customerId: any): Observable<ProjectType[]> {
const params = new HttpParams().set('customer_id', customerId.customerId);
return this.http.get<ProjectType[]>(this.baseUrl, { params, withCredentials: true });
return this.http.get<ProjectType[]>(this.baseUrl, { params });
}

createProjectType(projectTypeData): Observable<any> {
return this.http.post(this.baseUrl, projectTypeData, { withCredentials: true });
return this.http.post(this.baseUrl, projectTypeData);
}

deleteProjectType(projectTypeId: string): Observable<any> {
const url = `${this.baseUrl}/${projectTypeId}`;
return this.http.delete(url, { withCredentials: true });
return this.http.delete(url);
}

updateProjectType(projectTypeData): Observable<any> {
const url = `${this.baseUrl}/${projectTypeData.id}`;
return this.http.put(url, projectTypeData, { withCredentials: true });
return this.http.put(url, projectTypeData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export class ProjectService {

getProjects(customerId: any): Observable<Project[]> {
const params = new HttpParams().set('customer_id', customerId.customerId);
return this.http.get<Project[]>(this.url, { params, withCredentials: true });
return this.http.get<Project[]>(this.url, { params });
}

getAllProjects(): Observable<Project[]> {
return this.http.get<Project[]>(this.url, { withCredentials: true });
return this.http.get<Project[]>(this.url);
}

getRecentProjects(): Observable<Project[]> {
return this.http.get<Project[]>(`${this.url}/recent`, { withCredentials: true });
return this.http.get<Project[]>(`${this.url}/recent`);
}

createProject(projectData): Observable<any> {
return this.http.post<Project[]>(this.url, projectData, { withCredentials: true });
return this.http.post<Project[]>(this.url, projectData);
}

updateProject(projectData): Observable<any> {
Expand All @@ -39,12 +39,12 @@ export class ProjectService {
projectData.status = 1;
}
}
return this.http.put(`${this.url}/${id}`, projectData, { withCredentials: true });
return this.http.put(`${this.url}/${id}`, projectData);
}

deleteProject(projectId: string): Observable<any> {
return this.isDevelopmentOrProd
? this.http.put(`${this.url}/${projectId}`, { status: 0 })
: this.http.delete(`${this.url}/${projectId}`, { withCredentials: true });
: this.http.delete(`${this.url}/${projectId}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ export class CustomerService {
constructor(private http: HttpClient) {}

createCustomer(customerData): Observable<any> {
return this.http.post(this.baseUrl, customerData, { withCredentials: true });
return this.http.post(this.baseUrl, customerData);
}

getCustomers(): Observable<any> {
return this.http.get(this.baseUrl, { withCredentials: true });
return this.http.get(this.baseUrl);
}

deleteCustomer(customerId: string): Observable<any> {
const url = `${this.baseUrl}/${customerId}`;
return this.http.delete(url, { withCredentials: true });
return this.http.delete(url);
}

updateCustomer(customerData): Observable<any> {
const url = `${this.baseUrl}/${customerData.id}`;
return this.http.put(url, customerData, { withCredentials: true });
return this.http.put(url, customerData);
}
}
11 changes: 10 additions & 1 deletion src/app/modules/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ <h3>Please log in</h3>
<button (click)="login() " class="btn btn-primary">login</button>
</div>
<div *ngIf="!isProduction">
<button class="btn btn-primary" (click)="loginAuth()">Login</button>
<div
id="g_id_onload"
[attr.data-client_id]="cliendId"
data-callback="handleCredentialResponse">
</div>
<div
class="g_id_signin"
data-theme="filled_blue"
data-type="standard">
</div>
</div>
</div>
10 changes: 0 additions & 10 deletions src/app/modules/login/login.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,6 @@ describe('LoginComponent', () => {
expect(component).toBeTruthy();
});

it('should set local storage when the component is initialized and is not legacy production', inject([Router], (router: Router) => {
component.isProduction = false;
spyOn(loginService, 'getUser').and.returnValue(of(userTest));
spyOn(loginService, 'setLocalStorage');

component.ngOnInit();

expect(loginService.setLocalStorage).toHaveBeenCalled();
}));

it('should sign up or login with google if is not logged-in into the app on Production', inject([Router], (router: Router) => {
spyOn(azureAdB2CService, 'isLogin').and.returnValue(false);
spyOn(azureAdB2CService, 'setCookies').and.returnValue();
Expand Down
61 changes: 48 additions & 13 deletions src/app/modules/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ declare global {
export class LoginComponent implements OnInit {
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;
cliendId = CLIENT_URL;
authUrl = environment.authUrl;
authAppName = environment.authAppName;
auth2: any;


Expand All @@ -36,16 +34,57 @@ export class LoginComponent implements OnInit {
private ngZone?: NgZone
) {}


googleAuthSDK() {
const sdkLoaded = 'googleSDKLoaded';
const gapi = 'gapi';

(window as any)[sdkLoaded] = () => {
(window as any)[gapi].load('auth2', () => {
this.auth2 = ( window as any)[gapi].auth2.init({
client_id: this.cliendId,
plugin_name: 'login',
cookiepolicy: 'single_host_origin',
scope: 'profile email'
});
});
};

(async (d, s, id) => {
const keyGoogle = 'src';
const gjs = d.getElementsByTagName(s)[1];
let js = gjs;
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js[keyGoogle] = 'https://accounts.google.com/gsi/client';
gjs.parentNode.insertBefore(js, gjs);
})(document, 'script', 'async defer');
}

ngOnInit() {
if (!this.isProduction) {
this.loginService.getUser(null).subscribe((resp) => {
this.loginService.setCookies();
const tokenObject = JSON.stringify(resp);
const tokenJson = JSON.parse(tokenObject);
this.loginService.setLocalStorage('user', tokenJson.token);
this.ngZone.run(() => this.router.navigate(['']));

this.googleAuthSDK();
if (this.isProduction && this.azureAdB2CService.isLogin()) {
this.router.navigate(['']);
} else {
this.loginService.isLogin().subscribe(isLogin => {
if (isLogin) {
this.router.navigate(['']);
}
});
}
window.handleCredentialResponse = (response) => {
const {credential = ''} = response;
this.featureToggleCookiesService.setCookies();
this.loginService.setLocalStorage('idToken', credential);
this.loginService.getUser(credential).subscribe((resp) => {
this.loginService.setCookies();
const tokenObject = JSON.stringify(resp);
const tokenJson = JSON.parse(tokenObject);
this.loginService.setLocalStorage('user', tokenJson.token);
this.ngZone.run(() => this.router.navigate(['']));
});
};
}

login(): void {
Expand All @@ -67,8 +106,4 @@ export class LoginComponent implements OnInit {
}
}

loginAuth() {
window.location.href = `${this.authUrl}/authn/login/${this.authAppName}`;
}

}
11 changes: 2 additions & 9 deletions src/app/modules/login/services/login.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { TestBed } from '@angular/core/testing';
import { JwtHelperService } from '@auth0/angular-jwt';
import { SocialAuthService } from 'angularx-social-login';
import { CookieService } from 'ngx-cookie-service';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';

import { LoginService } from './login.service';
Expand All @@ -24,11 +23,11 @@ describe('LoginService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, RouterTestingModule.withRoutes([])],
imports: [HttpClientTestingModule],
providers: [
{ providers: CookieService, useValue: cookieStoreStub },
{ provide: SocialAuthService, useValue: socialAuthServiceStub },
{ provide: HttpClient, useValue: httpClientSpy },
{ provide: HttpClient, useValue: httpClientSpy }
],
});
service = TestBed.inject(LoginService);
Expand Down Expand Up @@ -123,19 +122,13 @@ describe('LoginService', () => {

it('should logout with social angularx-social-login', () => {
spyOn(cookieService, 'deleteAll').and.returnValue();
spyOn(service, 'invalidateSessionCookie').and.returnValue(of(true));

service.logout();

expect(localStorage.clear).toHaveBeenCalled();
expect(cookieService.deleteAll).toHaveBeenCalled();
});

it('should return an http observable when call invalidateSessionCooke', () => {
const result = service.invalidateSessionCookie();
expect(result).toBeDefined();
});

it('should call cookieService when app is isLegacyProd', () => {
service.isLegacyProd = true;
service.localStorageKey = 'user2';
Expand Down
Loading