Skip to content

Commit

Permalink
feat(web.privatedabase): move metrics to mimir (#12299)
Browse files Browse the repository at this point in the history
ref: MANAGER-15467

Signed-off-by: cyril.biencourt <[email protected]>
  • Loading branch information
lizardK authored Oct 24, 2024
1 parent 1d00d86 commit 0d118ba
Show file tree
Hide file tree
Showing 7 changed files with 280 additions and 205 deletions.
7 changes: 7 additions & 0 deletions packages/components/ng-tail-logs/src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default /* @ngInject */ ($q, $timeout, $http) =>
this.delay = opts.delay || 5000;

this.source = this.getFuncSource();
this.shouldStop = false;
this.timer = null;
}

getFuncSource() {
Expand All @@ -35,6 +37,9 @@ export default /* @ngInject */ ($q, $timeout, $http) =>
return undefined;
})
.finally(() => {
if (this.shouldStop) {
return this.logs;
}
this.timer = $timeout(() => {
this.log();
}, this.delay);
Expand All @@ -45,6 +50,8 @@ export default /* @ngInject */ ($q, $timeout, $http) =>
stop() {
if (this.timer) {
$timeout.cancel(this.timer);
this.timer = null;
this.shouldStop = true;
}
return $q.when(this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import template from './private-database-logs.html';
import controller from './private-database-logs.controller';

export default /* @ngInject */ ($stateProvider) => {
$stateProvider.state('app.private-database.dashboard.logs', {
url: '/logs',
template,
controller: 'PrivateDatabaseLogsCtrl',
controller,
controllerAs: 'listCtrl',
resolve: {
breadcrumb: /* @ngInject */ ($translate) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
angular.module('App').controller(
'PrivateDatabaseLogsCtrl',
class PrivateDatabaseLogsCtrl {
/* @ngInject */
constructor($scope, $stateParams, TailLogs, PrivateDatabaseLogsService) {
this.$scope = $scope;
this.$stateParams = $stateParams;
this.TailLogs = TailLogs;
this.privateDatabaseLogsService = PrivateDatabaseLogsService;
}

$onInit() {
this.productId = this.$stateParams.productId;

this.logger = new this.TailLogs({
source: () =>
this.privateDatabaseLogsService
.getLogs(this.productId)
.then((logs) => logs.url),
delay: 2000,
});

this.startLog();
}

$onDestroy() {
this.logger.stop();
}

stopLog() {
this.logger.stop();
}

startLog() {
this.logger.log();
}

getLogs() {
this.logger = this.logger.logs;
return this.logger;
}
},
);
export default class PrivateDatabaseLogsCtrl {
/* @ngInject */
constructor($scope, $stateParams, TailLogs, PrivateDatabaseLogsService) {
this.$scope = $scope;
this.$stateParams = $stateParams;
this.TailLogs = TailLogs;
this.privateDatabaseLogsService = PrivateDatabaseLogsService;
this.loader = true;

$scope.$on('$destroy', () => {
if (this.logger) {
this.logger.stop();
}
});
}

$onInit() {
this.loader = true;
this.productId = this.$stateParams.productId;

this.logger = new this.TailLogs({
source: () =>
this.privateDatabaseLogsService
.getLogs(this.productId)
.then((logs) => logs.url),
delay: 2000,
});

this.startLog();
this.loader = false;
}

$onDestroy() {
this.logger.stop();
}

stopLog() {
this.logger.stop();
}

startLog() {
this.logger.log();
}

getLogs() {
this.logger = this.logger.logs;
return this.logger;
}
}
Loading

0 comments on commit 0d118ba

Please sign in to comment.