-
Notifications
You must be signed in to change notification settings - Fork 5
/
helpdesk-angular.js
141 lines (132 loc) · 3.42 KB
/
helpdesk-angular.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*global require*/
/*
* Bootstrap and angular-based mashup
* @owner Erik Wetterberg (ewg)
*/
/*
* Fill in host and port for Qlik engine
*/
var prefix = window.location.pathname.substr( 0, window.location.pathname.toLowerCase().lastIndexOf( "/extensions" ) + 1 );
var config = {
host: window.location.hostname,
prefix: prefix,
port: window.location.port,
isSecure: window.location.protocol === "https:"
};
require.config( {
baseUrl: (config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port : "" ) + config.prefix + "resources"
} );
require( ["js/qlik"], function ( qlik ) {
//qlik app
var app;
//data for case listing
var data = {
headers: [],
rows: []
};
function getQlikApp () {
//return qlik.openApp( "4bf04442-aa89-43ff-870a-917c86c92990", config )
return qlik.openApp( "Helpdesk Management.qvf", config )
}
//callbacks -- inserted here --
function setCases ( reply, app ) {
data.headers.length = 0;
data.rows.length = 0;
//set headers
reply.qHyperCube.qDimensionInfo.forEach( function ( dim ) {
data.headers.push( dim.qFallbackTitle );
} );
reply.qHyperCube.qMeasureInfo.forEach( function ( mea ) {
data.headers.push( mea.qFallbackTitle );
} );
reply.qHyperCube.qDataPages.forEach( function ( page ) {
page.qMatrix.forEach( function ( row ) {
data.rows.push( row );
} );
} );
}
//
// Defining Module
//
var helpdeskApp = angular.module( "helpdeskApp", ['ngRoute'] );
//
// Defining Routes
//
helpdeskApp.config( function ( $routeProvider ) {
$routeProvider.when( '/cases', {
templateUrl: 'cases.html',
controller: 'CaseCtrl'
} ).
otherwise( {
controller: 'MainCtrl',
templateUrl: './main.html'
} );
} );
//controllers
helpdeskApp.controller( "MainCtrl", ['$scope', function ( $scope ) {
if ( !app ) {
app = getQlikApp();
}
//get objects -- inserted here --
app.getObject( 'QV00', 'CurrentSelections' );
app.getObject( 'QV01', 'hRZaKk' );
app.getObject( 'QV02', 'xfvKMP' );
app.getObject( 'QV03', 'a5e0f12c-38f5-4da9-8f3f-0e4566b28398' );
app.getObject( 'QV04', 'PAppmU' );
}] );
helpdeskApp.controller( "CaseCtrl", ['$scope', function ( $scope ) {
if ( !app ) {
app = getQlikApp();
}
app.createCube( {
"qInitialDataFetch": [
{
"qHeight": 400,
"qWidth": 8
}
],
"qDimensions": [
{
"qDef": {"qFieldDefs": ["CaseNumber"]}
},
{
"qDef": {"qFieldDefs": ["Status"]}
},
{
"qDef": {"qFieldDefs": ["Priority"]}
},
{
"qDef": {"qFieldDefs": ["Case Created Date"]}
},
{
"qDef": {"qFieldDefs": ["Case Closed Date"]}
},
{
"qDef": {"qFieldDefs": ["Case Duration Time"]}
},
{
"qDef": {"qFieldDefs": ["Case Owner"]}
},
{
"qDef": {"qFieldDefs": ["Subject"]}
}
],
"qMeasures": [],
"qSuppressZero": false,
"qSuppressMissing": false,
"qMode": "S"
}, setCases );
//set up scope headers and rows
$scope.headers = data.headers;
$scope.rows = data.rows;
}] );
// bootstrap my angular application, including the "qlik-angular" module
// must be done before the Qlik Sense API is used
// you must also set qva-bootstrap="false" in your html file
angular.bootstrap( document, ["helpdeskApp", "qlik-angular"] );
qlik.setOnError( function ( error ) {
//TODO:bootstrap removes html elements on dismiss..should hide instead
$( "#errmsg" ).html( error.message ).parent().show();
} );
//
} );