diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index d956e8f5..dd9e3e44 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -46,6 +46,10 @@ import { DockerTemplateDetailsComponent } from './components/preferences/docker/
import { IouTemplatesComponent } from './components/preferences/ios-on-unix/iou-templates/iou-templates.component';
import { AddIouTemplateComponent } from './components/preferences/ios-on-unix/add-iou-template/add-iou-template.component';
import { IouTemplateDetailsComponent } from './components/preferences/ios-on-unix/iou-template-details/iou-template-details.component';
+import { CopyQemuVmTemplateComponent } from './components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component';
+import { CopyIosTemplateComponent } from './components/preferences/dynamips/copy-ios-template/copy-ios-template.component';
+import { CopyDockerTemplateComponent } from './components/preferences/docker/copy-docker-template/copy-docker-template.component';
+import { CopyIouTemplateComponent } from './components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component';
const routes: Routes = [
{
@@ -78,9 +82,11 @@ const routes: Routes = [
{ path: 'server/:server_id/preferences/dynamips/templates', component: IosTemplatesComponent },
{ path: 'server/:server_id/preferences/dynamips/templates/addtemplate', component: AddIosTemplateComponent },
{ path: 'server/:server_id/preferences/dynamips/templates/:template_id', component: IosTemplateDetailsComponent },
+ { path: 'server/:server_id/preferences/dynamips/templates/:template_id/copy', component: CopyIosTemplateComponent },
// { path: 'server/:server_id/preferences/qemu', component: QemuPreferencesComponent },
{ path: 'server/:server_id/preferences/qemu/templates', component: QemuVmTemplatesComponent },
+ { path: 'server/:server_id/preferences/qemu/templates/:template_id/copy', component: CopyQemuVmTemplateComponent },
{ path: 'server/:server_id/preferences/qemu/templates/:template_id', component: QemuVmTemplateDetailsComponent },
{ path: 'server/:server_id/preferences/qemu/addtemplate', component: AddQemuVmTemplateComponent },
@@ -101,10 +107,12 @@ const routes: Routes = [
{ path: 'server/:server_id/preferences/docker/templates', component: DockerTemplatesComponent },
{ path: 'server/:server_id/preferences/docker/templates/:template_id', component: DockerTemplateDetailsComponent },
+ { path: 'server/:server_id/preferences/docker/templates/:template_id/copy', component: CopyDockerTemplateComponent },
{ path: 'server/:server_id/preferences/docker/addtemplate', component: AddDockerTemplateComponent },
{ path: 'server/:server_id/preferences/iou/templates', component: IouTemplatesComponent },
{ path: 'server/:server_id/preferences/iou/templates/:template_id', component: IouTemplateDetailsComponent },
+ { path: 'server/:server_id/preferences/iou/templates/:template_id/copy', component: CopyIouTemplateComponent },
{ path: 'server/:server_id/preferences/iou/addtemplate', component: AddIouTemplateComponent }
]
},
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 34cc08b0..6d66fb1a 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -155,6 +155,10 @@ import { IouService } from './services/iou.service';
import { AddIouTemplateComponent } from './components/preferences/ios-on-unix/add-iou-template/add-iou-template.component';
import { IouConfigurationService } from './services/iou-configuration.service';
import { IouTemplateDetailsComponent } from './components/preferences/ios-on-unix/iou-template-details/iou-template-details.component';
+import { CopyQemuVmTemplateComponent } from './components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component';
+import { CopyIosTemplateComponent } from './components/preferences/dynamips/copy-ios-template/copy-ios-template.component';
+import { CopyIouTemplateComponent } from './components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component';
+import { CopyDockerTemplateComponent } from './components/preferences/docker/copy-docker-template/copy-docker-template.component';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@@ -249,7 +253,11 @@ if (environment.production) {
DockerTemplateDetailsComponent,
IouTemplatesComponent,
AddIouTemplateComponent,
- IouTemplateDetailsComponent
+ IouTemplateDetailsComponent,
+ CopyQemuVmTemplateComponent,
+ CopyIosTemplateComponent,
+ CopyIouTemplateComponent,
+ CopyDockerTemplateComponent
],
imports: [
BrowserModule,
diff --git a/src/app/components/preferences/common/delete-confirmation-dialog/delete-confirmation-dialog.component.html b/src/app/components/preferences/common/delete-confirmation-dialog/delete-confirmation-dialog.component.html
index 8c5badac..53715261 100644
--- a/src/app/components/preferences/common/delete-confirmation-dialog/delete-confirmation-dialog.component.html
+++ b/src/app/components/preferences/common/delete-confirmation-dialog/delete-confirmation-dialog.component.html
@@ -1,6 +1,8 @@
Are you sure you want to delete template {{templateName}}?
-
+
diff --git a/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.html b/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.html
new file mode 100644
index 00000000..54e7516c
--- /dev/null
+++ b/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.html
@@ -0,0 +1,19 @@
+
diff --git a/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.scss b/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.scss
new file mode 100644
index 00000000..16e9201b
--- /dev/null
+++ b/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.scss
@@ -0,0 +1,30 @@
+.form-field {
+ width: 100%;
+}
+
+.radio-button {
+ width: 50%;
+ padding-top: 20px;
+ padding-bottom: 30px;
+}
+
+.radio-group {
+ margin-bottom: 20px;
+}
+
+.buttons-bar {
+ padding-top: 20px;
+}
+
+.nonvisible {
+ display: none;
+}
+
+.file-button {
+ width: 18%;
+}
+
+.file-name-form-field {
+ padding-left: 2%;
+ width: 80%;
+}
diff --git a/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.spec.ts b/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.spec.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.ts b/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.ts
new file mode 100644
index 00000000..96f3d511
--- /dev/null
+++ b/src/app/components/preferences/docker/copy-docker-template/copy-docker-template.component.ts
@@ -0,0 +1,55 @@
+import { Component, OnInit } from "@angular/core";
+import { Server } from '../../../../models/server';
+import { ActivatedRoute, ParamMap, Router } from '@angular/router';
+import { ServerService } from '../../../../services/server.service';
+import { ToasterService } from '../../../../services/toaster.service';
+import { v4 as uuid } from 'uuid';
+import { DockerTemplate } from '../../../../models/templates/docker-template';
+import { DockerService } from '../../../../services/docker.service';
+
+
+@Component({
+ selector: 'app-copy-docker-template',
+ templateUrl: './copy-docker-template.component.html',
+ styleUrls: ['./copy-docker-template.component.scss']
+})
+export class CopyDockerTemplateComponent implements OnInit {
+ server: Server;
+ templateName: string = '';
+ dockerTemplate: DockerTemplate;
+
+ constructor(
+ private route: ActivatedRoute,
+ private serverService: ServerService,
+ private dockerService: DockerService,
+ private toasterService: ToasterService,
+ private router: Router
+ ) {}
+
+ ngOnInit() {
+ const server_id = this.route.snapshot.paramMap.get("server_id");
+ const template_id = this.route.snapshot.paramMap.get("template_id");
+ this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
+ this.server = server;
+
+ this.dockerService.getTemplate(this.server, template_id).subscribe((dockerTemplate: DockerTemplate) => {
+ this.dockerTemplate = dockerTemplate;
+ this.templateName = `Copy of ${this.dockerTemplate.name}`;
+ })
+
+ });
+ }
+
+ addTemplate() {
+ if (this.templateName) {
+ this.dockerTemplate.template_id = uuid();
+ this.dockerTemplate.name = this.templateName;
+
+ this.dockerService.addTemplate(this.server, this.dockerTemplate).subscribe((template: DockerTemplate) => {
+ this.router.navigate(['/server', this.server.id, 'preferences', 'docker', 'templates']);
+ });
+ } else {
+ this.toasterService.error(`Fill all required fields`);
+ }
+ }
+}
diff --git a/src/app/components/preferences/docker/docker-templates/docker-templates.component.html b/src/app/components/preferences/docker/docker-templates/docker-templates.component.html
index a8bae8f6..de7e3506 100644
--- a/src/app/components/preferences/docker/docker-templates/docker-templates.component.html
+++ b/src/app/components/preferences/docker/docker-templates/docker-templates.component.html
@@ -10,9 +10,17 @@
{{template.name}}
-
diff --git a/src/app/components/preferences/docker/docker-templates/docker-templates.component.scss b/src/app/components/preferences/docker/docker-templates/docker-templates.component.scss
index e6125a7a..b0726321 100644
--- a/src/app/components/preferences/docker/docker-templates/docker-templates.component.scss
+++ b/src/app/components/preferences/docker/docker-templates/docker-templates.component.scss
@@ -4,9 +4,9 @@
}
.name {
- width: 90%;
+ width: 95%;
}
-.delete-button {
- width: 10%;
+.menu-button {
+ width: 5%;
}
diff --git a/src/app/components/preferences/docker/docker-templates/docker-templates.component.ts b/src/app/components/preferences/docker/docker-templates/docker-templates.component.ts
index 5a22d885..e5d48cf2 100644
--- a/src/app/components/preferences/docker/docker-templates/docker-templates.component.ts
+++ b/src/app/components/preferences/docker/docker-templates/docker-templates.component.ts
@@ -1,6 +1,6 @@
import { Component, OnInit, ViewChild } from "@angular/core";
import { Server } from '../../../../models/server';
-import { ActivatedRoute, ParamMap } from '@angular/router';
+import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { ServerService } from '../../../../services/server.service';
import { switchMap } from 'rxjs/operators';
import { DeleteTemplateComponent } from '../../common/delete-template-component/delete-template.component';
@@ -21,7 +21,8 @@ export class DockerTemplatesComponent implements OnInit {
constructor(
private route: ActivatedRoute,
private serverService: ServerService,
- private dockerService: DockerService
+ private dockerService: DockerService,
+ private router: Router
) {}
ngOnInit() {
@@ -50,4 +51,8 @@ export class DockerTemplatesComponent implements OnInit {
onDeleteEvent() {
this.getTemplates();
}
+
+ copyTemplate(template: DockerTemplate) {
+ this.router.navigate(['/server', this.server.id, 'preferences', 'docker', 'templates', template.template_id, 'copy']);
+ }
}
diff --git a/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.html b/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.html
index e69de29b..82b20843 100644
--- a/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.html
+++ b/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.html
@@ -0,0 +1,19 @@
+
diff --git a/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.scss b/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.scss
index e69de29b..16e9201b 100644
--- a/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.scss
+++ b/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.scss
@@ -0,0 +1,30 @@
+.form-field {
+ width: 100%;
+}
+
+.radio-button {
+ width: 50%;
+ padding-top: 20px;
+ padding-bottom: 30px;
+}
+
+.radio-group {
+ margin-bottom: 20px;
+}
+
+.buttons-bar {
+ padding-top: 20px;
+}
+
+.nonvisible {
+ display: none;
+}
+
+.file-button {
+ width: 18%;
+}
+
+.file-name-form-field {
+ padding-left: 2%;
+ width: 80%;
+}
diff --git a/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.ts b/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.ts
index e69de29b..24bc2d91 100644
--- a/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.ts
+++ b/src/app/components/preferences/dynamips/copy-ios-template/copy-ios-template.component.ts
@@ -0,0 +1,55 @@
+import { Component, OnInit } from "@angular/core";
+import { Server } from '../../../../models/server';
+import { ActivatedRoute, ParamMap, Router } from '@angular/router';
+import { ServerService } from '../../../../services/server.service';
+import { ToasterService } from '../../../../services/toaster.service';
+import { v4 as uuid } from 'uuid';
+import { IosTemplate } from '../../../../models/templates/ios-template';
+import { IosService } from '../../../../services/ios.service';
+
+
+@Component({
+ selector: 'app-copy-ios-template',
+ templateUrl: './copy-ios-template.component.html',
+ styleUrls: ['./copy-ios-template.component.scss']
+})
+export class CopyIosTemplateComponent implements OnInit {
+ server: Server;
+ templateName: string = '';
+ iosTemplate: IosTemplate;
+
+ constructor(
+ private route: ActivatedRoute,
+ private serverService: ServerService,
+ private iosService: IosService,
+ private toasterService: ToasterService,
+ private router: Router
+ ) {}
+
+ ngOnInit() {
+ const server_id = this.route.snapshot.paramMap.get("server_id");
+ const template_id = this.route.snapshot.paramMap.get("template_id");
+ this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
+ this.server = server;
+
+ this.iosService.getTemplate(this.server, template_id).subscribe((iosTemplate: IosTemplate) => {
+ this.iosTemplate = iosTemplate;
+ this.templateName = `Copy of ${this.iosTemplate.name}`;
+ })
+
+ });
+ }
+
+ addTemplate() {
+ if (this.templateName) {
+ this.iosTemplate.template_id = uuid();
+ this.iosTemplate.name = this.templateName;
+
+ this.iosService.addTemplate(this.server, this.iosTemplate).subscribe((template: IosTemplate) => {
+ this.router.navigate(['/server', this.server.id, 'preferences', 'dynamips', 'templates']);
+ });
+ } else {
+ this.toasterService.error(`Fill all required fields`);
+ }
+ }
+}
diff --git a/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.html b/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.html
index f1ba4fef..38eb0005 100644
--- a/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.html
+++ b/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.html
@@ -10,9 +10,17 @@
{{template.name}}
-
- delete
+
+
+
+ deleteDelete
+
+
+ content_copyCopy
+
+
diff --git a/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.scss b/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.scss
index e6125a7a..b0726321 100644
--- a/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.scss
+++ b/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.scss
@@ -4,9 +4,9 @@
}
.name {
- width: 90%;
+ width: 95%;
}
-.delete-button {
- width: 10%;
+.menu-button {
+ width: 5%;
}
diff --git a/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.ts b/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.ts
index 87b936d7..b66285f2 100644
--- a/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.ts
+++ b/src/app/components/preferences/dynamips/ios-templates/ios-templates.component.ts
@@ -1,6 +1,6 @@
import { Component, OnInit, ViewChild } from "@angular/core";
import { Server } from '../../../../models/server';
-import { ActivatedRoute, ParamMap } from '@angular/router';
+import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { ServerService } from '../../../../services/server.service';
import { switchMap } from 'rxjs/operators';
import { IosService } from '../../../../services/ios.service';
@@ -22,7 +22,8 @@ export class IosTemplatesComponent implements OnInit {
constructor(
private route: ActivatedRoute,
private serverService: ServerService,
- private iosService: IosService
+ private iosService: IosService,
+ private router: Router
) {}
ngOnInit() {
@@ -47,4 +48,8 @@ export class IosTemplatesComponent implements OnInit {
onDeleteEvent() {
this.getTemplates();
}
+
+ copyTemplate(template: IosTemplate) {
+ this.router.navigate(['/server', this.server.id, 'preferences', 'dynamips', 'templates', template.template_id, 'copy']);
+ }
}
diff --git a/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component.html b/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component.html
new file mode 100644
index 00000000..b5f823d4
--- /dev/null
+++ b/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component.html
@@ -0,0 +1,19 @@
+
diff --git a/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component.scss b/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component.scss
new file mode 100644
index 00000000..16e9201b
--- /dev/null
+++ b/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component.scss
@@ -0,0 +1,30 @@
+.form-field {
+ width: 100%;
+}
+
+.radio-button {
+ width: 50%;
+ padding-top: 20px;
+ padding-bottom: 30px;
+}
+
+.radio-group {
+ margin-bottom: 20px;
+}
+
+.buttons-bar {
+ padding-top: 20px;
+}
+
+.nonvisible {
+ display: none;
+}
+
+.file-button {
+ width: 18%;
+}
+
+.file-name-form-field {
+ padding-left: 2%;
+ width: 80%;
+}
diff --git a/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component.ts b/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component.ts
new file mode 100644
index 00000000..9fd057de
--- /dev/null
+++ b/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.component.ts
@@ -0,0 +1,55 @@
+import { Component, OnInit } from "@angular/core";
+import { Server } from '../../../../models/server';
+import { ActivatedRoute, ParamMap, Router } from '@angular/router';
+import { ServerService } from '../../../../services/server.service';
+import { ToasterService } from '../../../../services/toaster.service';
+import { v4 as uuid } from 'uuid';
+import { IouTemplate } from '../../../../models/templates/iou-template';
+import { IouService } from '../../../../services/iou.service';
+
+
+@Component({
+ selector: 'app-copy-iou-template',
+ templateUrl: './copy-iou-template.component.html',
+ styleUrls: ['./copy-iou-template.component.scss']
+})
+export class CopyIouTemplateComponent implements OnInit {
+ server: Server;
+ templateName: string = '';
+ iouTemplate: IouTemplate;
+
+ constructor(
+ private route: ActivatedRoute,
+ private serverService: ServerService,
+ private qemuService: IouService,
+ private toasterService: ToasterService,
+ private router: Router
+ ) {}
+
+ ngOnInit() {
+ const server_id = this.route.snapshot.paramMap.get("server_id");
+ const template_id = this.route.snapshot.paramMap.get("template_id");
+ this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
+ this.server = server;
+
+ this.qemuService.getTemplate(this.server, template_id).subscribe((iouTemplate: IouTemplate) => {
+ this.iouTemplate = iouTemplate;
+ this.templateName = `Copy of ${this.iouTemplate.name}`;
+ })
+
+ });
+ }
+
+ addTemplate() {
+ if (this.templateName) {
+ this.iouTemplate.template_id = uuid();
+ this.iouTemplate.name = this.templateName;
+
+ this.qemuService.addTemplate(this.server, this.iouTemplate).subscribe((template: IouTemplate) => {
+ this.router.navigate(['/server', this.server.id, 'preferences', 'iou', 'templates']);
+ });
+ } else {
+ this.toasterService.error(`Fill all required fields`);
+ }
+ }
+}
diff --git a/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.spec.ts b/src/app/components/preferences/ios-on-unix/copy-iou-template/copy-iou-template.spec.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.html b/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.html
index e928214c..9654e842 100644
--- a/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.html
+++ b/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.html
@@ -10,9 +10,17 @@
{{template.name}}
-
- delete
+
+
+
+ deleteDelete
+
+
+ content_copyCopy
+
+
diff --git a/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.scss b/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.scss
index e6125a7a..b0726321 100644
--- a/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.scss
+++ b/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.scss
@@ -4,9 +4,9 @@
}
.name {
- width: 90%;
+ width: 95%;
}
-.delete-button {
- width: 10%;
+.menu-button {
+ width: 5%;
}
diff --git a/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.ts b/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.ts
index 85c1e718..79a9524c 100644
--- a/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.ts
+++ b/src/app/components/preferences/ios-on-unix/iou-templates/iou-templates.component.ts
@@ -1,6 +1,6 @@
import { Component, OnInit, ViewChild } from "@angular/core";
import { Server } from '../../../../models/server';
-import { ActivatedRoute, ParamMap } from '@angular/router';
+import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { ServerService } from '../../../../services/server.service';
import { switchMap } from 'rxjs/operators';
import { DeleteTemplateComponent } from '../../common/delete-template-component/delete-template.component';
@@ -21,7 +21,8 @@ export class IouTemplatesComponent implements OnInit {
constructor(
private route: ActivatedRoute,
private serverService: ServerService,
- private iouService: IouService
+ private iouService: IouService,
+ private router: Router
) {}
ngOnInit() {
@@ -50,4 +51,8 @@ export class IouTemplatesComponent implements OnInit {
onDeleteEvent() {
this.getTemplates();
}
+
+ copyTemplate(template: IouTemplate) {
+ this.router.navigate(['/server', this.server.id, 'preferences', 'iou', 'templates', template.template_id, 'copy']);
+ }
}
diff --git a/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.html b/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.html
index e69de29b..2f0e703c 100644
--- a/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.html
+++ b/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.html
@@ -0,0 +1,19 @@
+
diff --git a/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.scss b/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.scss
index e69de29b..16e9201b 100644
--- a/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.scss
+++ b/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.scss
@@ -0,0 +1,30 @@
+.form-field {
+ width: 100%;
+}
+
+.radio-button {
+ width: 50%;
+ padding-top: 20px;
+ padding-bottom: 30px;
+}
+
+.radio-group {
+ margin-bottom: 20px;
+}
+
+.buttons-bar {
+ padding-top: 20px;
+}
+
+.nonvisible {
+ display: none;
+}
+
+.file-button {
+ width: 18%;
+}
+
+.file-name-form-field {
+ padding-left: 2%;
+ width: 80%;
+}
diff --git a/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.ts b/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.ts
index e69de29b..127fd31a 100644
--- a/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.ts
+++ b/src/app/components/preferences/qemu/copy-qemu-vm-template/copy-qemu-vm-template.component.ts
@@ -0,0 +1,58 @@
+import { Component, OnInit } from "@angular/core";
+import { Server } from '../../../../models/server';
+import { ActivatedRoute, ParamMap, Router } from '@angular/router';
+import { ServerService } from '../../../../services/server.service';
+import { QemuService } from '../../../../services/qemu.service';
+import { QemuBinary } from '../../../../models/qemu/qemu-binary';
+import { ToasterService } from '../../../../services/toaster.service';
+import { QemuTemplate } from '../../../../models/templates/qemu-template';
+import { v4 as uuid } from 'uuid';
+
+
+@Component({
+ selector: 'app-copy-qemu-virtual-machine-template',
+ templateUrl: './copy-qemu-vm-template.component.html',
+ styleUrls: ['./copy-qemu-vm-template.component.scss']
+})
+export class CopyQemuVmTemplateComponent implements OnInit {
+ server: Server;
+ qemuBinaries: QemuBinary[] = [];
+ templateName: string = '';
+ qemuTemplate: QemuTemplate;
+
+
+ constructor(
+ private route: ActivatedRoute,
+ private serverService: ServerService,
+ private qemuService: QemuService,
+ private toasterService: ToasterService,
+ private router: Router,
+ ) {}
+
+ ngOnInit() {
+ const server_id = this.route.snapshot.paramMap.get("server_id");
+ const template_id = this.route.snapshot.paramMap.get("template_id");
+ this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
+ this.server = server;
+
+ this.qemuService.getTemplate(this.server, template_id).subscribe((qemuTemplate: QemuTemplate) => {
+ this.qemuTemplate = qemuTemplate;
+ this.templateName = `Copy of ${this.qemuTemplate.name}`;
+ })
+
+ });
+ }
+
+ addTemplate() {
+ if (this.templateName) {
+ this.qemuTemplate.template_id = uuid();
+ this.qemuTemplate.name = this.templateName;
+
+ this.qemuService.addTemplate(this.server, this.qemuTemplate).subscribe((template: QemuTemplate) => {
+ this.router.navigate(['/server', this.server.id, 'preferences', 'qemu', 'templates']);
+ });
+ } else {
+ this.toasterService.error(`Fill all required fields`);
+ }
+ }
+}
diff --git a/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.html b/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.html
index 0406916c..db62a42e 100644
--- a/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.html
+++ b/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.html
@@ -10,9 +10,17 @@
{{template.name}}
-
- delete
+
+
+
+ deleteDelete
+
+
+ content_copyCopy
+
+
diff --git a/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.scss b/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.scss
index e6125a7a..b0726321 100644
--- a/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.scss
+++ b/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.scss
@@ -4,9 +4,9 @@
}
.name {
- width: 90%;
+ width: 95%;
}
-.delete-button {
- width: 10%;
+.menu-button {
+ width: 5%;
}
diff --git a/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.ts b/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.ts
index 2fbb290a..1350d19a 100644
--- a/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.ts
+++ b/src/app/components/preferences/qemu/qemu-vm-templates/qemu-vm-templates.component.ts
@@ -1,6 +1,6 @@
import { Component, OnInit, ViewChild } from "@angular/core";
import { Server } from '../../../../models/server';
-import { ActivatedRoute, ParamMap } from '@angular/router';
+import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { ServerService } from '../../../../services/server.service';
import { switchMap } from 'rxjs/operators';
import { QemuTemplate } from '../../../../models/templates/qemu-template';
@@ -21,12 +21,12 @@ export class QemuVmTemplatesComponent implements OnInit {
constructor(
private route: ActivatedRoute,
private serverService: ServerService,
- private qemuService: QemuService
+ private qemuService: QemuService,
+ private router: Router
) {}
ngOnInit() {
const server_id = this.route.snapshot.paramMap.get("server_id");
- const template_id = this.route.snapshot.paramMap.get("template_id");
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
this.server = server;
this.getTemplates();
@@ -51,4 +51,8 @@ export class QemuVmTemplatesComponent implements OnInit {
onDeleteEvent() {
this.getTemplates();
}
+
+ copyTemplate(template: QemuTemplate) {
+ this.router.navigate(['/server', this.server.id, 'preferences', 'qemu', 'templates', template.template_id, 'copy']);
+ }
}