Skip to content

Commit

Permalink
Added a angular service
Browse files Browse the repository at this point in the history
Major changes to the the way data is being fetched from the Qlik Engine. Using a angular service (which are singuar) rather than doing this in controler.
  • Loading branch information
kabir-rab committed Feb 29, 2020
1 parent ea22591 commit d242f85
Show file tree
Hide file tree
Showing 6 changed files with 332 additions and 166 deletions.
68 changes: 58 additions & 10 deletions lib/css/master-items-viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
-khtml-user-select: text !important;
-webkit-user-select: text !important;
-ms-user-select: text !important;
user-select: text !important;
user-select: text !important;
}

.qv-extension-mov-stat-td {
Expand All @@ -76,7 +76,7 @@
-khtml-user-select: text !important;
-webkit-user-select: text !important;
-ms-user-select: text !important;
user-select: text !important;
user-select: text !important;
}

.qv-extension-mov-master-table td, .qv-extension-mov-master-table th {
Expand Down Expand Up @@ -131,9 +131,9 @@ content: '\25bc';
display: inline-block;
box-sizing: border-box;
height: 24px;
min-width: 40px;
min-width: 40px;
font-size: 13px;
border-radius: 12px;
border-radius: 12px;
padding: 3px 10px;
margin: 1px;
list-style: none;
Expand All @@ -156,16 +156,16 @@ content: '\25bc';
list-style: none;
white-space: nowrap;
}
.qv-extension-mov-lui-tag:hover {
.qv-extension-mov-lui-tag:hover {
color: #fff;
background-color: #0089fa;
border: 1px solid #0089fac7;
border: 1px solid #0089fac7;
}

.qv-extension-mov-lui-tag-search {
.qv-extension-mov-lui-tag-search {
color: #fff;
background-color: #009845;
border: 1px solid #0aaf54;
border: 1px solid #0aaf54;
}

.qv-extension-mov-lui-tag-group {
Expand All @@ -175,5 +175,53 @@ content: '\25bc';
justify-content: center;
padding: 0.5em 0 0.5em 0;
margin: 1em;
text-align: center;
}
text-align: center;
}

/* list styling */
.qv-extension-mov-list-inline {
list-style: none;
padding: 0;
}

.qv-extension-mov-list-inline > li {
display: inline-flex;
border-bottom: 1px dotted black;
}

.qv-extension-mov-list-bull > li:not(:last-child)::after {
content: "•";
}

.qv-extension-mov-list-pipe > li:not(:last-child)::after {
content: "|";
margin: 0 .25em;
}

.qv-extension-mov-tooltip {
position: relative;
}

.qv-extension-mov-tooltip .qv-extension-mov-tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1200;
bottom: 100%;
left: 50%;
margin-left: -60px;

/* Fade in tooltip - takes 1 second to go from 0% to 100% opac: */
opacity: 0;
transition: opacity 1s;
}

