parent
0f935ceb48
commit
1bd86f5abd
@ -0,0 +1,22 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/analogj/scrutiny/webapp/backend/pkg/database"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DeleteDevice(c *gin.Context) {
|
||||||
|
logger := c.MustGet("LOGGER").(logrus.FieldLogger)
|
||||||
|
deviceRepo := c.MustGet("DEVICE_REPOSITORY").(database.DeviceRepo)
|
||||||
|
|
||||||
|
err := deviceRepo.DeleteDevice(c, c.Param("wwn"))
|
||||||
|
if err != nil {
|
||||||
|
logger.Errorln("An error occurred while deleting device", err)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, gin.H{"success": true})
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
<h2 mat-dialog-title>Delete {{data.title}}?</h2>
|
||||||
|
<mat-dialog-content>This will delete all data associated with this device (including all historical data).</mat-dialog-content>
|
||||||
|
<mat-dialog-actions>
|
||||||
|
<button mat-button mat-dialog-close>Cancel</button>
|
||||||
|
<!-- The mat-dialog-close directive optionally accepts a value as a result for the dialog. -->
|
||||||
|
<button class="red-600" mat-button [mat-dialog-close]="true">
|
||||||
|
<mat-icon class="icon-size-20 mr-3"
|
||||||
|
[svgIcon]="'delete_forever'"></mat-icon>
|
||||||
|
Delete</button>
|
||||||
|
</mat-dialog-actions>
|
@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { DashboardDeviceDeleteDialogComponent } from './dashboard-device-delete-dialog.component';
|
||||||
|
|
||||||
|
describe('DashboardDeviceDeleteDialogComponent', () => {
|
||||||
|
let component: DashboardDeviceDeleteDialogComponent;
|
||||||
|
let fixture: ComponentFixture<DashboardDeviceDeleteDialogComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ DashboardDeviceDeleteDialogComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(DashboardDeviceDeleteDialogComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,16 @@
|
|||||||
|
import { Component, OnInit, Inject } from '@angular/core';
|
||||||
|
import {MAT_DIALOG_DATA} from '@angular/material/dialog';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-dashboard-device-delete-dialog',
|
||||||
|
templateUrl: './dashboard-device-delete-dialog.component.html',
|
||||||
|
styleUrls: ['./dashboard-device-delete-dialog.component.scss']
|
||||||
|
})
|
||||||
|
export class DashboardDeviceDeleteDialogComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(@Inject(MAT_DIALOG_DATA) public data: {wwn: string, title: string}) { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { Overlay } from '@angular/cdk/overlay';
|
||||||
|
import { MAT_AUTOCOMPLETE_SCROLL_STRATEGY, MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatSelectModule } from '@angular/material/select';
|
||||||
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
import { SharedModule } from 'app/shared/shared.module';
|
||||||
|
import {DashboardDeviceDeleteDialogComponent} from 'app/layout/common/dashboard-device-delete-dialog/dashboard-device-delete-dialog.component'
|
||||||
|
import { MatButtonToggleModule} from "@angular/material/button-toggle";
|
||||||
|
import {MatTabsModule} from "@angular/material/tabs";
|
||||||
|
import {MatSliderModule} from "@angular/material/slider";
|
||||||
|
import {MatSlideToggleModule} from "@angular/material/slide-toggle";
|
||||||
|
import {MatTooltipModule} from "@angular/material/tooltip";
|
||||||
|
import {dashboardRoutes} from "../../../modules/dashboard/dashboard.routing";
|
||||||
|
import {MatDividerModule} from "@angular/material/divider";
|
||||||
|
import {MatMenuModule} from "@angular/material/menu";
|
||||||
|
import {MatProgressBarModule} from "@angular/material/progress-bar";
|
||||||
|
import {MatSortModule} from "@angular/material/sort";
|
||||||
|
import {MatTableModule} from "@angular/material/table";
|
||||||
|
import {NgApexchartsModule} from "ng-apexcharts";
|
||||||
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
DashboardDeviceDeleteDialogComponent
|
||||||
|
],
|
||||||
|
imports : [
|
||||||
|
RouterModule.forChild([]),
|
||||||
|
RouterModule.forChild(dashboardRoutes),
|
||||||
|
MatButtonModule,
|
||||||
|
MatDividerModule,
|
||||||
|
MatTooltipModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatMenuModule,
|
||||||
|
MatProgressBarModule,
|
||||||
|
MatSortModule,
|
||||||
|
MatTableModule,
|
||||||
|
NgApexchartsModule,
|
||||||
|
SharedModule,
|
||||||
|
MatDialogModule
|
||||||
|
],
|
||||||
|
exports : [
|
||||||
|
DashboardDeviceDeleteDialogComponent,
|
||||||
|
],
|
||||||
|
providers : []
|
||||||
|
})
|
||||||
|
export class DashboardDeviceDeleteDialogModule
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in new issue