Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cd6a676
Innecesary env files deleted
Jul 6, 2022
9dd2d22
New changes to env files
Jul 6, 2022
5cd8097
Merge from master
Jul 6, 2022
cee7a67
Add 1 git-crypt collaborator
Jul 6, 2022
37395a4
Add 1 git-crypt collaborator
Jul 6, 2022
64715d8
Add 2 git-crypt collaborators
Jul 6, 2022
04b36bf
New keys and env variables added
Jul 6, 2022
46713de
env files added & modified
Jul 7, 2022
3cbea5e
Merge from master
Jul 8, 2022
dd2e28c
Make run now uses .dev.env
Jul 8, 2022
5fbd76a
Pipeline modified
Jul 8, 2022
417fb0f
is the .env needed?
rodolfoIOET Jul 8, 2022
f98d359
using encrypted .stage.env
rodolfoIOET Jul 8, 2022
d829238
load secrets
rodolfoIOET Jul 8, 2022
f304803
adding env variables
rodolfoIOET Jul 8, 2022
d798597
scopes cannot be empty
rodolfoIOET Jul 8, 2022
71b814c
use env
rodolfoIOET Jul 8, 2022
e0557f3
using env var
rodolfoIOET Jul 8, 2022
09204b3
using env file
rodolfoIOET Jul 8, 2022
eaa95fe
adding mask
rodolfoIOET Jul 8, 2022
38b3cd8
using docker buildkit
rodolfoIOET Jul 11, 2022
c9a8046
only on tags
rodolfoIOET Jul 11, 2022
ac78df4
using buildkit directly
rodolfoIOET Jul 11, 2022
9f8f2f3
using dash source
rodolfoIOET Jul 11, 2022
4f78988
docker buildkit
rodolfoIOET Jul 11, 2022
c6ab1b4
missing folders added
rodolfoIOET Jul 11, 2022
82f58a6
nginx fix
rodolfoIOET Jul 11, 2022
0b5f089
fixing secrets
rodolfoIOET Jul 11, 2022
59dbb51
problem with double qoutes
rodolfoIOET Jul 11, 2022
6506028
fixing quotes in .stage.env
rodolfoIOET Jul 11, 2022
a3e3082
fixing secrets
rodolfoIOET Jul 11, 2022
ab39a18
loading to env
rodolfoIOET Jul 11, 2022
58f2706
quotes fixed
rodolfoIOET Jul 11, 2022
ac3c03d
replacing \r
rodolfoIOET Jul 12, 2022
103f4b4
fixing trailing \n
rodolfoIOET Jul 12, 2022
0a56877
one line expose
rodolfoIOET Jul 12, 2022
8ba2a27
fixing endpoint url
rodolfoIOET Jul 12, 2022
b7693a3
removing unnecessary jobs
rodolfoIOET Jul 12, 2022
1b62b4b
update creds
rodolfoIOET Jul 12, 2022
6b3a57c
adding with space at the end of the file
rodolfoIOET Jul 13, 2022
80278d5
merging from master
rodolfoIOET Jul 18, 2022
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.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ Makefile
.gitignore
*keys.ts
*.keys.json
.git-crypt
.git
Dockerfile
14 changes: 7 additions & 7 deletions .github/workflows/time-tracker-ui-cd-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
ARM_TENANT_ID: ${{secrets.TF_ARM_TENANT_ID}}

steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -29,16 +30,15 @@ jobs:
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

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

- name: Build the docker image
run: |-
docker build \
--target production -t timetracker_ui \
--build-arg API_URL="${{secrets.API_URL_STAGE}}" \
--build-arg AUTHORITY="${{secrets.AUTHORITY}}" \
--build-arg CLIENT_ID="${{secrets.CLIENT_ID_STAGE}}" \
--build-arg CLIENT_URL="${{ secrets.CLIENT_URL_STAGE}}" \
--build-arg SCOPES="${{secrets.SCOPES}}" \
--build-arg AZURE_APP_CONFIGURATION_CONNECTION_STRING="${{secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING}}" \
--target production -t timetracker_ui \
.

