Skip to content

Commit

Permalink
Merge pull request #5658 from deNBI/feat/stop_vm_message
Browse files Browse the repository at this point in the history
feat(VirtualMachine):added stopped vm info
  • Loading branch information
dweinholz authored Apr 26, 2023
2 parents 67fce07 + a17b165 commit f722507
Show file tree
Hide file tree
Showing 9 changed files with 1,222 additions and 1,222 deletions.
472 changes: 238 additions & 234 deletions src/app/api-connector/vo.service.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class Application {

migrate_to_simple_vm: boolean = false;

is_project_selected:boolean=false;
is_project_selected: boolean = false;

constructor(aj?: Partial<Application>) {
this.dissemination = new ApplicationDissemination(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,127 +1,120 @@
<div class="modal-header">
<h4 class="modal-title" data-test-id="confirmation_modal_title">Sent Mail to specific projects</h4>
<button type="button" class="close" style="cursor: pointer" (click)="bsModalRef.hide()" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" data-test-id="confirmation_modal_title">Sent Mail to specific projects</h4>
<button type="button" class="close" style="cursor: pointer" (click)="bsModalRef.hide()" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div>
Send Mail to:
<ul>
<li *ngFor="let pr of selectedProjects">{{pr.project_application_shortname}}</li>
</ul>
</div>
<form class="form-horizontal" id="email_form" #f="ngForm">


<div class="form-group row">
<div class="col-md-auto">
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
[(ngModel)]="emailAdminsOnly"
id="adminOnlyCheckbox"
/>
<label class="form-check-label" for="adminOnlyCheckbox"> Group administrators only </label>
</div>
</div>
</div>
<div

class="form-group row"
[ngClass]="{
'has-danger': emailSub.invalid && (emailSub.dirty || emailSub.touched),
'has-success': emailSub.valid && (emailSub.dirty || emailSub.touched)
}"
>
<label class="col-md-12 control-label"><strong>Email subject*</strong></label>
<div class="col-md-12">
<input
required
id="emailSubject"
name="emailSub"
placeholder="Subject"
class="form-control"
type="text"
[(ngModel)]="emailSubject"
minlength="1"
#emailSub="ngModel"
[ngClass]="{
'is-invalid': emailSub.invalid && (emailSub.dirty || emailSub.touched),
'is-valid': emailSub.valid && (emailSub.dirty || emailSub.touched)
}"
/>
</div>
</div>

<div class="form-group row">
<label class="col-md-12 control-label"><strong>Reply to (optional)</strong></label>
<div class="col-md-12">
<input
id="reply_to"
name="emailReply"
placeholder=""
class="form-control"
type="text"
[(ngModel)]="emailReply"
#emailRep="ngModel"
pattern="([ ]*)(?!(^[.-].*|[^@]*[.-]@|.*\.{2,}.*)|^.{254}.)([a-zA-Z0-9!#$%&'*+\/=?^_`{|}~.-]+@)(?!-.*|.*-\.)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,15}([ ]*)"
[ngClass]="{
'is-invalid': emailRep.invalid && (emailRep.dirty || emailRep.touched),
'is-valid': emailRep.valid && (emailRep.dirty || emailRep.touched)
}"
/>
</div>
</div>
<!-- Textarea -->
<div class="form-group row">
<label class="col-md-12 control-label"><strong>Email text*</strong></label>
<div class="col-md-12">
<textarea
minlength="1"
required
class="form-control"
id="emailText"
name="emailText"
[(ngModel)]="emailText"
type="text"
#emailT="ngModel"
[ngClass]="{
'is-invalid': emailT.invalid && (emailT.dirty || emailT.touched),
'is-valid': emailT.valid && (emailT.dirty || emailT.touched)
}"
></textarea>
</div>
</div>
</form>
<div class="templates-container">
<p>The following keys can be used as variables:</p>
<div class="templates-list">
<span *ngFor="let template of templates">{{ '{' + template + '}' }}, </span>
</div>
</div>


<div>
Send Mail to:
<ul>
<li *ngFor="let pr of selectedProjects">{{ pr.project_application_shortname }}</li>
</ul>
</div>
<form class="form-horizontal" id="email_form" #f="ngForm">
<div class="form-group row">
<div class="col-md-auto">
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
[(ngModel)]="emailAdminsOnly"
name="emailAdminsOnly"
id="adminOnlyCheckbox"
/>
<label class="form-check-label" for="adminOnlyCheckbox"> Group administrators only </label>
</div>
</div>
</div>
<div
class="form-group row"
[ngClass]="{
'has-danger': emailSub.invalid && (emailSub.dirty || emailSub.touched),
'has-success': emailSub.valid && (emailSub.dirty || emailSub.touched)
}"
>
<label class="col-md-12 control-label"><strong>Email subject*</strong></label>
<div class="col-md-12">
<input
required
id="emailSubject"
name="emailSubject"
placeholder="Subject"
class="form-control"
type="text"
[(ngModel)]="emailSubject"
minlength="1"
#emailSub="ngModel"
[ngClass]="{
'is-invalid': emailSub.invalid && (emailSub.dirty || emailSub.touched),
'is-valid': emailSub.valid && (emailSub.dirty || emailSub.touched)
}"
/>
</div>
</div>

