Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YORN DIALOG AND LOGIN VIEW CHANGE #82

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 76 additions & 59 deletions src/app/public/admin/admin-home/admin-home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,50 @@
* @modify date 2022-02-26 18:26:41
* @desc Admin Home Component
*/
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { AuthserviceService } from '../../services/authservice.service';
import { NodeclientService } from '../../services/nodeclient.service';
import { SpinnerService } from '../../services/spinner-service';
import { TeamService } from '../../services/teams.service';
import { UserService } from '../../services/users.service';
import { AlertDialogComponent } from '../../widget/alert-dialog/alert-dialog.component';
import { InputDialogComponent } from '../../widget/alert-dialog/input-dialog.component';
import { ToastService } from '../../widget/toast/toast-service';
import { AdminConfig } from '../admin.config';
import { Component, OnInit } from "@angular/core";
import { MatDialog } from "@angular/material/dialog";
import { Router } from "@angular/router";
import { AuthserviceService } from "../../services/authservice.service";
import { NodeclientService } from "../../services/nodeclient.service";
import { SpinnerService } from "../../services/spinner-service";
import { TeamService } from "../../services/teams.service";
import { UserService } from "../../services/users.service";
import { AlertDialogComponent } from "../../widget/alert-dialog/alert-dialog.component";
import { InputDialogComponent } from "../../widget/alert-dialog/input-dialog.component";
import { YornDialogComponent } from "../../widget/alert-dialog/yorn-dialog.component";
import { ToastService } from "../../widget/toast/toast-service";
import { AdminConfig } from "../admin.config";
@Component({
selector: 'app-admin-home',
templateUrl: './admin-home.component.html',
styleUrls: ['./admin-home.component.scss'],
selector: "app-admin-home",
templateUrl: "./admin-home.component.html",
styleUrls: [ "./admin-home.component.scss" ],
})
export class AdminHomeComponent implements OnInit {
cardsMetaData: any;
teamList: any;
userList: any;
loggedUser:any;
loggedUser: any;
constructor(
private _spinner: SpinnerService,
private _client: NodeclientService,
private dialog: MatDialog,
private router: Router,
private tms: TeamService,
private userService: UserService,
private _auth:AuthserviceService,
private toastService:ToastService
private _auth: AuthserviceService,
private toastService: ToastService
) {
this.cardsMetaData = AdminConfig.cardsMetaData;
if (_client.deviceIsMobile()) {
for (var row in this.cardsMetaData) {
for (var col in this.cardsMetaData[row]) {
//console.log(this.cardsMetaData[row][col]);
this.cardsMetaData[row][col].cardHeight = '200';
this.cardsMetaData[row][col].cardWidth = '300';
this.cardsMetaData[row][col].cardHeight = "200";
this.cardsMetaData[row][col].cardWidth = "300";
}
}
}
this.loggedUser=_auth.getUser();
this.loggedUser = _auth.getUser();
}
deleteTeam() {
//console.log('Delete User Called');
Expand All @@ -72,25 +73,28 @@ export class AdminHomeComponent implements OnInit {
parseList(res: any) {
var list = [];
for (var item in res) {
list.push(res[item]['team_name']);
list.push(res[item]["team_name"]);
}
return list;
}
getTeamFromDialogAndCallback(list: any) {
console.log(list);
this.openDialogInput(
{
title: 'Choose a team',
label: 'Team',
placeholder: 'Select team',
title: "Choose a team",
label: "Team",
placeholder: "Select team",
list: list,
bindLabel: 'team',
bindLabel: "team",
},
(res: any) => {
console.log('data from close:', res);
async (res: any) => {
console.log("data from close:", res);
res = res.dataCtrl;

if (!window.confirm('Delete team:' + res + '?')) {
let userConfirmation = await this.openYornDialog({
title: "Prompt",
message: `<p class="mb-3"><strong>Do you really want to remove this team "${res}"?</strong></p>`,
});
if (!userConfirmation) {
return;
}
this._spinner.setSpinnerState(true);
Expand All @@ -99,23 +103,23 @@ export class AdminHomeComponent implements OnInit {
.deleteTeam(res)
.then((res2: any) => {
res2 = JSON.parse(res2);
if (res2.status == 'SUCCESS') {
if (res2.status == "SUCCESS") {
this._spinner.setSpinnerState(false);

this.openDialog(
{
type: 'message',
message: 'Team deleted successfully!',
type: "message",
message: "Team deleted successfully!",
},
function () {
function() {
window.location.reload();
}
);
} else {
this._spinner.setSpinnerState(false);
this.openDialog(
{
type: 'alert',
type: "alert",
message: res2.message,
},
null
Expand All @@ -127,7 +131,7 @@ export class AdminHomeComponent implements OnInit {
this._spinner.setSpinnerState(false);
this.openDialog(
{
type: 'alert',
type: "alert",
message: err.message,
},
null
Expand All @@ -142,12 +146,12 @@ export class AdminHomeComponent implements OnInit {
this.dialog
.open(AlertDialogComponent, {
data: data,
panelClass: 'app-dialog-class',
panelClass: "app-dialog-class",
})
.afterClosed()
.toPromise()
.then((res: any) => {
if (typeof callback == 'function') {
if (typeof callback == "function") {
callback();
}
});
Expand All @@ -156,15 +160,15 @@ export class AdminHomeComponent implements OnInit {
this.dialog
.open(InputDialogComponent, {
data: data,
panelClass: 'app-dialog-class',
panelClass: "app-dialog-class",

width: '500px',
width: "500px",
})
.afterClosed()
.toPromise()
.then((res) => {
//console.log(res);
if (typeof callback == 'function' && res != '' && res != null) {
if (typeof callback == "function" && res != "" && res != null) {
callback(res);
}
});
Expand All @@ -188,11 +192,11 @@ export class AdminHomeComponent implements OnInit {
//console.log(list);
this.openDialogInput(
{
title: 'Choose a user',
label: 'Username',
placeholder: 'Select user',
title: "Choose a user",
label: "Username",
placeholder: "Select user",
list: list,
bindLabel: 'user_id',
bindLabel: "user_id",
},
(res: any) => {
//console.log('data from close:', res);
Expand All @@ -207,22 +211,26 @@ export class AdminHomeComponent implements OnInit {
.promoteUser(res.user.user_id)
.then((res2: any) => {
res2 = JSON.parse(res2);
if (res2.status == 'Success') {
if(this.loggedUser.useToast){
this.toastService.showSuccess('User promoted to Team Lead.',5000);
}else{
this.openDialog(
{
type: 'message',
message: 'User promoted to Team Lead.',
},
null
);}
if (res2.status == "Success") {
if (this.loggedUser.useToast) {
this.toastService.showSuccess(
"User promoted to Team Lead.",
5000
);
} else {
this.openDialog(
{
type: "message",
message: "User promoted to Team Lead.",
},
null
);
}
} else {
this._spinner.setSpinnerState(false);
this.openDialog(
{
type: 'alert',
type: "alert",
message: res2.message,
},
null
Expand All @@ -234,7 +242,7 @@ export class AdminHomeComponent implements OnInit {
this._spinner.setSpinnerState(false);
this.openDialog(
{
type: 'alert',
type: "alert",
message: err.message,
},
null
Expand All @@ -252,4 +260,13 @@ export class AdminHomeComponent implements OnInit {
);
}
ngOnInit(): void {}
openYornDialog(data: any) {
return this.dialog
.open(YornDialogComponent, {
data: data,
panelClass: "app-dialog-class",
})
.afterClosed()
.toPromise();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { ApplicationpropsService } from '../../services/applicationprops.service
import { NodeclientService } from '../../services/nodeclient.service';
import { SpinnerService } from '../../services/spinner-service';
import { AlertDialogComponent } from '../../widget/alert-dialog/alert-dialog.component';
import { YornDialogComponent } from '../../widget/alert-dialog/yorn-dialog.component';

@Component({
selector: 'app-application-properties',
Expand Down Expand Up @@ -130,14 +131,15 @@ export class ApplicationPropertiesComponent implements OnInit {
}
this.updatePropList[event.prop_name] = event.prop_value;
}
updateProps() {
if (
!window.confirm(
'Update Properties :' + JSON.stringify(this.updatePropList) + ' ?'
)
) {
return;
}
async updateProps() {
let userConfirmation = await this.openYornDialog({
title: "Prompt",
message: `<p class="mb-3"><strong>Do you really want to update these properties: "${JSON.stringify(this.updatePropList)}"?</strong></p>`,
});
if (!userConfirmation) {
return;
}

//console.log(this.updatePropList);
// display form values on success
var headers = new HttpHeaders({
Expand Down Expand Up @@ -204,4 +206,13 @@ export class ApplicationPropertiesComponent implements OnInit {
}
});
}
openYornDialog(data: any) {
return this.dialog
.open(YornDialogComponent, {
data: data,
panelClass: "app-dialog-class",
})
.afterClosed()
.toPromise();
}
}
22 changes: 16 additions & 6 deletions src/app/public/admin/dynamic-objects/dynamic-objects.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { MatDialog } from '@angular/material/dialog';
import { AlertDialogComponent } from '../../widget/alert-dialog/alert-dialog.component';
import { NodeclientService } from '../../services/nodeclient.service';
import { DynamicObjectsService } from '../../services/dynamicobjects.service';
import { YornDialogComponent } from '../../widget/alert-dialog/yorn-dialog.component';

const LOCAL_STORAGE_KEY = 'dynamicObjectListGridState';
const DEFAULT_PAGE_SIZE = 25;
Expand Down Expand Up @@ -383,14 +384,14 @@ export class ToolsDynamicObjectsComponent implements OnInit {
this.loggedUser.permissions.delete_vm
);
},
action: (_event: any, args: any) => {
action: async (_event: any, args: any) => {
const dataContext = args.dataContext;
const row = args?.row ?? 0;
if (
confirm(
`Do you really want to remove this object "${dataContext.description}"? CAUTION: This action will remove all data from object table.`
)
) {
let userConfirmation = await this.openYornDialog({
title: "Prompt",
message: `<p class="mb-3"><strong> Do you really want to remove this object "${dataContext.description}"? CAUTION: This action will remove all data from object table.</strong></p>`,
});
if (userConfirmation) {
this.spinner.setSpinnerState(true);
this.dynamicObjectService
.deleteDynamicObject(dataContext.name)
Expand Down Expand Up @@ -548,4 +549,13 @@ export class ToolsDynamicObjectsComponent implements OnInit {
localStorage[LOCAL_STORAGE_KEY] = JSON.stringify(gridState);
}
}
openYornDialog(data: any) {
return this.dialog
.open(YornDialogComponent, {
data: data,
panelClass: "app-dialog-class",
})
.afterClosed()
.toPromise();
}
}
Loading