@nova-ui/bits
Version:
SolarWinds Nova Framework
84 lines • 4.81 kB
JavaScript
"use strict";
// © 2022 SolarWinds Worldwide, LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeFrameBarAtom = void 0;
const tslib_1 = require("tslib");
const protractor_1 = require("protractor");
const atom_1 = require("../../../atom");
const button_atom_1 = require("../../button/button.atom");
const popover_atom_1 = require("../../popover/popover.atom");
const quick_picker_atom_1 = require("../../time-frame-picker/quick-picker.atom");
const time_frame_picker_atom_1 = require("../../time-frame-picker/time-frame-picker.atom");
const timepicker_atom_1 = require("../../timepicker/timepicker.atom");
class TimeFrameBarAtom extends atom_1.Atom {
constructor(rootElement) {
super(rootElement);
this.prevButton = atom_1.Atom.findIn(button_atom_1.ButtonAtom, rootElement.element(protractor_1.by.css(".prev")));
this.nextButton = atom_1.Atom.findIn(button_atom_1.ButtonAtom, rootElement.element(protractor_1.by.css(".next")));
this.undoButton = atom_1.Atom.findIn(button_atom_1.ButtonAtom, rootElement.element(protractor_1.by.css(".undo")));
this.clearButton = atom_1.Atom.findIn(button_atom_1.ButtonAtom, rootElement.element(protractor_1.by.css(".clear")));
this.popover = atom_1.Atom.findIn(popover_atom_1.PopoverAtom, rootElement.element(protractor_1.by.css(".picker-label")));
const popoverBody = this.popover.getPopoverBody();
this.quickPicker = atom_1.Atom.findIn(quick_picker_atom_1.QuickPickerAtom, popoverBody);
this.timeFramePicker = atom_1.Atom.findIn(time_frame_picker_atom_1.TimeFramePickerAtom, popoverBody);
this.timeFramePickerCancelButton = atom_1.Atom.findIn(button_atom_1.ButtonAtom, popoverBody.element(protractor_1.by.css(".cancel")));
this.timeFramePickerUseButton = atom_1.Atom.findIn(button_atom_1.ButtonAtom, popoverBody.element(protractor_1.by.css(".use")));
}
quickPickPreset(presetTitle) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield this.popover.open();
yield this.quickPicker.selectPresetByTitle(presetTitle);
return this.popover.waitForClosed();
});
}
// TODO: 1. Move this to TimeFramePickerAtom
// TODO: 2. Improve DatePickerAtom, TimePickerAtom and DateTimePickerAtom with easy to use `select(m: Moment)` methods
pickTimeFrame(start, end) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const date = "MM/DD/YYYY";
const time = timepicker_atom_1.TimepickerAtom.defaultFormat;
yield this.popover.open();
const startDate = this.timeFramePicker
.getStartDatetimePicker()
.getDatePicker();
const startTime = this.timeFramePicker
.getStartDatetimePicker()
.getTimePicker();
const endDate = this.timeFramePicker
.getEndDatetimePicker()
.getDatePicker();
const endTime = this.timeFramePicker
.getEndDatetimePicker()
.getTimePicker();
yield startDate.clearText();
yield startDate.acceptText(start.format(date));
yield startTime.selectTime(start.format(time));
yield endDate.clearText();
yield endDate.acceptText(end.format(date));
yield endTime.selectTime(end.format(time));
yield this.timeFramePickerUseButton.click();
return this.popover.waitForClosed();
});
}
}
exports.TimeFrameBarAtom = TimeFrameBarAtom;
TimeFrameBarAtom.CSS_SELECTOR = ".nui-time-frame-bar";
//# sourceMappingURL=time-frame-bar.atom.js.map