Skip to content

Commit

Permalink
Tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
SchoolGuy committed Jun 28, 2022
1 parent 1593a91 commit bda0078
Show file tree
Hide file tree
Showing 25 changed files with 398 additions and 134 deletions.
44 changes: 35 additions & 9 deletions projects/cobbler-api/src/lib/cobbler-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class CobblerApiService {
background_syncsystems(options: SyncSystemsOptions, token: string): Observable<string> {
const transformedOptions: XmlRpcStruct = {
members: [
{name: 'systems', value: { data: options.systems }},
{name: 'systems', value: {data: options.systems}},
{name: 'verbose', value: options.verbose},
]
}
Expand Down Expand Up @@ -245,7 +245,7 @@ export class CobblerApiService {
background_reposync(options: BackgroundReposyncOptions, token: string): Observable<string> {
const transformedOptions: XmlRpcStruct = {
members: [
{name: 'repos', value: { data: options.repos }},
{name: 'repos', value: {data: options.repos}},
{name: 'only', value: options.only},
{name: 'nofail', value: options.nofail},
{name: 'tries', value: options.tries},
Expand All @@ -268,7 +268,7 @@ export class CobblerApiService {
background_power_system(options: BackgroundPowerSystem, token: string): Observable<string> {
const transformedOptions: XmlRpcStruct = {
members: [
{name: 'systems', value: { data: options.systems }},
{name: 'systems', value: {data: options.systems}},
{name: 'power', value: options.power},
]
}
Expand Down Expand Up @@ -2050,18 +2050,44 @@ export class CobblerApiService {
);
}

private convertXmlRpcStructToTypeScriptObject(inputStruct: XmlRpcStruct): object {
const result_object = {}
inputStruct.members.forEach((member) => {
let value;
if (AngularXmlrpcService.instanceOfXmlRpcArray(member.value)) {
value = this.convertXmlRpcArrayToTypeScriptArray(member.value);
} else if (AngularXmlrpcService.instanceOfXmlRpcStruct(member.value)) {
value = this.convertXmlRpcStructToTypeScriptObject(member.value);
} else {
value = member.value;
}
result_object[member.name] = value;
})
return result_object;
}

private convertXmlRpcArrayToTypeScriptArray(inputArray: XmlRpcArray): Array<any> {
const resultArray = []
inputArray.data.forEach((value) => {
if (AngularXmlrpcService.instanceOfXmlRpcArray(value)) {
resultArray.push(this.convertXmlRpcArrayToTypeScriptArray(value));
} else if (AngularXmlrpcService.instanceOfXmlRpcStruct(value)) {
resultArray.push(this.convertXmlRpcStructToTypeScriptObject(value));
} else {
resultArray.push(value);
}
})
return resultArray;
}

get_settings(token: string): Observable<Settings> {
return this.client
.methodCall('get_settings', [token])
.pipe(
map<MethodResponse | MethodFault, Settings>((data: MethodResponse | MethodFault) => {
if (AngularXmlrpcService.instanceOfMethodResponse(data)) {
const return_value = {}
if (AngularXmlrpcService.instanceOfXmlRpcStruct(data.value)) {
data.value.members.forEach((value) => {
return_value[value.name] = value.value
});
return return_value as Settings;
return this.convertXmlRpcStructToTypeScriptObject(data.value) as Settings;
}
throw new Error('The return value of the settings was not in the expected format of an XML-RPC Struct!')
} else if (AngularXmlrpcService.instanceOfMethodFault(data)) {
Expand Down Expand Up @@ -2211,7 +2237,7 @@ export class CobblerApiService {
register_new_system(info: RegisterOptions): Observable<boolean> {
const transformedOptions: XmlRpcStruct = {
members: [
{name: 'name', value: info.name },
{name: 'name', value: info.name},
{name: 'profile', value: info.profile},
{name: 'hostname', value: info.hostname},
{name: 'interfaces', value: info.interfaces as XmlRpcStruct},
Expand Down
4 changes: 2 additions & 2 deletions projects/cobbler-frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {ImagesComponent} from './items/images/images.component';
import {TemplatesComponent} from './items/templates/templates.component';
import {SnippetsComponent} from './items/snippets/snippets.component';
import {ManagementClassesComponent} from './items/management-classes/management-classes.component';
import {AppSettingsComponent} from './app-settings/app-settings.component';
import {SettingsViewComponent} from './settings/view/settings-view.component';
import {PackagesComponent} from './items/packages/packages.component';
import {FilesComponent} from './items/files/files.component';
import {ImportDVDComponent} from './actions/import-dvd/import-dvd.component';
Expand Down Expand Up @@ -38,7 +38,7 @@ const routes: Routes = [
{path: 'templates', component: TemplatesComponent, canActivate: [AuthGuardService]},
{path: 'snippets', component: SnippetsComponent, canActivate: [AuthGuardService]},
{path: 'management-classes', component: ManagementClassesComponent, canActivate: [AuthGuardService]},
{path: 'settings', component: AppSettingsComponent, canActivate: [AuthGuardService]},
{path: 'settings', component: SettingsViewComponent, canActivate: [AuthGuardService]},
{path: 'packages', component: PackagesComponent, canActivate: [AuthGuardService]},
{path: 'app-files', component: FilesComponent, canActivate: [AuthGuardService]},
{path: 'import', component: ImportDVDComponent, canActivate: [AuthGuardService]},
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 14 additions & 2 deletions projects/cobbler-frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import {MatButtonModule} from '@angular/material/button';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatIconModule} from '@angular/material/icon';
import {MatInputModule} from '@angular/material/input';
import {MatRadioModule} from '@angular/material/radio';
import {MatSidenavModule} from '@angular/material/sidenav';
import {MatSnackBarModule} from '@angular/material/snack-bar';
import {MatTableModule} from '@angular/material/table';
import {MatTabsModule} from '@angular/material/tabs';
import {MatToolbarModule} from '@angular/material/toolbar';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatTreeModule} from '@angular/material/tree';
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
Expand All @@ -26,7 +29,7 @@ import {ImagesComponent} from './items/images/images.component';
import {TemplatesComponent} from './items/templates/templates.component';
import {SnippetsComponent} from './items/snippets/snippets.component';
import {ManagementClassesComponent} from './items/management-classes/management-classes.component';
import {AppSettingsComponent} from './app-settings/app-settings.component';
import {SettingsViewComponent} from './settings/view/settings-view.component';
import {PackagesComponent} from './items/packages/packages.component';
import {FilesComponent} from './items/files/files.component';
import {ImportDVDComponent} from './actions/import-dvd/import-dvd.component';
Expand All @@ -43,6 +46,9 @@ import {NavbarComponent} from './navbar/navbar.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {LayoutModule} from '@angular/cdk/layout';
import {MatListModule} from '@angular/material/list';
import { EditableTreeComponent } from './common/editable-tree/editable-tree.component';
import { ViewableTreeComponent } from './common/viewable-tree/viewable-tree.component';
import { SettingsEditComponent } from './settings/edit/settings-edit.component';

@NgModule({
declarations: [
Expand All @@ -57,7 +63,7 @@ import {MatListModule} from '@angular/material/list';
TemplatesComponent,
SnippetsComponent,
ManagementClassesComponent,
AppSettingsComponent,
SettingsViewComponent,
DistrosComponent,
ProfilesComponent,
SystemsComponent,
Expand All @@ -75,6 +81,9 @@ import {MatListModule} from '@angular/material/list';
NotFoundComponent,
ManageMenuComponent,
NavbarComponent,
EditableTreeComponent,
ViewableTreeComponent,
SettingsEditComponent,
],
imports: [
BrowserModule,
Expand All @@ -96,6 +105,9 @@ import {MatListModule} from '@angular/material/list';
MatTableModule,
MatTabsModule,
MatSnackBarModule,
MatRadioModule,
MatTreeModule,
MatTooltipModule,
],
providers: [
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<mat-tree>
</mat-tree>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { EditableTreeComponent } from './editable-tree.component';

describe('EditableTreeComponent', () => {
let component: EditableTreeComponent;
let fixture: ComponentFixture<EditableTreeComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ EditableTreeComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(EditableTreeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-editable-tree',
templateUrl: './editable-tree.component.html',
styleUrls: ['./editable-tree.component.scss']
})
export class EditableTreeComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<mat-tree
[dataSource]="dataSource"
[treeControl]="viewableTreeControl"
*ngIf="inputLength(inputObject) > 0">
<!-- This is the tree node template for leaf nodes -->
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding>
<!-- use a disabled button to provide padding for tree leaf -->
<button mat-icon-button disabled></button>
{{node.name}}: {{node.value}}
</mat-tree-node>
<!-- This is the tree node template for expandable nodes -->
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding>
<button mat-icon-button matTreeNodeToggle
[attr.aria-label]="'Toggle ' + node.name">
<mat-icon class="mat-icon-rtl-mirror">
{{viewableTreeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>
{{node.name}}
</mat-tree-node>
</mat-tree>
<span
*ngIf="inputLength(inputObject) === 0"
class="settings-values">
&#123;&nbsp;&#125;
</span>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.settings-values {
background-color: beige;
color: red;
}
Loading

0 comments on commit bda0078

Please sign in to comment.