Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Dec 7, 2018
2 parents e310f96 + d5b2d30 commit de0bb83
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 163 deletions.
62 changes: 7 additions & 55 deletions src/app/applications/addcloudapplication.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,23 @@ import {FlavorService} from '../api-connector/flavor.service';
import {Flavor} from '../virtualmachines/virtualmachinemodels/flavor';
import {FlavorType} from '../virtualmachines/virtualmachinemodels/flavorType';
import {forEach} from '@angular/router/src/utils/collection';
import {AbstractBaseClasse} from "../shared_modules/baseClass/abstract-base-class";

@Component({
templateUrl: 'addcloudapplication.component.html',
providers: [SpecialHardwareService, ApiSettings, ApplicationsService, FlavorService],
styleUrls: ['addcloudapplication.component.css']
})

export class AddcloudapplicationComponent {
export class AddcloudapplicationComponent extends AbstractBaseClasse{

/**
* If shortname is valid.
* @type {boolean}
*/
public wronginput: boolean = false;

//notification Modal variables
/**
* Notification Modal title.
* @type {string}
*/
public notificationModalTitle: string = 'Notification';
/**
* Notification Modal message.
* @type {string}
*/
public notificationModalMessage: string = 'Please wait...';
/**
* Notification Modal type.
* @type {string}
*/
public notificationModalType: string = 'info';
/**
* If Notification Modal is closable.
* @type {boolean}
*/
public notificationModalIsClosable: boolean = false;
/**
* If Notification Modal stays.
* @type {boolean}
*/
public notificationModalStay: boolean = true;

/**
* Contains errors recieved when submitting an application.
*/
Expand Down Expand Up @@ -123,6 +99,7 @@ export class AddcloudapplicationComponent {
*/
constructor(private specialhardwareservice: SpecialHardwareService,
private applicationsservice: ApplicationsService, private flavorservice: FlavorService) {
super();
this.getSpecialHardware();
this.getListOfFlavors();
this.getListOfTypes();
Expand Down Expand Up @@ -273,7 +250,7 @@ export class AddcloudapplicationComponent {
this.error = null;
if (this.wronginput == true) {

this.updateNotificaitonModal('Failed', 'The application was not submitted, please check the required fields and try again.', true, 'danger');
this.updateNotificationModal('Failed', 'The application was not submitted, please check the required fields and try again.', true, 'danger');
this.notificationModalStay = true;
}
else {
Expand All @@ -288,7 +265,7 @@ export class AddcloudapplicationComponent {
}
this.applicationsservice.addNewApplication(values).toPromise()
.then(result => {
this.updateNotificaitonModal('Success', 'The application was submitted', true, 'success');
this.updateNotificationModal('Success', 'The application was submitted', true, 'success');
this.notificationModalStay = false;
}).catch(error => {
var error_json = error
Expand All @@ -299,37 +276,12 @@ export class AddcloudapplicationComponent {
}


this.updateNotificaitonModal('Failed', 'The application was not submitted, please check the required fields and try again.', true, 'danger');
this.updateNotificationModal('Failed', 'The application was not submitted, please check the required fields and try again.', true, 'danger');
this.notificationModalStay = true;
})
}
}

/**
* Update notification modal attributes.
* @param {string} title
* @param {string} message
* @param closable
* @param {string} type
*/
public updateNotificaitonModal(title: string, message: string, closable: true, type: string) {
this.notificationModalTitle = title;
this.notificationModalMessage = message;
this.notificationModalIsClosable = closable;
this.notificationModalType = type;
}

/**
* Reset notificaton modal attributes.
*/
public resetNotificationModal() {

this.notificationModalTitle = 'Notification';
this.notificationModalMessage = 'Please wait...';
this.notificationModalType = 'info';
this.notificationModalIsClosable = false;
this.notificationModalStay = true;
}

/**
* Check if shortname is valid.
Expand Down
41 changes: 6 additions & 35 deletions src/app/applications/addsinglevm.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,20 @@ import {SpecialHardwareService} from '../api-connector/special-hardware.service'
import {SpecialHardware} from './special_hardware.model'
import {ApiSettings} from '../api-connector/api-settings.service'
import {ApplicationsService} from '../api-connector/applications.service'
import {AbstractBaseClasse} from "../shared_modules/baseClass/abstract-base-class";

@Component({
templateUrl: 'addsinglevm.component.html',
providers: [SpecialHardwareService, ApiSettings, ApplicationsService]
})

export class AddsinglevmComponent {
export class AddsinglevmComponent extends AbstractBaseClasse{
/**
* Check if the shortname provided is valid.
* @type {boolean}
*/
public wronginput: boolean = false;

//notification Modal variables
public notificationModalTitle: string = 'Notification';
public notificationModalMessage: string = 'Please wait...';
public notificationModalType: string = 'info';
public notificationModalIsClosable: boolean = false;
public notificationModalStay: boolean = true;
public error: string[];
public project_application_vms_requested=3;

Expand All @@ -41,6 +36,7 @@ export class AddsinglevmComponent {

constructor(private specialhardwareservice: SpecialHardwareService,
private applicationsservice: ApplicationsService) {
super();
this.getSpecialHardware();

}
Expand Down Expand Up @@ -69,7 +65,7 @@ export class AddsinglevmComponent {
onSubmit(f: NgForm) {
this.error = null;
if (this.wronginput == true) {
this.updateNotificaitonModal('Failed', 'The application was not submitted, please check the required fields and try again.', true, 'danger');
this.updateNotificationModal('Failed', 'The application was not submitted, please check the required fields and try again.', true, 'danger');
this.notificationModalStay = true;
}
else {
Expand All @@ -83,7 +79,7 @@ export class AddsinglevmComponent {

this.applicationsservice.addNewApplication(values).toPromise()
.then(result => {
this.updateNotificaitonModal('Success', 'The application was submitted', true, 'success');
this.updateNotificationModal('Success', 'The application was submitted', true, 'success');
this.notificationModalStay = false;
}).catch(error => {
var error_json = error;
Expand All @@ -94,37 +90,12 @@ export class AddsinglevmComponent {
}


this.updateNotificaitonModal('Failed', 'The application was not submitted, please check the required fields and try again.', true, 'danger');
this.updateNotificationModal('Failed', 'The application was not submitted, please check the required fields and try again.', true, 'danger');
this.notificationModalStay = true;
})
}
}

/**
* Update notification modal attributes with values.
* @param {string} title
* @param {string} message
* @param closable
* @param {string} type
*/
public updateNotificaitonModal(title: string, message: string, closable: true, type: string) {
this.notificationModalTitle = title;
this.notificationModalMessage = message;
this.notificationModalIsClosable = closable;
this.notificationModalType = type;
}

/**
* Reset notification modal.
*/
public resetNotificationModal() {

this.notificationModalTitle = 'Notification';
this.notificationModalMessage = 'Please wait...';
this.notificationModalType = 'info';
this.notificationModalIsClosable = false;
this.notificationModalStay = true;
}

/**
* Check if shortname is valid.
Expand Down
26 changes: 13 additions & 13 deletions src/app/applications/applications.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,11 @@ export class ApplicationsComponent extends AbstractBaseClasse {
this.groupservice.assignGroupToResource(new_group_id.toString(), compute_center).subscribe(res => {
this.applicationstatusservice.setApplicationStatus(application_id, this.application_statuses.WAIT_FOR_CONFIRMATION, compute_center).subscribe(result => {
if (result['Error']) {
this.updateNotificaitonModal("Failed", result['Error'], true, "danger");
this.updateNotificationModal("Failed", result['Error'], true, "danger");

}
else {
this.updateNotificaitonModal("Success", "The new project was created", true, "success");
this.updateNotificationModal("Success", "The new project was created", true, "success");
}
for (let app of this.user_applications) {
if (app.Id == application_id) {
Expand Down Expand Up @@ -774,7 +774,7 @@ export class ApplicationsComponent extends AbstractBaseClasse {

, error => {
console.log(error);
this.updateNotificaitonModal("Failed", "Project could not be created!", true, "danger");
this.updateNotificationModal("Failed", "Project could not be created!", true, "danger");
})

}
Expand All @@ -795,7 +795,7 @@ export class ApplicationsComponent extends AbstractBaseClasse {
let new_group_id: number;
this.applicationstatusservice.setApplicationStatus(application_id, this.application_statuses.APPROVED, compute_center).subscribe(result => {
if (result['Error']) {
this.updateNotificaitonModal("Failed", result['Error'], true, "danger");
this.updateNotificationModal("Failed", result['Error'], true, "danger");
this

}
Expand All @@ -813,11 +813,11 @@ export class ApplicationsComponent extends AbstractBaseClasse {
this.groupservice.addAdmin(new_group_id, manager_member_user_id, compute_center).subscribe(res => {
this.groupservice.setPerunGroupAttributes(application_id, new_group_id).subscribe(res => {
if (result['Error']) {
this.updateNotificaitonModal("Failed", result['Error'], true, "danger");
this.updateNotificationModal("Failed", result['Error'], true, "danger");

}
else {
this.updateNotificaitonModal("Success", "The new project was created", true, "success");
this.updateNotificationModal("Success", "The new project was created", true, "success");
}

for (let app of this.user_applications) {
Expand Down Expand Up @@ -850,7 +850,7 @@ export class ApplicationsComponent extends AbstractBaseClasse {

}, error => {
console.log(error);
this.updateNotificaitonModal("Failed", "Project could not be created!", true, "danger");
this.updateNotificationModal("Failed", "Project could not be created!", true, "danger");
})


Expand All @@ -868,15 +868,15 @@ export class ApplicationsComponent extends AbstractBaseClasse {

}
}
this.updateNotificaitonModal("Success", "The project was assigned to the facility.", true, "success");
this.updateNotificationModal("Success", "The project was assigned to the facility.", true, "success");

})


},
error => {
console.log(error);
this.updateNotificaitonModal("Failed", "Project could not be created!", true, "danger");
this.updateNotificationModal("Failed", "Project could not be created!", true, "danger");
});
}

Expand All @@ -893,10 +893,10 @@ export class ApplicationsComponent extends AbstractBaseClasse {
this.user_applications = [];
this.getUserApplications();
this.getAllApplications();
this.updateNotificaitonModal("Success", "The Application was declined", true, "success");
this.updateNotificationModal("Success", "The Application was declined", true, "success");
})
.catch(error => {
this.updateNotificaitonModal("Failed", "Application could be declined!", true, "danger");
this.updateNotificationModal("Failed", "Application could be declined!", true, "danger");
});
}

Expand All @@ -907,15 +907,15 @@ export class ApplicationsComponent extends AbstractBaseClasse {
public deleteApplication(application_id) {
this.applicataionsservice.deleteApplication(application_id).toPromise()
.then(result => {
this.updateNotificaitonModal('Success', 'The application has been successfully removed', true, 'success');
this.updateNotificationModal('Success', 'The application has been successfully removed', true, 'success');
}).then(result => {
this.user_applications = [];
this.all_applications = [];
this.getUserApplications();
this.getAllApplications();
})
.catch(error => {
this.updateNotificaitonModal("Failed", "Application could not be removed!", true, "danger");
this.updateNotificationModal("Failed", "Application could not be removed!", true, "danger");
});
}

Expand Down
Loading

0 comments on commit de0bb83

Please sign in to comment.