System Configuration new design

This commit is contained in:
Mohaimen Hasan 2026-11-16 16:17:32 +06:00
parent 18510679bb
commit 77321b60ff
3 changed files with 412 additions and 36 deletions

View File

@ -1 +1,233 @@

.sc-page {
/* padding: 1.5rem; */
}
.sc-header {
display: flex;
align-items: center;
gap: 14px;
margin-bottom: 0.5rem;
}
.sc-header-icon {
width: 44px;
height: 44px;
border-radius: 10px;
background: #f0f0f0;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
color: #555;
flex-shrink: 0;
}
.sc-title {
font-size: 18px;
font-weight: 600;
color: #1a1a1a;
margin: 0 0 2px;
}
.sc-subtitle {
font-size: 13px;
color: #888;
margin: 0;
}
.sc-card {
background: #fff;
border: 1px solid #e8e8e8;
border-radius: 12px;
padding: 0.85rem;
}
.sc-field {
margin-bottom: 0.5rem;
}
.sc-label {
display: block;
font-size: 12px;
font-weight: 600;
color: #888;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 8px;
}
.sc-drop-zone {
border: 1.5px dashed #d4d4d4;
border-radius: 10px;
transition: border-color 0.15s, background 0.15s;
overflow: hidden;
}
.sc-drop-zone--dragging {
border-color: #4a90d9;
background: #f0f6fd;
}
.sc-drop-zone--has-file {
border-style: solid;
border-color: #c8e0f7;
background: #f7fbff;
}
.sc-drop-empty {
padding: 1rem 1rem;
text-align: center;
}
.sc-drop-icon {
font-size: 28px;
color: #bbb;
display: block;
margin-bottom: 10px;
}
.sc-drop-label {
font-size: 14px;
color: #777;
margin: 0 0 4px;
}
.sc-drop-hint {
font-size: 13px;
color: #aaa;
margin: 0 0 12px;
}
.sc-browse-btn {
display: inline-block;
padding: 6px 18px;
border: 1px solid #4a90d9;
border-radius: 6px;
font-size: 13px;
font-weight: 500;
color: #4a90d9;
cursor: pointer;
transition: background 0.15s;
}
.sc-browse-btn:hover {
background: #f0f6fd;
}
.sc-drop-selected {
padding: 12px 14px;
}
.sc-file-info {
display: flex;
align-items: center;
gap: 12px;
}
.sc-file-icon-wrap {
width: 38px;
height: 38px;
border-radius: 8px;
background: #e8f2fd;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.sc-file-icon {
font-size: 18px;
color: #4a90d9;
}
.sc-file-details {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.sc-file-name {
font-size: 14px;
font-weight: 500;
color: #1a1a1a;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sc-file-size {
font-size: 12px;
color: #aaa;
margin-top: 2px;
}
.sc-file-clear {
background: none;
border: none;
cursor: pointer;
color: #bbb;
padding: 4px;
display: flex;
align-items: center;
border-radius: 4px;
transition: color 0.15s, background 0.15s;
flex-shrink: 0;
}
.sc-file-clear:hover {
color: #e24b4a;
background: #fef0f0;
}
.sc-drop-restriction {
font-size: 12px;
color: #aaa;
margin-top: 6px;
}
.sc-drop-restriction code {
font-family: monospace;
background: #f4f4f4;
padding: 1px 5px;
border-radius: 4px;
font-size: 11px;
color: #666;
}
.sc-divider {
border: none;
border-top: 1px solid #f0f0f0;
margin: 1.25rem 0;
}
.sc-btn-row {
display: flex;
gap: 10px;
}
.sc-btn {
display: inline-flex;
align-items: center;
gap: 7px;
height: 38px;
padding: 0 18px;
border-radius: 8px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: background 0.15s, opacity 0.15s, transform 0.1s;
border: 1px solid transparent;
}
.sc-btn:active:not(:disabled) {
transform: scale(0.98);
}
.sc-btn:disabled {
opacity: 0.4;
cursor: not-allowed;
}
.sc-btn--primary {
background: #1a1a1a;
color: #fff;
border-color: #1a1a1a;
}
.sc-btn--primary:hover:not(:disabled) {
background: #333;
}
.sc-btn--secondary {
background: #fff;
color: #1a1a1a;
border-color: #ddd;
}
.sc-btn--secondary:hover:not(:disabled) {
background: #f7f7f7;
}
.sc-status {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
margin-top: 14px;
padding: 10px 14px;
border-radius: 8px;
}
.sc-status--success {
background: #f0faf4;
color: #2e7d52;
border: 1px solid #c3e8d4;
}
.sc-status--error {
background: #fff5f5;
color: #c0392b;
border: 1px solid #f5c6c6;
}

View File

@ -1,36 +1,118 @@
<app-loading-panel> </app-loading-panel>
<div class="card card-w-title">
<div class="col-12">
<div class="col-12" style="font-weight: bold;color: red;">
<label>Please select respective Configuration Type from the dropboox & choose file to upload the configuration type</label>
</div>
<div class="col-12">
<div class="grid">
<div class="col-12">
<div class="example-wrapper">
<p>Configuration Type:</p>
</div>
</div>
<div class="col-3" style="margin: auto;">
<kendo-dropdownlist [(ngModel)]="fileTypeid"
[data]="configtypes"
[defaultItem]="{ name: 'Select a configuration type', value: null }"
[textField]="'name'"
[valueField]="'value'"
[valuePrimitive]="true"
id="itemid" style="width: 100%;">
</kendo-dropdownlist>
</div>
<div class="col-7">
<input id="fupEmpPhoto" kendoTextBox (change)="selectFile($event)" type="file" style="width: 100%;">
</div>
<div class="col-1" style="margin: auto;">
<button kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['upload']" (click)="upload()" style="width: 100%;">upload</button>
</div>
<div class="col-1" style="margin: auto;">
<button kendoButton themeColor="primary" [svgIcon]="apiService.KendoSVGIcon['download']" (click)="download()" style="width: 100%;">Download</button>
</div>
</div>
</div>
<app-loading-panel></app-loading-panel>
<div class="sc-page">
<!-- Page header -->
<div class="sc-header">
<div class="sc-header-icon">
<i class="pi pi-cog"></i>
</div>
</div>
<div>
<h2 class="sc-title">System Configuration</h2>
<p class="sc-subtitle">Upload or download XML configuration files</p>
</div>
</div>
<!-- Main card -->
<div class="sc-card">
<!-- Configuration type -->
<div class="sc-field">
<label class="sc-label" for="configTypeSelect">Configuration type</label>
<kendo-dropdownlist [(ngModel)]="fileTypeid"
[data]="configtypes"
[defaultItem]="{ name: 'Select a configuration type', value: null }"
[textField]="'name'"
[valueField]="'value'"
[valuePrimitive]="true"
id="configTypeSelect" style="width: 100%;">
</kendo-dropdownlist>
</div>
<!-- File upload drop zone -->
<div class="sc-field">
<label class="sc-label">Configuration file</label>
<div
class="sc-drop-zone"
[class.sc-drop-zone--dragging]="isDragging"
[class.sc-drop-zone--has-file]="selectedFileName"
(dragover)="onDragOver($event)"
(dragleave)="onDragLeave()"
(drop)="onDrop($event)">
<!-- Empty state -->
<div *ngIf="!selectedFileName" class="sc-drop-empty">
<i class="pi pi-upload sc-drop-icon"></i>
<p class="sc-drop-label">Drag & drop your XML file here</p>
<p class="sc-drop-hint">or</p>
<label class="sc-browse-btn" for="fileInputHidden">
Browse file
</label>
<input
id="fileInputHidden"
type="file"
accept=".xml"
(change)="selectFile($event)"
style="display:none">
</div>
<!-- File selected state -->
<div *ngIf="selectedFileName" class="sc-drop-selected">
<div class="sc-file-info">
<div class="sc-file-icon-wrap">
<i class="pi pi-file sc-file-icon"></i>
</div>
<div class="sc-file-details">
<span class="sc-file-name">{{ selectedFileName }}</span>
<span class="sc-file-size">{{ selectedFileSize }}</span>
</div>
<button class="sc-file-clear" (click)="clearFile()" title="Remove file" type="button">
<i class="pi pi-times"></i>
</button>
</div>
</div>
</div>
<p class="sc-drop-restriction">Only <code>.xml</code> files are accepted</p>
</div>
<hr class="sc-divider">
<!-- Action buttons -->
<div class="sc-btn-row">
<button
class="sc-btn sc-btn--primary"
[disabled]="!canUpload"
(click)="upload()"
type="button">
<i class="pi pi-upload"></i>
Upload
</button>
<button
class="sc-btn sc-btn--secondary"
[disabled]="!canDownload"
(click)="download()"
type="button">
<i class="pi pi-download"></i>
Download
</button>
</div>
<!-- Status message -->
<div
*ngIf="statusType"
class="sc-status"
[class.sc-status--success]="statusType === 'success'"
[class.sc-status--error]="statusType === 'error'">
<i
class="pi"
[class.pi-check-circle]="statusType === 'success'"
[class.pi-times-circle]="statusType === 'error'">
</i>
<span>{{ statusMessage }}</span>
</div>
</div>
</div>

View File

@ -59,6 +59,13 @@ export class SystemConfigurationComponent implements OnInit {
_fromValidator: FormGroup;
selectedFiles?: FileList;
// UI state for the redesigned template
public isDragging = false;
public selectedFileName = '';
public selectedFileSize = '';
public statusType: 'success' | 'error' | '' = '';
public statusMessage = '';
configtypes: any = EnumExtension.getNamesAndValues(EnumConfigurationType);
constructor(public systemConfigService: SystemConfigurationService,
@ -160,10 +167,14 @@ export class SystemConfigurationComponent implements OnInit {
(err) => {
this.loadingPanelService.ShowLoadingPanel = false;
this.notificationService.showError(err.error);
this.statusType = 'error';
this.statusMessage = err.error;
},
() => {
this.loadingPanelService.ShowLoadingPanel = false;
this.notificationService.showSuccess("Data uploaded successfully.")
this.statusType = 'success';
this.statusMessage = 'File uploaded successfully.';
});
}
@ -279,12 +290,63 @@ export class SystemConfigurationComponent implements OnInit {
selectFile(event: any): void {
this.selectedFiles = event.target.files;
if (this.selectedFiles && this.selectedFiles.length > 0) {
const file = this.selectedFiles.item(0);
this.selectedFileName = file.name;
this.selectedFileSize = this.formatFileSize(file.size);
this.statusType = '';
this.statusMessage = '';
}
//if (this.selectedFiles.length > 0) {
// const file: File | null = this.selectedFiles.item(0);
// this.selectedFiles = file;
//}
}
onDragOver(event: DragEvent): void {
event.preventDefault();
this.isDragging = true;
}
onDragLeave(): void {
this.isDragging = false;
}
onDrop(event: DragEvent): void {
event.preventDefault();
this.isDragging = false;
const files = event.dataTransfer?.files;
if (files && files.length > 0) {
const file = files[0];
if (!file.name.endsWith('.xml')) {
this.notificationService.showWarning('Only .xml files are accepted.');
return;
}
const dt = new DataTransfer();
dt.items.add(file);
this.selectedFiles = dt.files;
this.selectedFileName = file.name;
this.selectedFileSize = this.formatFileSize(file.size);
this.statusType = '';
this.statusMessage = '';
}
}
clearFile(): void {
this.selectedFiles = null;
this.selectedFileName = '';
this.selectedFileSize = '';
this.statusType = '';
this.statusMessage = '';
}
formatFileSize(bytes: number): string {
if (bytes < 1024) return bytes + ' B';
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
}
get canUpload(): boolean {
return !!this.fileTypeid && !!this.selectedFiles && this.selectedFiles.length > 0;
}
get canDownload(): boolean {
return !!this.fileTypeid;
}
public downloadFile(uid: string): void {
const temporiginalName = '';
let tempName = '';