mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-03-10 22:44:09 +00:00
Merge pull request #1312 from GNS3/bugfix/1307
I added authentication token for allow IOU or IOS templates to be cr…
This commit is contained in:
commit
65c48769b7
@ -135,9 +135,9 @@ export class AddIosTemplateComponent implements OnInit {
|
|||||||
this.uploader.queue.forEach((elem) => (elem.url = url));
|
this.uploader.queue.forEach((elem) => (elem.url = url));
|
||||||
|
|
||||||
const itemToUpload = this.uploader.queue[0];
|
const itemToUpload = this.uploader.queue[0];
|
||||||
(itemToUpload as any).options.disableMultipart = true;
|
if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.server.authToken }])
|
||||||
|
|
||||||
this.uploader.uploadItem(itemToUpload);
|
this.uploader.uploadItem(itemToUpload);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addTemplate() {
|
addTemplate() {
|
||||||
|
@ -75,7 +75,6 @@ export class AddIouTemplateComponent implements OnInit {
|
|||||||
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
|
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.getImages();
|
this.getImages();
|
||||||
|
|
||||||
this.templateMocksService.getIouTemplate().subscribe((iouTemplate: IouTemplate) => {
|
this.templateMocksService.getIouTemplate().subscribe((iouTemplate: IouTemplate) => {
|
||||||
this.iouTemplate = iouTemplate;
|
this.iouTemplate = iouTemplate;
|
||||||
});
|
});
|
||||||
@ -106,11 +105,13 @@ export class AddIouTemplateComponent implements OnInit {
|
|||||||
this.uploader.queue.forEach((elem) => (elem.url = url));
|
this.uploader.queue.forEach((elem) => (elem.url = url));
|
||||||
|
|
||||||
const itemToUpload = this.uploader.queue[0];
|
const itemToUpload = this.uploader.queue[0];
|
||||||
(itemToUpload as any).options.disableMultipart = true;
|
if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers = [{ name: 'Authorization', value: 'Bearer ' + this.server.authToken }])
|
||||||
|
|
||||||
this.uploader.uploadItem(itemToUpload);
|
this.uploader.uploadItem(itemToUpload);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
goBack() {
|
goBack() {
|
||||||
this.router.navigate(['/server', this.server.id, 'preferences', 'iou', 'templates']);
|
this.router.navigate(['/server', this.server.id, 'preferences', 'iou', 'templates']);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { Appliance } from '../models/appliance';
|
import { Appliance } from '../models/appliance';
|
||||||
import { Server } from '../models/server';
|
import { Server } from '../models/server';
|
||||||
@ -17,7 +18,7 @@ export class ApplianceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUploadPath(server: Server, emulator: string, filename: string) {
|
getUploadPath(server: Server, emulator: string, filename: string) {
|
||||||
return `${server.protocol}//${server.host}:${server.port}/v3/images/upload/${filename}`;
|
return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAppliances(server: Server): Observable<Appliance[]> {
|
updateAppliances(server: Server): Observable<Appliance[]> {
|
||||||
|
@ -8,6 +8,7 @@ import { getTestServer } from './testing';
|
|||||||
|
|
||||||
import { ImageManagerService } from './image-manager.service';
|
import { ImageManagerService } from './image-manager.service';
|
||||||
import { Image } from "../models/images";
|
import { Image } from "../models/images";
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
describe('ImageManagerService', () => {
|
describe('ImageManagerService', () => {
|
||||||
let httpClient: HttpClient;
|
let httpClient: HttpClient;
|
||||||
@ -34,7 +35,7 @@ describe('ImageManagerService', () => {
|
|||||||
|
|
||||||
it('should be get Images', inject([ImageManagerService], (service: ImageManagerService) => {
|
it('should be get Images', inject([ImageManagerService], (service: ImageManagerService) => {
|
||||||
service.getImages(server).subscribe();
|
service.getImages(server).subscribe();
|
||||||
const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/images');
|
const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/images`);
|
||||||
expect(req.request.method).toEqual('GET');
|
expect(req.request.method).toEqual('GET');
|
||||||
expect(service).toBeTruthy();
|
expect(service).toBeTruthy();
|
||||||
}));
|
}));
|
||||||
@ -53,7 +54,7 @@ describe('ImageManagerService', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
service.uploadedImage(server, install_appliance, image.filename, image).subscribe();
|
service.uploadedImage(server, install_appliance, image.filename, image).subscribe();
|
||||||
const req = httpTestingController.expectOne('http://127.0.0.1:3080/v3/images/upload/?install_appliances=true');
|
const req = httpTestingController.expectOne(`http://127.0.0.1:3080/${environment.current_version}/images/upload/?install_appliances=true`);
|
||||||
expect(req.request.method).toEqual('POST');
|
expect(req.request.method).toEqual('POST');
|
||||||
expect(req.request.body).toEqual(image);
|
expect(req.request.body).toEqual(image);
|
||||||
}));
|
}));
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { IosImage } from '../models/images/ios-image';
|
import { IosImage } from '../models/images/ios-image';
|
||||||
import { Server } from '../models/server';
|
import { Server } from '../models/server';
|
||||||
@ -14,7 +15,7 @@ export class IosService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getImagePath(server: Server, filename: string): string {
|
getImagePath(server: Server, filename: string): string {
|
||||||
return `${server.protocol}//${server.host}:${server.port}/images/upload/${filename}`;
|
return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemplates(server: Server): Observable<IosTemplate[]> {
|
getTemplates(server: Server): Observable<IosTemplate[]> {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { environment } from 'environments/environment';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { IouImage } from '../models/iou/iou-image';
|
import { IouImage } from '../models/iou/iou-image';
|
||||||
import { Server } from '../models/server';
|
import { Server } from '../models/server';
|
||||||
@ -22,7 +23,7 @@ export class IouService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getImagePath(server: Server, filename: string): string {
|
getImagePath(server: Server, filename: string): string {
|
||||||
return `${server.protocol}//${server.host}:${server.port}/images/upload/${filename}`;
|
return `${server.protocol}//${server.host}:${server.port}/${environment.current_version}/images/upload/${filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
addTemplate(server: Server, iouTemplate: any): Observable<any> {
|
addTemplate(server: Server, iouTemplate: any): Observable<any> {
|
||||||
|
@ -2,4 +2,5 @@ export const environment = {
|
|||||||
solarputty_download_url: '',
|
solarputty_download_url: '',
|
||||||
production: true,
|
production: true,
|
||||||
electron: true,
|
electron: true,
|
||||||
|
current_version:'v3'
|
||||||
};
|
};
|
||||||
|
@ -2,4 +2,5 @@ export const environment = {
|
|||||||
production: false,
|
production: false,
|
||||||
electron: true,
|
electron: true,
|
||||||
solarputty_download_url: '',
|
solarputty_download_url: '',
|
||||||
|
current_version:'v3'
|
||||||
};
|
};
|
||||||
|
@ -3,4 +3,5 @@ export const environment = {
|
|||||||
electron: false,
|
electron: false,
|
||||||
githubio: true,
|
githubio: true,
|
||||||
solarputty_download_url: '',
|
solarputty_download_url: '',
|
||||||
|
current_version:'v3'
|
||||||
};
|
};
|
||||||
|
@ -3,4 +3,5 @@ export const environment = {
|
|||||||
electron: false,
|
electron: false,
|
||||||
githubio: false,
|
githubio: false,
|
||||||
solarputty_download_url: '',
|
solarputty_download_url: '',
|
||||||
|
current_version:'v3'
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,7 @@ export const environment = {
|
|||||||
electron: false,
|
electron: false,
|
||||||
githubio: false,
|
githubio: false,
|
||||||
solarputty_download_url: '',
|
solarputty_download_url: '',
|
||||||
|
current_version:'v3'
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user