- name: Publish docker image to stage azure container registry
Expand Down
18 changes: 2 additions & 16 deletions .github/workflows/time-tracker-ui-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
runs-on: ubuntu-latest
env:
WORKING_DIR: infrastructure/
DB_CONNECTION: ${{ secrets.DB_CONNECTION }}
ARM_CLIENT_ID: ${{secrets.TF_ARM_CLIENT_ID}}
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
Expand All @@ -30,20 +29,6 @@ jobs:
with:
ssh-private-key: ${{ secrets.INFRA_TERRAFORM_MODULES_SSH_PRIV_KEY }}

- name: Inject Secrets
env:
AUTHORITY: ${{ secrets.AUTHORITY }}
API_URL: ${{ secrets.STAGE_API_URL}}
SCOPES: ${{ secrets.SCOPES }}
CLIENT_ID: ${{ secrets.STAGE_CLIENT_ID }}
CLIENT_URL: ${{ secrets.STAGE_CLIENT_URL }}
STACK_EXCHANGE_ID: ${{ secrets.STAGE_STACK_EXCHANGE_ID }}
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STAGE_STACK_EXCHANGE_ACCESS_TOKEN }}
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
run: |
chmod +x ./scripts/populate-keys.sh
sh ./scripts/populate-keys.sh

- name: build docker
run: make build

Expand Down Expand Up @@ -81,7 +66,8 @@ jobs:

- name: Terraform Plan Prod
id: plan-prod
run: terraform plan -var-file=${{ env.TF_WORKSPACE }}.tfvars -var image_tag=latest -no-color
# run: terraform plan -var-file=${{ env.TF_WORKSPACE }}.tfvars -var image_tag=latest -no-color
run: echo "Disabled for now up to restructure infra tiers"
continue-on-error: true
working-directory: ./${{ env.WORKING_DIR }}
env:
Expand Down
Binary file modified .prod.env
Binary file not shown.
Binary file modified .stage.env
Binary file not shown.
2 changes: 0 additions & 2 deletions Docker/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ RUN useradd -ms /bin/bash ${USERNAME}

WORKDIR ${HOME}/time-tracker-ui
COPY . .
RUN rm -f .env
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
RUN chmod -R 777 ${HOME}/time-tracker-ui

USER ${USERNAME}
COPY .env .
EXPOSE 4200
EXPOSE 9876
RUN npm cache clean --force && npm install
Expand Down
55 changes: 15 additions & 40 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,22 @@
FROM node:14 AS building

ENV USERNAME timetracker
ENV HOME /home/${USERNAME}
RUN useradd -ms /bin/bash ${USERNAME}
WORKDIR ${HOME}/time-tracker-ui
COPY . .
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
RUN chmod -R 777 ${HOME}/time-tracker-ui

USER ${USERNAME}
FROM node:14-alpine AS building
WORKDIR /app
# ENV USERNAME timetracker
# ENV HOME /home/${USERNAME}
# RUN useradd -ms /bin/bash ${USERNAME}
# WORKDIR ${HOME}/time-tracker-ui
COPY . /app
# RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
# RUN chmod -R 777 ${HOME}/time-tracker-ui
# USER ${USERNAME}
RUN npm cache clean --force && npm install
EXPOSE 4200
EXPOSE 9876
ARG API_URL
ARG AUTHORITY
ARG CLIENT_ID
ARG CLIENT_URL
ARG SCOPES
ARG AZURE_APP_CONFIGURATION_CONNECTION_STRING

RUN API_URL=${API_URL} \
AUTHORITY=${AUTHORITY} \
CLIENT_ID=${CLIENT_ID} \
CLIENT_URL=${CLIENT_URL} \
SCOPES=${SCOPES} \
AZURE_APP_CONFIGURATION_CONNECTION_STRING=${AZURE_APP_CONFIGURATION_CONNECTION_STRING}

RUN npm run build

EXPOSE 4200 9876
RUN source .stage.env && npm run build
# >> scrt &&
#

FROM nginx:1.21 AS production

