843 lines
44 KiB
JavaScript
843 lines
44 KiB
JavaScript
/**
|
|
* Created by npatil2.
|
|
*/
|
|
describe('service: assetConsoleModel', function () {
|
|
var $httpBackend, $rootScope, scope, response;
|
|
|
|
beforeEach(module('myitsmApp'));
|
|
beforeEach(inject(function ($rootScope, $injector, consoleService, configurationModel, metadataModel, userModel, $q, $filter, categoriesService, personModel, localStorageService) {
|
|
scope = $rootScope.$new();
|
|
this.consoleService = consoleService;
|
|
this.configurationModel = configurationModel;
|
|
this.metadataModel = metadataModel;
|
|
this.userModel = userModel;
|
|
this.$q = $q;
|
|
this.$filter = $filter;
|
|
this.categoriesService = categoriesService;
|
|
this.personModel = personModel;
|
|
this.localStorageService = localStorageService;
|
|
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
|
|
var getLocale = function () {
|
|
return readJSON('scripts/app/i18n/resources-locale_en.json');
|
|
};
|
|
|
|
$httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale());
|
|
$httpBackend.whenGET('/smartit/rest/serverstates').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200);
|
|
$httpBackend.whenGET('views/dashboard/index.html').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/category/query/asset/product?criteria=%7B%22company%22:%22test+company%22%7D&searchText=test+search').respond(200);
|
|
|
|
$rootScope = $injector.get('$rootScope');
|
|
this.assetConsoleModel = $injector.get('assetConsoleModel');
|
|
}));
|
|
beforeEach(inject(function ($q) {
|
|
var deferred = $q.defer(), data = [
|
|
{
|
|
accessRestrictions: [
|
|
{
|
|
name: 'Calbro Services'
|
|
}
|
|
],
|
|
available: 'OFFLINE',
|
|
availableForAssignment: true,
|
|
cell: '1 212',
|
|
company: {
|
|
name: 'Calbro Services',
|
|
site: {
|
|
name: 'Headquarters, Building 1.31'
|
|
}
|
|
},
|
|
department: 'Customer Service',
|
|
displayId: 'PPL000000000013',
|
|
email: 'A.Allbrook@calbroservices.com',
|
|
enabled: true,
|
|
firstName: 'Allen',
|
|
following: false,
|
|
fullName: 'Allen Allbrook',
|
|
id: 'Allen',
|
|
instanceId: 'AG00123F73CF5ERkUTSQmjgZAAgaQA',
|
|
isSupportStaff: true,
|
|
jobTitle: 'Supervisor',
|
|
lastName: 'Allbrook',
|
|
loginId: 'Allen',
|
|
modifiedDate: 1510216316000,
|
|
openTickets: 191,
|
|
organization: 'Information Technology',
|
|
personId: '',
|
|
thumbnail: '',
|
|
thumbnailMime: '',
|
|
entityLink: '#/person/Allen'
|
|
}
|
|
];
|
|
|
|
spyOn(this.userModel, 'getFullCurrentUserData').and.callFake(function () {
|
|
deferred.resolve(data);
|
|
return deferred.promise;
|
|
});
|
|
}));
|
|
beforeEach(inject(function ($q) {
|
|
var deferred = $q.defer(), data = [{
|
|
impacts: [
|
|
{
|
|
index: 1000,
|
|
name: '1-Extensive/Widespread',
|
|
label: '1-Extensive/Widespread'
|
|
}
|
|
],
|
|
metadatatype: 'asset',
|
|
statuses: [
|
|
{
|
|
isValidForCreate: true,
|
|
index: 0,
|
|
name: 'Ordered',
|
|
label: 'Ordered'
|
|
}
|
|
],
|
|
assetTypes: [
|
|
{
|
|
subType: [
|
|
{
|
|
putIntoInventory: true,
|
|
index: 0,
|
|
name: 'BMC_COMPUTERSYSTEM',
|
|
label: 'Computer System'
|
|
}
|
|
]
|
|
}
|
|
],
|
|
virtualSystemType: [
|
|
{
|
|
index: 0,
|
|
name: 'Other',
|
|
label: 'Other'
|
|
}
|
|
]
|
|
}];
|
|
|
|
spyOn(this.metadataModel, 'getMetadataByType').and.callFake(function () {
|
|
deferred.resolve(data);
|
|
return deferred.promise;
|
|
});
|
|
}));
|
|
beforeEach(inject(function ($q) {
|
|
var deferred = $q.defer(), data = [
|
|
{
|
|
"firstName": "Allen",
|
|
"lastName": "Allbrook",
|
|
"fullName": "Allen Allbrook",
|
|
"department": "Customer Service",
|
|
"email": "A.Allbrook@calbroservices.com",
|
|
"company": {
|
|
"name": "Calbro Services",
|
|
"site": {
|
|
"name": "Headquarters, Building 1.31",
|
|
"address": {
|
|
"street": "1114 Eighth Avenue, 31st Floor.",
|
|
"city": "New York",
|
|
"state": "New York",
|
|
"country": "United States",
|
|
"zip": "10036",
|
|
"address": "1114 Eighth Avenue, 31st Floor.\r\nNew York, New York 10036\r\nUnited States"
|
|
},
|
|
"region": "Americas",
|
|
"siteGroup": "United States",
|
|
"siteId": "STE_SOLN0002846"
|
|
}
|
|
},
|
|
"phone": "1 212 555-5454 (11)",
|
|
"site": {
|
|
"name": "Headquarters, Building 1.31",
|
|
"address": {
|
|
"street": "1114 Eighth Avenue, 31st Floor.",
|
|
"city": "New York",
|
|
"state": "New York",
|
|
"country": "United States",
|
|
"zip": "10036",
|
|
"address": "1114 Eighth Avenue, 31st Floor.\r\nNew York, New York 10036\r\nUnited States"
|
|
},
|
|
"region": "Americas",
|
|
"siteGroup": "United States",
|
|
"siteId": "STE_SOLN0002846"
|
|
},
|
|
"organization": "Information Technology",
|
|
"loginId": "Allen",
|
|
"available": "OFFLINE",
|
|
"jid": "allen_000000000000001",
|
|
"cell": "1 212",
|
|
"fax": "1 212",
|
|
"jobTitle": "Supervisor",
|
|
"customFields": {},
|
|
"following": false,
|
|
"type": "person",
|
|
"isVIP": false,
|
|
"isSupportStaff": true,
|
|
"enabled": true,
|
|
"introduction": "",
|
|
"linkedIn": "",
|
|
"twitter": "",
|
|
"availableForAssignment": true,
|
|
"deskLocation": "",
|
|
"manager": {
|
|
"customFields": {}
|
|
},
|
|
"costCenter": "225276-A",
|
|
"openTickets": 191,
|
|
"accessMappings": {
|
|
"detailsEditAllowed": true,
|
|
"timelineEditAllowed": true,
|
|
"relationsEditAllowed": false
|
|
},
|
|
"supportGroups": [
|
|
{
|
|
"name": "New Group of work",
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"organization": "IT Support",
|
|
"isDefault": false,
|
|
"id": "SGP000000000110"
|
|
},
|
|
{
|
|
"name": "Service Desk",
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"organization": "IT Support",
|
|
"isDefault": true,
|
|
"id": "SGP000000000011"
|
|
},
|
|
{
|
|
"name": "Frontoffice Support",
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"organization": "IT Support",
|
|
"isDefault": false,
|
|
"id": "SGP000000000010"
|
|
},
|
|
{
|
|
"name": "Backoffice Support",
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"organization": "IT Support",
|
|
"isDefault": false,
|
|
"id": "SGP000000000009"
|
|
}
|
|
],
|
|
"personId": "PPL000000000013",
|
|
"id": "Allen",
|
|
"createDate": 1226003984000
|
|
}];
|
|
|
|
spyOn(this.personModel, 'getPersonDetailsByID').and.callFake(function () {
|
|
deferred.resolve(data);
|
|
return deferred.promise;
|
|
});
|
|
}));
|
|
|
|
beforeEach(inject(function ($q) {
|
|
var deferred = $q.defer(), config = [
|
|
[
|
|
{
|
|
id: 'fa477f82-f3a2-491e-b0ee-5328df06bac8',
|
|
tenantId: '000000000000001',
|
|
name: '',
|
|
value: '',
|
|
defaultpreset: false,
|
|
systemgenerated: false
|
|
}
|
|
],
|
|
[
|
|
{
|
|
id: '9fd1591c-2dd0-404d-a99e-93e44789ef80',
|
|
tenantId: '000000000000001',
|
|
name: 'ritika',
|
|
"value": [
|
|
{
|
|
filter: 'keywords',
|
|
option: '%%%',
|
|
type: 'dynamic',
|
|
realOption: {
|
|
name: '%%%',
|
|
type: 'dynamic',
|
|
criteria: {
|
|
name: 'keywords',
|
|
value: [
|
|
'%%%'
|
|
]
|
|
}
|
|
}
|
|
}
|
|
],
|
|
defaultpreset: false,
|
|
systemgenerated: false
|
|
}
|
|
],
|
|
{
|
|
impacts: [
|
|
{
|
|
index: 1000,
|
|
name: '1-Extensive/Widespread',
|
|
label: '1-Extensive/Widespread'
|
|
}
|
|
]
|
|
}
|
|
], itemList = {
|
|
itemList: ['test', 'test1', 'test2', 'test3']
|
|
};
|
|
|
|
spyOn(this.userModel, 'getUserPreferences').and.callFake(function () {
|
|
deferred.resolve(config);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.consoleService, 'getAssetList').and.callFake(function () {
|
|
deferred.resolve(itemList);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.categoriesService, 'searchCategories').and.callFake(function () {
|
|
deferred.resolve(itemList);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.userModel, 'updateUserPreferences').and.callFake(function () {
|
|
deferred.resolve(itemList);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.consoleService, 'getRelatives').and.callFake(function () {
|
|
deferred.resolve(itemList);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.consoleService, 'getRelationshipTypes').and.callFake(function () {
|
|
deferred.resolve(itemList);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.userModel, 'removeUserPreferences').and.callFake(function () {
|
|
deferred.resolve(itemList);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.consoleService, 'removeFilterConfiguration').and.callFake(function () {
|
|
deferred.resolve(itemList);
|
|
return deferred.promise;
|
|
});
|
|
}));
|
|
|
|
it('should be defined', function () {
|
|
expect(this.assetConsoleModel).toBeDefined();
|
|
});
|
|
|
|
|
|
|
|
it('should populate Filters', function () {
|
|
this.assetConsoleModel.populateConfiguration();
|
|
scope.$apply();
|
|
});
|
|
|
|
it('should save Filter Preset', function () {
|
|
this.assetConsoleModel.selectedFilters = [
|
|
{
|
|
filter: 'managedBy',
|
|
type: 'dynamic',
|
|
option: 'me',
|
|
name: 'test',
|
|
criteria: {
|
|
name: 'test1'
|
|
}
|
|
}
|
|
];
|
|
this.assetConsoleModel.saveFilterPreset().then(function (data) {
|
|
response = data
|
|
});
|
|
scope.$apply();
|
|
expect(response[0].itemList[0]).toEqual('test');
|
|
});
|
|
|
|
it('should drop Criteria Start Index', function () {
|
|
this.assetConsoleModel.dropCriteriaStartIndex();
|
|
expect(this.assetConsoleModel.criteria.chunkInfo.startIndex).toEqual(0);
|
|
});
|
|
|
|
it('should apply ColumnSet', function () {
|
|
this.assetConsoleModel.columnsConfig = {
|
|
id: {
|
|
displayName: 'ciId',
|
|
visible: true,
|
|
name: 'id',
|
|
headerCellTemplate: "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>"
|
|
},
|
|
name: {
|
|
displayName: 'name',
|
|
visible: true,
|
|
name: 'name',
|
|
headerCellTemplate: "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
}
|
|
};
|
|
this.assetConsoleModel.applyColumnSet('test');
|
|
expect(this.assetConsoleModel.presetColumns).toBeTruthy();
|
|
expect(this.assetConsoleModel.criteria.attributeNames).toBeTruthy();
|
|
});
|
|
|
|
it('should return Relationship Types', function () {
|
|
this.assetConsoleModel.getRelationshipTypes().then(function (data) {
|
|
response = data
|
|
});
|
|
|
|
scope.$apply();
|
|
expect(response.itemList[0]).toEqual('test');
|
|
});
|
|
|
|
it('should remove User Filter Preset', function () {
|
|
this.userFilterPreset = {
|
|
id: 'AS123',
|
|
columnId: '123SDDF'
|
|
};
|
|
|
|
this.assetConsoleModel.removeUserFilterPreset(this.userFilterPreset);
|
|
scope.$apply();
|
|
});
|
|
|
|
it('should return Relatives', function () {
|
|
this.assetConsoleModel.getRelatives().then(function (data) {
|
|
response = data
|
|
});
|
|
|
|
scope.$apply();
|
|
console.log("this", response);
|
|
expect(response.itemList[0]).toEqual('test');
|
|
});
|
|
|
|
it('should Search Enabled', function () {
|
|
response = this.assetConsoleModel.isSearchEnabled();
|
|
expect(response).toBe(false);
|
|
});
|
|
|
|
it('should Search Enabled', function () {
|
|
response = this.assetConsoleModel.isSearchEnabled();
|
|
expect(response).toBe(false);
|
|
});
|
|
it('should update Column Config', function () {
|
|
this.columnsConfig = {
|
|
"id": {
|
|
"displayName": "ciId",
|
|
"attributeName": "CIid",
|
|
"field": "assetId",
|
|
"visible": true,
|
|
"order": 1,
|
|
"pinned": true,
|
|
"name": "id",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"name": {
|
|
"displayName": "name",
|
|
"attributeName": "name",
|
|
"field": "name",
|
|
"visible": true,
|
|
"order": 2,
|
|
"pinned": true,
|
|
"name": "name",
|
|
"width": 200,
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140
|
|
},
|
|
"assetType": {
|
|
"displayName": "assetType",
|
|
"attributeName": "type",
|
|
"field": "type",
|
|
"visible": true,
|
|
"order": 3,
|
|
"name": "assetType",
|
|
"sortable": false,
|
|
"cellFilter": "localizeLabel: \"assetType\":row.entity.ticketType",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"productName": {
|
|
"displayName": "productName",
|
|
"attributeName": "productName",
|
|
"field": "product.name",
|
|
"visible": true,
|
|
"order": 4,
|
|
"name": "productName",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"status": {
|
|
"displayName": "status",
|
|
"attributeName": "status",
|
|
"field": "status.value",
|
|
"visible": true,
|
|
"order": 5,
|
|
"name": "status",
|
|
"cellFilter": "localizeLabel: \"status\":row.entity.ticketType",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"serialNumber": {
|
|
"displayName": "serialNumber",
|
|
"attributeName": "serialNumber",
|
|
"field": "serialNumber",
|
|
"visible": true,
|
|
"order": 6,
|
|
"name": "serialNumber",
|
|
"width": 250,
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140
|
|
},
|
|
"floor": {
|
|
"displayName": "floor",
|
|
"attributeName": "floor",
|
|
"field": "floor",
|
|
"visible": false,
|
|
"name": "floor",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"manufacturer": {
|
|
"displayName": "manufacturer",
|
|
"attributeName": "manufacturer",
|
|
"field": "manufacturer",
|
|
"visible": false,
|
|
"name": "manufacturer",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"room": {
|
|
"displayName": "room",
|
|
"attributeName": "room",
|
|
"field": "room",
|
|
"visible": false,
|
|
"name": "room",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"region": {
|
|
"displayName": "region",
|
|
"attributeName": "siteRegion",
|
|
"field": "site.region",
|
|
"visible": false,
|
|
"name": "region",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"modelVersion": {
|
|
"displayName": "modelVersion",
|
|
"attributeName": "modelVersion",
|
|
"field": "product.model",
|
|
"visible": false,
|
|
"name": "modelVersion",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"systemRole": {
|
|
"displayName": "systemRole",
|
|
"attributeName": "systemRole",
|
|
"field": "systemRole",
|
|
"visible": false,
|
|
"name": "systemRole",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"site": {
|
|
"displayName": "site",
|
|
"attributeName": "siteName",
|
|
"field": "site.name",
|
|
"visible": true,
|
|
"order": 7,
|
|
"name": "site",
|
|
"width": 200,
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140
|
|
}
|
|
};
|
|
this.assetConsoleModel.updateColumnConfig(this.columnsConfig, 'test', 'ASEF234').then(function (data) {
|
|
response = data
|
|
});
|
|
scope.$apply();
|
|
});
|
|
it('should add User Saved Presets', function () {
|
|
this.assetConsoleModel.userSavedFilterPresets = [
|
|
{
|
|
id: 'allAssets',
|
|
fixed: true,
|
|
name: 'Hardware Managed by Me',
|
|
label: 'Hardware Managed by Me',
|
|
systemgenerated: true,
|
|
defaultpreset: true,
|
|
value: [
|
|
{
|
|
filter: 'managedBy',
|
|
option: 'me'
|
|
}
|
|
]
|
|
}
|
|
];
|
|
this.assetConsoleModel.userSavedColumnPresets = [
|
|
{
|
|
tenantId: "000000000000001",
|
|
name: "",
|
|
defaultpreset: false,
|
|
systemgenerated: false,
|
|
columnId: 'f3b32c08-e135-4a1b-8615-5a72ce603a1c',
|
|
columnValue: ''
|
|
}
|
|
];
|
|
this.name = 'Allen';
|
|
this.assetConsoleModel.userSavedPresets = [
|
|
{
|
|
id: 'allAssets',
|
|
fixed: true,
|
|
name: 'Hardware Managed by Me',
|
|
label: 'Hardware Managed by Me',
|
|
systemgenerated: true,
|
|
defaultpreset: true,
|
|
value: [
|
|
{
|
|
filter: 'managedBy',
|
|
option: 'me'
|
|
}
|
|
]
|
|
}
|
|
];
|
|
this.assetConsoleModel.addUserSavedPresets(this.name);
|
|
});
|
|
|
|
it('should return ItemList ', function () {
|
|
this.assetConsoleModel.criteria.attributeNames = [];
|
|
this.assetConsoleModel.columnsConfig = {
|
|
"id": {
|
|
"displayName": "ciId",
|
|
"attributeName": "CIid",
|
|
"field": "assetId",
|
|
"visible": true,
|
|
"order": 1,
|
|
"pinned": true,
|
|
"name": "id",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"name": {
|
|
"displayName": "name",
|
|
"attributeName": "name",
|
|
"field": "name",
|
|
"visible": true,
|
|
"order": 2,
|
|
"pinned": true,
|
|
"name": "name",
|
|
"width": 200,
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140
|
|
},
|
|
"assetType": {
|
|
"displayName": "assetType",
|
|
"attributeName": "type",
|
|
"field": "type",
|
|
"visible": true,
|
|
"order": 3,
|
|
"name": "assetType",
|
|
"sortable": false,
|
|
"cellFilter": "localizeLabel: \"assetType\":row.entity.ticketType",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"productName": {
|
|
"displayName": "productName",
|
|
"attributeName": "productName",
|
|
"field": "product.name",
|
|
"visible": true,
|
|
"order": 4,
|
|
"name": "productName",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
}
|
|
};
|
|
this.assetConsoleModel.getItemList().then(function (data) {
|
|
response = data
|
|
});
|
|
scope.$apply();
|
|
expect(response).toEqual(4);
|
|
expect(this.assetConsoleModel.itemList).toBeTruthy();
|
|
});
|
|
|
|
it('should apply Filter Set', function () {
|
|
this.filterSet = [
|
|
{
|
|
"filter": "managedBy",
|
|
"type": "date",
|
|
"option": "me"
|
|
},
|
|
{
|
|
"filter": "ticketSpecificStatuses",
|
|
"option": "Deployed",
|
|
"type": "dynamic",
|
|
"realOption": {
|
|
"name": "Deployed",
|
|
"criteria": {
|
|
"name": "ticketSpecificStatuses",
|
|
"value": [
|
|
"Deployed"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"filter": "assetTypes",
|
|
"option": "Computer System",
|
|
"type": "dynamic",
|
|
"realOption": {
|
|
"name": "Computer System",
|
|
"criteria": {
|
|
"name": "assetTypes",
|
|
"value": [
|
|
"Computer System"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"filter": "assetTypes",
|
|
"option": "Hardware",
|
|
"type": "dynamic",
|
|
"realOption": {
|
|
"name": "Hardware",
|
|
"criteria": {
|
|
"name": "assetTypes",
|
|
"value": [
|
|
"Hardware"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
];
|
|
this.assetConsoleModel.filterDict = {
|
|
assetTypes: {
|
|
name: "assetTypes",
|
|
label: "assetType",
|
|
expanded: true,
|
|
options: [
|
|
{
|
|
name: "Computer System",
|
|
type: "dynamic",
|
|
filterName: "assetTypes",
|
|
criteria: {
|
|
name: "assetTypes",
|
|
value: [
|
|
'Computer System'
|
|
]
|
|
},
|
|
criteriaValue: 'Computer System',
|
|
active: false
|
|
}
|
|
],
|
|
onDisplay: true
|
|
},
|
|
managedBy: {
|
|
name: "managedBy",
|
|
label: "managedBy",
|
|
showLabelInPill: true,
|
|
selectedSearchMode: {
|
|
id: 0,
|
|
method: 'personModel.getListOfPersonsByText',
|
|
name: 'common.labels.people',
|
|
fields: {
|
|
"key": "fullName",
|
|
"value": "personId"
|
|
}
|
|
},
|
|
"options": [
|
|
{
|
|
"name": "me",
|
|
"label": "me",
|
|
"type": "constant",
|
|
"criteria": {
|
|
"name": "managedBy",
|
|
"value": [
|
|
{
|
|
"id": "PPL000000000013"
|
|
}
|
|
]
|
|
},
|
|
"subLabel": "Allen Allbrook",
|
|
"active": false,
|
|
"filterName": "managedBy",
|
|
"filterLabel": "managedBy",
|
|
"$$hashKey": "object:1061"
|
|
}
|
|
],
|
|
"onDisplay": true
|
|
}
|
|
};
|
|
this.assetConsoleModel.criteria.filterCriteria = {
|
|
"managedBy": [],
|
|
"ticketSpecificStatuses": [],
|
|
"assetTypes": []
|
|
};
|
|
|
|
this.assetConsoleModel.criteria.filterCriteria = {
|
|
assetTypes: 'test',
|
|
assetSubTypes: 'test1'
|
|
|
|
};
|
|
this.assetConsoleModel.applyFilterSet(this.filterSet)
|
|
});
|
|
|
|
it('should save Column Preset ', function () {
|
|
this.assetConsoleModel.criteria.attributeNames = [];
|
|
this.columnsConfig = {
|
|
"id": {
|
|
"displayName": "ciId",
|
|
"attributeName": "CIid",
|
|
"field": "assetId",
|
|
"visible": true,
|
|
"order": 1,
|
|
"pinned": true,
|
|
"name": "id",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
},
|
|
"assetType": {
|
|
"displayName": "assetType",
|
|
"attributeName": "type",
|
|
"field": "type",
|
|
"visible": true,
|
|
"order": 3,
|
|
"name": "assetType",
|
|
"sortable": false,
|
|
"cellFilter": "localizeLabel: \"assetType\":row.entity.ticketType",
|
|
"headerCellTemplate": "<div class=\"ngHeaderSortColumn {{col.headerClass}}\" ng-style=\"{'cursor': col.cursor}\" ng-class=\"{ 'ngSorted': !noSortVisible }\"><div ng-click=\"col.sort($event)\" ng-class=\"'colt' + col.index\" class=\"ngHeaderText\">{{'console.column.' + col.displayName | i18n}}</div>\t<div class=\"ngSortButtonUp\" ng-show=\"col.showSortButtonDown()\"></div>\t<div class=\"ngSortButtonDown\" ng-show=\"col.showSortButtonUp()\"></div>\t<div class=\"ngSortPriority\">{{col.sortPriority}}</div>\t<div ng-class=\"{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }\" ng-click=\"togglePin(col)\" ng-show=\"col.pinnable\"></div></div><div ng-show=\"col.resizable\" class=\"ngHeaderGrip\" ng-click=\"col.gripClick($event)\" ng-mousedown=\"col.gripOnMouseDown($event)\"></div>",
|
|
"minWidth": 140,
|
|
"width": 140
|
|
}
|
|
|
|
};
|
|
this.assetConsoleModel.saveColumnPreset('test', this.columnsConfig).then(function (data) {
|
|
response = data
|
|
});
|
|
scope.$apply();
|
|
expect(response.itemList[0]).toEqual('test');
|
|
|
|
});
|
|
|
|
}); |