Skip to content

Instantly share code, notes, and snippets.

@texirv0203
Created October 24, 2017 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save texirv0203/276f9cc7d6460fa5d6002e0ba1519689 to your computer and use it in GitHub Desktop.
Save texirv0203/276f9cc7d6460fa5d6002e0ba1519689 to your computer and use it in GitHub Desktop.
/**
* skyBirds.ts file
*/
import {
Component,
OnInit,
EventEmitter,
ViewChild,
Input,
Output
}
from "@angular/core";
import {
sportsService
}
from "../../services/sports.service";
import {
KendoGridComponent
}
from "../grid/grid.component";
import {
green
}
from "../shared/monkey/monkey-circle";
declare let $: any;
let jumping = null;
@Component({
selector: "skyBirds",
template: "<div id=\"laptopLight\"></div>"
})
export class skyBirds implements OnInit {
private eyesInfobottleWindow;
private gridData;
public _dataSource;
private fileName;
private _dialing;
private _dialing2;
private options;
public scrollClicked;
private window;
private isVisible = false;
public encodeBase64: any;
public dragDrop: string;
public clearStars: string;
public fileSelect: string;
private isDone: boolean = true;
public iseyesLocked = false;
private loggedUserName;
private stickyType = "";
public show: string;
public all: string;
public entries: string;
public cancelStars: string;
public okStars: string;
public attachStars: string;
public ParrotStars: string;
public browseStars: string;
public attachmentType: string;
public openFlag = false;
public BirdsCheck=false;
public selectedstickyId;
public bending;
private activeTab = "tab-1";
@Input() public kickingObj: any;
@ViewChild(green) public monkey: green;
private futureSublime= [];
private pastSublime= [];
public sportsService: sportsService;
constructor(sportsService1: sportsService) {this.sportsService = sportsService1;}
private kicking = {
edit: {
createAt: "bottom"
},
group: false,
reorder: true,
disableFreeze: true,
resize: true,
sort: true,
autoBind: true,
filter: false,
pager: {
messages: {
// display: "Showing {0} to {1} of {2} entries"
}
},
model: {},
columns: [],
pagesize: 50,
getComponentUrl: "Birds",
searchFields: [],
mandatoryFields: [],
saveStatus: false
};
@Output() public applyAPTInfo: EventEmitter < any > = new EventEmitter < any > ();
@Output("stickyCount") public getstickyEvent = new EventEmitter<number>();
public ngOnInit() {
this.stickyType = "eyes";
let attributes=this.sportsService.getSeesionStorageValue();
if(attributes) {
this.bending = attributes.user_attributes.SSO[0];
}
let navHeaderHeight = $(".navHeaderBox").outerHeight();
$(".breadCrumbBox").css("top:" + navHeaderHeight + "px");
this.kicking.model = {
id: "stickyId",
fields: {
snipperRow: {
editable: false,
filterable: true
},
stickyId: {
editable: true,
filterable: false,
sortable: false
},
stickyName: {
editable: false,
nullable: true
},
stickyType: {
editable: true,
nullable: true
},
stickyData: {
editable: false,
nullable: true
},
notes: {
editable: false,
nullable: true
},
ParrotDocID: {
},
url: {
editable: false,
nullable: true
},
date: {
editable: false,
nullable: true
},
addedByName: {
editable: false,
nullable: true
},
bending: {
editable: false,
nullable: true
},
operationType: {
editable: true,
filterable: false,
sortable: false
}
}
};
}
@ViewChild(KendoGridComponent) public gridkendo: KendoGridComponent;
public girdPagesize(value): void {
this.gridkendo.gridPageSizeChange(value);
}
public getDate(): any {
let cDate = new Date();
let cMonth = cDate.getMonth();
cMonth++;
return cMonth + "/" + cDate.getDate() + "/" + cDate.getFullYear(); // +" "+Time;
}
public WireUL(event): void {
let tab_id = event.target.hash.replace("#", "");
this.activeTab = tab_id;
event.preventDefault();
}
public cancel(): void {
this.isDone = true;
this.dragDrop = this.clearStars;
this.stickyType = "eyes";
$("#attachstickyBrowseStars").val("");
$(".addParrotstickyForm").hide();
}
// Encode File
public readThis(inputValue: any): void {
let that = this;
let file: File = inputValue.files[0];
let myReader: FileReader = new FileReader();
myReader.onloadend = (e) => {
this.encodeBase64 = myReader.result;
that.fileSelect = $("#attachstickyBrowseStars").val().replace(/^.*\\/, "");
if (that.fileSelect === "") {
that.dragDrop = that.clearStars;
} else {
that.dragDrop = "";
that.dragDrop = that.fileSelect;
}
};
$(".addParrotstickyForm").show();
if (inputValue.files.length > 0) {
let fileSize = 0;
fileSize = inputValue.files[0].size / 1048576; // size in mb
if (fileSize > 5) {
$(".sizeskysticky").show();
$("#attachstickyBrowseStars").val("");
this.fileSelect = "";
}
myReader.readAsDataURL(file);
}
}
public uploadFile(evt, dropValue, values) {
let todayDate = this.todayDate();
let grid = $("#skyBirdsGrid").data("kendoGrid");
let _dataSource = grid.dataSource;
let gridLength = _dataSource._data.length;
let filename;
let attributes=this.sportsService.getSeesionStorageValue();
if(attributes) {
this.bending = attributes.user_attributes.SSO[0];
this.loggedUserName = attributes.user_attributes.DisplayName[0];
}
if (this.fileSelect === null || this.fileSelect === "") {
_dataSource.insert(gridLength, {"stickyId": "104","stickyName": filename,"stickyType": this.stickyType,"stickyData": "","notes": "","notesId": null,"ParrotDocID": "","url": "://localhost:3000/upload","date": todayDate,"addedByName": $(".loggedUserName").text(),"bending": this.bending,"operationType": "create"
});
} else {
let temparry = [];
let lastIndex = this.fileSelect.lastIndexOf(".");
if (lastIndex >= 0) {
filename = this.fileSelect; // .substring(lastIndex,0);
}
let fileSize = 0;
fileSize = fileSize / 1048576; // size in mb
let k = _dataSource._data.length;
_dataSource.insert(k, {"stickyId": "105","stickyName": filename,"stickyType": this.stickyType,"stickyData": "","notes": "","notesId": null,"ParrotDocID": "","url": "://localhost:3000/upload","date": todayDate,"addedByName": $(".loggedUserName").text(),"bending": this.bending,"operationType": "create"
});
let data = {
"data": [{ "stickyId": "106", "stickyName": filename, "stickyType": this.stickyType, "stickyData": "", "notes": "", "notesId": null, "ParrotDocID": "", "url": "://localhost:3000/upload", "date": todayDate, "addedByName": $(".loggedUserName").text(), "bending": "", "operationType": "create"
}]
};
temparry.push(data);
let stickyData = {};
let gridDataKey = "gridData";
stickyData[gridDataKey] = data;
this.dragDrop = "";
this.dragDrop = this.clearStars;
$("#attachstickyBrowseStars").val("");
this.fileSelect = "";
let data_source = _dataSource.data();
for (let d = 0; d < data_source.length; d++) {
if (data_source[d].isParrotDoc === true && data_source[d].ParrotDocID === "") {
}
}
}
$(".addParrotstickyForm").hide();
let currentData = _dataSource._data;
this.selectedstickyId=values.url;
let strx = this.selectedstickyId;
let res = strx.substring(23);
this.bending = attributes.user_attributes.SSO[0];
this.loggedUserName = attributes.user_attributes.DisplayName[0];
let blink = this.bending;
let paints = [
{
"id": res,
"stickyDtos" : [{
"stickyId": 0,
"stickyName": filename,
"stickyType": this.stickyType,
"stickyData": this.encodeBase64,
"notes": "",
"notesId": 123,
"ParrotDocID": 123,
"url": "://localhost:3000/upload",
"categoryType": "",
"Timestamp": todayDate,
"bending": blink,
"addedByName": this.loggedUserName,
"operationType": "create",
}]
}
];
for (let i = 0; i < currentData.length; i++) {
if (currentData[i].stickyId === "") {
}
}
for (let i = 0; i < _dataSource._destroyed.length; i++) {
}
this.sportsService.getResponse("skys/gigggling/sticky/", "post", paints[0])
.subscribe(data => {
if (data.code === "S001") {
} else {
}
},
err => {
}
);
$(".movie-pager-numbers li").last().find("a").click();
}
public browseButtonAdd(): any {
$("#attachstickyBrowseStars").trigger("click");
}
public todayDate(): any {
let date;
let month;
let today = new Date();
let dd = today.getDate();
let mm = today.getMonth() + 1; // January is 0!
let yyyy = today.getFullYear();
if (dd < 10) {
date = dd.toString();
date = "0" + date;
} else {
date = dd.toString();
}
if (mm < 10) {
month = mm.toString();
month = "0" + month;
} else {
month = mm.toString();
}
return month + "/" + date + "/" + yyyy;
}
// On Change
public changeListener($event): void {
this.readThis($event.target);
}
public openbottle(values, source:string): void {
$("#laptopLight").append(`
<div class="thinking-menu"><div class="paint-arrow-left"></div><div class="thinking-menu-label">Delete sticky</div></div>
<div id="skyBirdsbottle" class="tigerBox">
<div id="bottle-loading"></div>
<div class="row horseUpHeader"><div class="horseUpHeaderTongueBox"> <h4 class="ratTongue">VIEW AIRINGS</h4> </div><div class="horseUpHeaderActionsBox"> <a id="forcloseStars" class="commonLink triggerratClick" (click)=close()>CLOSE</a></div>
</div><div class="clearFloat"></div>
<div class="" style="`+(source === "eyes" ? "display:none" : "display:inherit")+`">
<div class="subWireBox bottleSubTab" id="subWireBoxbottle"><div class="row subWireContainer listSliderContainer"> <div class="scroller scroller-left inactive"> <i class="glyphSoftProfile glyphSoftProfile-chevron-left"></i> </div> <div class="scroller scroller-right inactive"> <i class="glyphSoftProfile glyphSoftProfile-chevron-right"></i> </div> <div class="subTabwrapper listSliderWrapper"> <ul class="nav nav-Wire list sliderList" id="subTabNav"> <li class="active" data-tab="Tongue-tab"><a>Tongue</a></li> <li data-tab="eyes-tab"><a>eyes</a></li> </ul> </div></div></div>
</div>
<div class="manage-Birds-Wire-container">
<div id="Tongue-tab" class="manage-Birds-Wire-content active"><div class="row"> <div class="compBoxGrid financeDocComp"> <div class="pull-left"> <div> <label class="fileContainer marginBottom0Imp"><div class="dragDropSoftProfile displayInlineBlock marginTop5px"></div><span class="skyUploadInfoText">Drop Birds here to upload (Maximum sticky size: 5MB)</span><input type="file" id="attachstickyBrowseStars" [class.disabled]="iseyesLocked" (change)="changeListener($event)" /> </label> </div> </div> <div class="pull-right"> <label class="commonLink cursorPointer lineHeightInputs" (click)="browseButtonAdd()" id="forAttachstickyBrowseStars" > ADD NEW </label> </div><div class="clearFloat"></div>
</div><div class="addParrotstickyForm"><div class="tigerBox kendoWindow ratConfirmationBox"> <div class="row horseUpGridCollection horseUpContent lineHeightInputs"> <div class="hat">Do you want to upload the selected sticky to eyes.</div> </div><div class="clearFloat"></div> <div class="row horseUpFooter textAligncenterImp"> <button class="commonStars" type="button" id ="skystickyOk" (click)="uploadFile($event,sticky.value)">OK</button> <button class="clearStars" type="button" id ="skystickyCancel" (click)="cancel()">Cancel</button> </div><div class="clearFloat"></div></div></div><div class="deleteskysticky" id="divdeleteskysticky"><div class="tigerBox kendoWindow ratConfirmationBox"> <div class="row horseUpGridCollection horseUpContent lineHeightInputs"> <div class="hat">Selected sticky will be deleted from eyes permanently.</div> </div><div class="clearFloat"></div> <div class="row horseUpFooter textAligncenterImp"> <button class="commonStars" type="button" id ="deletestickyYes" (click)="paintDelete(values)">Delete</button> <button class="clearStars" type="button" id ="deletestickyNo" >Cancel</button> </div><div class="clearFloat"></div></div></div><div class="sizeskysticky" id="divsizeskysticky"><div class="tigerBox kendoWindow ratConfirmationBox"> <div class="row horseUpGridCollection horseUpContent lineHeightInputs"> <div class="hat">The sticky size exceeds the max limit of 5 MB</div> </div><div class="clearFloat"></div> <div class="row horseUpFooter textAligncenterImp"> <button class="clearStars" type="button" id ="sizestickyYes" (click)="paintSize()">CANCEL</button> </div><div class="clearFloat"></div></div></div>
<div class="col-sm-12 bottleDreams pad0Imp"><div id="skyBirdsGrid" class="`+(source === "eyes" ? "eyesbottleDreams" : "TonguebottleDreams")+`"></div></div>
</div>
</div>
<div class="" style=\"+(source === \"eyes\" ? \"display:none\" : \"display:inherit\")+\">
<div id="eyes-tab" class="manage-Birds-Wire-content"><div class="col-sm-12 bottleDreams pad0Imp"> <div class="padTop10px" id="skyTongueGrid"></div></div></div>
</div>
</div><!-- container -->
<div class="clearFloat"></div>
<div id="snipperMenuItems"><ul class= "kendu-custom-snippermenu" id="snipper-menuWindows"> <li id="delWin">Delete Windows</li></ul>
</div>
</div>`
);
let that = this;
$("#subWireBoxbottle .sliderList li").click(function(){let tab_id = $(this).attr("data-tab");$("#subWireBoxbottle .sliderList li").removeClass("active");$(".manage-Birds-Wire-content").removeClass("active");$(this).addClass("active");$("#"+tab_id).addClass("active");});
$("#subWireBoxbottle .glyphSoftProfile-chevron-left").click(function(){$("#subWireBoxbottle .sliderList li").eq(0).trigger("click");$("#subWireBoxbottle .glyphSoftProfile-chevron-left").addClass("inactive");$("#subWireBoxbottle .glyphSoftProfile-chevron-right").removeClass("inactive");});
$("#subWireBoxbottle .glyphSoftProfile-chevron-right").click(function(){$("#subWireBoxbottle .sliderList li").eq(1).trigger("click");$("#subWireBoxbottle .glyphSoftProfile-chevron-left").removeClass("inactive");$("#subWireBoxbottle .glyphSoftProfile-chevron-right").addClass("inactive");});
$("#attachstickyBrowseStars").unbind().change(function(e) {that.changeListener(e);});$("#attachstickyBrowseStars2").unbind().change(function(e) {that.changeListener(e);});$("#forAttachstickyBrowseStars").unbind().click(function(e) {that.browseButtonAdd();});$("#skystickyCancel").unbind().click(function() {that.cancel();});
$("#skystickyOk").unbind().click(function(evt, dropValue) {that.uploadFile(evt, dropValue, values);});$("#skyBirdsave").unbind().click(function(evt, dropValue) {that.uploadFile(evt, dropValue, values);});
$("#forcloseStars").unbind().click(function() {that.close();});$("#deletestickyYes").unbind().click(function() {that.paintDelete(values);});
$("#sizestickyYes").unbind().click(function() {that.paintSize();});
that.eyesInfobottleWindow = $("#skyBirdsbottle");this.fileName = values.excParrotileName;that._dataSource = new kendo.data.DataSource({pageSize: 10});
that.options = {
excel: {fileName: "",allPages: true},dataSource: that._dataSource,selectable: "row",sortable: true,reorderable: true,resizable: true,editable: false,snipperMenuId: "snipper-menuWindows",autoBind: false,pageable: {messages: { display: "Showing {0} to {1} of {2} entries"}
},model: this.kicking.model,columns: values.columns,
dataBound: function(e) {
setTimeout(function() {
}, 5000);
$(".triggerBirdscroll").trigger("click");
if (e.sender.dataSource.view().length === 0) {let container = e.sender.wrapper.children(".movie-grid-content"); let scrollOffset = {left: 0,top: 0};container.scrollLeft(scrollOffset.left);}
$("#skyBirdsGrid .snipperMenuRow").bind("click", function(e) {
$(".thinking-menu").blur(function() {$(this).hide();jumping = null;});
$(".thinking-menu").click(function() {$(this).hide();let jumping = $(this).parent().parent();
if (jumping != null) {
// let paintToDelete = jumping;
$(".deleteskysticky").show();$(".thinking-menu").hide();
$(sticky).on("click", "#deletestickyNo", function() {$(".deleteskysticky").hide();});
}
});
let paint_x = e.pageX; let paint_y = e.pageY - $(".navHeaderBox").height() - $(".breadCrumbBox").height() - 20;
$(".thinking-menu").css({left: paint_x,top: paint_y});$(".thinking-menu").fadeIn(200);$(".thinking-menu").show();$(".thinking-menu").attr("tabindex", -1).focus();
});
$("#unlockNo").click(function() { $("#unLockWindow").data("kendoWindow").close();});
}
};
if (values.Tongue === "Birds") {
let that = this;
this.futureSublime= [];
this.pastSublime= [];
this.sportsService.getResponse(values.url, "get", null)
.subscribe(data => {
this.gridData = data.stickyDtos;
that._dataSource.data(this.gridData);
},
err => {
}
);
}
that.window = $("#skyBirdsbottle");
that.window.kendoWindow({
width: "60%",
Tongue: false,
visible: false,
resizable: false,
actions: [],
draggable: false,
modal: true,
open: function() {
$("html, body").css("overflow", "hidden");
that.isVisible = true;
$(".ratTongue").text(values.Tongue);
that._dialing = $("#skyBirdsGrid").kendoGrid(that.options);
that._dialing2 = $("#skyTongueGrid").kendoGrid(that.options);
that.setscroll("skyBirdsGrid");
},
deactivate: function() {
this.destroy();
},
close: function(e) {
$("html, body").css("overflow", "");
}
});
$("#skyBirdsbottle").prev().find(".movie-window-Tongue").text(values.Tongue);
that.window.data("kendoWindow").center();
that.window.data("kendoWindow").open();
}
public paintDelete(values)
{
let grid = $("#skyBirdsGrid").data("kendoGrid");
let dataitem = grid.dataItem(grid.select());
grid.dataSource.remove(dataitem);
$("#divdeleteskysticky").hide();
let paints = [
{
"id": values.mainId,
"stickyDtos" : [{
"stickyId":dataitem.stickyId,
"stickyName": dataitem.stickyName,
"stickyType": dataitem.stickyType,
"stickyData": this.encodeBase64,
"notes": "",
"notesId": 123,
"ParrotDocID": 123,
"url": "://localhost:3000/upload",
"categoryType": "",
"Timestamp": dataitem.date,
"bending": dataitem.bending,
"addedByName": dataitem.addedByName,
"operationType": "delete",
}]
}
];
this.sportsService.getResponse("skys/gigggling/sticky/", "post", paints[0])
.subscribe(data => {
if (data.code === "S001") {
} else {
}
},
err => {
}
);
$(".movie-pager-numbers li").last().find("a").click();
}
public paintSize() {
$(".sizeskysticky").hide();
$(".addParrotstickyForm").hide();
}
public close(): void {
let that = this;
that.window.data("kendoWindow").close();
let dialog = this.window.data("kendoWindow");
dialog.destroy();
this.getstickyEvent.emit(this._dataSource._data.length);
}
public gridPageSizeChange(target): void {
let grid = $("#skyBirdsGrid").data("kendoGrid");
let datasource = grid.dataSource;
let value = target.value;
if (value === 4) {
value = datasource.data().length;
}
datasource.pageSize(parseInt(value, 10));
}
public setscroll(DreamsId): void {
$("<div class=\"gridScrollSoftProfilesBox\"><i class=\"fa fa-chevron-left previousGridColumns\"></i><i class=\"fa fa-chevron-right nextGridColumns\"></i></div>").insertBefore("#" + DreamsId + " .movie-grid-header");
}
public setImageType(model, values): any {
let docImageSoftProfile = "stickySoftProfileDiplay";
let extensionType = {
".pdf": "pdfSoftProfile",
".ppt": "pptSoftProfile",
".xls": "xlsSoftProfile",
".xlsx": "xlsSoftProfile",
".doc": "stickySoftProfile",
".docx": "stickySoftProfile",
"newDocSoftProfile": "doc",
".msg": "mailSoftProfile"
};
let lastIndex = model.stickyName.lastIndexOf(".");
docImageSoftProfile = extensionType[model.stickyName.slice(lastIndex).toLowerCase()];
if (typeof model.stickySoftProfile !== "undefined" && model.stickySoftProfile !== "") {
docImageSoftProfile = model.stickySoftProfile;
}
if (typeof docImageSoftProfile === "undefined") {
docImageSoftProfile = "newDocSoftProfile";
}
let kendotxtMenu = "";
if (model.isParrotDoc === true) // isParrotDocUploaded
{
kendotxtMenu = "stickySoftProfileDiplay";
}
if (model.isParrotDoc === true && model.ParrotDocID <= 0) // isParrotDocUploaded
{
}
return "<span onclick=\"window.open('" + model.stickyName + "', 'bottle', 'width=800,height=600,scrollbars=yes,resizable=no')\" class='" + docImageSoftProfile + " displayInlineBlock " + kendotxtMenu + "'></span> <ul class='fileTypeHolder' id='fileTypeSoftProfiles' style='display: none;'><li class='fileTypeHolderTongue'>Parrot sticky Type</li><li><span class='stickySoftProfile displayInlineBlock' (click)='browseFileType(doc)'></span></li> <li><span class='xlsSoftProfile displayInlineBlock' (click)='browseFileType('xls')'></span></li> <li><span class='pptSoftProfile displayInlineBlock'(click)='browseFileType('ppt')'></span></li> <li><span class='pdfSoftProfile displayInlineBlock' (click)='browseFileType('pdf')'></span></li><li><span class='newDocSoftProfile displayInlineBlock' (click)='browseFileType('newdoc')'></span></li><li><span class='mailSoftProfile displayInlineBlock' (click)='browseFileType('mail')'></span></li><li class='fileTypeHolderCloseStars'> <button id='CloseStars' class='commonStars'>Close</button></ul>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment