Skip to content

Commit f11eeee

Browse files
committed
merge from branch 87
2 parents c21ca6c + 6b3a57c commit f11eeee

File tree

15 files changed

+83
-120
lines changed

15 files changed

+83
-120
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ Makefile
66
.gitignore
77
*keys.ts
88
*.keys.json
9+
.git-crypt
10+
.git
11+
Dockerfile

.github/workflows/time-tracker-ui-cd-stage.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
1616
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
1717
ARM_TENANT_ID: ${{secrets.TF_ARM_TENANT_ID}}
18+
1819
steps:
1920
- name: Checkout
2021
uses: actions/checkout@v3
@@ -29,16 +30,15 @@ jobs:
2930
with:
3031
creds: ${{ secrets.AZURE_CREDENTIALS }}
3132

33+
- name: Unlock STAGE secrets
34+
uses: sliteteam/[email protected]
35+
env:
36+
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY_STAGE }}
37+
3238
- name: Build the docker image
3339
run: |-
3440
docker build \
35-
--target production -t timetracker_ui \
36-
--build-arg API_URL="${{secrets.API_URL_STAGE}}" \
37-
--build-arg AUTHORITY="${{secrets.AUTHORITY}}" \
38-
--build-arg CLIENT_ID="${{secrets.CLIENT_ID_STAGE}}" \
39-
--build-arg CLIENT_URL="${{ secrets.CLIENT_URL_STAGE}}" \
40-
--build-arg SCOPES="${{secrets.SCOPES}}" \
41-
--build-arg AZURE_APP_CONFIGURATION_CONNECTION_STRING="${{secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING}}" \
41+
--target production -t timetracker_ui \
4242
.
4343
4444
- name: Publish docker image to stage azure container registry

.github/workflows/time-tracker-ui-ci.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
runs-on: ubuntu-latest
1515
env:
1616
WORKING_DIR: infrastructure/
17-
DB_CONNECTION: ${{ secrets.DB_CONNECTION }}
1817
ARM_CLIENT_ID: ${{secrets.TF_ARM_CLIENT_ID}}
1918
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
2019
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
@@ -30,20 +29,6 @@ jobs:
3029
with:
3130
ssh-private-key: ${{ secrets.INFRA_TERRAFORM_MODULES_SSH_PRIV_KEY }}
3231

33-
- name: Inject Secrets
34-
env:
35-
AUTHORITY: ${{ secrets.AUTHORITY }}
36-
API_URL: ${{ secrets.STAGE_API_URL}}
37-
SCOPES: ${{ secrets.SCOPES }}
38-
CLIENT_ID: ${{ secrets.STAGE_CLIENT_ID }}
39-
CLIENT_URL: ${{ secrets.STAGE_CLIENT_URL }}
40-
STACK_EXCHANGE_ID: ${{ secrets.STAGE_STACK_EXCHANGE_ID }}
41-
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STAGE_STACK_EXCHANGE_ACCESS_TOKEN }}
42-
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
43-
run: |
44-
chmod +x ./scripts/populate-keys.sh
45-
sh ./scripts/populate-keys.sh
46-
4732
- name: build docker
4833
run: make build
4934

@@ -81,7 +66,8 @@ jobs:
8166

8267
- name: Terraform Plan Prod
8368
id: plan-prod
84-
run: terraform plan -var-file=${{ env.TF_WORKSPACE }}.tfvars -var image_tag=latest -no-color
69+
# run: terraform plan -var-file=${{ env.TF_WORKSPACE }}.tfvars -var image_tag=latest -no-color
70+
run: echo "Disabled for now up to restructure infra tiers"
8571
continue-on-error: true
8672
working-directory: ./${{ env.WORKING_DIR }}
8773
env:

Docker/Dockerfile.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ RUN useradd -ms /bin/bash ${USERNAME}
3535

3636
WORKDIR ${HOME}/time-tracker-ui
3737
COPY . .
38-
RUN rm -f .env
3938
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
4039
RUN chmod -R 777 ${HOME}/time-tracker-ui
4140

4241
USER ${USERNAME}
43-
COPY .env .
4442
EXPOSE 4200
4543
EXPOSE 9876
4644
RUN npm cache clean --force && npm install

Dockerfile

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,22 @@
1-
FROM node:14 AS building
2-
3-
ENV USERNAME timetracker
4-
ENV HOME /home/${USERNAME}
5-
RUN useradd -ms /bin/bash ${USERNAME}
6-
WORKDIR ${HOME}/time-tracker-ui
7-
COPY . .
8-
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
9-
RUN chmod -R 777 ${HOME}/time-tracker-ui
10-
11-
USER ${USERNAME}
1+
FROM node:14-alpine AS building
2+
WORKDIR /app
3+
# ENV USERNAME timetracker
4+
# ENV HOME /home/${USERNAME}
5+
# RUN useradd -ms /bin/bash ${USERNAME}
6+
# WORKDIR ${HOME}/time-tracker-ui
7+
COPY . /app
8+
# RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
9+
# RUN chmod -R 777 ${HOME}/time-tracker-ui
10+
# USER ${USERNAME}
1211
RUN npm cache clean --force && npm install
13-
EXPOSE 4200
14-
EXPOSE 9876
15-
ARG API_URL
16-
ARG AUTHORITY
17-
ARG CLIENT_ID
18-
ARG CLIENT_URL
19-
ARG SCOPES
20-
ARG AZURE_APP_CONFIGURATION_CONNECTION_STRING
21-
22-
RUN API_URL=${API_URL} \
23-
AUTHORITY=${AUTHORITY} \
24-
CLIENT_ID=${CLIENT_ID} \
25-
CLIENT_URL=${CLIENT_URL} \
26-
SCOPES=${SCOPES} \
27-
AZURE_APP_CONFIGURATION_CONNECTION_STRING=${AZURE_APP_CONFIGURATION_CONNECTION_STRING}
28-
29-
RUN npm run build
30-
12+
EXPOSE 4200 9876
13+
RUN source .stage.env && npm run build
14+
# >> scrt &&
15+
#
3116

