Export excel sheer
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
<form [formGroup]="form" novalidate>
|
||||
<mat-card>
|
||||
<mat-card-header>
|
||||
<mat-card-title>Layer details</mat-card-title>
|
||||
<mat-card-header style="display: block;">
|
||||
<mat-card-title style="display:flex">
|
||||
Layer details
|
||||
<span style="flex: 1;"></span>
|
||||
<button mat-button (click)="export()">Export</button>
|
||||
</mat-card-title>
|
||||
<mat-card-subtitle> </mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
@@ -21,15 +25,16 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<mat-form-field class="full-width" appearance="outline">
|
||||
<mat-form-field class="full-width" appearance="outline" *ngIf="document">
|
||||
<mat-label>Created</mat-label>
|
||||
<input matInput disabled [value]="document?.created">
|
||||
<input matInput disabled [value]="document.created">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<table mat-table [dataSource]="dataSource" matSort matSortActive="code" matSortDisableClear matSortDirection="desc">
|
||||
<table mat-table [dataSource]="dataSource" matSort matSortActive="code" matSortDisableClear
|
||||
matSortDirection="desc">
|
||||
<ng-container matColumnDef="code">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Code</th>
|
||||
<td mat-cell *matCellDef="let row"> {{row.code}} </td>
|
||||
|
||||
@@ -13,7 +13,6 @@ import { MatInputModule } from '@angular/material/input';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatGridListModule } from '@angular/material/grid-list';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
|
||||
@Component({
|
||||
@@ -21,7 +20,7 @@ import { MatCardModule } from '@angular/material/card';
|
||||
templateUrl: './layer-detail.component.html',
|
||||
styleUrls: ['./layer-detail.component.scss'],
|
||||
standalone: true,
|
||||
imports: [FormsModule, ReactiveFormsModule, MatCardModule, MatToolbarModule,
|
||||
imports: [FormsModule, ReactiveFormsModule, MatCardModule,
|
||||
MatButtonModule, MatGridListModule, MatFormFieldModule, MatInputModule,
|
||||
NgIf, MatTableModule, MatSortModule, DecimalPipe, JsonPipe],
|
||||
providers: [DatePipe]
|
||||
|
||||
@@ -59,9 +59,6 @@ export class LayersListComponent implements OnInit {
|
||||
this.start = this.end;
|
||||
this.end = this.limit + this.start;
|
||||
}
|
||||
trackByUid(index : number, item : Layer) {
|
||||
return item.id;
|
||||
}
|
||||
async removeCode(code: string) {
|
||||
const index = this.codes.indexOf(code);
|
||||
if (index >= 0) {
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
<mat-drawer #drawer mode="side" opened>
|
||||
<diunabi-main-menu></diunabi-main-menu>
|
||||
<mat-divider></mat-divider>
|
||||
<small>
|
||||
{{appVersion}}
|
||||
</small>
|
||||
<br>
|
||||
<small>
|
||||
© DiunaBI {{currentDate | date: 'yyyy'}}
|
||||
</small>
|
||||
@@ -21,7 +25,6 @@
|
||||
<mat-icon>menu</mat-icon>
|
||||
</button>
|
||||
{{environment.appName}}
|
||||
<span style="font-size: x-small;"> {{appVersion}}</span>
|
||||
<div class="fill-space"></div>
|
||||
<a mat-icon-button [matMenuTriggerFor]="userMenu">
|
||||
<mat-icon *ngIf="!auth$.user.avatar">account_circle</mat-icon>
|
||||
|
||||
@@ -39,29 +39,11 @@
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.fill-to-right {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 4vh;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.sidenav-content {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.mat-toolbar.mat-primary {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.app-content {
|
||||
flex: 1;
|
||||
margin: 0 auto;
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.profile-photo-small {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ export const environment = {
|
||||
appName: "LOCAL_DiunaBI",
|
||||
production: false,
|
||||
api: {
|
||||
//url: "http://localhost:5400/api"
|
||||
url: "https://diunabi-morska.bim-it.pl/api"
|
||||
url: "http://localhost:5400/api"
|
||||
//url: "https://diunabi-morska.bim-it.pl/api"
|
||||
},
|
||||
google: {
|
||||
clientId: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com"
|
||||
|
||||
@@ -112,10 +112,10 @@ namespace WebAPI.Controllers
|
||||
public IActionResult ExportToGoogleSheet(Guid id)
|
||||
{
|
||||
Layer layer = db.Layers
|
||||
.Include(x => x.Records)
|
||||
.Include(x => x.Records!.OrderByDescending(x => x.Code))
|
||||
.Where(x => x.Id == id && !x.IsDeleted).First();
|
||||
|
||||
var export = new googleSheetExport(googleDriveHelper, googleSheetValues);
|
||||
var export = new googleSheetExport(googleDriveHelper, googleSheetValues, configuration);
|
||||
export.export(layer);
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Google.Apis.Drive.v3.Data;
|
||||
using System.Globalization;
|
||||
using Google.Apis.Drive.v3.Data;
|
||||
using Google.Apis.Sheets.v4;
|
||||
using Google.Apis.Sheets.v4.Data;
|
||||
using WebAPI.Models;
|
||||
@@ -10,10 +11,15 @@ namespace WebAPI.Exports
|
||||
{
|
||||
private GoogleDriveHelper googleDriveHelper;
|
||||
private SpreadsheetsResource.ValuesResource googleSheetValues;
|
||||
public googleSheetExport(GoogleDriveHelper _googleDriveHelper, SpreadsheetsResource.ValuesResource _googleSheetValues)
|
||||
private readonly IConfiguration configuration;
|
||||
public googleSheetExport(
|
||||
GoogleDriveHelper _googleDriveHelper,
|
||||
SpreadsheetsResource.ValuesResource _googleSheetValues,
|
||||
IConfiguration _configuration)
|
||||
{
|
||||
googleDriveHelper = _googleDriveHelper;
|
||||
googleSheetValues = _googleSheetValues;
|
||||
configuration = _configuration;
|
||||
}
|
||||
public void export(Layer layer)
|
||||
{
|
||||
@@ -26,9 +32,9 @@ namespace WebAPI.Exports
|
||||
}
|
||||
|
||||
Google.Apis.Drive.v3.Data.File body = new Google.Apis.Drive.v3.Data.File();
|
||||
body.Name = $"export-{DateTime.Now}";
|
||||
body.Name = $"{DateTime.Now.ToString(new CultureInfo("pl-PL"))}";
|
||||
body.MimeType = "application/vnd.google-apps.spreadsheet";
|
||||
body.Parents = new List<string> { "1c5GBQmsIoj6a9L-JYFTaLEZ3EfkbQHPt" };
|
||||
body.Parents = new List<string?> { configuration["exportDirectory"] };
|
||||
CreateRequest request = googleDriveHelper.Service.Files.Create(body);
|
||||
var file = request.Execute();
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"GoogleClientId": "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com",
|
||||
"Secret": "8393AF8EAEF8478CB738D44858690F9C7E2D19F65896DD9FBAA3EB2A6F493E80",
|
||||
"apiKey": "10763478CB738D4ecb2h76g803478CB738D4e",
|
||||
"exportDirectory": "1eTyCUzYbzVQB8f8sbNmvnebFXyW2-axt",
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"GoogleClientId": "#{google-backend-login-client-id}#",
|
||||
"Secret": "#{google-backend-login-secret}#",
|
||||
"apiKey": "#{api-key}#",
|
||||
"exportDirectory": "#{export-directory}#",
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
|
||||
Reference in New Issue
Block a user