this.router.navigate(['/block/rbd']);
}, (resp) => {
this.rbdForm.setErrors({'cdSubmitButton': true});
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
this.router.navigate(['/block/rbd']);
}).catch((resp) => {
this.rbdForm.setErrors({'cdSubmitButton': true});
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
this.router.navigate(['/block/rbd']);
}, (resp) => {
this.rbdForm.setErrors({'cdSubmitButton': true});
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
this.router.navigate(['/block/rbd']);
}).catch((resp) => {
this.rbdForm.setErrors({'cdSubmitButton': true});
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
this.loadImages(null);
}).catch((resp) => {
this.modalRef.content.stopLoadingSpinner();
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
}
this.modalRef.hide();
this.loadImages(null);
- }).catch((resp) => {
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
this.onSubmit.next(this.snapName);
}).catch((resp) => {
this.snapshotForm.setErrors({'cdSubmitButton': true});
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
this.onSubmit.next(snapshotName);
}).catch((resp) => {
this.snapshotForm.setErrors({'cdSubmitButton': true});
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
(asyncFinishedTask: FinishedTask) => {
this.notificationService.notifyTask(asyncFinishedTask);
});
- }).catch((resp) => {
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
})
.catch((resp) => {
this.modalRef.content.stopLoadingSpinner();
- finishedTask.success = false;
- finishedTask.exception = resp.error;
- this.notificationService.notifyTask(finishedTask);
});
}
--- /dev/null
+export enum Components {
+ cephfs = 'CephFS',
+ rbd = 'RBD',
+ pool = 'Pool',
+ osd = 'OSD'
+}
+import { Task } from './task';
+
export class TaskException {
status: number;
- errno: number;
+ code: number;
component: string;
detail: string;
+ task: Task;
}
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
+import * as _ from 'lodash';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/catch';
import { Observable } from 'rxjs/Observable';
import { NotificationType } from '../enum/notification-type.enum';
+import { FinishedTask } from '../models/finished-task';
import { AuthStorageService } from './auth-storage.service';
import { NotificationService } from './notification.service';
if (resp instanceof HttpErrorResponse) {
let showNotification = true;
switch (resp.status) {
+ case 400:
+ const finishedTask = new FinishedTask();
+
+ const task = resp.error.task;
+ if (_.isPlainObject(task)) {
+ task.metadata.component = task.metadata.component || resp.error.component;
+
+ finishedTask.name = task.name;
+ finishedTask.metadata = task.metadata;
+ } else {
+ finishedTask.metadata = resp.error;
+ }
+
+ finishedTask.success = false;
+ finishedTask.exception = resp.error;
+ this.notificationService.notifyTask(finishedTask);
+ showNotification = false;
+ break;
case 401:
this.authStorageService.remove();
this.router.navigate(['/login']);
case 404:
this.router.navigate(['/404']);
break;
- case 409:
- showNotification = false;
- break;
}
let timeoutId;
import { Injectable } from '@angular/core';
+
+import { Components } from '../enum/components.enum';
import { FinishedTask } from '../models/finished-task';
import { Task } from '../models/task';
return {
};
}
- ),
+ )
};
defaultMessage = new TaskManagerMessage(
- (metadata) => 'Unknown Task',
+ (metadata) => {
+ return Components[metadata.component] || metadata.component || 'Unknown Task';
+ },
(metadata) => 'Task executed successfully',
() => {
return {
getErrorMessage(finishedTask: FinishedTask) {
const taskManagerMessage = this.messages[finishedTask.name] || this.defaultMessage;
- return taskManagerMessage.error(finishedTask.metadata)[finishedTask.exception.errno] ||
+ return taskManagerMessage.error(finishedTask.metadata)[finishedTask.exception.code] ||
finishedTask.exception.detail;
}