ENV USERNAME app
RUN useradd -ms /bin/bash ${USERNAME}

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=building /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html
COPY .env /usr/share/nginx/html
RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
chown -R ${USERNAME}:${USERNAME} /var/log/nginx && \
chown -R ${USERNAME}:${USERNAME} /etc/nginx/conf.d
RUN touch /var/run/nginx.pid && chown -R ${USERNAME}:${USERNAME} /var/run/nginx.pid

COPY --from=building /app/dist/time-tracker /usr/share/nginx/html
# FIXME: Actually if we can deploy to azure in port 80 we need a root user
# Maybe we can refactor this dockerfile to use root user directly this is not a good approach y
# security terms. It's a good practice to have rootless in containers so for this
Expand Down
2 changes: 1 addition & 1 deletion 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 up -d timetracker_ui
docker-compose --env-file=.dev.env up -d timetracker_ui

.PHONY: logs
logs: ## Show logs of timetracker_ui.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@
},
"repositoryUrl": "https://github.com/ioet/time-tracker-ui.git"
}
}
}
1 change: 0 additions & 1 deletion scripts/populate-keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
> .env
echo "API_URL='$API_URL'" >> .env
echo "AUTHORITY='$AUTHORITY'" >> .env
echo "API_URL='$API_URL'" >> .env
echo "CLIENT_ID='$CLIENT_ID'" >> .env
echo "CLIENT_URL='$CLIENT_URL'" >> .env
echo "SCOPES='$SCOPES'" >> .env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('ActivityManagement Selectors', () => {
description: 'Some description'
},
];

