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