3217
FROM nginx:1.21 AS production
33-
34-
ENV USERNAME app
35-
RUN useradd -ms /bin/bash ${USERNAME}
36-
3718
COPY nginx.conf /etc/nginx/conf.d/default.conf
38-
COPY --from=building /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html
39-
COPY .env /usr/share/nginx/html
40-
RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
41-
chown -R ${USERNAME}:${USERNAME} /var/log/nginx && \
42-
chown -R ${USERNAME}:${USERNAME} /etc/nginx/conf.d
43-
RUN touch /var/run/nginx.pid && chown -R ${USERNAME}:${USERNAME} /var/run/nginx.pid
44-
19+
COPY --from=building /app/dist/time-tracker /usr/share/nginx/html
4520
# FIXME: Actually if we can deploy to azure in port 80 we need a root user
4621
# Maybe we can refactor this dockerfile to use root user directly this is not a good approach y
4722
# security terms. It's a good practice to have rootless in containers so for this

scripts/populate-keys.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
> .env
44
echo "API_URL='$API_URL'" >> .env
55
echo "AUTHORITY='$AUTHORITY'" >> .env
6-
echo "API_URL='$API_URL'" >> .env
76
echo "CLIENT_ID='$CLIENT_ID'" >> .env
87
echo "CLIENT_URL='$CLIENT_URL'" >> .env
98
echo "SCOPES='$SCOPES'" >> .env

src/app/modules/activities-management/store/activity-management.selectors.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('ActivityManagement Selectors', () => {
4242
description: 'Some description'
4343
},
4444
];
45-
45+
4646
const activitiesOrdered = [
4747
{
4848
id: '002',

src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ describe('Reports Page', () => {
142142
});
143143

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

152-
expect(component.isURL(param.url)).toEqual(param.expected_value);
152+
expect(component.isURL(param.url)).toEqual(param.expected_value);
153153
});
154154
});
155155

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

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

176-
component.ngAfterViewInit();
176+
component.ngAfterViewInit();
177177

178-
component.dtElement.dtInstance.then( (dtInstance) => {
179-
expect(component.dtTrigger.next).toHaveBeenCalled();
178+
component.dtElement.dtInstance.then((dtInstance) => {
179+
expect(component.dtTrigger.next).toHaveBeenCalled();
180+
});
180181
});
181-
});
182182

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

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

210210
afterEach(() => {

src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
6060
filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}`
6161
},
6262
],
63-
columnDefs: [{ type: 'date', targets: 2}],
64-
order: [[1,'asc'],[2,'desc'],[4,'desc']]
63+
columnDefs: [{ type: 'date', targets: 2 }],
64+
order: [[1, 'asc'], [2, 'desc'], [4, 'desc']]
6565
};
6666
dtTrigger: Subject<any> = new Subject();
6767
@ViewChild(DataTableDirective, { static: false })
@@ -72,7 +72,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
7272
resultSum: TotalHours;
7373
dateTimeOffset: ParseDateTimeOffset;
7474

75-
constructor(private store: Store<EntryState>, private actionsSubject$: ActionsSubject, private storeUser: Store<User> ) {
75+
constructor(private store: Store<EntryState>, private actionsSubject$: ActionsSubject, private storeUser: Store<User>) {
7676
this.reportDataSource$ = this.store.pipe(select(getReportDataSource));
7777
this.dateTimeOffset = new ParseDateTimeOffset();
7878
}
@@ -128,28 +128,28 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
128128
const durationColumnIndex = 3;
129129
return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated;
130130
}
131-
132-
sumDates(arrayData: Entry[]): TotalHours{
131+
132+
sumDates(arrayData: Entry[]): TotalHours {
133133
this.resultSum = new TotalHours();
134-
let arrayDurations= new Array();
135-
arrayData.forEach(entry =>{
136-
let start = moment(entry.end_date).diff(moment(entry.start_date));
137-
arrayDurations.push(moment.utc(start).format("HH:mm:ss"));
134+
const arrayDurations = new Array();
135+
arrayData.forEach(entry => {
136+
const start = moment(entry.end_date).diff(moment(entry.start_date));
137+
arrayDurations.push(moment.utc(start).format('HH:mm:ss'));
138138
});
139-
140-
let totalDurations = arrayDurations.slice(1)
141-
.reduce((prev, cur) => {
142-
return prev.add(cur);
143-
},
144-
moment.duration(arrayDurations[0]));
145-
let daysInHours = totalDurations.days() * 24;
146-
this.resultSum.hours=totalDurations.hours() + daysInHours;
139+
140+
const totalDurations = arrayDurations.slice(1)
141+
.reduce((prev, cur) => {
142+
return prev.add(cur);
143+
},
144+
moment.duration(arrayDurations[0]));
145+
const daysInHours = totalDurations.days() * 24;
146+
this.resultSum.hours = totalDurations.hours() + daysInHours;
147147
this.resultSum.minutes = totalDurations.minutes();
148148
this.resultSum.seconds = totalDurations.seconds();
149149
return this.resultSum;
150150
}
151151

152-
user(userId: string){
152+
user(userId: string) {
153153
this.selectedUserId.emit(userId);
154154
}
155155

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export class TotalHours {
2-
2+
33
hours: number;
44
minutes: number;
55
seconds: number;
@@ -9,4 +9,4 @@ export class TotalHours {
99
this.minutes = 0;
1010
this.seconds = 0;
1111
}
12-
}
12+
}

0 commit comments

Comments
 (0)