Skip to content

Commit

Permalink
update repository dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Jan 26, 2025
1 parent 25939ad commit 31cfefe
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 218 deletions.
4 changes: 3 additions & 1 deletion analytics-ui/src/repository/list/sample-grid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class SampleGridComponent implements OnInit {

ngOnInit() {
this.samples$ =
this.repositoryService.getAll_CEP_BlockSamples();
this.repositoryService.getCEP_BlockSamples();
this.samples$?.subscribe((samples) => (this.samples = samples));
this.bulkActionControls.push({
type: 'CREATE',
Expand Down Expand Up @@ -166,6 +166,8 @@ export class SampleGridComponent implements OnInit {
if (response) {
await this.repositoryService.saveRepositories();
this.repositoryService.updateCEP_BlockSamples(this.hideInstalled);
} else {
this.repositoryService.cancelChanges();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<c8y-modal title="Repositories for blocks" (onClose)="onSave()" [labels]="labels"
[headerClasses]="'modal-header dialog-header'">
<c8y-modal title="Repositories for blocks" (onClose)="onSave()" (onDismiss)="onCancel()" [labels]="labels"
[headerClasses]="'modal-header dialog-header'" [disabled]="!saveRequired">

<ng-container c8y-modal-title>
<span [c8yIcon]="'plugin'"></span>
Expand Down Expand Up @@ -60,8 +60,7 @@
</c8y-form-group>
<c8y-form-group>
<label for="name"><span>{{'Repository Url '}}</span>
<button type="button" placement="right" popover="Enter the Url to a github repository in the form:
https://api.github.com/repos/{REPO_SAMPLES_OWNER}/{REPO_SAMPLES_NAME}/contents/{REPO_SAMPLES_PATH}"
<button type="button" placement="right" popover="Enter the Url to a github repository in the form: https://api.github.com/repos/{REPO_SAMPLES_OWNER}/{REPO_SAMPLES_NAME}/contents/{REPO_SAMPLES_PATH}"
triggers="focus" class="btn-help" aria-label="Help content"></button>
</label>
<input type="text" title="Repository Url" id="url" formControlName="url"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import {
})
export class RepositoriesModalComponent implements OnInit {
repositories$: Observable<Repository[]>;
@Output() closeSubject: Subject<boolean> = new Subject();
closeSubject: Subject<boolean> = new Subject();
repositoryForm: FormGroup;
subscription: any;
selectedRepositoryIndex: number = -1;

saveRequired: boolean = false;
labels: ModalLabels = { ok: 'Save', cancel: 'Cancel' };

constructor(
Expand Down Expand Up @@ -59,6 +59,7 @@ export class RepositoriesModalComponent implements OnInit {
newRepository.id = uuidCustom();
newRepository.enabled = true;
this.repositoryService.addRepository(newRepository);
this.saveRequired = true;
this.repositoryForm.reset();
}
}
Expand All @@ -70,13 +71,15 @@ export class RepositoriesModalComponent implements OnInit {

toggleActivation(repository: Repository): void {
repository.enabled = !repository.enabled;
this.saveRequired = true;
this.repositoryService.updateRepository(repository);
}

updateRepository(): void {
if (this.repositoryForm.valid) {
const updatedRepository: Repository = this.repositoryForm.value;
this.repositoryService.updateRepository(updatedRepository);
this.saveRequired = true;
this.repositoryForm.reset();
}
}
Expand All @@ -100,6 +103,7 @@ export class RepositoriesModalComponent implements OnInit {
if (result) {
try {
this.repositoryService.deleteRepository(repositoryId);
this.saveRequired = true;
} catch (ex) {
if (ex) {
this.alertService.addServerFailure(ex);
Expand All @@ -113,15 +117,16 @@ export class RepositoriesModalComponent implements OnInit {

onSave() {
this.closeSubject.next(true);
this.closeSubject.complete();
}

onCancel() {
this.closeSubject.next(false);
this.closeSubject.complete();
}

resetForm() {
this.repositoryForm.reset();
this.selectedRepositoryIndex = -1;
}

}
12 changes: 6 additions & 6 deletions analytics-ui/src/shared/analytics.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ export interface CEP_Extension {
export interface CEP_Block {
id: string;
name: string;
installed: boolean;
producesOutput: string;
description: string;
installed?: boolean;
producesOutput?: string;
description?: string;
url: string;
downloadUrl: string;
path: string;
path?: string;
custom: boolean;
extension: string;
extension?: string;
repositoryName: string;
repositoryId: string;
category: Category;
category?: Category;
}

export interface Repository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ import { Subject } from 'rxjs';
export class ConfirmationModalComponent implements OnInit, AfterViewInit {
@Input() title: string;
@Input() message: string;
@ViewChild('modalRef', { static: false }) modalRef: ConfirmModalComponent;
messageTranslated: string;
closeSubject: Subject<boolean> = new Subject();
@Input() labels: ModalLabels = {
ok: gettext('Ok'),
cancel: gettext('Cancel')
};

@ViewChild('modalRef', { static: false }) modalRef: ConfirmModalComponent;

messageTranslated: string;
closeSubject: Subject<boolean> = new Subject();
status: StatusType = Status.WARNING;

constructor(private translateService: TranslateService) {}
Expand Down
Loading

0 comments on commit 31cfefe

Please sign in to comment.