Browse Source

naming++

master
Alexey Velikiy 6 years ago
parent
commit
1b2f90e940
  1. 4
      dist/module.js
  2. 10
      src/controllers/analytic_controller.ts
  3. 22
      src/models/analytic_unit.ts

4
dist/module.js vendored

File diff suppressed because one or more lines are too long

10
src/controllers/analytic_controller.ts

@ -73,7 +73,7 @@ export class AnalyticController {
async saveNew(metricExpanded: MetricExpanded, datasourceRequest: DatasourceRequest, panelId: number) {
this._savingNewAnalyticUnit = true;
await this._analyticService.postNewAnalyticUnit(metricExpanded, datasourceRequest, this._newAnalyticUnitType, panelId);
this._analyticUnitsSet.addAnomalyType(this._newAnalyticUnitType);
this._analyticUnitsSet.addItem(this._newAnalyticUnitType);
this._creatingNewAnalyticType = false;
this._savingNewAnalyticUnit = false;
this.runEnabledWaiter(this._newAnalyticUnitType);
@ -91,7 +91,7 @@ export class AnalyticController {
if(this._selectedAnalyticUnitKey === null) {
return null;
}
return this._analyticUnitsSet.byKey(this._selectedAnalyticUnitKey);
return this._analyticUnitsSet.byId(this._selectedAnalyticUnitKey);
}
async toggleAnomalyTypeLabelingMode(key: AnalyticUnitId) {
@ -162,7 +162,7 @@ export class AnalyticController {
}
onAnomalyColorChange(key: AnalyticUnitId, value) {
this._analyticUnitsSet.byKey(key).color = value;
this._analyticUnitsSet.byId(key).color = value;
}
fetchAnomalyTypesStatuses() {
@ -278,7 +278,7 @@ export class AnalyticController {
if(key === this._selectedAnalyticUnitKey) {
this.dropLabeling();
}
this._analyticUnitsSet.removeAnomalyType(key);
this._analyticUnitsSet.removeItem(key);
}
private async _runStatusWaiter(anomalyType: AnalyticUnit) {
@ -336,7 +336,7 @@ export class AnalyticController {
}
public toggleVisibility(key: AnalyticUnitId, value?: boolean) {
var anomaly = this._analyticUnitsSet.byKey(key);
var anomaly = this._analyticUnitsSet.byId(key);
if(value !== undefined) {
anomaly.visible = value;
} else {

22
src/models/analytic_unit.ts

@ -118,28 +118,28 @@ export class AnalyticUnit {
export class AnalyticUnitsSet {
private _mapKeyIndex: Map<AnalyticUnitId, number>;
private _mapIdIndex: Map<AnalyticUnitId, number>;
private _items: AnalyticUnit[];
constructor(private _panelObject: any[]) {
if(_panelObject === undefined) {
throw new Error('panel object can`t be undefined');
}
this._mapKeyIndex = new Map<AnalyticUnitId, number>();
this._mapIdIndex = new Map<AnalyticUnitId, number>();
this._items = _panelObject.map(p => new AnalyticUnit(p));
this._rebuildIndex();
}
get items() { return this._items; }
addAnomalyType(anomalyType: AnalyticUnit) {
this._panelObject.push(anomalyType.panelObject);
this._mapKeyIndex[anomalyType.name] = this._items.length;
this._items.push(anomalyType);
addItem(item: AnalyticUnit) {
this._panelObject.push(item.panelObject);
this._mapIdIndex[item.name] = this._items.length;
this._items.push(item);
}
removeAnomalyType(key: AnalyticUnitId) {
var index = this._mapKeyIndex[key];
removeItem(id: AnalyticUnitId) {
var index = this._mapIdIndex[id];
this._panelObject.splice(index, 1);
this._items.splice(index, 1);
this._rebuildIndex();
@ -147,12 +147,12 @@ export class AnalyticUnitsSet {
_rebuildIndex() {
this._items.forEach((a, i) => {
this._mapKeyIndex[a.key] = i;
this._mapIdIndex[a.key] = i;
});
}
byKey(key: AnalyticUnitId): AnalyticUnit {
return this._items[this._mapKeyIndex[key]];
byId(id: AnalyticUnitId): AnalyticUnit {
return this._items[this._mapIdIndex[id]];
}
byIndex(index: number): AnalyticUnit {

Loading…
Cancel
Save