diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 9b2b3650..b19c0c78 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -56,6 +56,7 @@ import { DefaultLayoutComponent } from './layouts/default-layout/default-layout.
import { ServerResolve } from './resolvers/server-resolve';
import { UserManagementComponent } from './components/user-management/user-management.component';
import { LoggedUserComponent } from './components/users/logged-user/logged-user.component';
+import { ImageManagerComponent } from '@components/image-manager/image-manager.component';
const routes: Routes = [
{
@@ -67,6 +68,7 @@ const routes: Routes = [
{ path: 'bundled', component: BundledServerFinderComponent },
{ path: 'server/:server_id/login', component: LoginComponent },
{ path: 'server/:server_id/loggeduser', component: LoggedUserComponent },
+ {path : 'server/:server_id/image-manager', component: ImageManagerComponent},
{
path: 'server/:server_id/projects',
component: ProjectsComponent,
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index caa42a53..1ba74ca7 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -272,6 +272,9 @@ import { HttpRequestsInterceptor } from './interceptors/http.interceptor';
import { UserManagementComponent } from './components/user-management/user-management.component'
import { UserService } from './services/user.service';
import { LoggedUserComponent } from './components/users/logged-user/logged-user.component';
+import { ImageManagerComponent } from './components/image-manager/image-manager.component';
+import { AddImageDialogComponent } from './components/image-manager/add-image-dialog/add-image-dialog.component';
+import { DeleteAllImageFilesDialogComponent } from './components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component';
@NgModule({
declarations: [
@@ -459,7 +462,10 @@ import { LoggedUserComponent } from './components/users/logged-user/logged-user.
ConfigureCustomAdaptersDialogComponent,
EditNetworkConfigurationDialogComponent,
UserManagementComponent,
- ProjectReadmeComponent
+ ProjectReadmeComponent,
+ ImageManagerComponent,
+ AddImageDialogComponent,
+ DeleteAllImageFilesDialogComponent,
],
imports: [
BrowserModule,
diff --git a/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.html b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.html
new file mode 100644
index 00000000..1fef1ff4
--- /dev/null
+++ b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.html
@@ -0,0 +1,70 @@
+
+
+
+
Would you like to automatically install appliances for this image?
+
+
+
+
+
+
+
+
+
+ Yes
+
+
+ No
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Please Select image
+
+
+
+
+
+
+
+
+
+
+
+ {{i+1}}. {{img?.name}}
+
+
+
+
+
+
0">
+
Uploaded image details
+
{{i+1}}. {{uploadFile?.filename ?? uploadFile?.error?.message}}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.scss b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.scss
new file mode 100644
index 00000000..26141499
--- /dev/null
+++ b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.scss
@@ -0,0 +1,83 @@
+.progress-bar {
+ padding: 0;
+ }
+ .progress {
+ width: 50px;
+ background-color: #263238;
+ height: 28px;
+ margin-left: 13px;
+ }
+ .mat-input-element {
+ font-size: medium;
+ font-weight: 200;
+ }
+ #fileInput {
+ position: absolute;
+ cursor: pointer;
+ z-index: 10;
+ opacity: 0;
+ height: 100%;
+ left: 0px;
+ top: 0px;
+ }
+ .mat-toolbar-single-row {
+ height: auto;
+ background: transparent;
+ padding: 0;
+ }
+ .mat-toolbar-single-row button {
+ width: 100px;
+ }
+ .mat-form-field {
+ width: 100%;
+ }
+ .message {
+ background-color: #ddd;
+ padding: 15px;
+ color: #333;
+ border: #aaa solid 1px;
+ border-radius: 4px;
+ margin: 15px 0;
+ }
+ .preview {
+ max-width: 200px;
+ vertical-align: middle;
+ }
+ .list-card {
+ margin-top: 20px;
+ }
+ .list-item {
+ margin-bottom: 20px;
+ }
+
+ .non-visible {
+ display: none;
+ }
+
+ mat-progress-bar{
+ margin-top: 10px;
+ }
+ .txt-align{
+ text-align: end;
+ }
+ .uploaded-text{
+ color: #0ca8c7;
+ font-size: 17px;
+ }
+ .uploaded-error-text{
+ color: #d52435;
+ font-weight: 600;
+ }
+
+ .choose-instal-appliance {
+ display: flex;
+ flex-direction: row;
+ margin: 15px 0px 11px 0px;
+ align-items: flex-start;
+ }
+
+ .instal-appliances-button {
+ margin: 11px;
+ }
+
+
\ No newline at end of file
diff --git a/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.spec.ts b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.spec.ts
new file mode 100644
index 00000000..cf51111b
--- /dev/null
+++ b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.spec.ts
@@ -0,0 +1,64 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { MatCheckboxModule } from '@angular/material/checkbox';
+import { MatDialog, MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { MatIconModule } from '@angular/material/icon';
+import { MatMenuModule } from '@angular/material/menu';
+import { MatToolbarModule } from '@angular/material/toolbar';
+import { ImageManagerService } from 'app/services/image-manager.service';
+import { ServerService } from '../../../services/server.service';
+import { MockedServerService } from '../../../services/server.service.spec';
+import { of } from 'rxjs';
+import { Server } from '../../../models/server';
+
+import { AddImageDialogComponent } from './add-image-dialog.component';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { ToasterService } from 'app/services/toaster.service';
+import { MockedToasterService } from 'app/services/toaster.service.spec';
+
+export class MockedImageManagerService {
+ public getImages(server: Server) {
+ return of();
+ }
+
+}
+
+describe('AddImageDialogComponent', () => {
+ let component: AddImageDialogComponent;
+ let fixture: ComponentFixture;
+
+ let mockedServerService = new MockedServerService();
+ let mockedImageManagerService = new MockedImageManagerService()
+ let mockedToasterService = new MockedToasterService()
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports:[
+ MatIconModule,
+ MatToolbarModule,
+ MatMenuModule,
+ MatCheckboxModule,
+ MatDialogModule
+ ],
+ providers: [
+ { provide: ServerService, useValue: mockedServerService },
+ { provide: ImageManagerService, useValue: mockedImageManagerService },
+ { provide: MAT_DIALOG_DATA, useValue: {} },
+ { provide: MatDialogRef, useValue: {} },
+ { provide: ToasterService, useValue: mockedToasterService },
+ ],
+ declarations: [ AddImageDialogComponent ],
+ schemas: [NO_ERRORS_SCHEMA],
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AddImageDialogComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.ts b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.ts
new file mode 100644
index 00000000..456e23d5
--- /dev/null
+++ b/src/app/components/image-manager/add-image-dialog/add-image-dialog.component.ts
@@ -0,0 +1,67 @@
+import { Component, Inject, OnInit } from '@angular/core';
+import { animate, state, style, transition, trigger } from '@angular/animations';
+import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { Server } from '../../../models/server';
+import { ImageManagerService } from '../../../services/image-manager.service';
+import { Observable, of } from 'rxjs';
+import { catchError } from 'rxjs/operators';
+import { ImageData } from '../../../models/images';
+
+@Component({
+ selector: 'app-add-image-dialog',
+ templateUrl: './add-image-dialog.component.html',
+ styleUrls: ['./add-image-dialog.component.scss'],
+ animations: [
+ trigger('detailExpand', [
+ state('collapsed', style({ height: '0px', minHeight: '0', visibility: 'hidden' })),
+ state('expanded', style({ height: '*', visibility: 'visible' })),
+ transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
+ ]),
+ ],
+})
+
+export class AddImageDialogComponent implements OnInit {
+ server: Server;
+ uploadedFile: boolean = false;
+ isExistImage: boolean = false;
+ isInstallAppliance: boolean = false
+ install_appliance: boolean = false
+ selectFile: any = [];
+ uploadFileMessage: ImageData = []
+
+ constructor(
+ @Inject(MAT_DIALOG_DATA) public data: any,
+ public dialogRef: MatDialogRef,
+ private imageService: ImageManagerService,
+
+ ) { }
+
+ public ngOnInit(): void {
+ this.server = this.data
+ }
+
+ selectInstallApplianceOption(ev) {
+ this.install_appliance = ev.value
+ }
+
+ async uploadImageFile(event) {
+ for (let imgFile of event.target.files) {
+ this.selectFile.push(imgFile)
+ }
+ await this.upload()
+ }
+
+ // files uploading
+ upload() {
+ const calls = [];
+ this.uploadedFile = true;
+ this.selectFile.forEach(imgElement => {
+ calls.push(this.imageService.uploadedImage(this.server, this.install_appliance, imgElement.name, imgElement).pipe(catchError(error => of(error))))
+ });
+ Observable.forkJoin(calls).subscribe(responses => {
+ this.uploadFileMessage = responses
+ this.uploadedFile = false;
+ this.isExistImage = true;
+ });
+ }
+}
diff --git a/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.html b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.html
new file mode 100644
index 00000000..72a4d605
--- /dev/null
+++ b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.html
@@ -0,0 +1,34 @@
+
+
Do you want delete all files ?.
+
+
Your selected files
+
{{i+1}}. {{file?.filename}}
+
+
+
+
+
+
+
+
Please wait.
+
+
+
+
+
+
+
+
+
+
0">
+
Images can't be deleted because image used in one or more template.
+
{{i+1}}. {{message?.error?.message}}
+
+
0">
+
{{fileNotDeleted.length}} Images deleted successfully.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.scss b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.scss
new file mode 100644
index 00000000..f962e55b
--- /dev/null
+++ b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.scss
@@ -0,0 +1,11 @@
+.delete-text{
+ color: #0ca8c7;
+ font-size: 17px;
+ }
+
+.deleted-error-text{
+ color: #d52435;
+ font-weight: 600;
+}
+
+
\ No newline at end of file
diff --git a/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.spec.ts b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.spec.ts
new file mode 100644
index 00000000..43aea89c
--- /dev/null
+++ b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.spec.ts
@@ -0,0 +1,65 @@
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { MatCheckboxModule } from '@angular/material/checkbox';
+import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { MatIconModule } from '@angular/material/icon';
+import { MatMenuModule } from '@angular/material/menu';
+import { MatToolbarModule } from '@angular/material/toolbar';
+import { ToasterService } from 'app/services/toaster.service';
+import { MockedToasterService } from 'app/services/toaster.service.spec';
+import { Server } from 'http';
+import { of } from 'rxjs';
+import { ImageManagerService } from '../../../services/image-manager.service';
+import { ServerService } from '../../../services/server.service';
+import { MockedServerService } from '../../../services/server.service.spec';
+import { ImageManagerComponent } from '../image-manager.component';
+
+import { DeleteAllImageFilesDialogComponent } from './deleteallfiles-dialog.component';
+
+export class MockedImageManagerService {
+ public deleteALLFile(server: Server, image_path) {
+ return of();
+ }
+}
+
+ describe('DeleteAllImageFilesDialogComponent', () => {
+ let component: DeleteAllImageFilesDialogComponent;
+ let fixture: ComponentFixture;
+ let mockedServerService = new MockedServerService();
+ let mockedImageManagerService = new MockedImageManagerService()
+ let mockedToasterService = new MockedToasterService()
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [
+ MatIconModule,
+ MatToolbarModule,
+ MatMenuModule,
+ MatCheckboxModule,
+ MatDialogModule,
+ ],
+ providers: [
+ { provide: ServerService, useValue: mockedServerService },
+ { provide: ImageManagerService, useValue: mockedImageManagerService },
+ { provide: MAT_DIALOG_DATA, useValue: {} },
+ { provide: MatDialogRef, useValue: {} },
+ { provide: ToasterService, useValue: mockedToasterService },
+
+ ],
+ declarations: [DeleteAllImageFilesDialogComponent,
+ ],
+ schemas: [NO_ERRORS_SCHEMA],
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(DeleteAllImageFilesDialogComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.ts b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.ts
new file mode 100644
index 00000000..6fd33fca
--- /dev/null
+++ b/src/app/components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component.ts
@@ -0,0 +1,50 @@
+import { Component, Inject, OnInit } from '@angular/core';
+import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { ImageManagerService } from '../../../services/image-manager.service';
+import { ToasterService } from '../../../services/toaster.service';
+import { Observable, of } from 'rxjs';
+import { catchError } from 'rxjs/operators';
+import { ImageData } from '../../../models/images';
+
+@Component({
+ selector: 'app-deleteallfiles-dialog',
+ templateUrl: './deleteallfiles-dialog.component.html',
+ styleUrls: ['./deleteallfiles-dialog.component.scss']
+})
+export class DeleteAllImageFilesDialogComponent implements OnInit {
+ isDelete: boolean = false;
+ isUsedFiles: boolean = false;
+ deleteFliesDetails: ImageData = []
+ fileNotDeleted: ImageData = []
+
+ constructor(
+ @Inject(MAT_DIALOG_DATA) public deleteData: any,
+ public dialogRef: MatDialogRef,
+ private imageService: ImageManagerService,
+ private toasterService: ToasterService
+ ) { }
+
+ ngOnInit(): void {
+ }
+
+ async deleteAll() {
+ this.isDelete = true
+ await this.deleteFile()
+ }
+
+ deleteFile() {
+ const calls = [];
+ this.deleteData.deleteFilesPaths.forEach(pathElement => {
+ calls.push(this.imageService.deleteFile(this.deleteData.server, pathElement.filename).pipe(catchError(error => of(error))))
+ });
+ Observable.forkJoin(calls).subscribe(responses => {
+ this.deleteFliesDetails = responses.filter(x => x !== null)
+ this.fileNotDeleted = responses.filter(x => x === null)
+ this.isUsedFiles = true;
+ this.isDelete = true
+ });
+
+ }
+
+
+}
diff --git a/src/app/components/image-manager/image-database-file.ts b/src/app/components/image-manager/image-database-file.ts
new file mode 100644
index 00000000..09415d7b
--- /dev/null
+++ b/src/app/components/image-manager/image-database-file.ts
@@ -0,0 +1,36 @@
+
+
+import { DataSource, SelectionModel } from '@angular/cdk/collections';
+import { MatSort } from '@angular/material/sort';
+import { BehaviorSubject, Observable, Subscription, merge } from 'rxjs';
+import { map } from 'rxjs/operators';
+import { Image } from '../../models/images';
+
+
+export class imageDatabase {
+ dataChange: BehaviorSubject = new BehaviorSubject([]);
+ get data(): Image[] {
+ return this.dataChange.value;
+ }
+
+ public addImages(fileData: Image[]) {
+ this.dataChange.next(fileData);
+ }
+
+}
+
+export class imageDataSource extends DataSource {
+ constructor(private serverDatabase: imageDatabase) {
+ super();
+ }
+
+ connect(): Observable {
+ return merge(this.serverDatabase.dataChange).pipe(
+ map(() => {
+ return this.serverDatabase.data;
+ })
+ );
+ }
+
+ disconnect() { }
+}
diff --git a/src/app/components/image-manager/image-manager.component.html b/src/app/components/image-manager/image-manager.component.html
new file mode 100644
index 00000000..5dde19d3
--- /dev/null
+++ b/src/app/components/image-manager/image-manager.component.html
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ File Name
+
+ {{ row.filename }}
+
+
+
+
+ Image Type
+ {{ row.image_type }}
+
+
+
+ Image Size
+ {{ (row.image_size/1000000).toFixed()}} MB
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/components/image-manager/image-manager.component.scss b/src/app/components/image-manager/image-manager.component.scss
new file mode 100644
index 00000000..047a0ad8
--- /dev/null
+++ b/src/app/components/image-manager/image-manager.component.scss
@@ -0,0 +1,17 @@
+.non-visible {
+ display: none;
+ }
+
+.img-btn{
+ margin: auto;
+ }
+.btn-box{
+ display: flex;
+ margin-top: 10px;
+}
+
+mat-header-cell, mat-cell {
+ justify-content: center;
+}
+
+
\ No newline at end of file
diff --git a/src/app/components/image-manager/image-manager.component.spec.ts b/src/app/components/image-manager/image-manager.component.spec.ts
new file mode 100644
index 00000000..bdba7db1
--- /dev/null
+++ b/src/app/components/image-manager/image-manager.component.spec.ts
@@ -0,0 +1,96 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { MatCheckboxModule } from '@angular/material/checkbox';
+import { MatDialogModule } from '@angular/material/dialog';
+import { MatIconModule } from '@angular/material/icon';
+import { MatMenuModule } from '@angular/material/menu';
+import { MatToolbarModule } from '@angular/material/toolbar';
+import { ImageManagerService } from 'app/services/image-manager.service';
+import { ServerService } from 'app/services/server.service';
+import { MockedServerService } from 'app/services/server.service.spec';
+import { of } from 'rxjs';
+import { Server } from '../../models/server';
+
+import { ImageManagerComponent } from './image-manager.component';
+import { Image } from '../../models/images';
+import { ProgressService } from 'app/common/progress/progress.service';
+import { MockedProgressService } from '../project-map/project-map.component.spec';
+import { MockedActivatedRoute } from '../preferences/preferences.component.spec';
+import { ActivatedRoute } from '@angular/router';
+import { MockedVersionService } from '../../services/version.service.spec';
+import { VersionService } from 'app/services/version.service';
+import { ToasterService } from 'app/services/toaster.service';
+import { MockedToasterService } from 'app/services/toaster.service.spec';
+
+export class MockedImageManagerService {
+ public getImages(server: Server) {
+ return of();
+ }
+
+ public deleteFile(server: Server, image_path) {
+ return of();
+ }
+
+}
+
+describe('ImageManagerComponent', () => {
+ let component: ImageManagerComponent;
+ let fixture: ComponentFixture;
+
+ let mockedServerService = new MockedServerService();
+ let mockedImageManagerService = new MockedImageManagerService()
+ let mockedProgressService = new MockedProgressService()
+ let mockedVersionService = new MockedVersionService()
+ let mockedToasterService = new MockedToasterService()
+ let activatedRoute = new MockedActivatedRoute().get();
+
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [
+ MatIconModule,
+ MatToolbarModule,
+ MatMenuModule,
+ MatCheckboxModule,
+ MatDialogModule
+ ],
+ providers: [
+ {
+ provide: ActivatedRoute,
+ useValue: activatedRoute,
+ },
+ { provide: ServerService, useValue: mockedServerService },
+ { provide: ImageManagerService, useValue: mockedImageManagerService },
+ { provide: ProgressService, useValue: mockedProgressService },
+ { provide: VersionService, useValue: mockedVersionService },
+ { provide: ToasterService, useValue: mockedToasterService },
+ ],
+ declarations: [ImageManagerComponent],
+ schemas: [NO_ERRORS_SCHEMA],
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ImageManagerComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+
+ it('should call save images', () => {
+ spyOn(mockedImageManagerService, 'getImages').and.returnValue(of({} as Image));
+ component.getImages()
+ expect(mockedImageManagerService.getImages).toHaveBeenCalled();
+ });
+
+ it('should delete image', () => {
+ spyOn(mockedImageManagerService, 'deleteFile').and.returnValue(of({} as Image));
+ component.deleteFile('image_path')
+ expect(mockedImageManagerService.deleteFile).toHaveBeenCalled();
+ });
+});
diff --git a/src/app/components/image-manager/image-manager.component.ts b/src/app/components/image-manager/image-manager.component.ts
new file mode 100644
index 00000000..ee51888f
--- /dev/null
+++ b/src/app/components/image-manager/image-manager.component.ts
@@ -0,0 +1,149 @@
+import { Component, OnInit } from '@angular/core';
+import { ActivatedRoute } from '@angular/router';
+import { ServerService } from '../../services/server.service';
+import { VersionService } from '../../services/version.service';
+import { ProgressService } from 'app/common/progress/progress.service';
+import { Image } from '../../models/images';
+import { Server } from '../../models/server';
+import { ImageManagerService } from "../../services/image-manager.service";
+import { DataSource, SelectionModel } from '@angular/cdk/collections';
+import { AddImageDialogComponent } from './add-image-dialog/add-image-dialog.component';
+import { MatDialog } from '@angular/material/dialog';
+import { ToasterService } from '../../services/toaster.service';
+import { DeleteAllImageFilesDialogComponent } from './deleteallfiles-dialog/deleteallfiles-dialog.component';
+import { imageDataSource, imageDatabase } from "./image-database-file";
+
+@Component({
+ selector: 'app-image-manager',
+ templateUrl: './image-manager.component.html',
+ styleUrls: ['./image-manager.component.scss']
+})
+export class ImageManagerComponent implements OnInit {
+ server: Server;
+ public version: string;
+ dataSource: imageDataSource;
+ imageDatabase = new imageDatabase();
+ isAllDelete: boolean = false
+ selection = new SelectionModel(true, []);
+
+ displayedColumns = ['select', 'filename', 'image_type', 'image_size','delete'];
+
+ constructor(
+ private imageService: ImageManagerService,
+ private progressService: ProgressService,
+ private route: ActivatedRoute,
+ private serverService: ServerService,
+ private versionService: VersionService,
+ private dialog: MatDialog,
+ private toasterService: ToasterService,
+
+ ) { }
+
+ ngOnInit(): void {
+ let server_id = parseInt(this.route.snapshot.paramMap.get('server_id'));
+ this.serverService.get(server_id).then((server: Server) => {
+ this.server = server;
+ if (server.authToken) {
+ this.getImages()
+ }
+ // this.versionService.get(this.server).subscribe((version: Version) => {
+ // this.version = version.version;
+ // });
+ });
+ this.dataSource = new imageDataSource(this.imageDatabase);
+ }
+
+ getImages() {
+ this.imageService.getImages(this.server).subscribe(
+ (images: Image[]) => {
+ this.imageDatabase.addImages(images)
+ },
+ (error) => {
+ this.toasterService.error(error.error.message)
+
+ }
+ );
+ }
+
+ deleteFile(path) {
+ this.imageService.deleteFile(this.server, path).subscribe(
+ (res) => {
+ this.getImages()
+ this.unChecked()
+ this.toasterService.success('File deleted');
+ },
+ (error) => {
+ this.getImages()
+ this.unChecked()
+ this.toasterService.error(error.error.message)
+ }
+ );
+ }
+
+ isAllSelected() {
+ const numSelected = this.selection.selected.length;
+ const numRows = this.imageDatabase.data.length;
+ return numSelected === numRows;
+ }
+
+ selectAllImages() {
+ this.isAllSelected() ? this.unChecked() : this.allChecked()
+ }
+
+ unChecked() {
+ this.selection.clear()
+ this.isAllDelete = false
+ }
+
+ allChecked() {
+ this.imageDatabase.data.forEach(row => this.selection.select(row))
+ this.isAllDelete = true;
+ }
+
+ public addImageDialog() {
+ const dialogRef = this.dialog.open(AddImageDialogComponent, {
+ width: '600px',
+ maxHeight: '550px',
+ autoFocus: false,
+ disableClose: true,
+ data: this.server
+ });
+
+ dialogRef.afterClosed().subscribe((isAddes: boolean) => {
+ if (isAddes) {
+ this.getImages()
+ this.unChecked()
+ } else {
+ this.getImages()
+ this.unChecked()
+ return false;
+ }
+ });
+ }
+
+ deleteAllFiles() {
+ const dialogRef = this.dialog.open(DeleteAllImageFilesDialogComponent, {
+ width: '500px',
+ maxHeight: '650px',
+ autoFocus: false,
+ disableClose: true,
+ data: {
+ server: this.server,
+ deleteFilesPaths: this.selection.selected
+ }
+ });
+
+ dialogRef.afterClosed().subscribe((isAllfilesdeleted: boolean) => {
+ if (isAllfilesdeleted) {
+ this.unChecked()
+ this.getImages()
+ this.toasterService.success('All files deleted');
+ } else {
+ this.unChecked()
+ this.getImages()
+ return false;
+ }
+ });
+ }
+}
+
diff --git a/src/app/components/project-map/project-map.component.html b/src/app/components/project-map/project-map.component.html
index 000f83de..fa9a4852 100644
--- a/src/app/components/project-map/project-map.component.html
+++ b/src/app/components/project-map/project-map.component.html
@@ -103,6 +103,10 @@
settings
Go to settings
+