const activitiesOrdered = [
{
id: '002',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ describe('Reports Page', () => {
});

const params = [
{url: 'http://example.com', expected_value: true},
{url: 'https://example.com', expected_value: true},
{url: 'no-url-example', expected_value: false}
{ url: 'http://example.com', expected_value: true },
{ url: 'https://example.com', expected_value: true },
{ url: 'no-url-example', expected_value: false }
];
params.map((param) => {
it(`Given the url ${param.url}, the method isURL should return ${param.expected_value}`, () => {

expect(component.isURL(param.url)).toEqual(param.expected_value);
expect(component.isURL(param.url)).toEqual(param.expected_value);
});
});

Expand All @@ -170,15 +170,15 @@ describe('Reports Page', () => {
});

it('when the rerenderDataTable method is called and dtElement and dtInstance are defined, the destroy and next methods are called ',
() => {
spyOn(component.dtTrigger, 'next');
() => {
spyOn(component.dtTrigger, 'next');

component.ngAfterViewInit();
component.ngAfterViewInit();

component.dtElement.dtInstance.then( (dtInstance) => {
expect(component.dtTrigger.next).toHaveBeenCalled();
component.dtElement.dtInstance.then((dtInstance) => {
expect(component.dtTrigger.next).toHaveBeenCalled();
});
});
});

it(`When the user method is called, the emit method is called`, () => {
const userId = 'abc123';
Expand All @@ -203,8 +203,8 @@ describe('Reports Page', () => {
});

it('The sum of the data dates is equal to {"hours": 3, "minutes":20,"seconds":0}', () => {
let {hours,minutes,seconds}: TotalHours = component.sumDates(timeEntryList);
expect({hours, minutes, seconds}).toEqual({hours:3,minutes:20,seconds:0});
const { hours, minutes, seconds }: TotalHours = component.sumDates(timeEntryList);
expect({ hours, minutes, seconds }).toEqual({ hours: 3, minutes: 20, seconds: 0 });
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}`
},
],
columnDefs: [{ type: 'date', targets: 2}],
order: [[1,'asc'],[2,'desc'],[4,'desc']]
columnDefs: [{ type: 'date', targets: 2 }],
order: [[1, 'asc'], [2, 'desc'], [4, 'desc']]
};
dtTrigger: Subject<any> = new Subject();
@ViewChild(DataTableDirective, { static: false })
Expand All @@ -72,7 +72,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
resultSum: TotalHours;
dateTimeOffset: ParseDateTimeOffset;

constructor(private store: Store<EntryState>, private actionsSubject$: ActionsSubject, private storeUser: Store<User> ) {
constructor(private store: Store<EntryState>, private actionsSubject$: ActionsSubject, private storeUser: Store<User>) {
this.reportDataSource$ = this.store.pipe(select(getReportDataSource));
this.dateTimeOffset = new ParseDateTimeOffset();
}
Expand Down Expand Up @@ -128,28 +128,28 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
const durationColumnIndex = 3;
return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated;
}
sumDates(arrayData: Entry[]): TotalHours{

sumDates(arrayData: Entry[]): TotalHours {
this.resultSum = new TotalHours();
let arrayDurations= new Array();
arrayData.forEach(entry =>{
let start = moment(entry.end_date).diff(moment(entry.start_date));
arrayDurations.push(moment.utc(start).format("HH:mm:ss"));
const arrayDurations = new Array();
arrayData.forEach(entry => {
const start = moment(entry.end_date).diff(moment(entry.start_date));
arrayDurations.push(moment.utc(start).format('HH:mm:ss'));
});
let totalDurations = arrayDurations.slice(1)
.reduce((prev, cur) => {
return prev.add(cur);
},
moment.duration(arrayDurations[0]));
let daysInHours = totalDurations.days() * 24;
this.resultSum.hours=totalDurations.hours() + daysInHours;

const totalDurations = arrayDurations.slice(1)
.reduce((prev, cur) => {
return prev.add(cur);
},
moment.duration(arrayDurations[0]));
const daysInHours = totalDurations.days() * 24;
this.resultSum.hours = totalDurations.hours() + daysInHours;
this.resultSum.minutes = totalDurations.minutes();
this.resultSum.seconds = totalDurations.seconds();
return this.resultSum;
}

user(userId: string){
user(userId: string) {
this.selectedUserId.emit(userId);
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/reports/models/total-hours-report.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class TotalHours {

hours: number;
minutes: number;
seconds: number;
Expand All @@ -9,4 +9,4 @@ export class TotalHours {
this.minutes = 0;
this.seconds = 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as moment from 'moment';

export class ParseDateTimeOffset {
export class ParseDateTimeOffset {

parseDateTimeOffset(date:string, offset): string{
if(date == null || date == undefined || date == '') return 'In progress';
return moment.utc(date).utcOffset(-1*offset).format("HH:mm");
parseDateTimeOffset(date: string, offset): string {
if (date === null || date === undefined || date === '') {
return 'In progress';
}
return moment.utc(date).utcOffset(-1 * offset).format('HH:mm');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ describe('EntryFieldsComponent', () => {
description: 'Some description'
},
];

const activitiesOrdered = [
{
id: '005',
Expand Down Expand Up @@ -488,10 +488,10 @@ describe('EntryFieldsComponent', () => {
});

it('when a activity is not register in DB should show activatefocus in select activity', () => {
const activitiesMock = [{
const activitiesMock = [{
id: 'xyz',
name: 'test',
description : 'test1'
description: 'test1'
}];
const data = {
activity_id: 'xyz',
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const environment = {

export const AUTHORITY = process.env["AUTHORITY"];
export const CLIENT_ID = process.env["CLIENT_ID"];
export const CLIENT_URL = process.env["CLIENT_URL"];
export const CLIENT_URL = process.env["CLIENT_URL"].replace(/[\n\r]/g, '');
export const SCOPES = process.env["SCOPES"].split(",");
export const ITEMS_PER_PAGE = 5;
export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"];
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.prodlegacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const environment = {

export const AUTHORITY = process.env["AUTHORITY"];
export const CLIENT_ID = process.env["CLIENT_ID"];
export const CLIENT_URL = process.env["CLIENT_URL"];
export const CLIENT_URL = process.env["CLIENT_URL"].replace(/[\n\r]/g, '');
export const SCOPES = process.env["SCOPES"].split(",");
export const ITEMS_PER_PAGE = 5;
export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"];
Expand Down
Loading