diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 95311bf8..c1a1006b 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -257,6 +257,7 @@ import { Gns3vmComponent } from './components/preferences/gns3vm/gns3vm.componen
import { Gns3vmService } from './services/gns3vm.service';
import { ThemeService } from './services/theme.service';
import { ConfigureGns3VMDialogComponent } from './components/servers/configure-gns3vm-dialog/configure-gns3vm-dialog.component';
+import { ImportApplianceComponent } from './components/project-map/import-appliance/import-appliance.component';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@@ -432,7 +433,8 @@ if (environment.production) {
ConfirmationBottomSheetComponent,
ConfigDialogComponent,
Gns3vmComponent,
- ConfigureGns3VMDialogComponent
+ ConfigureGns3VMDialogComponent,
+ ImportApplianceComponent
],
imports: [
BrowserModule,
diff --git a/src/app/components/project-map/import-appliance/import-appliance.component.html b/src/app/components/project-map/import-appliance/import-appliance.component.html
new file mode 100644
index 00000000..655de651
--- /dev/null
+++ b/src/app/components/project-map/import-appliance/import-appliance.component.html
@@ -0,0 +1,12 @@
+
+
diff --git a/src/app/components/project-map/import-appliance/import-appliance.component.scss b/src/app/components/project-map/import-appliance/import-appliance.component.scss
new file mode 100644
index 00000000..e69de29b
diff --git a/src/app/components/project-map/import-appliance/import-appliance.component.spec.ts b/src/app/components/project-map/import-appliance/import-appliance.component.spec.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/src/app/components/project-map/import-appliance/import-appliance.component.ts b/src/app/components/project-map/import-appliance/import-appliance.component.ts
new file mode 100644
index 00000000..550bc4d3
--- /dev/null
+++ b/src/app/components/project-map/import-appliance/import-appliance.component.ts
@@ -0,0 +1,70 @@
+import { Component, Input, OnInit } from "@angular/core";
+import { Project } from '../../../models/project';
+import { Server } from '../../../models/server';
+import { ComputeService } from '../../../services/compute.service';
+import { ToasterService } from '../../../services/toaster.service';
+import { ServerResponse } from '../../../models/serverResponse';
+import { FileUploader, ParsedResponseHeaders, FileItem } from 'ng2-file-upload';
+
+
+@Component({
+ selector: 'app-import-appliance',
+ templateUrl: './import-appliance.component.html',
+ styleUrls: ['./import-appliance.component.scss']
+})
+export class ImportApplianceComponent implements OnInit {
+ @Input('project') project: Project;
+ @Input('server') server: Server;
+ uploader: FileUploader;
+
+ constructor(
+ private computeService: ComputeService,
+ private toasterService: ToasterService
+ ) {}
+
+ ngOnInit() {
+ this.uploader = new FileUploader({});
+ this.uploader.onAfterAddingFile = file => {
+ file.withCredentials = false;
+ };
+
+ this.uploader.onErrorItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
+ let serverResponse: ServerResponse = JSON.parse(response);
+ let resultMessage = 'An error occured: ' + serverResponse.message;
+ this.toasterService.error(resultMessage);
+ };
+
+ this.uploader.onCompleteItem = (
+ item: FileItem,
+ response: string,
+ status: number,
+ headers: ParsedResponseHeaders
+ ) => {
+ this.toasterService.success('Appliance imported successfully');
+ };
+ }
+
+ public uploadAppliance(event) {
+ const url = this.computeService.getUploadPath(this.server, event.target.files[0].name);
+ this.uploader.queue.forEach(elem => (elem.url = url));
+ const itemToUpload = this.uploader.queue[0];
+ this.uploader.uploadItem(itemToUpload);
+ }
+
+ // public uploadAppliance(event) {
+ // let fileInput = event.target;
+ // let file: File = fileInput.files[0];
+ // let name: string = file.name;
+ // let fileReader: FileReader = new FileReader();
+
+ // fileReader.onloadend = () => {
+ // let appliance = fileReader.result;
+ // var obj = JSON.parse(appliance as string);
+ // console.log(obj);
+ // // this.computeService.postAppliance(this.server, obj).subscribe(() => {
+ // // this.toasterService.success('Appliance imported.');
+ // // });
+ // }
+ // fileReader.readAsText(file);
+ // }
+}
diff --git a/src/app/components/project-map/project-map.component.html b/src/app/components/project-map/project-map.component.html
index b5eee1c2..d976c9ee 100644
--- a/src/app/components/project-map/project-map.component.html
+++ b/src/app/components/project-map/project-map.component.html
@@ -75,16 +75,7 @@
call_received
Import portable project
-
-
+