Skip to content

Commit

Permalink
changing wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Nov 28, 2023
1 parent a202ceb commit 646ae0a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
4 changes: 4 additions & 0 deletions analytics-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ WORKDIR /apama_work
USER root

RUN microdnf install git
# RUN microdnf install unzip

# USER sagadmin
# Clone the apama-analytics-builder-block-sdk repository
RUN git clone https://github.com/SoftwareAG/apama-analytics-builder-block-sdk.git
# alternatively
# RUN wget https://github.com/SoftwareAG/apama-analytics-builder-block-sdk/archive/refs/heads/rel/10.18.0.x.zip
# RUN unzip apama-analytics-builder-block-sdk-rel-10.18.0.x.zip

COPY requirements.txt /apama_work
COPY flask_wrapper.py /apama_work
Expand Down
6 changes: 3 additions & 3 deletions analytics-service/flask_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
app = Flask(__name__)
agent = C8YAgent()
access_token = agent.get_github_access_token()
logger.info(
f"Github access token: {access_token}"
)
# logger.info(
# f"Github access token: {access_token}"
# )
auth = Auth.Token(access_token)
# initialize github endpoint
gh = Github(auth=auth)
Expand Down
3 changes: 2 additions & 1 deletion analytics-service/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
c8y_api
flask
PyGithub
PyGithub
python-dotenv
18 changes: 10 additions & 8 deletions analytics-ui/src/sample/list/sample.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,22 @@ export class SampleGridComponent implements OnInit {
}

public async createExtension(ids: string[]) {
const initialState = {};
const monitors = [];
for (let i = 0; i < this.samples.length; i++) {
if (ids.includes(this.samples[i].id)) {
monitors.push(this.samples[i].url);
}
}
const initialState = {
monitors
};

const modalRef = this.bsModalService.show(NameExtensionComponent, {
initialState,
});
modalRef.content.closeSubject.subscribe(async (conf) => {
console.log("Configuration after edit:", conf);
if (conf) {
const monitors = [];
for (let i = 0; i < this.samples.length; i++) {
if (ids.includes(this.samples[i].id)) {
monitors.push(this.samples[i].url);
}
}

const response = await this.analyticsService.createExtensionsZIP(
conf.name,
monitors
Expand Down
20 changes: 17 additions & 3 deletions analytics-ui/src/wizard/name-extension-modal.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, Input, OnInit, Output } from "@angular/core";
import { ModalLabels } from "@c8y/ngx-components";
import { Subject } from "rxjs";
import { AlertService, ModalLabels } from "@c8y/ngx-components";
import { BehaviorSubject, Subject } from "rxjs";
import { FormlyFieldConfig } from "@ngx-formly/core";
import { FormGroup } from "@angular/forms";
import { AnalyticsService } from "../shared/analytics.service";

@Component({
selector: "name-extension-modal",
Expand All @@ -26,12 +27,17 @@ import { FormGroup } from "@angular/forms";
})
export class NameExtensionComponent implements OnInit {
@Output() closeSubject: Subject<any> = new Subject();
@Input() monitors: string[];
configuration: any = {};

configFormlyFields: FormlyFieldConfig[] = [];
configFormly: FormGroup = new FormGroup({});
labels: ModalLabels = { ok: "Create extension", cancel: "Dismiss" };

constructor(
public analyticsService: AnalyticsService,
public alertService: AlertService,
) {}
ngOnInit(): void {
this.configFormlyFields = [
{
Expand All @@ -52,9 +58,17 @@ export class NameExtensionComponent implements OnInit {
this.closeSubject.next(undefined);
}

onSave(event) {
async onSave(event) {
console.log("Save");
const response = await this.analyticsService.createExtensionsZIP(
this.configuration.name,
this.monitors
);
this.closeSubject.next(this.configuration);
}

get progress(): BehaviorSubject<number> {
return this.progress;
}

}

0 comments on commit 646ae0a

Please sign in to comment.