* refactor(app): replace notification with es6 service (#6015) [EE-1897] chore(app): format * refactor(containers): remove the dependency on angular modal service (#6017) [EE-1898] * refactor(app): remove angular from http-request [EE-1899] (#6016) * feat(app): add axios [EE-2035](#6077) * refactor(feature): remove angular dependency from feature service [EE-2034] (#6078) * refactor(app): replace box-selector with react component (#6046) fix: rename angular2react refactor(app): make box-selector type generic feat(app): add story for box-selector feat(app): test box-selector feat(app): add stories for box selector item fix(app): remove unneccesary element refactor(app): remove assign * feat(feature): add be-indicator in react [EE-2005] (#6106) * refactor(app): add react components for headers [EE-1949] (#6023) * feat(auth): provide user context * feat(app): added base header component [EE-1949] style(app): reformat refactor(app/header): use same api as angular * feat(app): add breadcrumbs component [EE-2024] * feat(app): remove u element from user links * fix(users): handle axios errors Co-authored-by: Chaim Lev-Ari <chiptus@gmail.com> * refactor(app): convert switch component to react [EE-2005] (#6025) Co-authored-by: Marcelo Rydel <marcelorydel26@gmail.com>
66 lines
2.3 KiB
JavaScript
66 lines
2.3 KiB
JavaScript
class DockerComposeFormController {
|
|
/* @ngInject */
|
|
constructor($async, EdgeTemplateService, Notifications) {
|
|
Object.assign(this, { $async, EdgeTemplateService, Notifications });
|
|
|
|
this.methodOptions = [
|
|
{ id: 'method_editor', icon: 'fa fa-edit', label: 'Web editor', description: 'Use our Web editor', value: 'editor' },
|
|
{ id: 'method_upload', icon: 'fa fa-upload', label: 'Upload', description: 'Upload from your computer', value: 'upload' },
|
|
{ id: 'method_repository', icon: 'fab fa-github', label: 'Repository', description: 'Use a git repository', value: 'repository' },
|
|
{ id: 'method_template', icon: 'fa fa-rocket', label: 'Template', description: 'Use an Edge stack template', value: 'template' },
|
|
];
|
|
|
|
this.selectedTemplate = null;
|
|
|
|
this.onChangeFileContent = this.onChangeFileContent.bind(this);
|
|
this.onChangeFile = this.onChangeFile.bind(this);
|
|
this.onChangeTemplate = this.onChangeTemplate.bind(this);
|
|
this.onChangeMethod = this.onChangeMethod.bind(this);
|
|
this.onChangeFormValues = this.onChangeFormValues.bind(this);
|
|
}
|
|
|
|
onChangeFormValues(values) {
|
|
this.formValues = values;
|
|
}
|
|
|
|
onChangeMethod(method) {
|
|
this.state.Method = method;
|
|
this.formValues.StackFileContent = '';
|
|
this.selectedTemplate = null;
|
|
}
|
|
|
|
onChangeTemplate(template) {
|
|
return this.$async(async () => {
|
|
this.formValues.StackFileContent = '';
|
|
try {
|
|
const fileContent = await this.EdgeTemplateService.edgeTemplate(template);
|
|
this.formValues.StackFileContent = fileContent;
|
|
} catch (err) {
|
|
this.Notifications.error('Failure', err, 'Unable to retrieve Template');
|
|
}
|
|
});
|
|
}
|
|
|
|
onChangeFileContent(value) {
|
|
this.formValues.StackFileContent = value;
|
|
this.state.isEditorDirty = true;
|
|
}
|
|
|
|
onChangeFile(value) {
|
|
this.formValues.StackFile = value;
|
|
}
|
|
|
|
async $onInit() {
|
|
return this.$async(async () => {
|
|
try {
|
|
const templates = await this.EdgeTemplateService.edgeTemplates();
|
|
this.templates = templates.map((template) => ({ ...template, label: `${template.title} - ${template.description}` }));
|
|
} catch (err) {
|
|
this.Notifications.error('Failure', err, 'Unable to retrieve Templates');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
export default DockerComposeFormController;
|