Skip to content

Commit 43defbc

Browse files
committed
refactor(guide-utmstack): simplify ngOnInit and enhance token retrieval logic
Signed-off-by: Manuel Abascal <mjabascal10@gmail.com>
1 parent bb922e5 commit 43defbc

2 files changed

Lines changed: 16 additions & 21 deletions

File tree

frontend/src/app/app-module/guides/guide-utmstack/guide-utmstack.component.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,21 @@ export class GuideUtmstackComponent implements OnInit {
3333
private federationConnectionService: FederationConnectionService) {
3434
}
3535

36-
ngOnInit(): void {
37-
this.ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host;
38-
this.getToken();
39-
this.loadArchitectures();
40-
}
36+
ngOnInit() {
37+
this.getToken();
38+
}
4139

42-
getToken() {
43-
this.federationConnectionService.getToken().subscribe(response => {
44-
if (response.body !== null && response.body !== '') {
45-
this.token = response.body;
46-
} else {
47-
this.token = '';
48-
}
49-
this.vars = {
50-
V_IP: this.ip,
51-
V_TOKEN: this.token
52-
};
53-
});
54-
}
40+
41+
getToken() {
42+
this.federationConnectionService.getToken().subscribe(response => {
43+
if (response.body !== null && response.body !== '') {
44+
this.token = response.body;
45+
} else {
46+
this.token = '';
47+
}
48+
this.loadArchitectures();
49+
});
50+
}
5551

5652
configValidChange($event: boolean) {
5753
this.configValidity = !$event;
@@ -81,13 +77,13 @@ export class GuideUtmstackComponent implements OnInit {
8177
getCommandUbuntu(installerName: string): string {
8278
const ip = window.location.host.includes(':') ? window.location.host.split(':')[0] : window.location.host;
8379

84-
return `sudo bash -c "apt update -y && \
80+
return `sudo bash -c 'apt update -y && \
8581
apt install wget -y && \
8682
mkdir -p /opt/utmstack-collector && \
8783
wget --no-check-certificate -P /opt/utmstack-collector \
8884
https://${ip}:9001/private/dependencies/collector/${installerName} && \
8985
chmod -R 777 /opt/utmstack-collector/${installerName} && \
90-
/opt/utmstack-collector/${installerName} install ${ip} <secret>${this.token}</secret> yes"`;
86+
/opt/utmstack-collector/${installerName} install ${ip} <secret>${this.token}</secret>' yes'`;
9187
}
9288

9389

frontend/src/app/shared/components/utm/util/utm-code-view/utm-code-view.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export class UtmCodeViewComponent implements OnInit, OnChanges {
5454
}
5555

5656
removeSecretsTags(str) {
57-
console.log(str);
5857
const regex = /<\/?secret>/g;
5958
return str.replace(regex, '');
6059
}

0 commit comments

Comments
 (0)