Skip to content

Commit

Permalink
Merge pull request #930 from hashmapinc/Tempus-929
Browse files Browse the repository at this point in the history
Tempus-929-Bugbash
  • Loading branch information
shgupta22 committed Dec 13, 2018
2 parents 96af27c + ad37f3f commit e125866
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 300 deletions.
16 changes: 0 additions & 16 deletions ui/src/app/api/asset.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function AssetService($http, $q, customerService, userService) {
deleteAsset: deleteAsset,
assignAssetToCustomer: assignAssetToCustomer,
unassignAssetFromCustomer: unassignAssetFromCustomer,
makeAssetPublic: makeAssetPublic,
getTenantAssets: getTenantAssets,
getCustomerAssets: getCustomerAssets,
findByQuery: findByQuery,
Expand Down Expand Up @@ -140,21 +139,6 @@ function AssetService($http, $q, customerService, userService) {
return deferred.promise;
}

function makeAssetPublic(assetId, ignoreErrors, config) {
var deferred = $q.defer();
var url = '/api/customer/public/asset/' + assetId;
if (!config) {
config = {};
}
config = Object.assign(config, { ignoreErrors: ignoreErrors });
$http.post(url, null, config).then(function success(response) {
deferred.resolve(response.data);
}, function fail() {
deferred.reject();
});
return deferred.promise;
}

function getTenantAssets(pageLink, applyCustomersInfo, config, type) {
var deferred = $q.defer();
var url = '/api/tenant/assets?limit=' + pageLink.limit;
Expand Down
24 changes: 0 additions & 24 deletions ui/src/app/api/dashboard.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ function DashboardService($rootScope, $http, $q, $location, $filter) {
updateDashboardCustomers: updateDashboardCustomers,
addDashboardCustomers: addDashboardCustomers,
removeDashboardCustomers: removeDashboardCustomers,
makeDashboardPublic: makeDashboardPublic,
makeDashboardPrivate: makeDashboardPrivate,
getPublicDashboardLink: getPublicDashboardLink,
getAssetLandingDashboardByDataModelObjId:getAssetLandingDashboardByDataModelObjId
}
Expand Down Expand Up @@ -240,28 +238,6 @@ function DashboardService($rootScope, $http, $q, $location, $filter) {
return deferred.promise;
}

function makeDashboardPublic(dashboardId) {
var deferred = $q.defer();
var url = '/api/customer/public/dashboard/' + dashboardId;
$http.post(url, null).then(function success(response) {
deferred.resolve(prepareDashboard(response.data));
}, function fail() {
deferred.reject();
});
return deferred.promise;
}

function makeDashboardPrivate(dashboardId) {
var deferred = $q.defer();
var url = '/api/customer/public/dashboard/' + dashboardId;
$http.delete(url).then(function success(response) {
deferred.resolve(prepareDashboard(response.data));
}, function fail() {
deferred.reject();
});
return deferred.promise;
}

function getPublicDashboardLink(dashboard) {
var url = $location.protocol() + '://' + $location.host();
var port = $location.port();
Expand Down
12 changes: 0 additions & 12 deletions ui/src/app/api/device.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function DeviceService($http, $q, $window, userService, attributeService, custom
saveDevice: saveDevice,
saveDeviceCredentials: saveDeviceCredentials,
unassignDeviceFromCustomer: unassignDeviceFromCustomer,
makeDevicePublic: makeDevicePublic,
getDeviceAttributes: getDeviceAttributes,
subscribeForDeviceAttributes: subscribeForDeviceAttributes,
unsubscribeForDeviceAttributes: unsubscribeForDeviceAttributes,
Expand Down Expand Up @@ -239,17 +238,6 @@ function DeviceService($http, $q, $window, userService, attributeService, custom
return deferred.promise;
}

function makeDevicePublic(deviceId) {
var deferred = $q.defer();
var url = '/api/customer/public/device/' + deviceId;
$http.post(url, null).then(function success(response) {
deferred.resolve(response.data);
}, function fail() {
deferred.reject();
});
return deferred.promise;
}

function getDeviceAttributes(deviceId, attributeScope, query, successCallback, config) {
return attributeService.getEntityAttributes(types.entityType.device, deviceId, attributeScope, query, successCallback, config);
}
Expand Down
3 changes: 0 additions & 3 deletions ui/src/app/asset/asset-fieldset.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
limitations under the License.
-->
<md-button ng-click="onMakePublic({event: $event})"
ng-show="!isEdit && assetScope === 'tenant' && !isAssignedToCustomer && !isPublic"
class="md-raised md-primary">{{ 'asset.make-public' | translate }}</md-button>
<md-button ng-click="onAssignToCustomer({event: $event})"
ng-show="!isEdit && assetScope === 'tenant' && !isAssignedToCustomer"
class="md-raised md-primary">{{ 'asset.assign-to-customer' | translate }}</md-button>
Expand Down
57 changes: 0 additions & 57 deletions ui/src/app/asset/asset.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export function AssetController($rootScope, userService, assetService, customerS
vm.assetsScope = $state.$current.data.assetsType;

vm.assignToCustomer = assignToCustomer;
vm.makePublic = makePublic;
vm.unassignFromCustomer = unassignFromCustomer;

initController();
Expand Down Expand Up @@ -141,18 +140,6 @@ export function AssetController($rootScope, userService, assetService, customerS
return {"topIndex": vm.topIndex};
};

assetActionsList.push({
onAction: function ($event, item) {
makePublic($event, item);
},
name: function() { return $translate.instant('action.share') },
details: function() { return $translate.instant('asset.make-public') },
icon: "share",
isEnabled: function(asset) {
return asset && (!asset.customerId || asset.customerId.id === types.id.nullUid);
}
});

assetActionsList.push(
{
onAction: function ($event, item) {
Expand Down Expand Up @@ -181,18 +168,6 @@ export function AssetController($rootScope, userService, assetService, customerS
}
);

assetActionsList.push({
onAction: function ($event, item) {
unassignFromCustomer($event, item, true);
},
name: function() { return $translate.instant('action.make-private') },
details: function() { return $translate.instant('asset.make-private') },
icon: "reply",
isEnabled: function(asset) {
return asset && asset.customerId && asset.customerId.id !== types.id.nullUid && asset.assignedCustomer.isPublic;
}
});

assetActionsList.push(
{
onAction: function ($event, item) {
Expand Down Expand Up @@ -255,20 +230,6 @@ export function AssetController($rootScope, userService, assetService, customerS
}
}
);
assetActionsList.push(
{
onAction: function ($event, item) {
unassignFromCustomer($event, item, true);
},
name: function() { return $translate.instant('action.make-private') },
details: function() { return $translate.instant('asset.make-private') },
icon: "reply",
isEnabled: function(asset) {
return asset && asset.assignedCustomer.isPublic;
}
}
);

assetGroupActionsList.push(
{
onAction: function ($event, items) {
Expand Down Expand Up @@ -488,22 +449,4 @@ export function AssetController($rootScope, userService, assetService, customerS
});
});
}

function makePublic($event, asset) {
if ($event) {
$event.stopPropagation();
}
var confirm = $mdDialog.confirm()
.targetEvent($event)
.title($translate.instant('asset.make-public-asset-title', {assetName: asset.name}))
.htmlContent($translate.instant('asset.make-public-asset-text'))
.ariaLabel($translate.instant('asset.make-public'))
.cancel($translate.instant('action.no'))
.ok($translate.instant('action.yes'));
$mdDialog.show(confirm).then(function () {
assetService.makeAssetPublic(asset.id.id).then(function success() {
vm.grid.refreshList();
});
});
}
}
1 change: 0 additions & 1 deletion ui/src/app/asset/asset.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export default function AssetDirective($compile, $templateCache, toast, $transla
assetScope: '=',
theForm: '=',
onAssignToCustomer: '&',
onMakePublic: '&',
onUnassignFromCustomer: '&',
onDeleteAsset: '&'
}
Expand Down
7 changes: 0 additions & 7 deletions ui/src/app/dashboard/dashboard-fieldset.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
<md-button ng-click="onExportDashboard({event: $event})"
ng-show="!isEdit && (dashboardScope === 'tenant' || dashboardScope === 'customer_user')"
class="md-raised md-primary">{{ 'dashboard.export' | translate }}</md-button>
<md-button ng-click="onMakePublic({event: $event})"
ng-show="!isEdit && dashboardScope === 'tenant' && !dashboard.publicCustomerId"
class="md-raised md-primary">{{ 'dashboard.make-public' | translate }}</md-button>
<md-button ng-click="onMakePrivate({event: $event})"
ng-show="!isEdit && ((dashboardScope === 'tenant' && dashboard.publicCustomerId ||
dashboardScope === 'customer' && customerId == dashboard.publicCustomerId))"
class="md-raised md-primary">{{ 'dashboard.make-private' | translate }}</md-button>
<md-button ng-click="onManageAssignedCustomers({event: $event})"
ng-show="!isEdit && dashboardScope === 'tenant'"
class="md-raised md-primary">{{ 'dashboard.manage-assigned-customers' | translate }}</md-button>
Expand Down
13 changes: 7 additions & 6 deletions ui/src/app/dashboard/dashboard.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,19 +397,20 @@ export default function DashboardController(types, utils, dashboardUtils, widget
vm.configurationError = true;
});
}
if(vm.user.authority === 'TENANT_ADMIN') {
vm.displayAddAssetBasedPermission = true;
}else{
getUserPermission();
if(vm.user.authority != 'SYS_ADMIN') {
if(vm.user.authority === 'TENANT_ADMIN') {
vm.displayAddAssetBasedPermission = true;
}else{
getUserPermission();
}
}

}

function getUserPermission(){
userGroupService.getUserPermissions(vm.user.id)
.then(function success(permissions) {
for(var i=0;i<permissions.length;i++){
if(permissions[i].includes(vm.dashboard.assetLandingInfo.dataModelObjectId.id)){
if(permissions[i].includes(vm.dashboard.assetLandingInfo && vm.dashboard.assetLandingInfo.dataModelObjectId.id)){
if(permissions[i].includes('CREATE')) {
vm.displayAddAssetBasedPermission = true
}
Expand Down
1 change: 0 additions & 1 deletion ui/src/app/dashboard/dashboard.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export default function DashboardDirective($compile, $templateCache, $translate,
customerId: '=',
dashboardScope: '=',
theForm: '=',
onMakePublic: '&',
onMakePrivate: '&',
onManageAssignedCustomers: '&',
onUnassignFromCustomer: '&',
Expand Down
101 changes: 0 additions & 101 deletions ui/src/app/dashboard/dashboards.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import addDashboardTemplate from './add-dashboard.tpl.html';
import dashboardCard from './dashboard-card.tpl.html';
import addDashboardsToCustomerTemplate from './add-dashboards-to-customer.tpl.html';
import makeDashboardPublicDialogTemplate from './make-dashboard-public-dialog.tpl.html';
import manageAssignedCustomersTemplate from './manage-assigned-customers.tpl.html';

/* eslint-enable import/no-unresolved, import/default */
Expand Down Expand Up @@ -123,8 +122,6 @@ export function DashboardsController(userService, dashboardService, customerServ

vm.dashboardsScope = $state.$current.data.dashboardsType;

vm.makePublic = makePublic;
vm.makePrivate = makePrivate;
vm.manageAssignedCustomers = manageAssignedCustomers;
vm.unassignFromCustomer = unassignFromCustomer;
vm.exportDashboard = exportDashboard;
Expand Down Expand Up @@ -176,28 +173,6 @@ export function DashboardsController(userService, dashboardService, customerServ
icon: "file_download"
});

dashboardActionsList.push({
onAction: function ($event, item) {
makePublic($event, item);
},
name: function() { return $translate.instant('action.share') },
details: function() { return $translate.instant('dashboard.make-public') },
icon: "share",
isEnabled: function(dashboard) {
return dashboard && !dashboard.publicCustomerId;
}
});
dashboardActionsList.push({
onAction: function ($event, item) {
makePrivate($event, item);
},
name: function() { return $translate.instant('action.make-private') },
details: function() { return $translate.instant('dashboard.make-private') },
icon: "reply",
isEnabled: function(dashboard) {
return dashboard && dashboard.publicCustomerId;
}
});
dashboardActionsList.push({
onAction: function ($event, item) {
manageAssignedCustomers($event, item);
Expand Down Expand Up @@ -329,20 +304,6 @@ export function DashboardsController(userService, dashboardService, customerServ
}
);

dashboardActionsList.push(
{
onAction: function ($event, item) {
makePrivate($event, item);
},
name: function() { return $translate.instant('action.make-private') },
details: function() { return $translate.instant('dashboard.make-private') },
icon: "reply",
isEnabled: function(dashboard) {
return dashboard && customerId == dashboard.publicCustomerId;
}
}
);

dashboardActionsList.push(
{
onAction: function ($event, item) {
Expand Down Expand Up @@ -390,29 +351,6 @@ export function DashboardsController(userService, dashboardService, customerServ
icon: "file_download"
});

dashboardActionsList.push({
onAction: function ($event, item) {
makePublic($event, item);
},
name: function() { return $translate.instant('action.share') },
details: function() { return $translate.instant('dashboard.make-public') },
icon: "share",
isEnabled: function(dashboard) {
return dashboard && !dashboard.publicCustomerId;
}
});
dashboardActionsList.push({
onAction: function ($event, item) {
makePrivate($event, item);
},
name: function() { return $translate.instant('action.make-private') },
details: function() { return $translate.instant('dashboard.make-private') },
icon: "reply",
isEnabled: function(dashboard) {
return dashboard && dashboard.publicCustomerId;
}
});

dashboardActionsList.push(
{
onAction: function ($event, item) {
Expand Down Expand Up @@ -620,45 +558,6 @@ export function DashboardsController(userService, dashboardService, customerServ
});
}

function makePublic($event, dashboard) {
if ($event) {
$event.stopPropagation();
}
dashboardService.makeDashboardPublic(dashboard.id.id).then(function success(dashboard) {
$mdDialog.show({
controller: 'MakeDashboardPublicDialogController',
controllerAs: 'vm',
templateUrl: makeDashboardPublicDialogTemplate,
locals: {dashboard: dashboard},
parent: angular.element($document[0].body),
fullscreen: true,
targetEvent: $event
}).then(function () {
vm.grid.refreshList();
});
});
}

function makePrivate($event, dashboard) {
if ($event) {
$event.stopPropagation();
}
var title = $translate.instant('dashboard.make-private-dashboard-title', {dashboardTitle: dashboard.title});
var content = $translate.instant('dashboard.make-private-dashboard-text');
var label = $translate.instant('dashboard.make-private-dashboard');
var confirm = $mdDialog.confirm()
.targetEvent($event)
.title(title)
.htmlContent(content)
.ariaLabel(label)
.cancel($translate.instant('action.no'))
.ok($translate.instant('action.yes'));
$mdDialog.show(confirm).then(function () {
dashboardService.makeDashboardPrivate(dashboard.id.id).then(function success() {
vm.grid.refreshList();
});
});
}

function exportDashboard($event, dashboard) {
$event.stopPropagation();
Expand Down

0 comments on commit e125866

Please sign in to comment.