issue-86 #102

Merged
sebastian merged 10 commits from issue-86 into master 2024-03-14 14:57:52 +01:00
17 changed files with 454 additions and 3 deletions
Showing only changes of commit 4155af45f5 - Show all commits

View File

@ -5,6 +5,7 @@ api/account.service.ts
api/api.ts api/api.ts
api/history.service.ts api/history.service.ts
api/login.service.ts api/login.service.ts
api/ntfy.service.ts
api/properties.service.ts api/properties.service.ts
api/schedule.service.ts api/schedule.service.ts
api/task.service.ts api/task.service.ts
@ -32,6 +33,7 @@ model/loginRequest.ts
model/loginResponse.ts model/loginResponse.ts
model/manualScheduleStopInfo.ts model/manualScheduleStopInfo.ts
model/models.ts model/models.ts
model/ntfyInformation.ts
model/passwordChangeRequest.ts model/passwordChangeRequest.ts
model/propertiesInfo.ts model/propertiesInfo.ts
model/propertyInfo.ts model/propertyInfo.ts

View File

@ -5,6 +5,7 @@ import { HttpClient } from '@angular/common/http';
import { AccountService } from './api/account.service'; import { AccountService } from './api/account.service';
import { HistoryService } from './api/history.service'; import { HistoryService } from './api/history.service';
import { LoginService } from './api/login.service'; import { LoginService } from './api/login.service';
import { NtfyService } from './api/ntfy.service';
import { PropertiesService } from './api/properties.service'; import { PropertiesService } from './api/properties.service';
import { ScheduleService } from './api/schedule.service'; import { ScheduleService } from './api/schedule.service';
import { TaskService } from './api/task.service'; import { TaskService } from './api/task.service';

View File

@ -4,6 +4,8 @@ export * from './history.service';
import { HistoryService } from './history.service'; import { HistoryService } from './history.service';
export * from './login.service'; export * from './login.service';
import { LoginService } from './login.service'; import { LoginService } from './login.service';
export * from './ntfy.service';
import { NtfyService } from './ntfy.service';
export * from './properties.service'; export * from './properties.service';
import { PropertiesService } from './properties.service'; import { PropertiesService } from './properties.service';
export * from './schedule.service'; export * from './schedule.service';
@ -14,4 +16,4 @@ export * from './taskgroup.service';
import { TaskgroupService } from './taskgroup.service'; import { TaskgroupService } from './taskgroup.service';
export * from './users.service'; export * from './users.service';
import { UsersService } from './users.service'; import { UsersService } from './users.service';
export const APIS = [AccountService, HistoryService, LoginService, PropertiesService, ScheduleService, TaskService, TaskgroupService, UsersService]; export const APIS = [AccountService, HistoryService, LoginService, NtfyService, PropertiesService, ScheduleService, TaskService, TaskgroupService, UsersService];

View File

