Skip to content

Commit

Permalink
update service
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Jan 26, 2025
1 parent 31cfefe commit 4ee8ec2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,6 @@ In order to check if an extension is deployed look for a relevant message in the

The log file can be accessed: Administration> Ecosystem>Microservices>apama-ctrl-1c-4g>Logs

> **Note**
When a warning `Microservice: analytics-ext-service not subscribed. Please subscribe this service before using the analytics plugin!`appears please deploy the missing backend microservice.

![Backend microservice missing](resources/images/missing-microsevice.png)

------------------------------

These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.
Expand Down
1 change: 0 additions & 1 deletion analytics-service/c8y_agent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
from sre_constants import CATEGORY
import requests
from dotenv import load_dotenv
from c8y_api.app import MultiTenantCumulocityApp
from c8y_api.model import Binary, TenantOption
Expand Down
7 changes: 6 additions & 1 deletion analytics-service/flask_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ def parse_boolean(value):
return value.lower() == "true"
return False


def prepare_header(request):
headers = dict(request.headers)
if "authorization" in request.cookies:
headers["Authorization"] = f"Bearer {request.cookies['authorization']}"
return headers

if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, debug=False)
18 changes: 14 additions & 4 deletions analytics-ui/src/shared/repository.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class RepositoryService {
throw error;
}
}

private loadRepositories(): Observable<Repository[]> {
return from(this.fetchRepositoriesFromBackend()).pipe(
catchError(error => {
Expand Down Expand Up @@ -204,8 +204,18 @@ export class RepositoryService {
);

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
// Try to get the error message from the response body
try {
const errorData = await response.json();
const errorMessage = errorData.message || errorData.error || JSON.stringify(errorData);
throw new Error(errorMessage);
} catch (parseError) {
// If we can't parse the JSON, fall back to text
const errorText = parseError.message;
throw new Error(errorText);
}
}

return response.json();
}

Expand Down Expand Up @@ -295,7 +305,7 @@ export class RepositoryService {
private handleError(error: HttpErrorResponse): void {
const message = error.status
? `Backend returned code ${error.status}: ${error.message}`
: `Network error: ${error.message}`;
this.alertService.danger('Repository error', message);
: error.message;
this.alertService.danger(message);
}
}

0 comments on commit 4ee8ec2

Please sign in to comment.