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

22
src/models/analytic_unit.ts

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

Loading…
Cancel
Save