Skip to content

Commit

Permalink
Addressing #13: LoudML datasource missed config options and list of M…
Browse files Browse the repository at this point in the history
…L models/jobs
  • Loading branch information
Volodymyr Sergeyev committed Sep 10, 2020
1 parent f5a8f5d commit 845347f
Show file tree
Hide file tree
Showing 14 changed files with 60,939 additions and 1,594 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Please post issue to tracker or contact me via vova.sergeyev at gmail.com

# Changelog

* 1.7.0dev Fixed issue with updating model on a server (#19).
* 1.7.0dev Fixed issue with updating model on a server (#19). Fixed datasource config page in Grafana 7.x (#12).
* 1.6.0 Better Grafana 6.x compatibility. Fixed issue with output bucket.
* 1.5.0 Added capability to add and edit models on Loud ML Datasource page.
* 1.4.0 Changed ID to correct format "loudml-grafana-app"; Fixes code style follow guidelines.
Expand Down
16 changes: 9 additions & 7 deletions dist/datasource/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/datasource/module.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/datasource/partials/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ <h3 class="page-heading">HTTP</h3>
<select
class="gf-form-input"
ng-model="ctrl.current.access"
ng-options="f.key as f.value for f in ctrl.ACCESS_OPTIONS"
/>
ng-options="f.key as f.value for f in ctrl.ACCESS_OPTIONS">
</select>
</div>
</div>
<div class="gf-form">
Expand Down
62,128 changes: 60,732 additions & 1,396 deletions dist/panel/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/panel/module.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"screenshots": [],
"version": "1.7.0dev",
"updated": "08/10/2020"
"updated": "09/10/2020"
},

"includes": [
Expand Down
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is needed because it is used by vscode and other tools that
// call `jest` directly. However, unless you are doing anything special
// do not edit this file

const standard = require('@grafana/toolkit/src/config/jest.plugin.config');

// This process will use the same config that `yarn test` is using
module.exports = standard.jestConfig();
81 changes: 38 additions & 43 deletions src/datasource/config_ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ import appEvents from 'grafana/app/core/app_events';
import LoudMLAPI from './loudml_api';
import configTemplate from './partials/config.html';
import LoudMLDatasource from './datasource';
import {
DEFAULT_MODEL,
DEFAULT_JOB,
DEFAULT_FEATURE,
ANOMALY_HOOK_NAME,
ANOMALY_HOOK,
} from './types';
import { DEFAULT_MODEL, DEFAULT_JOB, DEFAULT_FEATURE, ANOMALY_HOOK_NAME, ANOMALY_HOOK } from './types';

const POST_A_BUG_SAVE_PLANET = 'Be aware, it may be an alien bug. If so - save planet, post bug report at https://github.com/vsergeyev/loudml-grafana-app/issues (starship troopers will do the rest of bloody job for you)';
const POST_A_BUG_SAVE_PLANET =
'Be aware, it may be an alien bug. If so - save planet, post bug report at https://github.com/vsergeyev/loudml-grafana-app/issues (starship troopers will do the rest of bloody job for you)';

function sorry_its_error(err) {
// Guys, it's really sorry
Expand Down Expand Up @@ -70,8 +65,8 @@ export class LoudMLConfigCtrl {
})
.catch(err => {
console.error(err.statusText);
console.error("Long time ago, in a galaxy far far away...");
console.log("https://www.google.com/search?q=parallel+worlds+michio+kaku");
console.error('Long time ago, in a galaxy far far away...');
console.log('https://www.google.com/search?q=parallel+worlds+michio+kaku');
appEvents.emit(AppEvents.alertError, [err.statusText]);
});

Expand Down Expand Up @@ -114,9 +109,9 @@ export class LoudMLConfigCtrl {
...DEFAULT_MODEL,
features: [
{
...DEFAULT_FEATURE
}
]
...DEFAULT_FEATURE,
},
],
});
appEvents.emit('show-modal', {
src: '/public/plugins/loudml-grafana-app/datasource/partials/add_model.html',
Expand All @@ -142,7 +137,7 @@ export class LoudMLConfigCtrl {
async addModelPost() {
console.log(this.model);

if (this.model.features[0].default != "previous") {
if (this.model.features[0].default !== 'previous') {
this.model.features[0].default = 0;
}

Expand All @@ -152,41 +147,41 @@ export class LoudMLConfigCtrl {
ds.loudml
.getModel(this.model.name)
.then(result => {
console.log("Model exists, updating it...");
console.log('Model exists, updating it...');
ds.loudml
.patchModel(this.model.name, this.model)
.then(result => {})
.catch(err => {
sorry_its_error(err);
return;
});
// // Let remove it and recreate
// ds.loudml.deleteModel(this.model.name).then(response => {
// ds.loudml
// .createModel(this.model)
// .then(result => {
// ds.loudml
// .createModelHook(this.model.name, ds.loudml.createHook(ANOMALY_HOOK, this.model.default_bucket))
// .then(result => {
// appEvents.emit(AppEvents.alertSuccess, ['Model has been updated on Loud ML server']);
// this.refreshModels();
// })
// .catch(err => {
// window.console.log('createModelHook error', err);
// appEvents.emit(AppEvents.alertError, [err.message]);
// return;
// });
// })
// .catch(err => {
// window.console.log('Model create error', err);
// appEvents.emit(AppEvents.alertError, ['Model create error', err.data]);
// return;
// });
// });
})
sorry_its_error(err);
return;
});
// // Let remove it and recreate
// ds.loudml.deleteModel(this.model.name).then(response => {
// ds.loudml
// .createModel(this.model)
// .then(result => {
// ds.loudml
// .createModelHook(this.model.name, ds.loudml.createHook(ANOMALY_HOOK, this.model.default_bucket))
// .then(result => {
// appEvents.emit(AppEvents.alertSuccess, ['Model has been updated on Loud ML server']);
// this.refreshModels();
// })
// .catch(err => {
// window.console.log('createModelHook error', err);
// appEvents.emit(AppEvents.alertError, [err.message]);
// return;
// });
// })
// .catch(err => {
// window.console.log('Model create error', err);
// appEvents.emit(AppEvents.alertError, ['Model create error', err.data]);
// return;
// });
// });
})
.catch(err => {
// New model
console.log("New model, creating it...");
console.log('New model, creating it...');
ds.loudml
.createModel(this.model)
.then(result => {
Expand Down
10 changes: 7 additions & 3 deletions src/datasource/module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { DataSourcePlugin } from '@grafana/data';

import { LoudMLDatasource } from './datasource';
import { LoudMLQueryCtrl as QueryCtrl } from './query_ctrl';
import { LoudMLConfigCtrl as ConfigCtrl } from './config_ctrl';
// import { LoudMLQueryCtrl as QueryCtrl } from './query_ctrl';
// import { LoudMLConfigCtrl as ConfigCtrl } from './config_ctrl';
import { LoudMLQueryCtrl } from './query_ctrl';
import { LoudMLConfigCtrl } from './config_ctrl';
import { LoudMLQuery, LoudMLOptions } from './types';

export { LoudMLDatasource as Datasource, ConfigCtrl, QueryCtrl };
// export { LoudMLDatasource as Datasource, ConfigCtrl, QueryCtrl };

export { LoudMLDatasource, LoudMLDatasource as Datasource, LoudMLQueryCtrl as QueryCtrl, LoudMLConfigCtrl as ConfigCtrl };
8 changes: 4 additions & 4 deletions src/datasource/partials/add_job.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ <h3 class="page-heading">General</h3>
<select
class="gf-form-input"
ng-model="model.job.method"
ng-options="f as f for f in ['get', 'post', 'head', 'patch', 'delete']"
/>
ng-options="f as f for f in ['get', 'post', 'head', 'patch', 'delete']">
</select>
</div>
</div>

Expand Down Expand Up @@ -110,8 +110,8 @@ <h3 class="page-heading">Time</h3>
'thursday',
'friday',
'saturday',
'sunday',]"
/>
'sunday',]">
</select>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions src/datasource/partials/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ <h3 class="page-heading">HTTP</h3>
<select
class="gf-form-input"
ng-model="ctrl.current.access"
ng-options="f.key as f.value for f in ctrl.ACCESS_OPTIONS"
/>
ng-options="f.key as f.value for f in ctrl.ACCESS_OPTIONS">
</select>
</div>
</div>
<div class="gf-form">
Expand Down
Loading

0 comments on commit 845347f

Please sign in to comment.