.qv-extension-mov-tooltip:hover .qv-extension-mov-tooltiptext {
visibility: visible;
opacity: 1;
}
207 changes: 207 additions & 0 deletions lib/js/masterItemService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
define([
"jquery",
"qlik",
"qvangular"
],
function ( jQuery, qlik, qvangular ) {
'use strict';

qvangular
.service('masterItemService', class MasterItemService {
constructor(){

};
getData(){
var deferred = $.Deferred();
var app = qlik.currApp(this),
dimensionList,
measureList,
objectDestroyId=[],
masterItemsList=[],
destroyObject = function(objectId){
var deferred = $.Deferred(),
destroyedConfirmation=[];
$.each(objectId, function(kye, id){
app.destroySessionObject(id)
.then(function(a){
destroyedConfirmation.push({id:id,message:a});
});
});
if(destroyedConfirmation.length == objectId.length){
deferred.resolve(destroyedConfirmation);
}
return deferred;
},
// settings up the createGenericObject call for the qMeasureListDef
measureCall = {
qInfo: {
qId:"measureObjectExt",
qType: "MeasureListExt"
},
qMeasureListDef: {
qType: "measure",
qData: {
title: "/qMetaDef/title",
tags: "/qMetaDef/tags",
expression: "/qMeasure/qDef",
description: "/qMetaDef/description"
}
}
},
// settings up the createGenericObject call for the qDimensionListDef
dimensionCall = {
qInfo: {
qId:"DimensionObjectExt",
qType: "DimensionListExt"
},
qDimensionListDef: {
qType: "dimension",
qData: {
grouping: "/qDim/qGrouping",
info: "/qDimInfos",
title: "/qMetaDef/title",
tags: "/qMetaDef/tags",
expression: "/qDim",
description: "/qMetaDef/description"
}
}
},
// qDimensionListDef
generateDimensionList = app.createGenericObject(
dimensionCall, function(reply) {
objectDestroyId.push(reply.qInfo.qId);
dimensionList = reply.qDimensionList.qItems;
}),
// qMeasureListDef
generateMeasureList = app.createGenericObject(
measureCall, function(reply) {
objectDestroyId.push(reply.qInfo.qId);
measureList = reply.qMeasureList.qItems;
}),
// get only the master objects that are being used in dashboard
getMasterObjects = function(id) {
var deferred = $.Deferred();
app.getObject(id).then(function(model) {
deferred.resolve(model);
});
return deferred;
},
// get list of all sheets
generateSheetList = function(){
var deferred = $.Deferred(),
sheetObjectList = [];
app.getList( "Sheet", function(sheets){
sheetObjectList = sheets.qAppObjectList.qItems;
})
.then(function(sheets){
app.destroySessionObject(sheets.id)
.then(function(a){
deferred.resolve(sheetObjectList);
});
});
return deferred;
},
allProperty = function(sheets){
var deferred = $.Deferred(),
fullPropertyTree=[],
allObjectProperty=[],
sheetsCount = sheets.length;
$.each(sheets, function(key, sheet) {
generateFullPropertyTree(sheet.qInfo.qId)
.then(function(objectProperty){
fullPropertyTree.push(objectProperty);
if(fullPropertyTree.length == sheetsCount){
$.each(fullPropertyTree, function(key, singleProperty){
$.each(singleProperty, function(key, qObject){
if(qObject.qProperty.qExtendsId){
masterItemsList.push(qObject.qProperty.qInfo.qId);
}
else{
allObjectProperty.push(JSON.stringify(qObject));
};
});
});
fullPropertyTree=[];
$.each(masterItemsList, function(key, itemId){
getMasterObjects(itemId).done(function (masterObject){
allObjectProperty.push(JSON.stringify(masterObject.pureLayout));
fullPropertyTree.push(1);
}).done(function(){
if(fullPropertyTree.length == masterItemsList.length){
fullPropertyTree=[];
deferred.resolve(allObjectProperty);
}
});
});
};
});
});
return deferred;
}

var generateFullPropertyTree = function(sheetId){
var deferred = $.Deferred(),
sheetFullPropertyTree = [];
app.getFullPropertyTree(sheetId)
.then(function(model){
var sheetTitle = model.properties.qMetaDef.title;
model.propertyTree.qChildren.forEach(function(p){p.qSheetTitle = sheetTitle;});
sheetFullPropertyTree = model.propertyTree.qChildren;
deferred.resolve(sheetFullPropertyTree);
});
return deferred;
};

generateSheetList().done(function(sheets){
allProperty(sheets).done(function(objectProperty){
$.each(dimensionList, function(key, dimension){
var holdingObject = [];
$.each(objectProperty, function(key, value) {
if(value.indexOf('"qId":"') != -1){
var idStartPosition = value.indexOf('"qId":"')+7;
var idFinishPosition = value.indexOf('",', idStartPosition);
var holdingObjectId = value.substring(idStartPosition, idFinishPosition);
}
if(value.indexOf('"qSheetTitle":"') != -1){
var idStartPosition = value.indexOf('"qSheetTitle":"')+15;
var idFinishPosition = value.indexOf('"', idStartPosition);
var holdingSheetTitle = value.substring(idStartPosition, idFinishPosition);
}
if(value.indexOf('"'+dimension.qInfo.qId+'"') > -1){
if(holdingObject.filter(function(qObjectId){ return qObjectId.objectId === holdingObjectId }).length < 1){
holdingObject.push({objectId:holdingObjectId, sheetTitle:holdingSheetTitle});
}
}
});
dimension.qInfo.inObject = holdingObject;
});
$.each(measureList, function(key, measure){
var holdingObject = [];
$.each(objectProperty, function(key, value) {
if(value.indexOf('"qId":"') != -1){
var idStartPosition = value.indexOf('"qId":"')+7;
var idFinishPosition = value.indexOf('",', idStartPosition);
var holdingObjectId = value.substring(idStartPosition, idFinishPosition);
}
if(value.indexOf('"qSheetTitle":"') != -1){
var idStartPosition = value.indexOf('"qSheetTitle":"')+15;
var idFinishPosition = value.indexOf('"', idStartPosition);
var holdingSheetTitle = value.substring(idStartPosition, idFinishPosition);
}
if(value.indexOf(''+measure.qInfo.qId+'') > -1){
if(holdingObject.filter(function(qObjectId){ return qObjectId.objectId === holdingObjectId }).length < 1){
holdingObject.push({objectId:holdingObjectId, sheetTitle:holdingSheetTitle});
}
}
});
measure.qInfo.inObject = holdingObject;
});
var qMasterMeasures = {dimensions:dimensionList,measures:measureList};
var destroy = destroyObject(objectDestroyId);
deferred.resolve(qMasterMeasures);
});
});
return deferred;
};
});
});
9 changes: 8 additions & 1 deletion lib/js/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function (qlik) {
},
columnId = {
ref: "props.showId",
label: "Show Id",
label: "Show List Number",
type: "boolean",
defaultValue: true
},
Expand All @@ -20,6 +20,12 @@ function (qlik) {
type: "boolean",
defaultValue: true
},
columnObjectId = {
ref: "props.showObjectId",
label: "Show Id",
type: "boolean",
defaultValue: true
},
columnDescription = {
ref: "props.showDesc",
label: "Show Description",
Expand Down Expand Up @@ -80,6 +86,7 @@ function (qlik) {
items: {
columnId: columnId,
columnName: columnName,
columnObjectId: columnObjectId,
columnDescription: columnDescription,
columnExpression: columnExpression,
columnStats: columnStats,
Expand Down
Loading

0 comments on commit d242f85

Please sign in to comment.