type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
MethodDeclaration
ngOnInit() { this.createIdeogram(); }
Zhu-Ying/ideogram
examples/angular/src/app/ideogram/ideogram.component.ts
TypeScript
MethodDeclaration
createIdeogram() { const ideogram = new Ideogram({ organism: 'human', dataDir: 'https://unpkg.com/ideogram@0.10.0/dist/data/bands/native/', container: '#ideo-container' }); }
Zhu-Ying/ideogram
examples/angular/src/app/ideogram/ideogram.component.ts
TypeScript
ArrowFunction
() => this.alive
vladhj38/ngx-admin
src/app/@theme/components/banner/banner.component.ts
TypeScript
ArrowFunction
({ name }) => this.isDarkTheme = name === 'cosmic'
vladhj38/ngx-admin
src/app/@theme/components/banner/banner.component.ts
TypeScript
ClassDeclaration
@Component({ selector: 'ngx-release-banner', template: ` <div class="heading-with-icon"> <img class="icon" [src]="getBellPath()" alt="bell"> <h1 class="banner-heading">Nebular 2.0 stable <br> with 30+ components is out!</h1> <button class="close-button" aria-label="close" (click)="closeBanner()"> <span class="nb-close"></span> </button> </div> <p class="cta"> Don't forget to <a class="cta-link" href="https://github.com/akveo/nebular">check out</a> and star our repo :) </p> `, styleUrls: ['./banner.component.scss'], }) export class BannerComponent implements OnInit, OnDestroy { private alive = true; storage: Storage; isDarkTheme: boolean; @HostBinding('attr.hidden') isHidden: true | null = null; @HostBinding('attr.dir') dir = 'ltr'; constructor( @Inject(NB_WINDOW) private window, private themeService: NbThemeService, ) {} ngOnInit() { this.storage = this.window.localStorage; this.isHidden = this.storage && this.storage.getItem(HIDE_BANNER_KEY) ? true : null; this.isDarkTheme = this.themeService.currentTheme === 'cosmic'; this.themeService.onThemeChange() .pipe(takeWhile(() => this.alive)) .subscribe(({ name }) => this.isDarkTheme = name === 'cosmic'); } closeBanner() { if (this.storage) { this.storage.setItem(HIDE_BANNER_KEY, 'true'); } this.isHidden = true; } getBellPath() { return `assets/images/bell${this.isDarkTheme ? '' : '-white'}.svg`; } ngOnDestroy() { this.alive = false; } }
vladhj38/ngx-admin
src/app/@theme/components/banner/banner.component.ts
TypeScript
MethodDeclaration
ngOnInit() { this.storage = this.window.localStorage; this.isHidden = this.storage && this.storage.getItem(HIDE_BANNER_KEY) ? true : null; this.isDarkTheme = this.themeService.currentTheme === 'cosmic'; this.themeService.onThemeChange() .pipe(takeWhile(() => this.alive)) .subscribe(({ name }) => this.isDarkTheme = name === 'cosmic'); }
vladhj38/ngx-admin
src/app/@theme/components/banner/banner.component.ts
TypeScript
MethodDeclaration
closeBanner() { if (this.storage) { this.storage.setItem(HIDE_BANNER_KEY, 'true'); } this.isHidden = true; }
vladhj38/ngx-admin
src/app/@theme/components/banner/banner.component.ts
TypeScript
MethodDeclaration
getBellPath() { return `assets/images/bell${this.isDarkTheme ? '' : '-white'}.svg`; }
vladhj38/ngx-admin
src/app/@theme/components/banner/banner.component.ts
TypeScript
MethodDeclaration
ngOnDestroy() { this.alive = false; }
vladhj38/ngx-admin
src/app/@theme/components/banner/banner.component.ts
TypeScript
InterfaceDeclaration
interface GroupItem { title: string; icon: string; color: string; desc: string; date: string; group: string; }
sunchir/vue3-xd-fundamental
src/views/dashboard/workbench/components/data.ts
TypeScript
InterfaceDeclaration
interface NavItem { title: string; icon: string; color: string; }
sunchir/vue3-xd-fundamental
src/views/dashboard/workbench/components/data.ts
TypeScript
InterfaceDeclaration
interface DynamicInfoItem { avatar: string; name: string; date: string; desc: string; }
sunchir/vue3-xd-fundamental
src/views/dashboard/workbench/components/data.ts
TypeScript
InterfaceDeclaration
interface GroupTitleItems { appNum?: number; id: number; isInit?: number; name: String; parentId?: number; }
sunchir/vue3-xd-fundamental
src/views/dashboard/workbench/components/data.ts
TypeScript
InterfaceDeclaration
interface AppList { appId: string; appSecret: string; appUrl?: string; categoryId?: number; description: string; h5Url?: string; icon?: string; id: number; isInit?: number; maintenanceUrl?: string; name: string; orgName?: string; orgSn?: string; sort?: number; thirdApp?: number; type?: string; }
sunchir/vue3-xd-fundamental
src/views/dashboard/workbench/components/data.ts
TypeScript
ArrowFunction
(hasSeenTutorial) => { if (hasSeenTutorial) { this.rootPage = TabsPage; } else { this.rootPage = TutorialPage; } this.platformReady() }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
ArrowFunction
(hasLoggedIn) => { this.enableMenu(hasLoggedIn === true); }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
ArrowFunction
(err: any) => { console.log(`Didn't set nav root: ${err}`); }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
ArrowFunction
() => { this.enableMenu(true); }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
ArrowFunction
() => { this.enableMenu(false); }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
ArrowFunction
() => { this.splashScreen.hide(); }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
ClassDeclaration
@Component({ templateUrl: 'app.template.html' }) export class ConferenceApp { // the root nav is a child of the root app component // @ViewChild(Nav) gets a reference to the app's root nav @ViewChild(Nav) nav: Nav; // List of pages that can be navigated to from the left menu // the left menu only works after login // the login page disables the left menu appPages: PageInterface[] = [ { title: 'Charts', name: 'TabsPage', component: TabsPage, tabComponent: SchedulePage, index: 0, icon: 'musical-notes' }, { title: 'Speakers', name: 'TabsPage', component: TabsPage, tabComponent: SpeakerListPage, index: 1, icon: 'contacts' }, { title: 'Map', name: 'TabsPage', component: TabsPage, tabComponent: MapPage, index: 2, icon: 'map' }, { title: 'About', name: 'TabsPage', component: TabsPage, tabComponent: AboutPage, index: 3, icon: 'information-circle' } ]; loggedInPages: PageInterface[] = [ { title: 'Account', name: 'AccountPage', component: AccountPage, icon: 'person' }, { title: 'Support', name: 'SupportPage', component: SupportPage, icon: 'help' }, { title: 'Logout', name: 'TabsPage', component: TabsPage, icon: 'log-out', logsOut: true } ]; loggedOutPages: PageInterface[] = [ { title: 'Login', name: 'LoginPage', component: LoginPage, icon: 'log-in' }, { title: 'Support', name: 'SupportPage', component: SupportPage, icon: 'help' }, { title: 'Signup', name: 'SignupPage', component: SignupPage, icon: 'person-add' } ]; rootPage: any; constructor( public events: Events, public userData: UserData, public menu: MenuController, public platform: Platform, public confData: ConferenceData, public storage: Storage, public splashScreen: SplashScreen ) { // Check if the user has already seen the tutorial this.storage.get('hasSeenTutorial') .then((hasSeenTutorial) => { if (hasSeenTutorial) { this.rootPage = TabsPage; } else { this.rootPage = TutorialPage; } this.platformReady() }); // load the conference data confData.load(); // decide which menu items should be hidden by current login status stored in local storage this.userData.hasLoggedIn().then((hasLoggedIn) => { this.enableMenu(hasLoggedIn === true); }); this.enableMenu(true); this.listenToLoginEvents(); } openPage(page: PageInterface) { let params = {}; // the nav component was found using @ViewChild(Nav) // setRoot on the nav to remove previous pages and only have this page // we wouldn't want the back button to show in this scenario if (page.index) { params = { tabIndex: page.index }; } // If we are already on tabs just change the selected tab // don't setRoot again, this maintains the history stack of the // tabs even if changing them from the menu if (this.nav.getActiveChildNav() && page.index != undefined) { this.nav.getActiveChildNav().select(page.index); // Set the root of the nav with params if it's a tab index } else { this.nav.setRoot(page.name, params).catch((err: any) => { console.log(`Didn't set nav root: ${err}`); }); } if (page.logsOut === true) { // Give the menu time to close before changing to logged out this.userData.logout(); } } openTutorial() { this.nav.setRoot(TutorialPage); } listenToLoginEvents() { this.events.subscribe('user:login', () => { this.enableMenu(true); }); this.events.subscribe('user:signup', () => { this.enableMenu(true); }); this.events.subscribe('user:logout', () => { this.enableMenu(false); }); } enableMenu(loggedIn: boolean) { this.menu.enable(loggedIn, 'loggedInMenu'); this.menu.enable(!loggedIn, 'loggedOutMenu'); } platformReady() { // Call any initial plugins when ready this.platform.ready().then(() => { this.splashScreen.hide(); }); } isActive(page: PageInterface) { let childNav = this.nav.getActiveChildNav(); // Tabs are a special case because they have their own navigation if (childNav) { if (childNav.getSelected() && childNav.getSelected().root === page.tabComponent) { return 'primary'; } return; } if (this.nav.getActive() && this.nav.getActive().name === page.name) { return 'primary'; } return; } }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
InterfaceDeclaration
export interface PageInterface { title: string; name: string; component: any; icon: string; logsOut?: boolean; index?: number; tabName?: string; tabComponent?: any; }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
MethodDeclaration
openPage(page: PageInterface) { let params = {}; // the nav component was found using @ViewChild(Nav) // setRoot on the nav to remove previous pages and only have this page // we wouldn't want the back button to show in this scenario if (page.index) { params = { tabIndex: page.index }; } // If we are already on tabs just change the selected tab // don't setRoot again, this maintains the history stack of the // tabs even if changing them from the menu if (this.nav.getActiveChildNav() && page.index != undefined) { this.nav.getActiveChildNav().select(page.index); // Set the root of the nav with params if it's a tab index } else { this.nav.setRoot(page.name, params).catch((err: any) => { console.log(`Didn't set nav root: ${err}`); }); } if (page.logsOut === true) { // Give the menu time to close before changing to logged out this.userData.logout(); } }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
MethodDeclaration
openTutorial() { this.nav.setRoot(TutorialPage); }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
MethodDeclaration
listenToLoginEvents() { this.events.subscribe('user:login', () => { this.enableMenu(true); }); this.events.subscribe('user:signup', () => { this.enableMenu(true); }); this.events.subscribe('user:logout', () => { this.enableMenu(false); }); }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
MethodDeclaration
enableMenu(loggedIn: boolean) { this.menu.enable(loggedIn, 'loggedInMenu'); this.menu.enable(!loggedIn, 'loggedOutMenu'); }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
MethodDeclaration
platformReady() { // Call any initial plugins when ready this.platform.ready().then(() => { this.splashScreen.hide(); }); }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
MethodDeclaration
isActive(page: PageInterface) { let childNav = this.nav.getActiveChildNav(); // Tabs are a special case because they have their own navigation if (childNav) { if (childNav.getSelected() && childNav.getSelected().root === page.tabComponent) { return 'primary'; } return; } if (this.nav.getActive() && this.nav.getActive().name === page.name) { return 'primary'; } return; }
Levitskyi/test-music-app
src/app/app.component.ts
TypeScript
ClassDeclaration
@NgModule({ imports: [CommonModule, MATERIAL_MODULES, RouterModule.forChild(routes)], declarations: [FAQ] }) export class FAQModule {}
qdouble/material
src/app/features/faq/index.ts
TypeScript
ArrowFunction
(response: any) => { return ( _.map(response.data.value, val => { return { text: val.name, value: val.properties.customerId }; }) || [] ); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
val => { return { text: val.name, value: val.properties.customerId }; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(response: any) => { return new ResponseParser(response.data).parseSchemaResult(); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
item => { return item.hide !== true; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
target => { const item = target.azureLogAnalytics; const querystringBuilder = new LogAnalyticsQuerystringBuilder( this.templateSrv.replace(item.query, options.scopedVars, this.interpolateVariable), options, 'TimeGenerated' ); const generated = querystringBuilder.generate(); const workspace = this.templateSrv.replace(item.workspace, options.scopedVars); const url = `${this.baseUrl}/${workspace}/query?${generated.uriString}`; return { refId: target.refId, intervalMs: options.intervalMs, maxDataPoints: options.maxDataPoints, datasourceId: this.id, url: url, query: generated.rawQuery, format: target.format, resultFormat: item.resultFormat, }; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
results => { return new ResponseParser(results).parseQueryResult(); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(workspace: any) => { const queries: any[] = this.buildQuery(query, null, workspace); const promises = this.doQueries(queries); return this.$q .all(promises) .then(results => { return new ResponseParser(results).parseToVariables(); }) .catch(err => { if ( err.error && err.error.data && err.error.data.error && err.error.data.error.innererror && err.error.data.error.innererror.innererror ) { throw { message: err.error.data.error.innererror.innererror.message }; } else if (err.error && err.error.data && err.error.data.error) { throw { message: err.error.data.error.message }; } }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
results => { return new ResponseParser(results).parseToVariables(); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
err => { if ( err.error && err.error.data && err.error.data.error && err.error.data.error.innererror && err.error.data.error.innererror.innererror ) { throw { message: err.error.data.error.innererror.innererror.message }; } else if (err.error && err.error.data && err.error.data.error) { throw { message: err.error.data.error.message }; } }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
val => { if (typeof value === 'number') { return value; } return "'" + val + "'"; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(workspaces: any[]) => { this.defaultOrFirstWorkspace = workspaces[0].value; return this.defaultOrFirstWorkspace; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
results => { const annotations = new ResponseParser(results).transformToAnnotations(options); return annotations; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
query => { return this.doRequest(query.url) .then((result: any) => { return { result: result, query: query, }; }) .catch((err: any) => { throw { error: err, query: query, }; }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(result: any) => { return { result: result, query: query, }; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(err: any) => { throw { error: err, query: query, }; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(error: any) => { if (maxRetries > 0) { return this.doRequest(url, maxRetries - 1); } throw error; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(ws: any) => { const url = `${this.baseUrl}/${ws}/metadata`; return this.doRequest(url); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(response: any) => { if (response.status === 200) { return { status: 'success', message: 'Successfully queried the Azure Log Analytics service.', title: 'Success', }; } return { status: 'error', message: 'Returned http status code ' + response.status, }; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(error: any) => { let message = 'Azure Log Analytics: '; if (error.config && error.config.url && error.config.url.indexOf('workspacesloganalytics') > -1) { message = 'Azure Log Analytics requires access to Azure Monitor but had the following error: '; } message = this.getErrorMessage(message, error); return { status: 'error', message: message, }; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
isConfigured(): boolean { return ( (!!this.instanceSettings.jsonData.logAnalyticsSubscriptionId && this.instanceSettings.jsonData.logAnalyticsSubscriptionId.length > 0) || !!this.instanceSettings.jsonData.azureLogAnalyticsSameAs ); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
setWorkspaceUrl() { if (!!this.instanceSettings.jsonData.subscriptionId || !!this.instanceSettings.jsonData.azureLogAnalyticsSameAs) { this.subscriptionId = this.instanceSettings.jsonData.subscriptionId; const azureCloud = this.instanceSettings.jsonData.cloudName || 'azuremonitor'; this.azureMonitorUrl = `/${azureCloud}/subscriptions`; } else { this.subscriptionId = this.instanceSettings.jsonData.logAnalyticsSubscriptionId; this.azureMonitorUrl = `/workspacesloganalytics/subscriptions`; } }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
getWorkspaces(subscription: string) { const subscriptionId = this.templateSrv.replace(subscription || this.subscriptionId); const workspaceListUrl = this.azureMonitorUrl + `/${subscriptionId}/providers/Microsoft.OperationalInsights/workspaces?api-version=2017-04-26-preview`; return this.doRequest(workspaceListUrl).then((response: any) => { return ( _.map(response.data.value, val => { return { text: val.name, value: val.properties.customerId }; }) || [] ); }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
getSchema(workspace: string) { if (!workspace) { return Promise.resolve(); } const url = `${this.baseUrl}/${workspace}/metadata`; return this.doRequest(url).then((response: any) => { return new ResponseParser(response.data).parseSchemaResult(); }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
async query(options: DataQueryRequest<AzureMonitorQuery>) { const queries = _.filter(options.targets, item => { return item.hide !== true; }).map(target => { const item = target.azureLogAnalytics; const querystringBuilder = new LogAnalyticsQuerystringBuilder( this.templateSrv.replace(item.query, options.scopedVars, this.interpolateVariable), options, 'TimeGenerated' ); const generated = querystringBuilder.generate(); const workspace = this.templateSrv.replace(item.workspace, options.scopedVars); const url = `${this.baseUrl}/${workspace}/query?${generated.uriString}`; return { refId: target.refId, intervalMs: options.intervalMs, maxDataPoints: options.maxDataPoints, datasourceId: this.id, url: url, query: generated.rawQuery, format: target.format, resultFormat: item.resultFormat, }; }); if (!queries || queries.length === 0) { return; } const promises = this.doQueries(queries); return this.$q.all(promises).then(results => { return new ResponseParser(results).parseQueryResult(); }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
metricFindQuery(query: string) { return this.getDefaultOrFirstWorkspace().then((workspace: any) => { const queries: any[] = this.buildQuery(query, null, workspace); const promises = this.doQueries(queries); return this.$q .all(promises) .then(results => { return new ResponseParser(results).parseToVariables(); }) .catch(err => { if ( err.error && err.error.data && err.error.data.error && err.error.data.error.innererror && err.error.data.error.innererror.innererror ) { throw { message: err.error.data.error.innererror.innererror.message }; } else if (err.error && err.error.data && err.error.data.error) { throw { message: err.error.data.error.message }; } }); }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
private buildQuery(query: string, options: any, workspace: any) { const querystringBuilder = new LogAnalyticsQuerystringBuilder( this.templateSrv.replace(query, {}, this.interpolateVariable), options, 'TimeGenerated' ); const querystring = querystringBuilder.generate().uriString; const url = `${this.baseUrl}/${workspace}/query?${querystring}`; const queries: any[] = []; queries.push({ datasourceId: this.id, url: url, resultFormat: 'table', }); return queries; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
interpolateVariable(value: string, variable: { multi: any; includeAll: any }) { if (typeof value === 'string') { if (variable.multi || variable.includeAll) { return "'" + value + "'"; } else { return value; } } if (typeof value === 'number') { return value; } const quotedValues = _.map(value, val => { if (typeof value === 'number') { return value; } return "'" + val + "'"; }); return quotedValues.join(','); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
getDefaultOrFirstWorkspace() { if (this.defaultOrFirstWorkspace) { return Promise.resolve(this.defaultOrFirstWorkspace); } return this.getWorkspaces(this.subscriptionId).then((workspaces: any[]) => { this.defaultOrFirstWorkspace = workspaces[0].value; return this.defaultOrFirstWorkspace; }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
annotationQuery(options: any) { if (!options.annotation.rawQuery) { return this.$q.reject({ message: 'Query missing in annotation definition', }); } const queries: any[] = this.buildQuery(options.annotation.rawQuery, options, options.annotation.workspace); const promises = this.doQueries(queries); return this.$q.all(promises).then(results => { const annotations = new ResponseParser(results).transformToAnnotations(options); return annotations; }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
doQueries(queries: any[]) { return _.map(queries, query => { return this.doRequest(query.url) .then((result: any) => { return { result: result, query: query, }; }) .catch((err: any) => { throw { error: err, query: query, }; }); }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
doRequest(url: string, maxRetries = 1) { return this.backendSrv .datasourceRequest({ url: this.url + url, method: 'GET', }) .catch((error: any) => { if (maxRetries > 0) { return this.doRequest(url, maxRetries - 1); } throw error; }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
testDatasource() { const validationError = this.isValidConfig(); if (validationError) { return validationError; } return this.getDefaultOrFirstWorkspace() .then((ws: any) => { const url = `${this.baseUrl}/${ws}/metadata`; return this.doRequest(url); }) .then((response: any) => { if (response.status === 200) { return { status: 'success', message: 'Successfully queried the Azure Log Analytics service.', title: 'Success', }; } return { status: 'error', message: 'Returned http status code ' + response.status, }; }) .catch((error: any) => { let message = 'Azure Log Analytics: '; if (error.config && error.config.url && error.config.url.indexOf('workspacesloganalytics') > -1) { message = 'Azure Log Analytics requires access to Azure Monitor but had the following error: '; } message = this.getErrorMessage(message, error); return { status: 'error', message: message, }; }); }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
private getErrorMessage(message: string, error: any) { message += error.statusText ? error.statusText + ': ' : ''; if (error.data && error.data.error && error.data.error.code) { message += error.data.error.code + '. ' + error.data.error.message; } else if (error.data && error.data.error) { message += error.data.error; } else if (error.data) { message += error.data; } else { message += 'Cannot connect to Azure Log Analytics REST API.'; } return message; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
isValidConfig() { if (this.instanceSettings.jsonData.azureLogAnalyticsSameAs) { return undefined; } if (!this.isValidConfigField(this.instanceSettings.jsonData.logAnalyticsSubscriptionId)) { return { status: 'error', message: 'The Subscription Id field is required.', }; } if (!this.isValidConfigField(this.instanceSettings.jsonData.logAnalyticsTenantId)) { return { status: 'error', message: 'The Tenant Id field is required.', }; } if (!this.isValidConfigField(this.instanceSettings.jsonData.logAnalyticsClientId)) { return { status: 'error', message: 'The Client Id field is required.', }; } return undefined; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
MethodDeclaration
isValidConfigField(field: string) { return field && field.length > 0; }
Amann1965/mygrafana
public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/azure_log_analytics_datasource.ts
TypeScript
ArrowFunction
(accmulator, current) => { if (current.id !== botID) { accmulator.push(current.tag ? current.tag : current.username); } return accmulator; }
tenkawa0/DuskBot
src/events/reactionAdd.ts
TypeScript
ArrowFunction
(accmulator, current) => { const weapons = Array.from(new Set(data)); const weapon = weapons.splice( Math.floor(Math.random() * weapons.length), 1 ); accmulator.push(weapon[0]); return accmulator; }
tenkawa0/DuskBot
src/events/reactionAdd.ts
TypeScript
ArrowFunction
(user, index) => { embed.addField( [icons[index], user].join(""), ["```", chooseRandom(results[index].value), "```"].join("") ); }
tenkawa0/DuskBot
src/events/reactionAdd.ts
TypeScript
ClassDeclaration
export class QuestionUpdatedPublisher extends Publisher<QuestionUpdatedEvent> { readonly subject = Subjects.QuestionUpdated; }
wat1881mayer/remember-commnad
questions/src/events/publisher/question-updated-publisher.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): ClusterUpdate[] => { return _.get(cv, 'status.availableUpdates', []); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): ClusterUpdate[] => { const available = getAvailableClusterUpdates(cv) || []; try { return available.sort(({ version: left }, { version: right }) => semver.rcompare(left, right)); } catch (e) { // eslint-disable-next-line no-console console.error('error sorting cluster updates', e); return available; } }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
({ version: left }, { version: right }) => semver.rcompare(left, right)
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(currentVersion, availableUpdates) => { const currentVersionParsed = semver.parse(currentVersion); return availableUpdates?.find( // find the next minor version update, which there should never be more than one (update) => { const updateParsed = semver.parse(update.version); return semver.gt( semver.coerce(`${updateParsed.major}.${updateParsed.minor}`), semver.coerce(`${currentVersionParsed.major}.${currentVersionParsed.minor}`), ); }, ); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
// find the next minor version update, which there should never be more than one (update) => { const updateParsed = semver.parse(update.version); return semver.gt( semver.coerce(`${updateParsed.major}.${updateParsed.minor}`), semver.coerce(`${currentVersionParsed.major}.${currentVersionParsed.minor}`), ); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(currentVersion, otherVersion) => { const currentVersionParsed = semver.parse(currentVersion); const otherVersionParsed = semver.parse(otherVersion); return semver.gt( semver.coerce(`${otherVersionParsed.major}.${otherVersionParsed.minor}`), semver.coerce(`${currentVersionParsed.major}.${currentVersionParsed.minor}`), ); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv) => { return cv?.status?.desired?.channels || []; }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): string => { return _.get(cv, 'status.desired.version'); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): string => cv?.spec?.channel
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(channel: string) => { const parsed = /^(.+)-(\d\.\d+)$/.exec(channel); return parsed ? { prefix: parsed[1], version: parsed[2] } : null; }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv, currentPrefix) => { return getAvailableClusterChannels(cv).filter((channel: string) => { return currentPrefix && splitClusterVersionChannel(channel)?.prefix === currentPrefix; }); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(channel: string) => { return currentPrefix && splitClusterVersionChannel(channel)?.prefix === currentPrefix; }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(similarChannels, currentChannel) => { return similarChannels.find( // find the next minor version, which there should never be more than one (channel) => semver.gt(semver.coerce(channel).version, semver.coerce(currentChannel).version), ); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
// find the next minor version, which there should never be more than one (channel) => semver.gt(semver.coerce(channel).version, semver.coerce(currentChannel).version)
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): string => { const history: UpdateHistory[] = _.get(cv, 'status.history', []); const lastCompleted: UpdateHistory = history.find((update) => update.state === 'Completed'); return lastCompleted && lastCompleted.version; }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(update) => update.state === 'Completed'
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
( cv: ClusterVersionKind, type: ClusterVersionConditionType, status: K8sResourceConditionStatus = undefined, ): ClusterVersionCondition => { const conditions: ClusterVersionCondition[] = _.get(cv, 'status.conditions'); if (status) { return _.find(conditions, { type, status }); } return _.find(conditions, { type }); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): boolean => { return !_.isEmpty( getClusterVersionCondition( cv, ClusterVersionConditionType.Progressing, K8sResourceConditionStatus.True, ), ); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): boolean => { return !_.isEmpty( getClusterVersionCondition( cv, ClusterVersionConditionType.Invalid, K8sResourceConditionStatus.True, ), ); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): boolean => { return !_.isEmpty( getClusterVersionCondition( cv, ClusterVersionConditionType.RetrievedUpdates, K8sResourceConditionStatus.False, ), ); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): boolean => { return !_.isEmpty( getClusterVersionCondition( cv, ClusterVersionConditionType.Failing, K8sResourceConditionStatus.True, ), ); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): boolean => { return !_.isEmpty(getAvailableClusterUpdates(cv)); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): ClusterUpdateStatus => { if (invalid(cv)) { return ClusterUpdateStatus.Invalid; } if (isProgressing(cv) && updateFailing(cv)) { return ClusterUpdateStatus.UpdatingAndFailing; } if (updateFailing(cv)) { return ClusterUpdateStatus.Failing; } if (isProgressing(cv)) { return ClusterUpdateStatus.Updating; } if (failedToRetrieveUpdates(cv)) { return ClusterUpdateStatus.ErrorRetrieving; } return hasAvailableUpdates(cv) ? ClusterUpdateStatus.UpdatesAvailable : ClusterUpdateStatus.UpToDate; }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(k8sVersionResponse): string => _.get(k8sVersionResponse, 'gitVersion')
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): string => { const lastUpdate: UpdateHistory = _.get(cv, 'status.history[0]'); if (!lastUpdate) { return null; } return lastUpdate.state === 'Partial' ? `Updating to ${lastUpdate.version}` : lastUpdate.version; }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): string => { return _.get(cv, 'status.history[0].version') || _.get(cv, 'spec.desiredUpdate.version'); }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): { label: string; href: string } => { const version: string = getCurrentVersion(cv); const parsed = semver.parse(version); if (!parsed) { return null; } // Show a Bugzilla link for prerelease versions and a support case link for supported versions. const { major, minor, prerelease } = parsed; const bugzillaVersion = major === 4 && minor <= 3 ? `${major}.${minor}.0` : `${major}.${minor}`; const environment = encodeURIComponent(`Version: ${version} Cluster ID: ${cv.spec.clusterID} Browser: ${window.navigator.userAgent} `); return _.isEmpty(prerelease) ? { label: i18next.t('public~Open support case with Red Hat'), href: `https://access.redhat.com/support/cases/#/case/new?product=OpenShift%20Container%20Platform&version=${major}.${minor}&clusterId=${cv.spec.clusterID}`, } : { label: i18next.t('public~Report bug to Red Hat'), href: `https://bugzilla.redhat.com/enter_bug.cgi?product=OpenShift%20Container%20Platform&version=${bugzillaVersion}&cf_environment=${environment}`, }; }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(): boolean => { return window.SERVER_FLAGS.branding === 'ocp'; }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(version: string): string => { if (!showReleaseNotes()) { return null; } const parsed = semver.parse(version); if (!parsed) { return null; } const { major, minor, patch, prerelease } = parsed; if (major !== 4 || !_.isEmpty(prerelease)) { return null; } return `https://access.redhat.com/documentation/en-us/openshift_container_platform/${major}.${minor}/html/release_notes/ocp-${major}-${minor}-release-notes#ocp-${major}-${minor}-${patch}`; }
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(): string => window.SERVER_FLAGS.kubeAPIServerURL || null
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(cv: ClusterVersionKind): string => _.get(cv, 'spec.clusterID')
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript
ArrowFunction
(clusterID: string): string => `https://console.redhat.com/openshift/details/${clusterID}`
DaoDaoNoCode/console
frontend/public/module/k8s/cluster-settings.ts
TypeScript