@ -0,0 +1,210 @@
/**
* API Title
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
import { NtfyInformation } from '../model/models';
import { SimpleStatusResponse } from '../model/models';
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
@Injectable({
providedIn: 'root'
})
export class NtfyService {
protected basePath = 'http://127.0.0.1:8080/api';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
if (configuration) {
this.configuration = configuration;
}
if (typeof this.configuration.basePath !== 'string') {
if (typeof basePath !== 'string') {
basePath = this.basePath;
}
this.configuration.basePath = basePath;
}
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
}
private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
if (typeof value === "object" && value instanceof Date === false) {
httpParams = this.addToHttpParamsRecursive(httpParams, value);
} else {
httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
}
return httpParams;
}
private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
if (value == null) {
return httpParams;
}
if (typeof value === "object") {
if (Array.isArray(value)) {
(value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
} else if (value instanceof Date) {
if (key != null) {
httpParams = httpParams.append(key,
(value as Date).toISOString().substr(0, 10));
} else {
throw Error("key may not be null if value is Date");
}
} else {
Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive(
httpParams, value[k], key != null ? `${key}.${k}` : k));
}
} else if (key != null) {
httpParams = httpParams.append(key, value);
} else {
throw Error("key may not be null if value is not object or array");
}
return httpParams;
}
/**
* Get ntfy information
* Get ntfy information
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public ntfyGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<NtfyInformation>;
public ntfyGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<NtfyInformation>>;
public ntfyGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<NtfyInformation>>;
public ntfyGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
let localVarHeaders = this.defaultHeaders;
let localVarCredential: string | undefined;
// authentication (API_TOKEN) required
localVarCredential = this.configuration.lookupCredential('API_TOKEN');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}
let responseType_: 'text' | 'json' = 'json';
if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}
return this.httpClient.get<NtfyInformation>(`${this.configuration.basePath}/ntfy`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}
/**
* Edit ntfy information
* Edit ntfy information
* @param ntfyInformation
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public ntfyPost(ntfyInformation?: NtfyInformation, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<SimpleStatusResponse>;
public ntfyPost(ntfyInformation?: NtfyInformation, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<SimpleStatusResponse>>;
public ntfyPost(ntfyInformation?: NtfyInformation, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<SimpleStatusResponse>>;
public ntfyPost(ntfyInformation?: NtfyInformation, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
let localVarHeaders = this.defaultHeaders;
let localVarCredential: string | undefined;
// authentication (API_TOKEN) required
localVarCredential = this.configuration.lookupCredential('API_TOKEN');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
}
let responseType_: 'text' | 'json' = 'json';
if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}
return this.httpClient.post<SimpleStatusResponse>(`${this.configuration.basePath}/ntfy`,
ntfyInformation,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}
}

View File

@ -15,6 +15,7 @@ export * from './inlineResponse409';
export * from './loginRequest'; export * from './loginRequest';
export * from './loginResponse'; export * from './loginResponse';
export * from './manualScheduleStopInfo'; export * from './manualScheduleStopInfo';
export * from './ntfyInformation';
export * from './passwordChangeRequest'; export * from './passwordChangeRequest';
export * from './propertiesInfo'; export * from './propertiesInfo';
export * from './propertyInfo'; export * from './propertyInfo';

View File

@ -0,0 +1,32 @@
/**
* API Title
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface NtfyInformation {
/**
* host of ntfy service
*/
ntfy_host: string;
/**
* topic of ntfy service
*/
ntfy_topic: string;
/**
* username of ntfy account for publishing news
*/
ntfy_user: string;
/**
* token to ntfy useraccount
*/
ntfy_token?: string;
}

View File

@ -89,6 +89,8 @@ import { ScheduleHistoryComponent } from './statistics/schedule-history/schedule
import {MatButtonToggleModule} from "@angular/material/button-toggle"; import {MatButtonToggleModule} from "@angular/material/button-toggle";
import {MatGridListModule} from "@angular/material/grid-list"; import {MatGridListModule} from "@angular/material/grid-list";
import { StopScheduleManuallyComponent } from './dashboard/active-schedule/stop-schedule-manually/stop-schedule-manually.component'; import { StopScheduleManuallyComponent } from './dashboard/active-schedule/stop-schedule-manually/stop-schedule-manually.component';
import { ConnectionSettingsComponent } from './user-settings/connection-settings/connection-settings.component';
import { NtfySettingsComponent } from './user-settings/connection-settings/ntfy-settings/ntfy-settings.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,
@ -134,6 +136,8 @@ import { StopScheduleManuallyComponent } from './dashboard/active-schedule/stop-
HeatmapActivityComponent, HeatmapActivityComponent,
ScheduleHistoryComponent, ScheduleHistoryComponent,
StopScheduleManuallyComponent, StopScheduleManuallyComponent,
ConnectionSettingsComponent,
NtfySettingsComponent,
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View File

@ -0,0 +1 @@
<app-ntfy-settings></app-ntfy-settings>

View File

@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ConnectionSettingsComponent } from './connection-settings.component';
describe('ConnectionSettingsComponent', () => {
let component: ConnectionSettingsComponent;
let fixture: ComponentFixture<ConnectionSettingsComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ConnectionSettingsComponent]
});
fixture = TestBed.createComponent(ConnectionSettingsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-connection-settings',
templateUrl: './connection-settings.component.html',
styleUrls: ['./connection-settings.component.css']
})
export class ConnectionSettingsComponent {
}

View File