<div class="form-group row">
<label class="col-md-12 control-label"><strong>Reply to (optional)</strong></label>
<div class="col-md-12">
<input
id="reply_to"
name="emailReply"
placeholder=""
class="form-control"
type="text"
[(ngModel)]="emailReply"
#emailRep="ngModel"
pattern="([ ]*)(?!(^[.-].*|[^@]*[.-]@|.*\.{2,}.*)|^.{254}.)([a-zA-Z0-9!#$%&'*+\/=?^_`{|}~.-]+@)(?!-.*|.*-\.)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,15}([ ]*)"
[ngClass]="{
'is-invalid': emailRep.invalid && (emailRep.dirty || emailRep.touched),
'is-valid': emailRep.valid && (emailRep.dirty || emailRep.touched)
}"
/>
</div>
</div>
<!-- Textarea -->
<div class="form-group row">
<label class="col-md-12 control-label"><strong>Email text*</strong></label>
<div class="col-md-12">
<textarea
minlength="1"
required
class="form-control"
id="emailText"
name="emailText"
[(ngModel)]="emailText"
type="text"
#emailT="ngModel"
[ngClass]="{
'is-invalid': emailT.invalid && (emailT.dirty || emailT.touched),
'is-valid': emailT.valid && (emailT.dirty || emailT.touched)
}"
></textarea>
</div>
</div>
</form>
<div class="templates-container">
<p>The following keys can be used as variables:</p>
<div class="templates-list">
<span *ngFor="let template of templates">{{ '{' + template + '}' }}, </span>
</div>
</div>
</div>
<div class="modal-footer">
<button
class="btn btn-secondary col-md-4"
type="reset"
data-test-id="close_confirmation_modal_btn"
(click)=" bsModalRef.hide()"
>
Abort & Close
</button>
<button
class="btn btn-success col-md-4"
[disabled]="
f.invalid
"
data-test-id="confirm_confirmation_modal_btn"
(click)="sentProjectsMail(); bsModalRef.hide()"
>
Sent Mail
</button>
<button
class="btn btn-secondary col-md-4"
type="reset"
data-test-id="close_confirmation_modal_btn"
(click)="bsModalRef.hide()"
>
Abort & Close
</button>
<button
class="btn btn-success col-md-4"
[disabled]="f.invalid"
data-test-id="confirm_confirmation_modal_btn"
(click)="sentProjectsMail(); bsModalRef.hide()"
>
Sent Mail
</button>
</div>
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
import {Component, EventEmitter, Input, OnInit} from '@angular/core';
import {Application} from '../../../../applications/application.model/application.model';
import {BsModalRef} from 'ngx-bootstrap/modal';
import {VoService} from '../../../../api-connector/vo.service';
import {IResponseTemplate} from '../../../../api-connector/response-template';
import {
Component, EventEmitter, Input, OnDestroy, OnInit,
} from '@angular/core';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { Application } from '../../../../applications/application.model/application.model';
import { VoService } from '../../../../api-connector/vo.service';
import { IResponseTemplate } from '../../../../api-connector/response-template';

@Component({
selector: 'app-project-email-modal',
templateUrl: './project-email-modal.component.html',
styleUrls: ['./projext-email-modal.component.scss'],

selector: 'app-project-email-modal',
templateUrl: './project-email-modal.component.html',
styleUrls: ['./projext-email-modal.component.scss'],
})
export class ProjectEmailModalComponent implements OnInit {

//currently only for vo
@Input() selectedProjects: Application[];
emailAdminsOnly: boolean;
emailSubject: string;
emailReply: string;
emailText: string;
templates: string[];

public mailSuccesfullySent: EventEmitter<boolean> = new EventEmitter();

constructor(public bsModalRef: BsModalRef, private voService: VoService) {
// eslint-disable-next-line no-empty-function
}

ngOnInit() {
this.getMailTemplates()
}

getMailTemplates(): void {
this.voService.getMailTemplates().subscribe((res: string[]) => {
this.templates = res
})
}

sentProjectsMail(): void {
const project_ids = this.selectedProjects.map((pr: Application) => {
return pr.project_application_perun_id;
});

this.voService.sendMailToProjects(project_ids, this.emailSubject, this.emailText, this.emailAdminsOnly, this.emailReply).subscribe((res: IResponseTemplate) => {
this.mailSuccesfullySent.emit(res.value as boolean)
}, () => {
this.mailSuccesfullySent.emit(false)
})
}

ngOnDestroy(): void {
this.bsModalRef.hide();
}
export class ProjectEmailModalComponent implements OnDestroy, OnInit {
// currently only for vo
@Input() selectedProjects: Application[];
emailAdminsOnly: boolean;
emailSubject: string;
emailReply: string;
emailText: string;
templates: string[];

public event: EventEmitter<boolean> = new EventEmitter();

constructor(public bsModalRef: BsModalRef, private voService: VoService) {
// eslint-disable-next-line no-empty-function
}

ngOnInit() {
this.getMailTemplates();
}

getMailTemplates(): void {
this.voService.getMailTemplates().subscribe((res: string[]) => {
this.templates = res;
});
}

sentProjectsMail(): void {
const project_ids = this.selectedProjects.map((pr: Application) => pr.project_application_perun_id);

this.voService
.sendMailToProjects(project_ids, this.emailSubject, this.emailText, this.emailAdminsOnly, this.emailReply)
.subscribe(
(res: IResponseTemplate) => {
this.event.emit(res.value as boolean);
},
() => {
this.event.emit(false);
},
);
}

ngOnDestroy(): void {
this.bsModalRef.hide();
}
}
Loading

0 comments on commit f722507

Please sign in to comment.