+ _snackBar |
- GetObjService
+ MatSnackBar
|
@@ -291,24 +358,61 @@
+
+
+
+
+
+ ngOnInit
+
+
+ |
+
+
+
+ngOnInit()
+ |
+
+
+
+
+
+
|
@@ -316,36 +420,10 @@
-
- Parameters :
-
-
-
-
- Name |
- Optional |
-
-
-
-
- index |
-
-
- No
- |
-
-
-
-
-
-
-
-
-
|
@@ -360,22 +438,64 @@
+
+
+
+
+
- currentItem
-
+ fileCard
+
|
- Type : string
+ Type : LandingPageStatsCard
|
+
+
+ Default value : {
+ cardTitle: 'File count',
+ cardData: new BehaviorSubject(''),
+ }
+ |
+
-
+
|
@@ -386,16 +506,30 @@
+
+
+
+
+
+
+ Private
+ ngUnsubscribe
+
+
+ |
+
+
+
+ Default value : new Subject<void>()
|
-
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ packageCard
+
+
+ |
+
+
+
+ Type : LandingPageStatsCard
+
+ |
+
+
+
+ Default value : {
+ cardTitle: 'Package count',
+ cardData: new BehaviorSubject(''),
+ }
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ profileCard
+
+
+ |
+
+
+
+ Type : LandingPageStatsCard
+
+ |
+
+
+
+ Default value : {
+ cardTitle: 'Profile count',
+ cardData: new BehaviorSubject(''),
+ }
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ repoCard
+
+
+ |
+
+
+
+ Type : LandingPageStatsCard
+
+ |
+
+
+
+ Default value : {
+ cardTitle: 'Repository count',
+ cardData: new BehaviorSubject(''),
+ }
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ snippetCard
+
+
+ |
+
+
+
+ Type : LandingPageStatsCard
+
+ |
+
+
+
+ Default value : {
+ cardTitle: 'Snippet count',
+ cardData: new BehaviorSubject(''),
+ }
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ systemCard
+
+
+ |
+
+
+
+ Type : LandingPageStatsCard
+
+ |
+
+
+
+ Default value : {
+ cardTitle: 'System count',
+ cardData: new BehaviorSubject(''),
+ }
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ templateCard
+
+
+ |
+
+
+
+ Type : LandingPageStatsCard
+
+ |
+
+
+
+ Default value : {
+ cardTitle: 'Template count',
+ cardData: new BehaviorSubject(''),
+ }
+ |
+
+
+
+
|
@@ -454,68 +848,268 @@
- import { Component } from '@angular/core';
-import { GetObjService } from '../services/get-obj.service';
+ import { AsyncPipe } from '@angular/common';
+import { Component, OnDestroy, OnInit } from '@angular/core';
+import { MatCardModule } from '@angular/material/card';
+import { MatGridListModule } from '@angular/material/grid-list';
+import { MatSnackBar } from '@angular/material/snack-bar';
+import { CobblerApiService } from 'cobbler-api';
+import { BehaviorSubject, Subject } from 'rxjs';
+import { takeUntil } from 'rxjs/operators';
+import { UserService } from '../services/user.service';
+import Utils from '../utils';
+
+interface LandingPageStatsCard {
+ cardTitle: string;
+ cardData: BehaviorSubject<string>;
+}
@Component({
selector: 'cobbler-app-manage',
templateUrl: './app-manage.component.html',
- styleUrls: ['./app-manage.component.css'],
+ styleUrls: ['./app-manage.component.scss'],
+ imports: [MatGridListModule, MatCardModule, AsyncPipe],
standalone: true,
})
-export class AppManageComponent {
- username: string;
- currentItem: string;
- currentObjs;
- saveObj;
-
- constructor(service: GetObjService) {
- const user = window.sessionStorage.getItem('user');
- const item = window.sessionStorage.getItem('CurrentItem');
- this.currentObjs = service.getITEMS();
- // console.log(`Current objects: ${this.current_objs}. Type=`, typeof this.current_objs)
- if (user) {
- this.username = user;
- }
-
- if (item) {
- this.currentItem = item;
- } else {
- // console.log(`item not found: ${item}`)
- this.currentItem = 'No Item has been selected.';
- }
- this.saveObj = (value) => {
- // console.log("saving current value in service")
- service.name = value;
- };
+export class AppManageComponent implements OnInit, OnDestroy {
+ // Unsubscribe
+ private ngUnsubscribe = new Subject<void>();
+
+ // Content
+ distroCard: LandingPageStatsCard = {
+ cardTitle: 'Distro count',
+ cardData: new BehaviorSubject(''),
+ };
+ profileCard: LandingPageStatsCard = {
+ cardTitle: 'Profile count',
+ cardData: new BehaviorSubject(''),
+ };
+ systemCard: LandingPageStatsCard = {
+ cardTitle: 'System count',
+ cardData: new BehaviorSubject(''),
+ };
+ repoCard: LandingPageStatsCard = {
+ cardTitle: 'Repository count',
+ cardData: new BehaviorSubject(''),
+ };
+ imageCard: LandingPageStatsCard = {
+ cardTitle: 'Image count',
+ cardData: new BehaviorSubject(''),
+ };
+ mgmtClassCard: LandingPageStatsCard = {
+ cardTitle: 'Management Class count',
+ cardData: new BehaviorSubject(''),
+ };
+ packageCard: LandingPageStatsCard = {
+ cardTitle: 'Package count',
+ cardData: new BehaviorSubject(''),
+ };
+ fileCard: LandingPageStatsCard = {
+ cardTitle: 'File count',
+ cardData: new BehaviorSubject(''),
+ };
+ templateCard: LandingPageStatsCard = {
+ cardTitle: 'Template count',
+ cardData: new BehaviorSubject(''),
+ };
+ snippetCard: LandingPageStatsCard = {
+ cardTitle: 'Snippet count',
+ cardData: new BehaviorSubject(''),
+ };
+ landingPageCards: LandingPageStatsCard[] = [
+ this.distroCard,
+ this.profileCard,
+ this.systemCard,
+ this.repoCard,
+ this.imageCard,
+ this.mgmtClassCard,
+ this.packageCard,
+ this.fileCard,
+ this.templateCard,
+ this.snippetCard,
+ ];
+
+ constructor(
+ private userService: UserService,
+ private cobblerApiService: CobblerApiService,
+ private _snackBar: MatSnackBar,
+ ) {}
+
+ ngOnInit() {
+ this.cobblerApiService
+ .get_item_names('distro')
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.distroCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
+ this.cobblerApiService
+ .get_item_names('profile')
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.profileCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
+ this.cobblerApiService
+ .get_item_names('system')
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.systemCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
+ this.cobblerApiService
+ .get_item_names('repo')
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.repoCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
+ this.cobblerApiService
+ .get_item_names('image')
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.imageCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
+ this.cobblerApiService
+ .get_item_names('mgmtclass')
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.mgmtClassCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
+ this.cobblerApiService
+ .get_item_names('package')
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.packageCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
+ this.cobblerApiService
+ .get_item_names('file')
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.fileCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
+ this.cobblerApiService
+ .get_autoinstall_templates(this.userService.token)
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.templateCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
+ this.cobblerApiService
+ .get_autoinstall_snippets(this.userService.token)
+ .pipe(takeUntil(this.ngUnsubscribe))
+ .subscribe({
+ next: (value) => {
+ this.snippetCard.cardData.next(value.length.toString());
+ },
+ error: (error) => {
+ // HTML encode the error message since it originates from XML
+ this._snackBar.open(Utils.toHTML(error.message), 'Close');
+ },
+ });
}
- // TODO: Find a way to also save this in current service
- save(index): void {
- // console.log('saving item')
- // let size = this.current_objs.length
- const current = this.currentObjs[index];
- this.currentItem = current;
- this.saveObj(current);
+ ngOnDestroy(): void {
+ this.ngUnsubscribe.next();
+ this.ngUnsubscribe.complete();
}
}
- <div class="right-column" id="dataScreen">
- <div class="Welcome-div low-contrast">
- <h1 class="title">WELCOME!</h1>
- </div>
-</div>
+ <h1 class="title">WELCOME!</h1>
+
+<mat-grid-list cols="8" rowHeight="1:1" [gutterSize]="'10px'">
+ @for (card of landingPageCards; track card) {
+ <mat-grid-tile>
+ <mat-card>
+ <mat-card-header>
+ <mat-card-title>
+ {{ card.cardTitle }}
+ </mat-card-title>
+ </mat-card-header>
+ <mat-card-content>
+ <div class="container">
+ <p>{{ card.cardData | async }}</p>
+ </div>
+ </mat-card-content>
+ </mat-card>
+ </mat-grid-tile>
+ }
+</mat-grid-list>
-
+ mat-card {
+ width: 100%;
+ height: 100%;
+}
+
+mat-card mat-card-content {
+ height: 100%;
+}
+
+.container {
+ height: 100%;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
@@ -543,7 +1137,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - Injectables
- - GetObjService
-
-
-
-
-
-
- File
-
-
-
-
-
-
-
-
- Index
-
-
-
-
- Properties
- |
-
-
-
-
- |
-
-
-
-
- Methods
- |
-
-
-
-
- |
-
-
-
-
-
-
-
-
- Accessors
- |
-
-
-
-
- |
-
-
-
-
-
-
- Constructor
-
-
-
-
-constructor()
- |
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
- Methods
-
-
-
-
-
-
-
- getITEMS
-
-
- |
-
-
-
-getITEMS()
- |
-
-
-
-
-
-
- |
-
-
-
-
-
-
-
- Returns : string[]
-
-
- |
-
-
-
-
-
-
-
- Properties
-
-
-
-
-
-
-
- Public
- CurrentITEM
-
-
- |
-
-
-
- Type : BehaviorSubject<string>
-
- |
-
-
-
- Default value : new BehaviorSubject<string>(
- this.MockObjname,
- )
- |
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
- CurrentITEM$
-
-
- |
-
-
-
- Type : Observable<string>
-
- |
-
-
-
- Default value : this.CurrentITEM.asObservable()
- |
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
- MockObject
-
-
- |
-
-
-
- Type : []
-
- |
-
-
-
- Default value : []
- |
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
- MockObjname
-
-
- |
-
-
-
- Default value : window.sessionStorage.getItem('CurrentItem')
- |
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
- MockValues
-
-
- |
-
-
-
- Type : []
-
- |
-
-
-
- Default value : ['Item 0x1', 'Item 1x2', 'Item 2x3']
- |
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
- Accessors
-
-
-
-
-
-
- name
- |
-
-
-
-
-
- setname(item: string)
- |
-
-
-
-
- |
-
-
-
-
-
- Parameters :
-
-
-
- Name |
- Type |
- Optional |
-
-
-
-
- item |
-
-
- string
- |
-
-
- No
- |
-
-
-
-
-
-
-
-
- |
-
-
-
-
-
-
-
-
- import { Injectable } from '@angular/core';
-import { BehaviorSubject } from 'rxjs';
-import { Observable } from 'rxjs';
-
-/*
-Item returned from XMLrpc will be an object that
-houses a list of all the current mock data.
- Each item will have ['Distros', 'Profiles', 'Systems',
- 'Repos', 'Images', 'Templates',
- 'Snippets', 'Management Classes',
- 'Settings', 'Packages', 'Files']
- Example of component data:
- Management Classes : { MngclassesService }
- FIELDS = [
- # non-editable in UI (internal)
- FIELDS[0-4]
-
- FIELDS[5-11]
- # editable in UI
- 0-["class_name", "", 0, "Class Name", True, "Actual Class Name (leave blank to use the name field)", 0, "str"],
- 1-["comment", "", 0, "Comment", True, "Free form text description", 0, "str"],
- 2-["files", [], 0, "Files", True, "File resources", 0, "list"],
- 3-["name", "", 0, "Name", True, "Ex: F10-i386-webserver", 0, "str"],
- 4-["owners", "SETTINGS:default_ownership", "SETTINGS:default_ownership", "Owners", True, "Owners list for
- authz_ownership (space delimited)", 0, "list"],
- 5-["packages", [], 0, "Packages", True, "Package resources", 0, "list"],
- 6-["params", {}, 0, "Parameters/Variables", True, "List of parameters/variables", 0, "dict"],
-]
-
-See docs-additonal for each components data structure.
-"../docs-additonal/component-schema.md"
-
-*/
-
-@Injectable({
- providedIn: 'root',
-})
-export class GetObjService {
- MockObject = [];
- MockValues = ['Item 0x1', 'Item 1x2', 'Item 2x3'];
- // If MockObjname is not left blank/undefined, the value hear overrides the session value on construction.
- MockObjname = window.sessionStorage.getItem('CurrentItem');
-
- // ERROR is thrown if MockObjname is Left undefined before constructor
-
- public CurrentITEM: BehaviorSubject<string> = new BehaviorSubject<string>(
- this.MockObjname,
- );
- CurrentITEM$: Observable<string> = this.CurrentITEM.asObservable();
-
- constructor() {
- // Add authorization check??
- const current = window.sessionStorage.getItem('CurrentItem');
-
- if (current) {
- this.MockObjname = current;
- }
-
- window.sessionStorage.setItem(
- 'CobblerITEMS',
- JSON.stringify(this.MockValues),
- );
- }
-
- getITEMS(): string[] {
- return this.MockValues;
- }
-
- set name(item: string) {
- window.sessionStorage.setItem('CurrentItem', item);
- const sessionItem = window.sessionStorage.getItem('CurrentItem');
- if (sessionItem) {
- this.MockObjname = sessionItem;
- }
- this.CurrentITEM.next(item);
- // let message = `Current Item is set to: ${this.MockObjname}`
- /// console.log(message)
- // window.sessionStorage.setItem('CurrentItem', this.MockObjname)
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- results matching ""
-
-
-
- No results matching ""
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- |