+
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.SIZE' | translate }}
-
{{ template.size | division:2:30:2 }} {{ 'UNITS.GB' | translate }}
+
{{ entity.size | division:2:30:2 }} {{ 'UNITS.GB' | translate }}
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.EXTRACTABLE' | translate }}
-
{{ template.isExtractable | viewValue | async }}
+
{{ entity.isExtractable | viewValue | async }}
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.PUBLIC' | translate }}
-
{{ template.isPublic | viewValue | async }}
+
{{ entity.isPublic | viewValue | async }}
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.RECOMMENDED' | translate }}
-
{{ template.isFeatured | viewValue | async }}
+
{{ entity.isFeatured | viewValue | async }}
-
+
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.PASSWORD_ENABLED' | translate }}
-
{{ template.isPasswordEnabled | viewValue | async }}
+
{{ entity.isPasswordEnabled | viewValue | async }}
-
+
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.DYNAMICALLY_SCALABLE' | translate }}
-
{{ template.isDynamicallyScalable | viewValue | async }}
+
{{ entity.isDynamicallyScalable | viewValue | async }}
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.CROSS_ZONES' | translate }}
-
{{ template.crossZones | viewValue | async }}
+
{{ entity.crossZones | viewValue | async }}
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.DOMAIN' | translate }}
-
{{ template.domain }}
+
{{ entity.domain }}
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.CREATED' | translate }}
-
{{ template.created | stringifyDate }}
+
{{ entity.created | stringifyDate }}
-
+
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.TYPE' | translate }}
{{ templateTypeTranslationToken | translate }}
-
+
{{ 'TEMPLATE_PAGE.TEMPLATE_DETAILS.HYPERVISOR' | translate }}
-
{{ template.hypervisor }}
+
{{ entity.hypervisor }}
@@ -112,7 +112,7 @@
{{ "TEMPLATE_PAGE.TEMPLATE_DETAILS.DETAILS" | tra
{{ 'COMMON.UPDATE' | translate }}
-
+
{{ zone.zoneName }}
@@ -137,7 +137,11 @@ {{ zone.zoneName }}
local_offer
-
+
+
+
+
+
diff --git a/src/app/template/template-sidebar/base-template-sidebar.component.ts b/src/app/template/template-sidebar/base-template-sidebar.component.ts
index 67b2f1cdb2..90ca06d364 100644
--- a/src/app/template/template-sidebar/base-template-sidebar.component.ts
+++ b/src/app/template/template-sidebar/base-template-sidebar.component.ts
@@ -1,44 +1,39 @@
-import { Input, OnInit } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
-import { BaseTemplateModel } from '../shared/base-template.model';
-import { TemplateActionsService } from '../shared/template-actions.service';
-import { ListService } from '../../shared/components/list/list.service';
-import { BaseTemplateService } from '../shared/base-template.service';
+import { OnInit } from '@angular/core';
+import { ActivatedRoute, Router } from '@angular/router';
+import { Observable } from 'rxjs/Observable';
import { DialogService } from '../../dialog/dialog-module/dialog.service';
-import { NotificationService } from '../../shared/services/notification.service';
+import { ListService } from '../../shared/components/list/list.service';
+import { SidebarComponent } from '../../shared/components/sidebar/sidebar.component';
import { DateTimeFormatterService } from '../../shared/services/date-time-formatter.service';
+import { NotificationService } from '../../shared/services/notification.service';
+import { BaseTemplateModel } from '../shared/base-template.model';
+import { BaseTemplateService } from '../shared/base-template.service';
+import { TemplateActionsService } from '../shared/template-actions.service';
+import { TemplateTagKeys } from '../../shared/services/tags/template-tag-keys';
-export abstract class BaseTemplateSidebarComponent implements OnInit {
- @Input() public template: BaseTemplateModel;
+export abstract class BaseTemplateSidebarComponent extends SidebarComponent
implements OnInit {
+ public templateDownloadUrl: string;
public readyInEveryZone: boolean;
public updating: boolean;
-
private service: BaseTemplateService;
constructor(
service: BaseTemplateService,
public dateTimeFormatterService: DateTimeFormatterService,
- private route: ActivatedRoute,
private dialogService: DialogService,
- private notificationService: NotificationService,
- protected templateActions: TemplateActionsService,
+ protected route: ActivatedRoute,
+ protected router: Router,
protected listService: ListService,
+ protected notificationService: NotificationService,
+ protected templateActions: TemplateActionsService
) {
+ super(service, notificationService, route, router);
this.service = service;
}
- public ngOnInit(): void {
- this.route.params.pluck('id').filter(id => !!id).subscribe((id: string) => {
- this.service.getWithGroupedZones(id).subscribe(template => {
- this.template = template;
- this.checkZones();
- });
- });
- }
-
public get templateTypeTranslationToken(): string {
- const type = this.template && (this.template as any).type || '';
+ const type = this.entity && (this.entity as any).type || '';
const templateTypeTranslations = {
'BUILTIN': 'Built-in',
'USER': 'User'
@@ -48,30 +43,26 @@ export abstract class BaseTemplateSidebarComponent implements OnInit {
}
public remove(): void {
- this.templateActions.removeTemplate(this.template).subscribe(() => {
- this.listService.onUpdate.emit(this.template);
+ this.templateActions.removeTemplate(this.entity).subscribe(() => {
+ this.listService.onUpdate.emit(this.entity);
});
}
public updateStatus(): void {
- if (this.template) {
+ if (this.entity) {
this.updating = true;
- this.service.getWithGroupedZones(this.template.id, null, false)
+ this.service.getWithGroupedZones(this.entity.id, null, false)
.finally(() => this.updating = false)
.subscribe(
template => {
- this.template = template;
- this.checkZones();
+ this.entity = template;
+ this.checkZones(template);
},
error => this.dialogService.alert(error.message)
);
}
}
- private checkZones(): void {
- this.readyInEveryZone = this.template.zones.every(template => template.isReady);
- }
-
public onCopySuccess(): void {
this.notificationService.message('COPY_SUCCESS');
}
@@ -79,4 +70,28 @@ export abstract class BaseTemplateSidebarComponent implements OnInit {
public onCopyFail(): void {
this.notificationService.message('COPY_FAIL');
}
+
+ private checkZones(template: BaseTemplateModel): void {
+ this.readyInEveryZone = template && template.zones.every(_ => _.isReady);
+ }
+
+ protected loadEntity(id: string): Observable {
+ return this.service.getWithGroupedZones(id)
+ .switchMap(template => {
+ if (template) {
+ return Observable.of(template);
+ } else {
+ return Observable.throw('ENTITY_DOES_NOT_EXIST');
+ }
+ })
+ .do(template => {
+ const downloadUrlTag = template.tags.find(
+ tag => tag.key === TemplateTagKeys.downloadUrl
+ );
+ if (downloadUrlTag) {
+ this.templateDownloadUrl = downloadUrlTag.value;
+ }
+ this.checkZones(template);
+ });
+ }
}
diff --git a/src/app/template/template-sidebar/iso-sidebar.component.ts b/src/app/template/template-sidebar/iso-sidebar.component.ts
index 678fb26013..870cf8f623 100644
--- a/src/app/template/template-sidebar/iso-sidebar.component.ts
+++ b/src/app/template/template-sidebar/iso-sidebar.component.ts
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
import { ListService } from '../../shared/components/list/list.service';
import { IsoService } from '../shared';
import { TemplateActionsService } from '../shared/template-actions.service';
@@ -18,6 +18,7 @@ export class IsoSidebarComponent extends BaseTemplateSidebarComponent {
isoService: IsoService,
dateTimeFormatterService: DateTimeFormatterService,
route: ActivatedRoute,
+ router: Router,
templateActions: TemplateActionsService,
listService: ListService,
dialogService: DialogService,
@@ -26,11 +27,12 @@ export class IsoSidebarComponent extends BaseTemplateSidebarComponent {
super(
isoService,
dateTimeFormatterService,
- route,
dialogService,
+ route,
+ router,
+ listService,
notificationService,
- templateActions,
- listService
+ templateActions
);
}
}
diff --git a/src/app/template/template-sidebar/template-sidebar.component.ts b/src/app/template/template-sidebar/template-sidebar.component.ts
index 21d2476c6c..11d1a35a32 100644
--- a/src/app/template/template-sidebar/template-sidebar.component.ts
+++ b/src/app/template/template-sidebar/template-sidebar.component.ts
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
import { TemplateService } from '../shared';
import { BaseTemplateSidebarComponent } from './base-template-sidebar.component';
import { TemplateActionsService } from '../shared/template-actions.service';
@@ -18,6 +18,7 @@ export class TemplateSidebarComponent extends BaseTemplateSidebarComponent {
templateService: TemplateService,
dateTimeFormatterService: DateTimeFormatterService,
route: ActivatedRoute,
+ router: Router,
templateActions: TemplateActionsService,
listService: ListService,
dialogService: DialogService,
@@ -26,11 +27,12 @@ export class TemplateSidebarComponent extends BaseTemplateSidebarComponent {
super(
templateService,
dateTimeFormatterService,
- route,
dialogService,
+ route,
+ router,
+ listService,
notificationService,
- templateActions,
- listService
+ templateActions
);
}
}
diff --git a/src/app/vm/shared/vm.service.ts b/src/app/vm/shared/vm.service.ts
index 3e3980bc01..197aa7d4f9 100644
--- a/src/app/vm/shared/vm.service.ts
+++ b/src/app/vm/shared/vm.service.ts
@@ -71,10 +71,11 @@ export class VmService extends BaseBackendService {
public getListWithDetails(params?: {}, customApiFormat?: ApiFormat, lite = false): Observable> {
if (lite) {
- return super.getList(params);
+ return this.getList(params);
}
+
return Observable.forkJoin(
- super.getList(params),
+ this.getList(params),
this.volumeService.getList(),
this.osTypesService.getList(),
this.serviceOfferingService.getList(),
diff --git a/src/app/vm/vm-sidebar/vm-sidebar.component.html b/src/app/vm/vm-sidebar/vm-sidebar.component.html
index f074bb27f2..2e6015a687 100644
--- a/src/app/vm/vm-sidebar/vm-sidebar.component.html
+++ b/src/app/vm/vm-sidebar/vm-sidebar.component.html
@@ -1,39 +1,41 @@
-
-
-
-
-
-
-
- computer
-
-
-
-
-
-
-
- storage
-
-
-
-
-
-
-
- router
-
-
-
-
-
-
-
- local_offer
-
-
-
-
-
-
-
+
+
+
+
+
+
+ computer
+
+
+
+
+
+
+
+ storage
+
+
+
+
+
+
+
+ router
+
+
+
+
+
+
+
+ local_offer
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/vm/vm-sidebar/vm-sidebar.component.scss b/src/app/vm/vm-sidebar/vm-sidebar.component.scss
index 3112edcc1a..34e9d9e9db 100644
--- a/src/app/vm/vm-sidebar/vm-sidebar.component.scss
+++ b/src/app/vm/vm-sidebar/vm-sidebar.component.scss
@@ -8,4 +8,4 @@ h4.details-header {
:host /deep/ .mat-tab-label {
min-width: 83px !important;
-}
\ No newline at end of file
+}
diff --git a/src/app/vm/vm-sidebar/vm-sidebar.component.ts b/src/app/vm/vm-sidebar/vm-sidebar.component.ts
index c1ed4dcac1..602f8b2c00 100644
--- a/src/app/vm/vm-sidebar/vm-sidebar.component.ts
+++ b/src/app/vm/vm-sidebar/vm-sidebar.component.ts
@@ -1,9 +1,10 @@
-import { Component, Input } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
-
+import { Component } from '@angular/core';
+import { ActivatedRoute, Router } from '@angular/router';
+import { SidebarComponent } from '../../shared/components/sidebar/sidebar.component';
+import { NotificationService } from '../../shared/services/notification.service';
import { VirtualMachine } from '../shared/vm.model';
import { VmService } from '../shared/vm.service';
-import { NotificationService } from '../../shared/services/notification.service';
+import { Observable } from 'rxjs/Observable';
@Component({
@@ -11,20 +12,24 @@ import { NotificationService } from '../../shared/services/notification.service'
templateUrl: 'vm-sidebar.component.html',
styleUrls: ['vm-sidebar.component.scss']
})
-export class VmSidebarComponent {
- @Input() public vm: VirtualMachine;
-
+export class VmSidebarComponent extends SidebarComponent {
constructor(
- private vmService: VmService,
- private notificationService: NotificationService,
- private route: ActivatedRoute
+ protected vmService: VmService,
+ protected notificationService: NotificationService,
+ protected route: ActivatedRoute,
+ protected router: Router
) {
- this.route.params.pluck('id')
- .filter(id => !!id)
- .switchMap((id: string) => this.vmService.getWithDetails(id))
- .subscribe(
- vm => this.vm = vm,
- (error) => this.notificationService.error(error.message)
- );
+ super(vmService, notificationService, route, router);
+ }
+
+ protected loadEntity(id: string): Observable {
+ return this.vmService.getWithDetails(id)
+ .switchMap(vm => {
+ if (vm) {
+ return Observable.of(vm);
+ } else {
+ return Observable.throw('ENTITY_DOES_NOT_EXIST');
+ }
+ });
}
}
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 6700f74313..e07236941b 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -772,6 +772,10 @@
"SELECT_AN_OPTION": "Select an option"
},
+ "VM_NOT_FOUND": "Virtual machine not found",
+ "VOLUME_NOT_FOUND": "Volume not found",
+ "TEMPLATE_NOT_FOUND": "Template not found",
+
"PULSE": {
"PULSE": "Pulse",
"CPU_RAM": "CPU / RAM",
diff --git a/src/i18n/ru.json b/src/i18n/ru.json
index 5cc8ada27b..07fe132905 100644
--- a/src/i18n/ru.json
+++ b/src/i18n/ru.json
@@ -772,6 +772,10 @@
"SELECT_AN_OPTION": "Выберите опцию"
},
+ "VM_NOT_FOUND": "Виртуальная машина не найдена",
+ "VOLUME_NOT_FOUND": "Диск не найден",
+ "TEMPLATE_NOT_FOUND": "Шаблон не найден",
+
"PULSE": {
"PULSE": "Pulse",
"CPU_RAM": "ЦП / ОЗУ",