Frontend to update ntfy data
This commit is contained in:
parent
4653ab9866
commit
4155af45f5
@ -5,6 +5,7 @@ api/account.service.ts
|
||||
api/api.ts
|
||||
api/history.service.ts
|
||||
api/login.service.ts
|
||||
api/ntfy.service.ts
|
||||
api/properties.service.ts
|
||||
api/schedule.service.ts
|
||||
api/task.service.ts
|
||||
@ -32,6 +33,7 @@ model/loginRequest.ts
|
||||
model/loginResponse.ts
|
||||
model/manualScheduleStopInfo.ts
|
||||
model/models.ts
|
||||
model/ntfyInformation.ts
|
||||
model/passwordChangeRequest.ts
|
||||
model/propertiesInfo.ts
|
||||
model/propertyInfo.ts
|
||||
|
@ -5,6 +5,7 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { AccountService } from './api/account.service';
|
||||
import { HistoryService } from './api/history.service';
|
||||
import { LoginService } from './api/login.service';
|
||||
import { NtfyService } from './api/ntfy.service';
|
||||
import { PropertiesService } from './api/properties.service';
|
||||
import { ScheduleService } from './api/schedule.service';
|
||||
import { TaskService } from './api/task.service';
|
||||
|
@ -4,6 +4,8 @@ export * from './history.service';
|
||||
import { HistoryService } from './history.service';
|
||||
export * from './login.service';
|
||||
import { LoginService } from './login.service';
|
||||
export * from './ntfy.service';
|
||||
import { NtfyService } from './ntfy.service';
|
||||
export * from './properties.service';
|
||||
import { PropertiesService } from './properties.service';
|
||||
export * from './schedule.service';
|
||||
@ -14,4 +16,4 @@ export * from './taskgroup.service';
|
||||
import { TaskgroupService } from './taskgroup.service';
|
||||
export * 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];
|
||||
|
210
frontend/src/api/api/ntfy.service.ts
Normal file
210
frontend/src/api/api/ntfy.service.ts
Normal 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
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -15,6 +15,7 @@ export * from './inlineResponse409';
|
||||
export * from './loginRequest';
|
||||
export * from './loginResponse';
|
||||
export * from './manualScheduleStopInfo';
|
||||
export * from './ntfyInformation';
|
||||
export * from './passwordChangeRequest';
|
||||
export * from './propertiesInfo';
|
||||
export * from './propertyInfo';
|
||||
|
32
frontend/src/api/model/ntfyInformation.ts
Normal file
32
frontend/src/api/model/ntfyInformation.ts
Normal 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;
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ import { ScheduleHistoryComponent } from './statistics/schedule-history/schedule
|
||||
import {MatButtonToggleModule} from "@angular/material/button-toggle";
|
||||
import {MatGridListModule} from "@angular/material/grid-list";
|
||||
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({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
@ -134,6 +136,8 @@ import { StopScheduleManuallyComponent } from './dashboard/active-schedule/stop-
|
||||
HeatmapActivityComponent,
|
||||
ScheduleHistoryComponent,
|
||||
StopScheduleManuallyComponent,
|
||||
ConnectionSettingsComponent,
|
||||
NtfySettingsComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -0,0 +1 @@
|
||||
<app-ntfy-settings></app-ntfy-settings>
|
@ -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();
|
||||
});
|
||||
});
|
@ -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 {
|
||||
|
||||
}
|
@ -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>
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
@ -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("****");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -4,4 +4,10 @@
|
||||
<app-account-settings></app-account-settings>
|
||||
</div>
|
||||
</mat-tab>
|
||||
|
||||
<mat-tab label="Connections">
|
||||
<div class="container">
|
||||
<app-connection-settings></app-connection-settings>
|
||||
</div>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
|
71
openapi.yaml
71
openapi.yaml
@ -2027,7 +2027,53 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
$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:
|
||||
securitySchemes:
|
||||
@ -2712,4 +2758,25 @@ components:
|
||||
duration:
|
||||
type: number
|
||||
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
|
Loading…
Reference in New Issue
Block a user