Browse Source

Fix app config

master
rozetko 6 years ago
parent
commit
4d95c7758f
  1. 23
      src/config/config_ctrl.ts
  2. 13
      src/config/template.html

23
src/config/config_ctrl.ts

@ -1,36 +1,13 @@
import template from './template.html';
import { normalizeUrl } from '../utlis';
class ConfigCtrl {
static template = template;
appModel: any;
appEditCtrl: any;
constructor() {
if(this.appModel.jsonData === undefined) {
this.appModel.jsonData = {};
}
this.appEditCtrl.setPreUpdateHook(this.preUpdate.bind(this));
this.appEditCtrl.setPostUpdateHook(this.postUpdate.bind(this));
}
preUpdate() {
this.normalizeUrl();
return Promise.resolve();
}
postUpdate() {
// TODO: check whether hasticServerUrl is accessible
if(!this.appModel.enabled) {
return Promise.resolve();
}
return { message: 'Hastic app installed!' };
}
normalizeUrl() {
this.appModel.jsonData.hasticServerUrl = normalizeUrl(this.appModel.jsonData.hasticServerUrl);
}
}

13
src/config/template.html

@ -1,12 +1 @@
<h3 class="page-heading">Enter your Hastic config</h3>
<div class="gf-form-group">
<div class="gf-form">
<label class="gf-form-label width-10">Hastic server url</label>
<input
type="text"
class="gf-form-input max-width-20"
ng-model="ctrl.appModel.jsonData.hasticServerUrl"
ng-blur="ctrl.normalizeUrl"
/>
</div>
</div>

Loading…
Cancel
Save