@ -0,0 +1,24 @@
<mat-form-field appearance="outline" class="long-form">
<mat-label>Hostname</mat-label>
<input matInput [formControl]="host_formCtrl" placeholder="https://ntfy.sh">
</mat-form-field>
<mat-form-field appearance="outline" class="long-form">
<mat-label>Topic</mat-label>
<input matInput [formControl]="topic_formCtrl" placeholder="Topic">
</mat-form-field>
<mat-form-field appearance="outline" class="long-form">
<mat-label>Username</mat-label>
<input matInput [formControl]="user_formCtrl" placeholder="username">
</mat-form-field>
<mat-form-field appearance="outline" class="long-form">
<mat-label>Token</mat-label>
<input matInput [formControl]="token_formCtrl" placeholder="Token" type="password">
</mat-form-field>
<div style="float: right">
<button mat-raised-button color="primary" (click)="save()">Save</button>
</div>

View File

@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NtfySettingsComponent } from './ntfy-settings.component';
describe('NtfySettingsComponent', () => {
let component: NtfySettingsComponent;
let fixture: ComponentFixture<NtfySettingsComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [NtfySettingsComponent]
});
fixture = TestBed.createComponent(NtfySettingsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,49 @@
import { Component } from '@angular/core';
import {NtfyService} from "../../../../api";
import {Form, FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
import {MatSnackBar} from "@angular/material/snack-bar";
@Component({
selector: 'app-ntfy-settings',
templateUrl: './ntfy-settings.component.html',
styleUrls: ['./ntfy-settings.component.css']
})
export class NtfySettingsComponent {
host_formCtrl = new FormControl('', [Validators.required])
topic_formCtrl = new FormControl('', [Validators.required])
user_formCtrl = new FormControl('', [Validators.required])
token_formCtrl = new FormControl('', [Validators.required])
constructor(private ntfyService: NtfyService,
private snackbar: MatSnackBar) {
}
ngOnInit() {
this.ntfyService.ntfyGet().subscribe({
next: resp => {
this.host_formCtrl.setValue(resp.ntfy_host);
this.topic_formCtrl.setValue(resp.ntfy_topic);
this.user_formCtrl.setValue(resp.ntfy_user);
this.token_formCtrl.setValue(resp.ntfy_token!);
}
})
}
save() {
const token = this.token_formCtrl.value === "****" ? "" : this.token_formCtrl.value!
const user = this.user_formCtrl.value === "****" ? "" : this.user_formCtrl.value!
this.ntfyService.ntfyPost({
ntfy_host: this.host_formCtrl.value!,
ntfy_topic: this.topic_formCtrl.value!,
ntfy_token: token,
ntfy_user: user
}).subscribe({
next: resp => {
this.snackbar.open("Ntfy-Configuration updated", "", {duration: 2000})
this.user_formCtrl.setValue("****");
this.token_formCtrl.setValue("****");
}
})
}
}

View File

@ -4,4 +4,10 @@
<app-account-settings></app-account-settings> <app-account-settings></app-account-settings>
</div> </div>
</mat-tab> </mat-tab>
<mat-tab label="Connections">
<div class="container">
<app-connection-settings></app-connection-settings>
</div>
</mat-tab>
</mat-tab-group> </mat-tab-group>

View File

@ -2027,6 +2027,52 @@ paths:
type: array type: array
items: items:
$ref: '#/components/schemas/ScheduleInfo' $ref: '#/components/schemas/ScheduleInfo'
/ntfy:
get:
security:
- API_TOKEN: []
tags:
- ntfy
description: Get ntfy information
summary: Get ntfy information
responses:
200:
description: Operation successfull
content:
application/json:
schema:
$ref: '#/components/schemas/NtfyInformation'
404:
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
post:
security:
- API_TOKEN: []
tags:
- ntfy
description: Edit ntfy information
summary: Edit ntfy information
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NtfyInformation'
responses:
200:
description: Operation successfull
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
404:
description: Operation successfull
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
components: components:
@ -2713,3 +2759,24 @@ components:
type: number type: number
description: duration in minutes description: duration in minutes
example: 10 example: 10
NtfyInformation:
required:
- ntfy_host
- ntfy_topic
additionalProperties: false
properties:
ntfy_host:
type: string
description: host of ntfy service
example: https://ntfy.fawkes100.de
ntfy_topic:
type: string
description: topic of ntfy service
example: Topicname
ntfy_user:
type: string
description: username of ntfy account for publishing news
example: password
ntfy_token:
type: string
description: token to ntfy useraccount